All pastes #440652 Raw Edit

Lucas! php2.0

public php v1 · immutable
·published 2007-04-15 05:29 UTC
rendered paste body
<?php$time_start = microtime_float();ob_start();session_start();$page = array();foreach($_GET as $key => $value) $page[] = htmlentities(stripslashes($key));// allowed pages$pages = array('index');// the first element in the $page array$tpage = in_array($page[0], $pages) ? $page[0] : null;// writes color to session if issetif(isset($_GET['c'])) $_SESSION['c'] = $_GET['c'];// calls the head function with specified color, and default if not setif(isset($_SESSION['c'])) head($_SESSION['c'], $loc, $tpage);else head(fc0, $loc, $tpage);// index if the page is nullif($tpage == null) index();else{    // if called page is in array, then show that page.. else show index    if(in_array($page[0], $pages)) $page[0]();    else index();}foot('true');// flushes out buffer to browserob_end_flush;// functions//structure: page function then supporting functions.function index(){    echo "welcome test 123";    }function direc($dir) {    if(is_dir($dir)) {        if($dh = opendir($dir)) {            while(($fh = readdir($dh)) !== false) {                if($fh != '.' && $fh != '..') {                    if(is_dir($realfile)) {                        chdir('.');                        $tree[$fh] = direc($realfile);                    } else {                            $tree[] = $fh;                    }                }            }            closedir($dh);            return @$tree;        }    }}function microtime_float(){   list($usec, $sec) = explode(" ", microtime());   return ((float)$usec + (float)$sec);}function top($title, $time, $auth = 'lucmedia'){    global $page;    echo '<h1>'.$title.'</h1><div class="htimeauth">'.$time.' |';    //echo ' <a href="'.$loc.'?about='.$auth.'">'.$auth.'</a></div>'."\n";    echo ' '.$auth.'</div>'."\n";    //echo '<pre>';    //print_r($page);    //echo '</pre>';}function head($color, $location, $sub = 'index'){?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" ><head><title>lucasmedia - <?= $sub ?></title><meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /><meta name="description" content="" /><meta name="keywords" content="" /><script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">_uacct = "UA-573671-1";urchinTracker();</script><style type="text/css"><?php include 'style.php'; ?></style></head><body>    <div id="outer">        <div class="orange"></div>        <div id="location">/lucmedia/site/<?=$sub?>/</div>        <div id="left">            <div class="navouter">                <div class="orange"></div>                <div class="navheader">Main Menu</div>                <div class="navcontent">                    <ul>                    <li><a href="<?= $location ?>">home</a></li>                    </ul>                </div>            </div>            <div class="navouter">                <div class="orange"></div>                <div class="navheader">Linkage</div>                <div class="navcontent">                    i support:                    <ul>                    <li><a href="http://tinyurl.com/zo4qr">firefox</a></li>                    <li><a href="http://notepad-plus.sourceforge.net/uk/site.htm">notepad++</a></li>                    <li><a href="http://linux.com">linux</a></li>                    <li><a href="http://php.net">php</a>/<a href="http://mysql.org">mysql</a></li>                    <li><a href="http://nintendo.com">nintendo</a></li>                    <li><a href="http://en.wikipedia.org/wiki/Open_Source">open source</a></li>                    </ul>                    other:                    <ul>                    <li><a href="http://icodeviruses.com/forum.virus">i code viruses</a></li>                    </ul>                </div>            </div>        </div>  <!-- left -->        <div id="right"><?php}function foot($color = null){global $time_start, $page, $pages;if(in_array($page[0], $pages))    $link = '?'.$page[0].'&c=';else    $link = '?c=';$time_end = microtime_float();$time = $time_end - $time_start;?>        </div> <!-- right -->            </div> <!-- outer -->    <div id="footer">        <div class="orange"></div>        <p>        <?php if($color == true){ ?>::         <?php } ?>source rendered in (<?php echo $time; ?>) seconds        | displays best in <a href="http://tinyurl.com/zo4qr">firefox</a>        <?php if($color == true){ ?>        ::        <?php } ?>        </p>    </div>    </body></html><?php}function format($chk_str){    $a = explode(" ", $chk_str);    for($i=0; $i<count($a); $i++){//Take care of URLs that don't start with "http://"        $b = str_replace("ww.", "http://www.", $a[$i]);        $b = str_replace("www.", "http://www.", $a[$i]);        $b = str_replace("http://http://", "http://", $b);//Identify URL        $pos = strpos($b, "http://");        if ($pos === false) { // note: three equal signs            $url_found = false;        } else {            $url_found = true;        }                if($url_found){//Replace URL with formatted URL            $a[$i] = "$b";        }    }    //Put string toghet with formatted links    $chk_str = implode(" ", $a);//Return formatted string    return $chk_str;}    ?>