Ready to upload to benroberts.net/ecs

tidied up unneeded files, played with css
added an empty projects page.
removed the cv page and instead hyperlinked directly to .pdf
This commit is contained in:
2008-04-21 01:27:18 +00:00
parent 8447c7a41a
commit 46cd0f0c98
12 changed files with 219 additions and 89 deletions

View File

@@ -0,0 +1,115 @@
<?php
/*
* IValidator
*
*/
interface IValidator {
/* Overhead to be called internally by the validator */
// Called when the class is first loaded
public static function initialise();
// Called whent the validation engine shuts down
public static function shutdown();
// Called when a validator object is associated with a variable to be validated
public function associate();
// Called when a validator obhject is disassociated from a variable having been validated
public function disassociate();
// Validate some input against the constructor parameters
public function validate($input);
};
/*
* IValidatorFactory
* Creates an instance of an Validator module, given its name
*/
class IValidatorFactory {
// Prevent any instances of this class being constructed
private function __construct() {
}
public static function get( $module ) {
global $_meta;
// Get the filename and classnames for this module
$filename = "{$_meta['script-dir']}/code/validation/{$module}_validator.php";
$classname = "{$module}Validator";
// Check to make sure this module exists
if( !file_exists($filename) ) throw new ConfigException("Validation module could not be found: '{$filename}.'", 500);
// Import the auth modules code
require_once( $filename );
// Ensure the class has been defined
if( !class_exists( $classname ) ) throw new ConfigException("Validation module is invalid: '{$classname}'.", 500);
// Create an instance of the module, and return it
return new $classname();
}
};
/*
* Validator
* This class provides validation for a variable using a variety of algorithms
*/
abstract class Validator {
public static function check($name, &$value) {
// Retrieve the varargs for this function
$args = func_get_args();
// Remove the first two arguments, since we already have those by name
array_shift($args); array_shift($args);
try {
// Each of the remaining arguments should be implementations of IValidator
foreach ($args as $validator) {
// Ensure this object is a validator
if (!( $validator instanceof IValidator)) {
throw new ValidationException("Invalid Validator object");
}
// Attempt to validate the input through each validator in turn
$validator->validate( $value );
}
// All successful
} catch (ValidationException $e) {
// Add the friendly name of the variable that failed validation, and rethrow the exception
// for the calling code to catch
$e->append_name($name);
throw $e;
}
}
};
/*
* Validation Exceptions
*/
class ValidationException extends BaseException {
public function __construct($message) {
parent::__construct($message);
}
public function append_name($name) {
$this->e .= ", while validating '{$name}'.";
}
};
?>

View File

@@ -0,0 +1,40 @@
<?php
/*
*
*
*/
class RangeValidator implements IValidator {
private $min;
private $max;
public function __construct($min, $max) {
}
public static function initialise() {
// Nothing to do
}
public static function shutdown() {
// Nothing to do
}
public function associate() {
// Nothing to do
}
public function disassociate() {
// Nothing to do
}
public function validate($input) {
if( $input < $min || $input > $max )
throw new ValidationException("Input is no in the range {$this->min}-{$this->max}");
}
};
?>

View File

@@ -1,2 +0,0 @@
Order Allow,Deny
Deny from all

BIN
files/BenRobertsCv.pdf Normal file

Binary file not shown.

View File

@@ -1,10 +0,0 @@
<?php
/*
* Curriculum Vitae
*
*/
$_template['title'] = "Curriculum Vitae";
?>

View File

@@ -9,14 +9,16 @@
?> ?>
<div> <div>
<img class="bio" src="<?php echo $_meta['base-dir']; ?>/resources/bios_scott.jpg" alt="Me?" />
<p> <p>
I am a third year student at ECS in Southampton, studying for a Masters degree in Computer Science (with Networks and Distributed Systems). I am a third year student at ECS in Southampton, studying for a Master's degree in Computer Science (with Networks and Distributed Systems).
I am about to start an Industrial Year out, working for <a href="http://www.netcraft.com/" title="Netcraft homepage">Netcraft</a> in Bath.
</p> </p>
<p> <p>
Here you can find a copy of my <a href="<?php echo $_req->construct('page','cv'); ?>" title="Curriculum Vitae">CV</a>, On this site you can find a copy of my <a href="<?php echo $_meta['base-dir']; ?>/files/BenRobertsCv.pdf" title="Curriculum Vitae">CV</a>,
or you can contact me via bar105<img class="at" src="<?php echo $_meta['base-dir']; ?>/resources/at.png" alt="@" />ecs.soton.ac.uk. or see what <a href="<?php echo $_req->construct('page','projects'); ?>" title="Projects">projects</a> I have been working on.
</p>
<p>
You can contact me via bar105<img class="at" src="<?php echo $_meta['base-dir']; ?>/resources/at.png" alt="@" />ecs.soton.ac.uk.
</p> </p>

13
page-sources/projects.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
/*
*
*
*/
$_template['title'] = "Projects";
?>
<p>
<em>I have not yet written up the list of projects I am working on</em>
</p>

BIN
resources/at.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

9
resources/email.js Normal file
View File

@@ -0,0 +1,9 @@
window.onload = function() {
for (var imgs = document.getElementsByTagName('img'),i=0,l=imgs.length; i<l; i++) {
if (/at\.png$/.exec(imgs[i].src) ) {
imgs[i].parentNode.insertBefore(document.createTextNode('@'),imgs[i]);
imgs[i].parentNode.removeChild(imgs[i]);
}
}
}

View File

@@ -5,11 +5,11 @@
body { body {
margin: 0em; margin: 0em;
padding: 0em; padding: 0em;
font-family: verdana, tahoma, sans-serif; font-family: verdana, helvetica, tahoma, sans-serif;
} }
div.header { div.header {
border-bottom: 1px solid grey; /*border-bottom: 1px solid grey;*/
padding-bottom: 0.5em; padding-bottom: 0.5em;
margin: 0.5em 1em 1em 1em; margin: 0.5em 1em 1em 1em;
} }
@@ -41,7 +41,7 @@ div.footer {
} }
div.sidebar ul { div.sidebar ul {
list-style: circle; list-style: none;
} }
/* /*
@@ -52,6 +52,27 @@ div.header h1 {
font-size: 3.0em; font-size: 3.0em;
margin: 0.2em; margin: 0.2em;
margin-left: 0em; margin-left: 0em;
color: dimgrey;
}
p.subtitle {
font-weight: bold;
font-style: italic;
color: dimgrey;
}
h2 {
color: steelblue;
}
a {
text-decoration: underline;
color: steelblue;
}
a:visited {
color: dimgrey;
text-decoration: none;
} }
@@ -135,17 +156,3 @@ p.loginform label {
p.loginform input { p.loginform input {
float: right; float: right;
} }
/*
Homepage
*/
img.bio {
display: block;
margin-left: auto;
margin-right: auto;
border: 1px solid grey;
padding: 0.2em;
}

View File

@@ -13,7 +13,7 @@
<head> <head>
<title><?php echo $_template['title']; ?></title> <title><?php echo $_template['title']; ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo $_meta['base-dir']; ?>/resources/normal.css" /> <link rel="stylesheet" type="text/css" href="<?php echo $_meta['base-dir']; ?>/resources/normal.css" />
<script language="javascript" type="text/javascript" src="<?php echo $_meta['base-dir']; ?>/resources/email.js" /> <script language="javascript" type="text/javascript" src="<?php echo $_meta['base-dir']; ?>/resources/email.js"></script>
<?php <?php
// If we have a redirection, implement a meta refresh here // If we have a redirection, implement a meta refresh here
if( $_template['redirect-to'] ) { if( $_template['redirect-to'] ) {
@@ -29,15 +29,15 @@
<body> <body>
<div class="header"> <div class="header">
<h1>Ben Roberts</h1> <h1>Ben Roberts</h1>
<strong>MEng Computer Science @ ecs.soton.ac.uk</strong> <p class="subtitle">MEng Computer Science @ ecs.soton.ac.uk</p>
</div> </div>
<div class="sidebar"> <div class="sidebar">
<strong>Navigation</strong>
<ul> <ul>
<li><a href="<?php echo $_req->construct('page','home'); ?>" title="Homepage">Home</a></li> <li><a href="<?php echo $_req->construct('page','home'); ?>" title="Homepage">Home</a></li>
<li><a href="<?php echo $_req->construct('page','cv'); ?>" title="Curriculum Vitae">Curriculum Vitae</a></li> <li><a href="<?php echo $_meta['base-dir']; ?>/files/BenRobertsCv.pdf" title="Curriculum Vitae">Curriculum Vitae</a></li>
<li><a href="<?php echo $_req->construct('page','projects'); ?>" title="Projects">Projects</a></li>
<?php if( $_session->is_logged_in() ) { ?> <?php if( $_session->is_logged_in() ) { ?>
<li><a href="<?php echo $_req->construct('page','logout'); ?>" title="Logout">Logout</a></li> <li><a href="<?php echo $_req->construct('page','logout'); ?>" title="Logout">Logout</a></li>
<?php } ?> <?php } ?>
@@ -57,7 +57,7 @@
} }
} }
?> ?>
<h1><?php echo $_template['title']; ?></h1> <h2><?php echo $_template['title']; ?></h2>
<?php <?php
// Include the main page content // Include the main page content
echo $_template['page']; echo $_template['page'];
@@ -74,7 +74,12 @@
</div> </div>
<div class="footer"> <div class="footer">
Footer, rar rar rar. <p>
Copyright &copy; 2008 by Ben Roberts. All rights reserved unless otherwise specified.
</p>
<p>
This file was last modified <?php echo date("j F Y", filemtime($_page)); ?>.
</p>
</div> </div>
</body> </body>

View File

@@ -1,49 +0,0 @@
<?php
/*
*
*
*/
require_once( 'code/config.php' );
if( isset($_GET['destroy']) ) {
session_start();
session_destroy();
echo "Session destroyed";
}
if( isset($_GET['request']) ) {
require_once( "code/request_handler.php" );
echo '<pre>';
$req1 = new RequestHandler( "/page/user_reviews/username/tw205/aux&/true/false/" );
var_dump( $req1->get("page") );
var_dump( $req1->get("username") );
var_dump( $req1->get("aux") );
var_dump( $req1->get("aux&", ".+") );
var_dump( $req1->construct('page', $req1->get('page'), 'username', null, 'aux&', null) );
echo '</pre>';
}
if( isset($_GET['session']) ) {
session_start();
echo '<pre>';
var_dump($_SESSION);
echo '</pre>';
}
if (isset($_GET['validate'])) {
require_once('code/validation/ivalidator.php');
try {
Validator::check('Value', $_GET['value'], IValidatorFactory::get('Range',5,32));
} catch (ValidationException $e) {
echo $e->getMessage();
}
}
?>