Skip to content
Snippets Groups Projects
Commit d41e4e4e authored by Brett Bieber's avatar Brett Bieber
Browse files

Get the basics up and running.

parent 0bd1a93c
No related branches found
No related tags found
No related merge requests found
No preview for this file type
<?xml version="1.0" encoding="UTF-8"?>
<channel version="1.0" xmlns="http://pear.php.net/channel-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/channel-1.0http://pear.php.net/dtd/channel-1.0.xsd">
<name>pear.unl.edu</name>
<summary>UNL PHP Extension and Application Repository</summary>
<suggestedalias>unl</suggestedalias>
<servers>
<primary>
<rest>
<baseurl type="REST1.0">http://pear.unl.edu/Chiara_PEAR_Server_REST/</baseurl>
<baseurl type="REST1.1">http://pear.unl.edu/Chiara_PEAR_Server_REST/</baseurl>
<baseurl type="REST1.3">http://pear.unl.edu/Chiara_PEAR_Server_REST/</baseurl>
</rest>
</primary>
</servers>
</channel>
pear.unl.edu
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.8.0alpha1" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>UNL_Autoload</name>
<channel>pear.unl.edu</channel>
<summary>An autoloader implementation for UNL PEAR packages</summary>
<description>This package provides an autoloader for classes beginning
with UNL_ and is mainly used for autoloading package files from http://pear.unl.edu/.</description>
<lead>
<name>Brett Bieber</name>
<user>saltybeagle</user>
<email>brett.bieber@gmail.com</email>
<active>yes</active>
</lead>
<date>2010-01-21</date>
<time>11:02:13</time>
<version>
<release>0.5.0</release>
<api>0.5.0</api>
</version>
<stability>
<release>alpha</release>
<api>alpha</api>
</stability>
<license uri="http://www1.unl.edu/wdn/wiki/Software_License">BSD License</license>
<notes>* First release.</notes>
<contents>
<dir name="/">
<file baseinstalldir="/" md5sum="2d13c44763ebe506f915d211dcd8f00a" name="UNL/Autoload.php" role="php"/>
</dir>
</contents>
<dependencies>
<required>
<php>
<min>5.2.0</min>
</php>
<pearinstaller>
<min>1.4.3</min>
</pearinstaller>
</required>
</dependencies>
<phprelease>
<changelog>
<release>
<version>
<release>0.5.0</release>
<api>0.5.0</api>
</version>
<stability>
<release>alpha</release>
<api>alpha</api>
</stability>
<date>2008-11-10</date>
<license uri="http://www1.unl.edu/wdn/wiki/Software_License">BSD License</license>
<notes>* First release.</notes>
</release>
</changelog>
</phprelease>
</package>
File added
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
/** /**
* Base class for exceptions in PEAR * Base class for exceptions in PEAR
*/ */
require_once 'PEAR/Exception.php';
/** /**
* Exception class for HTTP_Request2 package * Exception class for HTTP_Request2 package
...@@ -56,7 +55,7 @@ require_once 'PEAR/Exception.php'; ...@@ -56,7 +55,7 @@ require_once 'PEAR/Exception.php';
* @package HTTP_Request2 * @package HTTP_Request2
* @version Release: 0.5.1 * @version Release: 0.5.1
*/ */
class HTTP_Request2_Exception extends PEAR_Exception class HTTP_Request2_Exception extends Exception
{ {
} }
?> ?>
\ No newline at end of file
<?php
function UNL_Autoload($class)
{
if (substr($class, 0, 4) !== 'UNL_') {
return false;
}
$fp = @fopen(str_replace('_', '/', $class) . '.php', 'r', true);
if ($fp) {
fclose($fp);
require str_replace('_', '/', $class) . '.php';
if (!class_exists($class, false) && !interface_exists($class, false)) {
die(new Exception('Class ' . $class . ' was not present in ' .
str_replace('_', '/', $class) . '.php (include_path="' . get_include_path() .
'") [UNL_Autoload version 1.0]'));
}
return true;
}
$e = new Exception('Class ' . $class . ' could not be loaded from ' .
str_replace('_', '/', $class) . '.php, file does not exist (include_path="' . get_include_path() .
'") [UNL_Autoload version 1.0]');
$trace = $e->getTrace();
if (isset($trace[2]) && isset($trace[2]['function']) &&
in_array($trace[2]['function'], array('class_exists', 'interface_exists'))) {
return false;
}
if (isset($trace[1]) && isset($trace[1]['function']) &&
in_array($trace[1]['function'], array('class_exists', 'interface_exists'))) {
return false;
}
die ((string) $e);
}
// set up __autoload
if (function_exists('spl_autoload_register')) {
if (!($_____t = spl_autoload_functions()) || !in_array('UNL_Autoload', spl_autoload_functions())) {
spl_autoload_register('UNL_Autoload');
if (function_exists('__autoload') && ($_____t === false)) {
// __autoload() was being used, but now would be ignored, add
// it to the autoload stack
spl_autoload_register('__autoload');
}
}
unset($_____t);
} elseif (!function_exists('__autoload')) {
function __autoload($class) { return UNL_Autoload($class); }
}
// set up include_path if it doesn't register our current location
$____paths = explode(PATH_SEPARATOR, get_include_path());
$____found = false;
foreach ($____paths as $____path) {
if ($____path == dirname(dirname(__FILE__))) {
$____found = true;
break;
}
}
if (!$____found) {
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)));
}
unset($____paths);
unset($____path);
unset($____found);
<?php
class UNL_WDN_Assessment
{
public $baseUri;
public $db;
function __construct($baseUri, $db)
{
$this->baseUri = $baseUri;
$this->db = $db;
}
function runValidation()
{
$validator = new Services_W3C_HTMLValidator();
$validator->validator_uri = 'http://validator.unl.edu/check';
$logger = new UNL_WDN_Assessment_ValidationLogger($validator, $this);
$downloader = new Spider_Downloader();
$parser = new Spider_Parser();
$spider = new Spider($downloader, $parser);
$spider->addLogger($logger);
$spider->addUriFilter('Spider_AnchorFilter');
$spider->addUriFilter('Spider_MailtoFilter');
$spider->addUriFilter('UNL_WDN_Assessment_FileExtensionFilter');
$spider->spider('http://www.unl.edu/fwc/');
}
function removeEntries()
{
$sth = $this->db->prepare('DELETE FROM assessment WHERE baseurl = ?');
$sth->execute(array($this->baseUri));
}
function addUri($uri)
{
$sth = $this->db->prepare('INSERT INTO assessment (baseurl, url, timestamp) VALUES (?, ?, ?);');
$sth->execute(array($this->baseUri, $uri, date('Y-m-d H:i:s')));
}
function setValidationResult($uri, $result)
{
$sth = $this->db->prepare('UPDATE assessment SET valid = ? WHERE baseurl = ? AND url = ?;');
if ($result) {
$result = 'true';
} else {
$result = 'false';
}
$sth->execute(array($result, $this->baseUri, $uri));
}
}
\ No newline at end of file
<?php
class UNL_WDN_Assessment_FileExtensionFilter extends Spider_UriFilterInterface
{
function accept()
{
$path_parts = pathinfo($this->current());
if (!isset($path_parts['extension'])
|| $path_parts['extension'] == 'html'
|| $path_parts['extension'] == 'php'
|| $path_parts['extension'] == 'shtml'
|| $path_parts['extension'] == 'asp'
|| $path_parts['extension'] == 'aspx'
|| $path_parts['extension'] == 'jsp') {
return true;
}
return false;
}
}
\ No newline at end of file
<?php
class UNL_WDN_Assessment_ValidationLogger extends Spider_LoggerAbstract
{
/**
*
* @var Services_W3C_HTMLValidator
*/
public $validator;
/**
*
* @var UNL_WDN_Assessment
*/
public $assessment;
function __construct(Services_W3C_HTMLValidator $validator, UNL_WDN_Assessment $assessment)
{
$this->validator = $validator;
$this->assessment = $assessment;
}
function log($uri, DOMXPath $xpath)
{
$this->assessment->addUri($uri);
$r = $this->validator->validate($uri);
$this->assessment->setValidationResult($uri, $r->isValid());
}
}
\ No newline at end of file
<?php <?php
require_once 'config.inc.php';
require_once 'UNL/Autoload.php'; $uri = '';
$page = UNL_Templates::factory('Document');
echo $page; if (isset($_GET['uri'])) {
$uri = htmlentities($_GET['uri'], ENT_QUOTES);
$assessment = new UNL_WDN_Assessment($uri, $db);
$assessment->removeEntries();
$assessment->runValidation();
}
?>
<h1>Welcome to the batch validator</h1>
<form method="GET" action="">
<input type="text" name="uri" value="<?php echo $uri; ?>" />
<input type="submit" name="submit" /></form>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment