Aquarionics

/home/a/aquarion/sites/www.aquarionics.com/epistula/epistula.php

All my code (That is, anything not in the "Others" list on the right) is BSD licenced.

You can also view this page as text/plain or colour-coded source


<?PHP
/*******************************************************************************
    Epistula
********************************************************************************

    Start page. Set up variables and libraries, check cache for page existance,
    and if it shouldn't display the cached version generate and display the page,
    handing temporary control to the right "chapter" (Module)

    $Id: epistula.php,v 1.4 2004/08/17 19:59:34 aquarion Exp $

    $log$

*******************************************************************************/


#$override = "remember";

ini_set ("track_errors", "1");
chdir("../epistula/");
$caching = true;

$_urls = array(); // Database of known URLs, so we don't have to look them up again
$finalOutput = false;

$stopwatch = microtime(); 


if (file_exists("epistula.ini")){
    $_EP = parse_ini_file("epistula.ini", true);
} else {
    die ("Configuration file doesn't exist. Sharn't.");
}



$needed = array(
    "Code Directory" => $_EP['codedir'],
    "Web Directory" => $_EP['webdir'],
    "Data Directory" => $_EP['datadir'],
    "Database Connect file" => $_EP['codedir']."/include/dbconnect.inc",
    "Configuration defaults" => "include/epistula.conf"
);

foreach ($needed as $needed => $file){
    if (!file_exists($file)){
        die("Can't find $needed ($file), so Epistula can't run");
    }elseif(!is_readable($file)){
        die("Permissions problem with $needed, Epistula won't run");        
    }
}

$_SECRET = $_EP['Secrets'];

$_EP['menu'] = array(
    array("name" => "Index", "link" => "/", "title" => "Last ten items on the site"),
    array("name" => "Journal", "link" => "/journal", "title" => "The life and times of a not-a-geek"),
    array("name" => "Gallery", "link" => "/gallery", "title" => "Photos, Videos and Drawings of people and events"),
    array("name" => "Articles", "link" => "/article", "title" => "Essays and Thesis' on life, computers, and everything"),
    array("name" => "Misc", "link" => "/misc/", "title" => "Sections that don't fall under any other category"),
    array("name" => "Writings", "link" => "/writing/", "title" => "Fiction, Poetry, and Creative Stuff."),
    array("name" => "Projects", "link" => "/projects", "title" => "Stuff I Do")
);

$_EP['gmenu'] = array(
        array ('name' => "About", "link" => "/article/name/about", "title" => "What is this, anyway?"),
#        array ('name' => "FAQ", "link" => "/article/name/faq", "title" => "Questions Seldom Asked"),
        array ('name' => "Archive", "link" => "/archive", "title" => "Archived Futility"),
        array ('name' => "Contact", "link" => "/article/name/contact", "title" => "Speak!"),
#        array ('name' => "Search", "link" => "/search", "title" => "Find!"),
        array ('name' => "Syndicate", "link" => "/meta", "title" => "Data about data")
    );

/*if ($_SERVER["HTTP_USER_AGENT"] == "LiveJournal.com (webmaster@livejournal.com; for http://www.livejournal.com/users/aquarionicsblog/; 1 readers)" || $_GET['ljtest']){
    header("Content-Type: text/xml");
    readfile("assets/lj_moved.xml");
    die();
}*/
#"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6a) Gecko/20031006 Firebird/0.7+"
#"LiveJournal.com (webmaster@livejournal.com; for http://www.livejournal.com/users/aquarionicsblog/; 1 readers)"
#$caching = false;


if (isset($_GET['nocache']) || isset($_GET['regen'])){
    $caching = false; 
    $_EP['caching'] = false;
    }

$filetypes = array (
    "rss" => "text/xml",
    "rss2" => "text/xml",
    "cdf" => "application/cdf",
    "rdf" => "text/xml",
    "xml" => "text/xml",
    "xfml" => "text/xml",
    "necho" => "text/xml",
    "esf" => "text/plain"
);


header("X-Powered-By: Epistula ".$_EP['version']);
header("X-Pingback: ".$_EP['url']."/xmlrpc");

if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")){
    $compress = true;
} else {
    $compress = false;
}

$cachename = strtolower(strtr(urldecode($_SERVER['REQUEST_URI']), "/", "_"));
if ($cachename != "_"){
    $length = strlen($cachename) -1;
    $pos = strrpos($cachename, "_");
    #echo $pos."/".$length;
    if ($pos == $length){
        $cachename =  substr ($cachename, 0 , $length);
    }
}

$parsedURL = @parse_url($_SERVER['REQUEST_URI']);

$keyboom = explode(".",$parsedURL['path']);
if (isset($keyboom[1]) && isset($filetypes[$keyboom[1]])){
    header("Content-Type: ".$filetypes[$keyboom[1]]);
}

include("include/class.php"); // Classes file
include("include/library.php"); // Library file


if (file_exists($_EP['cachedir']."/".$cachename) && ($caching || $_EP['caching'])){

    keepTrack("cachedPage");

    $etagval=false;

    $mtime = filemtime($_EP['cachedir']."/".$cachename);
    $gmt_mtime = gmdate('D, d M Y H:i:s', $mtime) . ' GMT';    
    $lastmod_header = "Last-Modified: " . $gmt_mtime;
    header($lastmod_header);
    $etag = md5($lastmod_header);
    $nnwheaders = getallheaders();
    foreach ($nnwheaders as $header => $value) {
        if ($header=="If-None-Match") { 
            $etagval=substr($value,1,-1); 
        } 
    }

    header ("ETag: \"$etag\""); 
    if ($etagval==$etag || $HTTP_IF_MODIFIED_SINCE == $gmt_mtime) {
        header("HTTP/1.1 304 Not Modified");
    } elseif ($compress){
            //die(finfo_file($_EP['cachedir']."/".$cachename));
            header("X-Compression: gzip");
            header("Content-Encoding: gzip");
            header("Content-Length: ".filesize($_EP['cachedir']."/".$cachename));
            readfile($_EP['cachedir']."/".$cachename) or die("Couldn't open cache");
    } else {
        header("X-Compression: None");
        $zd = gzopen ($_EP['cachedir']."/".$cachename, "r") or die("Couldn't open cache");
        $contents = gzread ($zd, 1000000);
        header("Content-Length: ".strlen($contents));
        echo $contents;
        gzclose ($zd);
    }

    die();
} else {
    keepTrack("dynPage");
} 


$finalOutput = false;



$page = new $_EP['out'];

$page->title = "Front Page";
$page->author = "Aquarion";
$page->email = "aquarion@suespammers.org";

$types = array("journal","article","writing", "gallery", "postcard");
$attachments = array("comments", "category");
$outputfeeds = array("esf", "rss", "rss2");

$_EP['outputfeeds'] = $outputfeeds;

$page->globalnav = $page->menu($_EP['menu']);

/*
    ."<LINK REL=\"SHORTCUT ICON\" HREF=\"http://www.aquarionics.com/favicon.ico\">\n"

*/

$page->links[] = array ( 
    #<link rel="pingback" href="http://www.dummy-blog.org/">
    'rel' => "pingback", 'href' => $_EP['url']."/xmlrpc",
    'rel' => "SHORTCUT ICON", 'href' => $_EP['url']."/assets/aq9/favicon.png"
    );


$page->links[] = array ( 
    #<link rel="pingback" href="http://www.dummy-blog.org/">
    'rel' => "top", 'href' => $_EP['url'],
    );

// Possibly move this to a per-item section, generated from user profile?

#preg_match("/^(N|S)(\d+)\:(\d+)\:(\d+) (E|W)(\d+)\:(\d+)\:(\d+)$/",$_EP['location'],$location);

# 1 - N/S
# 2 - Degrees
# 3 - Minutes


$page->meta[] = array('name' => 'dc.creator.e-mail', 'content' => $page->email);
$page->meta[] = array('name' => 'author', 'content' => $page->author);
$page->meta[] = array('name' => 'dc.creator.name', 'content' => $page->author);
$page->meta[] = array('name' => 'dc.title', 'content' => $_EP['book']);
$page->meta[] = array('name' => 'geo.position', 'content' => '53.1378;-0.985');
#$page->meta[] = array('name' => 'geo.placename', 'content' => 'Reading, Berkshire');
$page->meta[] = array('name' => 'geo.country', 'content' => 'UK');
$page->meta[] = array('name' => 'dmoz.id', 'content' => 'Top/Computers/Internet/On_the_Web/Weblogs/Personal/A/');


$page->links[] = array ( 
    'rel' => "contents",
    'href' => $_EP['url']
);

foreach ($_EP['menu'] as $section){
    $page->links[] = array ( 
        'rel' => "section",
        'href' => $section['link'],
        'title' => $section['name']
    );
}

if (isset($HTTP_SERVER_VARS['REDIRECT_URL'])){
    $wanted = $HTTP_SERVER_VARS['REDIRECT_URL'];
} else {
    $wanted = $_SERVER['REQUEST_URI'];
}

if ($_SERVER['QUERY_STRING'] != ""){
    $query = explode( "&",$_SERVER['QUERY_STRING']);
    $querypos = strpos($_SERVER['REQUEST_URI'], "?");
    $wanted = explode("/",substr($wanted, 0 , $querypos));
} else {
    $query = false;
    $wanted = explode("/",$wanted);
}
array_shift($wanted);

if ($wanted[0] == "sysadmin"){
    $override = false;
}

$page->chapter = $wanted[0];


if (isset($types[$wanted[0]])){
    $page->links[] = array ( 
        'rel' => "alternate",
        'type' => "application/rss+xml",
        'title' => "RSS",
        'href' => $_EP['url']."/meta/".$wanted[0].".rss"
    );
}

$dontcache = array(    // Sections not to cache
    "sysadmin",
    "xmlrpc",
    "trackback",
    "comment",
    "testing",
    "trigger",
    "logging",
    "error",
    "attachment"
);


if (in_array($wanted[0], $dontcache)){
    $page->debug[] = array(0, "Caching turned off");
    $caching = false;
    $_EP['caching'] = false;
}

$redirects = array( // a series of redirects - and urls to redirect to. Redirects are regexs

    //regex to match for, Place to redirect to. [[0]] is replaced with full thing, [[1]] with first match etc.
    
    array($wanted[0], "^suds", "/gallery/Stags__And_Hens"),
    array($wanted[0], "^quoth", "/article/name/quoth"),
    array($wanted[0], "^~aquarion(.*)", "/aquarion/[[1]]"),
    array($wanted[0], "^rss\/foaf.rdf", "/meta/foaf.rdf"),
    array($wanted[0], "^rss", "/meta/all.rss"),
    array($wanted[0], "^favicon\.ico", "/assets/aq9/favicon.png"),
    array($query[0], "id=(.*)$", "/journal/id/[[1]]"),
    array($query[0], "^name=(.*)", "/article/name/[[1]]"),
    array($query[0], "^node=(.*)", "/article/id/[[1]]"),
    array($query[0], "^lastupdated", "/"),
    array($query[0], "^limit", "/"),
    array($query[0], "^filter", "/"),
    array($query[0], "^month=(.*)&year=(.*)", "/archive/[[1]]/[[2]]"),
    array($query[0], "^rss\/(.*)", "/meta/[[1]]"),
    array($query[0], "^diary.rss", "/meta/all.rss")
);

$forceRedirects = array ( // redirect these even if the page isn't 404
    array($_SERVER['REQUEST_URI'], "^\/meta\/blink.rss2", "http://del.icio.us/rss/Aquarion/blink")
);

function doRedirects($redirects){
    global $_EP;

    global $page;
    $found = false;
    foreach ($redirects as $redirect){
        $subject = $redirect[0];
        $regex = $redirect[1];
        $forward = $_EP['url'].$redirect[2];
        $matches = array();
        $page->debug[] = array(1, "Checking $subject for $regex...");
        if (preg_match("/".$regex."/i", $subject, $matches)){
            
            $page->debug[] = array(1, "Matched on $regex...");
            $countmatch = count($matches);
            $debug = array();
            for ($i = 0; $i <= $countmatch; $i++) {
                if(isset($matches[$i])){
                    $debug[] = "replace [[$i]] with ".$matches[$i]." in ".$forward;
                    $forward = preg_replace("/\[\[".$i."\]\]/", preg_quote($matches[$i]), $forward);
                }
            }
            #$page->content .= $page->forwardto($forward);
            #$page->content .= $page->item("Sending you to ".$page->ulink($forward,$forward));
            
            header("HTTP/1.1 303 See Other");
            header("location: $forward");
            #echo "MATCHED IT!";
            $page->content = "<p>Okay, Couldn't find what you asked for, but I suspect it's somewhere else. Forwarding you to: <a href=\"".$forward."\">".$forward."</a></p>";
            global $caching;
            $caching = false;
            $_EP['caching'] = false;
            $page->debug[] = array(0, "Caching turned off in redirects");
            $page->debug[] = $debug;
            $found = true;
            break;
            #die;
        }
    }
    return $found;
    
}


if ($wanted[0] == ""){
    #array_unshift($wanted, $_EP['defaultChapter']); 
    $wanted[0] = $_EP['defaultChapter'];
    $page->debug[] = "Using default chapter ".$_EP['defaultChapter'];
}


$page->debug[] = array(0, "Doing searchy stuff");

doRedirects($forceRedirects);

if (isset($override) && !empty($override)){
    require("chapters/".$override.".inc.php");
    $_EP['chapter'] = $override.".inc.php";
} elseif(is_string($db)){
    $page->status = 500;
    $found = false;
    $caching = false;
    $_EP['caching'] = false;
    $page->content = "Error, Something went wrong when I tried to connect to the database. Sorry :-|".mysql_error().$_EP['Database'][name];
    $page->debug[] = $db;
    $_EP['chapter'] = "";
} elseif (isset($forward)){
    // We're golden.

/*} elseif ($wanted[0] == ""){
    $found = true;
    $page->debug[] = array(0, "Wanted-0 unset, Front Page");
    require("chapters/".$_EP['defaultChapter'].".inc.php");
    $_EP['chapter'] = $_EP['defaultChapter'].".inc.php";
*/

## Use the new style chapters system
} elseif ($wanted[0] == "error"){
    $page->status = $wanted[1];
} elseif (file_exists("newchapters/".$wanted[0].".inc.php")){
    $found = true;
    $page->debug[] = array(0, "Found new style chapter ".$wanted[0].".inc.php");
    require("newchapters/".$wanted[0].".inc.php");
    $_EP['newchapter'] = $wanted[0].".inc.php";
    $chapter = new $wanted[0];
    $page = $chapter->display($wanted, $page);

## Use the old style chapters system
} elseif (file_exists("chapters/".$wanted[0].".inc.php")){
    $found = true;
    $page->debug[] = array(0, "Found old style chapter ".$wanted[0].".inc.php");
    require("chapters/".$wanted[0].".inc.php");
    $_EP['chapter'] = $wanted[0].".inc.php";

} else {
    if (isset($_GET['id'])) {
        header('location: /journal/id/'.$_GET['id']);
        die();
    } elseif (!doRedirects($redirects)){
        $page->debug[] = array(0, "Wanted-0 (".$wanted[0].") Unrecognised");
        $page->status = 404;
    }
}


if ($page->status != 200){
    $page->debug[] = array(0, "Status was ".$page->status.".");
    $page->debug[] = array(0, "Caching turned off (non 200 status)");
    $caching = false;
    $_EP['caching'] = false;
}

switch ($page->status){

case "303":
    header("HTTP/1.1 303 See Other");
    $forward = $page->content;
    header("location: ".$forward);
    $page->content = "<p>Okay, Couldn't find what you asked for, but I suspect it's somewhere else. Forwarding you to: <a href=\"".$forward."\">".$forward."</a></p>";
    break;

case "404":
    header("HTTP/1.1 404 File Not Found");
    $page->title = ("404");
    $out .= $page->subheading("Four hundred and four");
    $out .= "<p>".$HTTP_SERVER_VARS['REDIRECT_URL']."</p>";
    $out .= file_get_contents("include/404.html");
    /*$out .= "<p>I looked. Really, I did. I wandered though the depths of old URL schemes, searching - praying - that I"
        ." would find the document you so desperatly wanted. I looked though all my sections, I feverishly ripped"
        ." though <em>years</em> of articles and entries and links and, for my sins, source code searching for that"
        ." simple document you so innocently asked for. This page denotes my failure. I have no excuse, I have no"
        ." reason. My sole reason for existance is to serve documents to those who request them, and I've failed.</p>"
        ."<p> Now, I can offer no solace in the form of replacement documents - who am I to suggest things to you? -"
        ." yet I can only offer you this humble alternative:</p>";*/

                // code for case
                #header("status: 404");

                $trans = array("_" => " ", "-" => " ");


                if (empty($askedfor)) {
                        $askedfor = urldecode($_SERVER['REDIRECT_URL']);
                }
                // Asked for is the URL the user requested, shorn of all hosts
                
                $path = explode("/", $askedfor); 
                $items = (count($path)-1);
                $quickcrit = $path[$items];                     // Last item in Path.
                if (empty($quickcrit)) {
                        $value = $items-1;
                        $quickcrit = $path[$value];
                }
                $keyboom = explode(".",$quickcrit);     // Split $quickcrit by ".", which...
                $quickcrit = $keyboom[0];                       // neatly loses the file extension. Neato...

                $quickcrit = strtr($quickcrit, $trans);
                
                $criteria = "";

                // Build $criteria as the directory path, shorn of extensions, 
                // and with "/" replaced by far more useful spaces :-)

                for ($i=0;$i<=$items;$i++) {
                        $keyword = $path[$i];                   // Key-boom, Ka-boom, Geddit? Aha. Bah
                        $keyboom = explode(".",$keyword);
                        $keyword = $keyboom[0];
                        $criteria .= "$keyword ";
                }
                $criteria = trim($criteria);  // Lose Whitespace

                // Search links, copypasted from Google Results.
                //
                        // Ugly, arn't they?
                $criteria = strtr($criteria, $trans);
                
        

                //Full text search 
                $search="http://www.google.com/search?q=" . rawurlencode($criteria) . "&amp;domains=aquarionics.com&amp;sitesearch=aquarionics.com";

        
                // Search on last word only
                $quicksearch="http://www.google.com/search?q=" . rawurlencode($quickcrit) . "&amp;domains=aquarionics.com&amp;sitesearch=aquarionics.com";

#                echo "<meta http-equiv=\"refresh\" content=\"15; URL=$quicksearch&btnI=Indeed\">";


        if ($results = googleSearch("site:aquarionics.com ".$criteria)){
        
            $out .= "<h3>Best guesses for $criteria:</h3>\n<dl>";
            foreach($results as $result){
                $out .="<dt><a href='".$result['URL']."'>".$result['title']."</a></dt>\n";
                $out .= "<dd>".utf8_decode($result['snippet'])."</dd>\n";
                $out .= "<!--- -->\n\n";
            }
            $out .= "</dl> (Powered by <a href='http://www.google.com'>Google</a>)";
            
        }

                $out .= "<ul><li><a href=\"$search\">Google-search Aquarionics for \"$criteria\"</a></li>\n";
                if ($criteria != $quickcrit) {
                        $out .= "<li><a href=\"$quicksearch\">Google-search Aquarionics for \"$quickcrit\"</a></li>\n";
                }
        $out .="</ul>\n";

    $page->content = $page->item($out);

    break; // end 404

case 400:
    header("HTTP/1.1 400 Bad Request");
    $page->title = "400 - Bad Request";
    $page->content = "<p>The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.</p><p class=\"errordefine\">I've no idea what you're blathering on about</p><hr>".$page->content;
    break;

case 405:
    header("HTTP/1.1 405 Method Not Allowed");
    $page->title = "405 - Method Not Allowed";
    break;

case 410:
    header("HTTP/1.1 410 Gone");
    $page->title = "410 - Gone";
    $page->content = $page->content."<hr><h1>410 - Gone:</h1><p>The requested resource is no longer available at the server and no forwarding address is known. This condition SHOULD be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cachable unless indicated otherwise.</p><hr><p>This is a dead resource,<br> Bereft of content it has ceased to be.<br> It hasn't"
    ." Moved, it's <i>gone</i>.<br> Removed from the server.<br> If you hadn't asked for it,"
    ." the server wouldn't even know it existed,<br> it's expired and gone to meet it's maker<br>"
    ." 'E's kicked the bucket,<br> 'e's shuffled off 'is mortal coil, run down the curtain and "
    ." joined the bleedin' choir invisibile.<br> THIS IS AN EX-RESOURCE.</p>"
    ." <p>*ahem*</p>"
    ." <p>I got a slug?</p>";
    break;

case 500:
    header("HTTP/1.1 500 Internal Server Error");
    $page->title = "500 - Internal Server Error";
    $page->content = "<p>The server encountered an unexpected "
    ."condition which prevented it from fulfilling the request.</p><hr>"

    ."<p>".$page->content."</p>";
    break;

case 503:
    header("HTTP/1.1 503 Service Unavailable");
    $page->title = "503 - Service Unavailable";
    $page->content = $page->content."<p>The server is currently unable to handle"
    ." the request due to a temporary overloading or maintenance of the server. The implication is"
    ." that this is a temporary condition which will be alleviated after some delay. If known, the"
    ." length of the delay may be indicated in a <code>Retry-After</code> header.  If no Retry-After"
    ." is given, the client SHOULD handle the response as it would for a 500 response</p><hr>"

    ."<p>Something odd happened, it'll be fixed in a bit, I hope.</p>";
    break;

default:
    if ($page->status > 299){ 
        $wanted[0] = "error";
        $wanted[1] = $page->status;
        include("chapters/error.inc.php");
    }
}// end Switch on status


if (! $finalOutput){
    /*
    //****************************
    //*    Fortune system 

    include("otherfolks/fortune.php"); // Fortune system file
     $f = new Fortune; 
     $page->smallprint .= '<q class="fortune">'.strip_tags($f->quoteFromDir($_EP['datadir']."/quotes/")).'</q>';

    //                                                           *
    //                                ****************************

    $page->smallprint .= '<!-- SiteSearch Google -->
    <FORM method=GET action="http://www.google.com/search" style="text-align: center;">
    <p>
    <input type=hidden name=ie value=UTF-8>
    <input type=hidden name=oe value=UTF-8>
    <INPUT TYPE=text name=q size=31 maxlength=255 value="">
    <INPUT type=submit name=btnG VALUE="Google Search">
    <input type=hidden name=domains value="Aquarionics"><br><input type=radio name=sitesearch value=""> Everything <input type=radio name=sitesearch value="aquarionics.com" checked> Aquarionics 
    </p>
    </FORM>
    <!-- SiteSearch Google -->';*/

    $page->smallprint .= "&copy; 2000 to ".date("Y")." inclusive "
        #.$page->ulink("mailto:".$page->email, $page->author, "Email the author")
        .$page->ulink($_EP['adminurl'], $_EP['adminname'])
        ."<br>All comments are the property of their creators, published with permission"
        ."<br>(Unless otherwise indicated, the opinions and sentiments expressed on this site are those of the author and not of any organisation of which he is an affiliate, including his employer. Caveat Lector, E&amp;OE. <em>sigh</em>)";

    $page->generator = "Generated by <A HREF=\"http://trac.aqxs.net/epistula\">Epistula</A> Version ".$_EP['version'];

    $page->pagestats = number_format($stopwatch,3)." seconds, ".$_EP['sql']." queries, ";
    $page->pagestats .= round(memory_get_usage()/(1024*1024), 2).'Mb';
    $page->pagestats .= " on ".date("r");

    if (!$caching && !$_EP['caching']){
        $page->pagestats .= ", Not cached";
    }


    /*if(isset($_EP['chapter'])){
        $page->smallprint .= "<br>".$page->ulink("/showcode/chapters/".$_EP['chapter'], "/usr/src/luke","Source code for this page");
    }*/
    //$page->smallprint .= "<br>".$page->ulink("http://www.w3.org/WAI/", $page->image("/assets/images/buttons/wai-aa.gif", "[WAI AA Compliant]"), "Web Accessibility Guidelines Rule.");


    /*
    $temp = tempnam ("NOTHERE", "EP_");

    $fp = fopen ($temp, "a") or die("Cache Creation Failed!!");
    fwrite ($fp, $page->build());
    fclose($fp);

    $valid = `/home/webusers/aquarion/bin/validate $temp`;
    
    $valid = "";

    if ($valid != ""){
        $page->smallprint .= "<h3><a href=\"http://validator.w3.org/check/referer\">HTML Invalid :-|</A></h3><pre style=\"text-align: left\">$valid</pre>";
    } else {
        $page->smallprint .= $page->ulink("http://validator.w3.org/check/referer", $page->image("/assets/images/buttons/validhtml4.gif", "[HTML 4 Compliant]"), "Validation Is Good")."<br>\n";
    }


    unlink ($temp);
    */
    //$page->smallprint .= $page->ulink("http://validator.w3.org/check/referer", $page->image("/assets/images/buttons/validhtml4.gif", "[HTML 4 Compliant]"), "Validation Is Good")."<br>\n";

    //$del =  glob("/tmp/EP_*");

    $finalOutput = $page->build(); 
}

echo $finalOutput;

#echo "<pre>".$_EP['sqllog']."</pre>";

if ($caching == true || $_EP['caching'] == true || isset($_GET['regen'])){
    #$fp = fopen ($_EP['cachedir']."/".$cachename, "a") or die("Cache Creation Failed!!");
    #fwrite ($fp, $finalOutput);
    #fclose($fp);

    $gz = gzopen($_EP['cachedir']."/".$cachename, "wb") or die("Cache Creation Failed!!");
    gzwrite($gz, $finalOutput, strlen($finalOutput));
    gzclose($gz);
    
    
/*
    New directory-based caching. Unfinished 2003-06-28
    Problems:
        PHP saves the files as whatever apache is running as, ie nobody:nobody, meaning
        we shouldn't do this until we know that we can delete them from inside [E]

        It doesn't work :-|, it creates files like ../newcache/journalid812/index.html,
        which should be ../newcache/journal/id/812/index.html

    $path = "../newcache/";
    foreach($wanted as $dir){
        $path .= $dir;
        if (!file_exists($path)){
            mkdir($path);
        }
        $path .= "/";
    }

    $path .= "index.html";

    if ($fp = fopen ($path, "w")){
        fwrite ($fp, $finalOutput);
        #echo "Created ".$path."<br>";
    } else {
        #echo "Error writing to ".$path;
    }
    fclose($fp);*/
}

if (isset($_EP['debug'])){
    echo "<pre style='text-align: left; color: black; background: white;'>";
    print_r($page->debug);
    echo "</pre>";
}

?>



Using a heavily customised version of Tom's PHPCode2ValidXHTML Thing

Nicholas 'Aquarion' Avenell is a web developer in London, you can find out more about him or how to get in touch.

There are more Articles, Projects, Journal Entries, Photographs and things that defy description here, too.

If you're looking for something specific, there are Calendar & Category -based lists of everything.

And if you want to follow stuff that appears here, try a Syndication Feed, or the generic Feed of everything.


Aquarion's last Twitter was: [updating]
Twitter last updated


© 2000 to 2008 inclusive Nicholas Avenell
All comments are the property of their creators, published with permission
(Unless otherwise indicated, the opinions and sentiments expressed on this site are those of the author and not of any organisation of which he is an affiliate, including his employer. Caveat Lector, E&OE. sigh)
0.880 seconds, 1 queries, 3.02Mb on Sat, 17 May 2008 04:19:47 +0000, Not cached
Generated by Epistula Version 2.0.3