Aquarionics

/home/a/aquarion/sites/www.aquarionics.com/epistula/chapters/showcode.inc.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
/*******************************************************************************
    Chapter - ShowCode
********************************************************************************

    Display the sourcecode of Epistula

    $Id: showcode.inc.php,v 1.3 2004/08/17 19:59:35 aquarion Exp $

    $log$

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

/* Showcode.inc. Display the sourcecode of Epistula

    26/11/2002 - aq - First version.
    11/01/2004 - aq - Modified for licencing issues.

*/

$caching = false;


array_shift($wanted);

if ($wanted[0] == "newchapters"){
    $srcfile = "newchapters/".$wanted[1];
} elseif ($wanted[0] == "chapters"){
    $srcfile = "chapters/".$wanted[1];
} elseif ($wanted[0] == "include"){
    $srcfile = "include/".$wanted[1];
} elseif ($wanted[0] == "misc"){
    $srcfile = "admin/".$wanted[1];
} elseif ($wanted[0] == "contrib"){
    $srcfile = "contrib/".$wanted[1];
} else

#$srcfile = implode("/",$wanted);

$page->bgcolor = "#82004A";
$page->fgcolor = "#FFFFFF";


$srcmenu = array(
    array("name" => "Start", "link" => "/showcode/"),
    array("name" => "Library", "link" => "/showcode/include/library.php"),
    array("name" => "Classes", "link" => "/showcode/include/class.php"),
#    array("name" => "Comments", "link" => "/showcode/include/comment.inc"),
    array("name" => "XML-RPC Server", "link" => "/showcode/include/xmlrpc.inc"),
    array("name" => "[Ping|Track]back library", "link" => "/showcode/include/prackback.inc"),
    array("name" => "XFML Generation", "link" => "/showcode/include/xfml.inc"),
    array("name" => "SQL", "link" => "/showcode/src/maketables.sql")
);



$modulesmenu = array(
    array("name" => "Front Page", "link" => "/showcode/chapters/frontpage.inc.php"),
    array("name" => "Archive", "link" => "/showcode/chapters/archive.inc.php"),
    array("name" => "Article", "link" => "/showcode/chapters/article.inc.php"),
    array("name" => "Attachment", "link" => "/showcode/chapters/attachment.inc.php"),
    array("name" => "Blink", "link" => "/showcode/chapters/blink.inc.php"),
    array("name" => "Category", "link" => "/showcode/chapters/category.inc".php),
    array("name" => "Comments", "link" => "/showcode/chapters/comment.inc.php"),
#    array("name" => "Error", "link" => "/showcode/chapters/error.inc"), // no longer used
    array("name" => "Gallery", "link" => "/showcode/chapters/gallery.inc.php"),
    array("name" => "Logging", "link" => "/showcode/chapters/logging.inc.php"),
    array("name" => "Journal", "link" => "/showcode/chapters/journal.inc.php"),
    array("name" => "Meta", "link" => "/showcode/chapters/meta.inc.php"),
    array("name" => "Showcode", "link" => "/showcode/chapters/showcode.inc.php"),
    array("name" => "Sysadmin", "link" => "/showcode/chapters/sysadmin.inc.php"),
    array("name" => "Trackback", "link" => "/showcode/chapters/trackback.inc.php"),
    array("name" => "Writing", "link" => "/showcode/chapters/writing.inc.php"),
    array("name" => "Webcam", "link" => "/showcode/chapters/webcam.inc.php"),

);

$othersmenu = array(
    array("name" => "Amazon API", "link" => "/showcode/include/AmazonSearch.php"),
    array("name" => "IXR", "link" => "/showcode/include/IXR_Library.inc.php"),
    array("name" => "Jabber Class", "link" => "/showcode/include/class.jabber.php"),
    array("name" => "NuSoap", "link" => "/showcode/include/nusoap.php"),
    array("name" => "Textile", "link" => "/showcode/include/textile.php"),
    array("name" => "Other", "link" => "/showcode/include/ext-libs.inc.php")
);
    


$contribmenu = array(
    array("name" => "Example config", "link" => "/showcode/contrib/epistula.ini.dist"),
    array("name" => "SQL for tables", "link" => "/showcode/contrib/tables.sql"),
    array("name" => "Update reading list", "link" => "/showcode/contrib/amazon.php"),
    #array("name" => "Send apache log to database", "link" => "/showcode/contrib/apache2perl.pl"),
    array("name" => "Backups", "link" => "/showcode/contrib/backup.sh"),
    array("name" => "Incremental Backups", "link" => "/showcode/contrib/increment.sh"),
    array("name" => "Rotate banner", "link" => "/showcode/contrib/banner.sh"),
    array("name" => "Download Blogroll", "link" => "/showcode/contrib/blogroll.sh"),
    array("name" => "LJ Friends", "link" => "/showcode/contrib/ljfriends.sh"),
    array("name" => "Thumbnailise images", "link" => "/showcode/contrib/thumbnail")
);
    
$page->localnav = $page->subheading("Functions");
$page->localnav .= $page->menu($srcmenu,"cleanlist");

$page->localnav .= $page->subheading("Modules");
$page->localnav .= $page->menu($modulesmenu,"cleanlist");

$page->localnav .= $page->subheading("Scripts");
$page->localnav .= "Helpful scripts for the site";
$page->localnav .= $page->menu($contribmenu,"cleanlist");


$page->localnav .= $page->subheading("Other");
$page->localnav .= "Other people's libraries that [E]2 uses";
$page->localnav .= $page->menu($othersmenu,"cleanlist");


if ($srcfile == ""){
    $srcfile = "epistula.php";
}

$page->content .= $page->subheading($_EP['codedir']."/".$srcfile);

$page->content .= "<p>All my code (That is, anything not in the \"Others\" list on the right) is BSD licenced.</p>";

$page->content .= "<p> You can also view this page as <A HREF=\"?type=text\">text/plain</A> or <A HREF=\"?type=phps\">colour-coded source</A>";

if (!file_exists($_EP['codedir']."/".$srcfile)){
    #$page->status = 404;
    $page->content .= $_EP['codedir']."/".$srcfile;
} elseif (stristr($srcfile, "epistula.conf") || stristr($srcfile, "..")) {
    $page->status = 403;
    $page->content .= $page->item("Can't, or won't, display $srcfile.");
} elseif ($_GET['type'] == "text"){
    header("Content-Type: text/plain");
    $finalOutput = file_get_contents($srcfile);
} else {
    #ob_start();
    $colorsource .= '<pre class="source">';
    $source = highlight_file($srcfile, true);
    $search[0] = '<font color="'.ini_get('highlight.html').'">';
    $search[1] = '<font color="'.ini_get('highlight.default').'">';
    $search[2] = '<font color="'.ini_get('highlight.keyword').'">';
    $search[3] = '<font color="'.ini_get('highlight.string').'">';
    $search[4] = '<font color="'.ini_get('highlight.comment').'">';
    $search[5] = '</font>';
    $search[6] = '<br />';
    $search[7] = "\r";
    $search[8] = '&nbsp;';
#    $search[9] = '?';

    $replace[0] = '<code class="html">';
    $replace[1] = '<code class="default">';
    $replace[2] = '<code class="keyword">';
    $replace[3] = '<code class="string">';
    $replace[4] = '<code class="comment">';
    $replace[5] = '</code>';
    $replace[6] = "\n";
    $replace[7] = '';
    $replace[8] = ' ';
#    $replace[9] = '&quot;';

    #$pregin = "#".preg_quote("<code class=\"keyword\">function </code><code class=\"default\">","#")."(.*?)".preg_quote("</code>","#")."#";
    #echo $pregin;

    #$pregin = '#\<code class\="keyword"\>function \</code\>#';
    #$pregout = '<code class\="keyword"\>funktion \</code\>';

    $colorsource .=  str_replace($search,$replace,$source);
    $colorsource .= '</pre>';

    $pregin = '#function \</code\>\<code class\="default"\>(.*?)\</code\>#';
    $pregout = 'function <code class="default"><a href="#func$1" name="func$1">$1</a></code>';
    $colorsource = preg_replace($pregin, $pregout, $colorsource);

    $pregin = '#class \</code\>\<code class\="default"\>(.*?)\</code\>#';
    $pregout = 'class <code class="default"><a href="#class$1" name="class$1">$1</a></code>';
    $colorsource = preg_replace($pregin, $pregout, $colorsource);

    $pregin = '#class \</code\>\<code class\="default"\>(.*?)\</code\>#';
    $pregout = 'class <code class="default"><a href="#class$1" name="class$1">$1</a></code>';
    $colorsource = preg_replace($pregin, $pregout, $colorsource);

    #ob_end_clean();
    if ($_GET['type'] == "phps"){
        $finalOutput = "<html>\n"
            . "<head>\n"
            . "<title></title>\n"
            . "<link rel=\"stylesheet\" type=\"text/css\" href=\"/assets/basic.css\">\n"
            . "</head>\n"
            . "<body>\n"
            . $colorsource
            . "</body>\n"
            . "</html>\n";
    } else {
        $page->content .= "<div class=\"srccode\">".($colorsource."<br>Using a heavily customised version of ".$page->ulink("http://www.xiven.com/blog.php?start=26&amp;count=1","Tom's PHPCode2ValidXHTML Thing"))."</div>";
    }
}
?>



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.918 seconds, 1 queries, 2.73Mb on Fri, 08 Aug 2008 21:18:36 +0000, Not cached
Generated by Epistula Version 2.0.3