/**
 * Brings all the output elements together and terminates the rendering of the page.  Saves the current user info and updates the rendering statistics
 * Hooks provided:
 *	footer-{$script name}
 *	everyfooter
 *
 */
function page_footer($saveuser = true)
{
    global $output, $nestedtags, $header, $nav, $session, $REMOTE_ADDR, $REQUEST_URI, $pagestarttime, $quickkeys, $template, $y2, $z2, $logd_version, $copyright, $SCRIPT_NAME, $nopopups, $footer, $dbinfo;
    $z = $y2 ^ $z2;
    $footer = $template['footer'];
    //page footer module hooks
    $script = substr($SCRIPT_NAME, 0, strpos($SCRIPT_NAME, "."));
    $replacementbits = array();
    $replacementbits = modulehook("footer-{$script}", $replacementbits);
    if ($script == "runmodule" && ($module = httpget('module')) > "") {
        // This modulehook allows you to hook directly into any module without
        // the need to hook into footer-runmodule and then checking for the
        // required module.
        modulehook("footer-{$module}", $replacementbits);
    }
    // Pass the script file down into the footer so we can do something if
    // we need to on certain pages (much like we do on the header.
    // Problem is 'script' is a valid replacement token, so.. use an
    // invalid one which we can then blow away.
    $replacementbits['__scriptfile__'] = $script;
    $replacementbits = modulehook("everyfooter", $replacementbits);
    if ($session['user']['loggedin']) {
        $replacementbits = modulehook("everyfooter-loggedin", $replacementbits);
    }
    unset($replacementbits['__scriptfile__']);
    //output any template part replacements that above hooks need (eg,
    //advertising)
    reset($replacementbits);
    while (list($key, $val) = each($replacementbits)) {
        $header = str_replace("{" . $key . "}", "{" . $key . "}" . join($val, ""), $header);
        $footer = str_replace("{" . $key . "}", "{" . $key . "}" . join($val, ""), $footer);
    }
    $builtnavs = buildnavs();
    restore_buff_fields();
    calculate_buff_fields();
    tlschema("common");
    $charstats = charstats();
    restore_buff_fields();
    $sql = "SELECT motddate FROM " . db_prefix("motd") . " ORDER BY motditem DESC LIMIT 1";
    $result = db_query_cached($sql, "motd-dates");
    $row = db_fetch_assoc($result);
    db_free_result($result);
    $headscript = "";
    if (isset($session['user']['lastmotd']) && $row['motddate'] > $session['user']['lastmotd'] && (!isset($nopopup[$SCRIPT_NAME]) || $nopopups[$SCRIPT_NAME] != 1) && $session['user']['loggedin']) {
        // $headscript.=popup("motd.php");
        $session['needtoviewmotd'] = true;
    } else {
        $session['needtoviewmotd'] = false;
    }
    $pre_headscript = "<LINK REL=\"shortcut icon\" HREF=\"favicon.ico\" TYPE=\"image/x-icon\"/>";
    if ($headscript > "") {
        $header = str_replace("{headscript}", $pre_headscript . "<script language='JavaScript'>" . $headscript . "</script>", $header);
    } else {
        $header = str_replace("{headscript}", $pre_headscript, $header);
    }
    $script = "";
    if (!isset($session['user']['name'])) {
        $session['user']['name'] = "";
    }
    if (!isset($session['user']['login'])) {
        $session['user']['login'] = "";
    }
    //clean up unclosed output tags.
    while (list($key, $val) = each($nestedtags)) {
        if ($nestedtags[$key] === true) {
            $output .= "</{$key}>";
        }
        unset($nestedtags[$key]);
    }
    //output keypress script
    $script .= "<script language='JavaScript'>\r\n\t<!--\r\n\tdocument.onkeypress=keyevent;\r\n\tfunction keyevent(e){\r\n\t\tvar c;\r\n\t\tvar target;\r\n\t\tvar altKey;\r\n\t\tvar ctrlKey;\r\n\t\tif (window.event != null) {\r\n\t\t\tc=String.fromCharCode(window.event.keyCode).toUpperCase();\r\n\t\t\taltKey=window.event.altKey;\r\n\t\t\tctrlKey=window.event.ctrlKey;\r\n\t\t}else{\r\n\t\t\tc=String.fromCharCode(e.charCode).toUpperCase();\r\n\t\t\taltKey=e.altKey;\r\n\t\t\tctrlKey=e.ctrlKey;\r\n\t\t}\r\n\t\tif (window.event != null)\r\n\t\t\ttarget=window.event.srcElement;\r\n\t\telse\r\n\t\t\ttarget=e.originalTarget;\r\n\t\tif (target.nodeName.toUpperCase()=='INPUT' || target.nodeName.toUpperCase()=='TEXTAREA' || altKey || ctrlKey){\r\n\t\t}else{";
    reset($quickkeys);
    while (list($key, $val) = each($quickkeys)) {
        $script .= "\n\t\t\tif (c == '" . strtoupper($key) . "') { {$val}; return false; }";
    }
    $script .= "\r\n\t\t}\r\n\t}\r\n\t//-->\r\n\t</script>";
    //handle paypal
    if (strpos($footer, "{paypal}") || strpos($header, "{paypal}")) {
        $palreplace = "{paypal}";
    } else {
        $palreplace = "{stats}";
    }
    //NOTICE |
    //NOTICE | Although under the license, you're not required to keep this
    //NOTICE | paypal link, I do request, as the author of this software
    //NOTICE | which I have made freely available to you, that you leave it in.
    //NOTICE |
    $paypalstr = '<table align="center"><tr><td>';
    $currency = getsetting("paypalcurrency", "USD");
    if (!isset($_SESSION['logdnet']) || !isset($_SESSION['logdnet']['']) || $_SESSION['logdnet'][''] == "" || !isset($session['user']['laston']) || date("Y-m-d H:i:s", strtotime("-1 hour")) > $session['user']['laston']) {
        $already_registered_logdnet = false;
    } else {
        $already_registered_logdnet = true;
    }
    if (getsetting("logdnet", 0) && $session['user']['loggedin'] && !$already_registered_logdnet) {
        //account counting, just for my own records, I don't use this in the calculation for server order.
        $sql = "SELECT count(*) AS c FROM " . db_prefix("accounts");
        $result = db_query_cached($sql, "acctcount", 600);
        $row = db_fetch_assoc($result);
        $c = $row['c'];
        $a = getsetting("serverurl", "http://" . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . $_SERVER['SERVER_PORT']) . dirname($_SERVER['REQUEST_URI']));
        if (!preg_match("/\\/\$/", $a)) {
            $a = $a . "/";
            savesetting("serverurl", $a);
        }
        $l = getsetting("defaultlanguage", "en");
        $d = getsetting("serverdesc", "Another LoGD Server");
        $e = getsetting("gameadminemail", "*****@*****.**");
        $u = getsetting("logdnetserver", "http://logdnet.logd.com/");
        if (!preg_match("/\\/\$/", $u)) {
            $u = $u . "/";
            savesetting("logdnetserver", $u);
        }
        global $logd_version;
        $v = $logd_version;
        $c = rawurlencode($c);
        $a = rawurlencode($a);
        $l = rawurlencode($l);
        $d = rawurlencode($d);
        $e = rawurlencode($e);
        $v = rawurlencode($v);
        $u = rawurlencode($u);
        $paypalstr .= "<script language='JavaScript' src='images/logdnet.php?op=register&c={$c}&l={$l}&v={$v}&a={$a}&d={$d}&e={$e}&u={$u}'></script>";
    } else {
        $paypalstr .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="*****@*****.**">
<input type="hidden" name="item_name" value="Legend of the Green Dragon Author Donation from ' . full_sanitize($session['user']['name']) . '">
<input type="hidden" name="item_number" value="' . htmlentities($session['user']['login'] . ":" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . '">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="notify_url" value="http://lotgd.net/payment.php">
<input type="hidden" name="cn" value="Your Character Name">
<input type="hidden" name="cs" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0">
<input type="image" src="images/paypal1.gif" border="0" name="submit" alt="Donate!">
</form>';
    }
    $paysite = getsetting("paypalemail", "");
    if ($paysite != "") {
        $paypalstr .= '</td></tr><tr><td colspan=\'2\' align=\'center\'>';
        $paypalstr .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="' . $paysite . '">
<input type="hidden" name="item_name" value="' . getsetting("paypaltext", "Legend of the Green Dragon Site Donation from") . ' ' . full_sanitize($session['user']['name']) . '">
<input type="hidden" name="item_number" value="' . htmlentities($session['user']['login'] . ":" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . '">
<input type="hidden" name="no_shipping" value="1">';
        if (file_exists("payment.php")) {
            $paypalstr .= '<input type="hidden" name="notify_url" value="http://' . $_SERVER["HTTP_HOST"] . dirname($_SERVER['REQUEST_URI']) . '/payment.php">';
        }
        $paypalstr .= '<input type="hidden" name="cn" value="Your Character Name">
<input type="hidden" name="cs" value="1">
<input type="hidden" name="currency_code" value="' . $currency . '">
<input type="hidden" name="lc" value="' . getsetting("paypalcountry-code", "US") . '">
<input type="hidden" name="bn" value="PP-DonationsBF">
<input type="hidden" name="tax" value="0">
<input type="image" src="images/paypal2.gif" border="0" name="submit" alt="Donate!">
</form>';
    }
    $paypalstr .= '</td></tr></table>';
    $footer = str_replace($palreplace, (strpos($palreplace, "paypal") ? "" : "{stats}") . $paypalstr, $footer);
    $header = str_replace($palreplace, (strpos($palreplace, "paypal") ? "" : "{stats}") . $paypalstr, $header);
    //NOTICE |
    //NOTICE | Although I will not deny you the ability to remove the above
    //NOTICE | paypal link, I do request, as the author of this software
    //NOTICE | which I made available for free to you that you leave it in.
    //NOTICE |
    //output the nav
    $footer = str_replace("{" . $z . "}", ${$z}, $footer);
    $header = str_replace("{nav}", $builtnavs, $header);
    $footer = str_replace("{nav}", $builtnavs, $footer);
    //output the motd
    $header = str_replace("{motd}", motdlink(), $header);
    $footer = str_replace("{motd}", motdlink(), $footer);
    //output the mail link
    if (isset($session['user']['acctid']) && $session['user']['acctid'] > 0 && $session['user']['loggedin']) {
        $header = str_replace("{mail}", maillink(), $header);
        $footer = str_replace("{mail}", maillink(), $footer);
    } else {
        $header = str_replace("{mail}", "", $header);
        $footer = str_replace("{mail}", "", $footer);
    }
    //output petition count
    $header = str_replace("{petition}", "<a href='petition.php' onClick=\"" . popup("petition.php") . ";return false;\" target='_blank' align='right' class='motd'>" . translate_inline("Petition for Help") . "</a>", $header);
    $footer = str_replace("{petition}", "<a href='petition.php' onClick=\"" . popup("petition.php") . ";return false;\" target='_blank' align='right' class='motd'>" . translate_inline("Petition for Help") . "</a>", $footer);
    if ($session['user']['superuser'] & SU_EDIT_PETITIONS) {
        $sql = "SELECT count(petitionid) AS c,status FROM " . db_prefix("petitions") . " GROUP BY status";
        $result = db_query_cached($sql, "petition_counts");
        $petitions = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0);
        while ($row = db_fetch_assoc($result)) {
            $petitions[(int) $row['status']] = $row['c'];
        }
        $pet = translate_inline("`0`bPetitions:`b");
        $ued = translate_inline("`0`bUser Editor`b");
        db_free_result($result);
        if ($session['user']['superuser'] & SU_EDIT_USERS) {
            $p = "<a href='user.php'>{$ued}</a>|<a href='viewpetition.php'>{$pet}</a>";
            addnav("", "user.php");
            addnav("", "viewpetition.php");
        } else {
            $p = "<a href='viewpetition.php'>{$pet}</a>";
            addnav("", "viewpetition.php");
        }
        $p .= " `\${$petitions[5]}`0|`^{$petitions[4]}`0|`b{$petitions[0]}`b|{$petitions[1]}|`!{$petitions[3]}`0|`#{$petitions[7]}`0|`%{$petitions[6]}`0|`i{$petitions[2]}`i";
        $pcount = templatereplace("petitioncount", array("petitioncount" => appoencode($p, true)));
        $footer = str_replace("{petitiondisplay}", $pcount, $footer);
        $header = str_replace("{petitiondisplay}", $pcount, $header);
    } else {
        $footer = str_replace("{petitiondisplay}", "", $footer);
        $header = str_replace("{petitiondisplay}", "", $header);
    }
    //output character stats
    $footer = str_replace("{stats}", $charstats, $footer);
    $header = str_replace("{stats}", $charstats, $header);
    //do something -- I don't know what
    $header = str_replace("{script}", $script, $header);
    //output view PHP source link
    $sourcelink = "source.php?url=" . preg_replace("/[?].*/", "", $_SERVER['REQUEST_URI']);
    $footer = str_replace("{source}", "<a href='{$sourcelink}' onclick=\"" . popup($sourcelink) . ";return false;\" target='_blank'>" . translate_inline("View PHP Source") . "</a>", $footer);
    $header = str_replace("{source}", "<a href='{$sourcelink}' onclick=\"" . popup($sourcelink) . ";return false;\" target='_blank'>" . translate_inline("View PHP Source") . "</a>", $header);
    //output version
    $footer = str_replace("{version}", "Version: {$logd_version}", $footer);
    //output page generation time
    $gentime = getmicrotime() - $pagestarttime;
    $session['user']['gentime'] += $gentime;
    $session['user']['gentimecount']++;
    $load = exec("uptime");
    $load = split("load average:", $load);
    $load = split(", ", $load[1]);
    $perfhook = array("gentime" => $gentime, "dbinfo" => $dbinfo, "cpu" => $load, "script" => $SCRIPT_NAME, "request" => $REQUEST_URI);
    $perfhook = modulehook("footer-performance", $perfhook);
    $l1 = $load[0];
    $l5 = $load[1];
    $l15 = $load[2];
    $mem = memory_get_usage(true);
    if ($mem < 1024) {
        $memdisp = $mem . " bytes";
    } else {
        if ($mem < 1048576) {
            $memdisp = round($mem / 1024, 6) . " kilobytes";
        } else {
            $memdisp = round($mem / 1048576, 6) . " megabytes";
        }
    }
    if (!isset($dbinfo['cache_fail'])) {
        $dbinfo['cache_fail'] = 0;
    }
    global $output_time;
    $footer = str_replace("{pagegen}", "Page gen: " . round($gentime, 3) . "s / " . $dbinfo['queriesthishit'] . " queries (" . round($dbinfo['querytime'], 3) . "s), cache " . $dbinfo['cache_success'] . " successful (" . round($dbinfo['cachetime'], 3) . "s) / " . $dbinfo['cache_fail'] . " failed.  Average for this account: " . round($session['user']['gentime'] / $session['user']['gentimecount'], 3) . "s - " . round($session['user']['gentime'], 3) . "/" . round($session['user']['gentimecount'], 3) . "<br />Current CPU Load: {$l1} | {$l5} | {$l15}<br />Memory usage for this page: {$memdisp}", $footer);
    tlschema();
    // global $allqueries;
    // debug($allqueries);
    // global $cachedqueries;
    // debug($cachedqueries);
    // global $module_prefs;
    // debug($module_prefs);
    // global $moduleperformance;
    // debug($moduleperformance);
    // global $allqueriesbyfile;
    // debug($allqueriesbyfile);
    //clean up spare {fields}s from header and footer (in case they're not used)
    $footer = preg_replace("/{[^} \t\n\r]*}/i", "", $footer);
    $header = preg_replace("/{[^} \t\n\r]*}/i", "", $header);
    //finalize output
    $output = $header . $output . $footer;
    $session['user']['gensize'] += strlen($output);
    $session['output'] = $output;
    if ($saveuser === true) {
        saveuser();
    }
    unset($session['output']);
    //this somehow allows some frames to load before the user's navs say it can
    //session_write_close();
    echo $output;
    $session['badnav'] = 0;
    exit;
}
コード例 #2
0
function page_footer()
{
    global $output, $nestedtags, $header, $nav, $session, $REMOTE_ADDR, $REQUEST_URI, $pagestarttime, $quickkeys, $template, $logd_version;
    while (list($key, $val) = each($nestedtags)) {
        $output .= "</{$key}>";
        unset($nestedtags[$key]);
    }
    $script .= "<script type='text/javascript'>\n\t<!--\n\tdocument.onkeypress=keyevent;\n\tfunction keyevent(e){\n\t\tvar c;\n\t\tvar target;\n\t\tvar altKey;\n\t\tvar ctrlKey;\n\t\tif (window.event != null) {\n\t\t\tc=String.fromCharCode(window.event.keyCode).toUpperCase(); \n\t\t\taltKey=window.event.altKey;\n\t\t\tctrlKey=window.event.ctrlKey;\n\t\t}else{\n\t\t\tc=String.fromCharCode(e.charCode).toUpperCase();\n\t\t\taltKey=e.altKey;\n\t\t\tctrlKey=e.ctrlKey;\n\t\t}\n\t\tif (window.event != null)\n\t\t\ttarget=window.event.srcElement;\n\t\telse\n\t\t\ttarget=e.originalTarget;\n\t\tif (target.nodeName.toUpperCase()=='INPUT' || target.nodeName.toUpperCase()=='TEXTAREA' || altKey || ctrlKey){\n\t\t}else{";
    reset($quickkeys);
    while (list($key, $val) = each($quickkeys)) {
        $script .= "\n\t\t\tif (c == '" . strtoupper($key) . "') { {$val}; return false; }";
    }
    $script .= "\n\t\t}\n\t}\n\t//-->\n\t</script>";
    $footer = $template['footer'];
    $header = str_replace("{nav}", $nav, $header);
    $footer = str_replace("{nav}", $nav, $footer);
    $header = str_replace("{motd}", motdlink(), $header);
    $footer = str_replace("{motd}", motdlink(), $footer);
    if ($session['user']['acctid'] > 0) {
        $header = str_replace("{mail}", maillink(), $header);
        $footer = str_replace("{mail}", maillink(), $footer);
    } else {
        $header = str_replace("{mail}", "", $header);
        $footer = str_replace("{mail}", "", $footer);
    }
    $header = str_replace("{petition}", "<a href='petition.php' onClick=\"" . popup("petition.php") . ";return false;\" target='_blank' class='motd'>Petition for Help</a>", $header);
    $footer = str_replace("{petition}", "<a href='petition.php' onClick=\"" . popup("petition.php") . ";return false;\" target='_blank' class='motd'>Petition for Help</a>", $footer);
    if ($session['user']['superuser'] > 1) {
        $sql = "SELECT count(petitionid) AS c,status FROM petitions GROUP BY status";
        $result = db_query($sql);
        $petitions = array(0 => 0, 1 => 0, 2 => 0);
        for ($i = 0; $i < db_num_rows($result); $i++) {
            $row = db_fetch_assoc($result);
            $petitions[(int) $row['status']] = $row['c'];
        }
        db_free_result($result);
        $footer = "<table border='0' cellpadding='5' cellspacing='0' align='right'><tr><td><b>Petitions:</b> {$petitions['0']} Unseen, {$petitions['1']} Seen, {$petitions['2']} Closed.</td></tr></table>" . $footer;
    }
    $footer = str_replace("{stats}", charstats(), $footer);
    $header = str_replace("{stats}", charstats(), $header);
    //$footer=str_replace("{onlinechars}", onlinechars(), $footer);
    //$header=str_replace("{onlinechars}", onlinechars(), $header);
    $header = str_replace("{script}", $script, $header);
    $footer = str_replace("{source}", "<a href='source.php?url=" . preg_replace("/[?].*/", "", $_SERVER['REQUEST_URI']) . "' target='_blank'>View PHP Source</a>", $footer);
    $header = str_replace("{source}", "<a href='source.php?url=" . preg_replace("/[?].*/", "", $_SERVER['REQUEST_URI']) . "' target='_blank'>View PHP Source</a>", $header);
    $footer = str_replace("{copyright}", "Copyright 2002-2003, Game: Eric Stevens", $footer);
    $footer = str_replace("{version}", "Version: {$logd_version}", $footer);
    $gentime = getmicrotime() - $pagestarttime;
    $session['user']['gentime'] += $gentime;
    $session['user']['gentimecount']++;
    $footer = str_replace("{pagegen}", "Page gen: " . round($gentime, 2) . "s, Ave: " . round($session['user']['gentime'] / $session['user']['gentimecount'], 2) . "s - " . round($session['user']['gentime'], 2) . "/" . round($session['user']['gentimecount'], 2) . "", $footer);
    $output = $header . $output . $footer;
    $session['user']['gensize'] += strlen($output);
    $session['output'] = $output;
    saveuser();
    session_write_close();
    //`mpg123 -g 100 -q hit.mp3 2>&1 > /dev/null`;
    echo $output;
    exit;
}
コード例 #3
0
function page_footer(){
	global $output,$nestedtags,$header,$nav,$session,$REMOTE_ADDR,$REQUEST_URI,$pagestarttime,$quickkeys,$template,$logd_version;
	while (list($key,$val)=each($nestedtags)){
		$output.="</$key>";

		unset($nestedtags[$key]);
	}
	$script.="<script language='JavaScript'>
	<!--
	document.onkeypress=keyevent;
	function keyevent(e){
		var c;
		var target;
		var altKey;
		var ctrlKey;
		if (window.event != null) {
			c=String.fromCharCode(window.event.keyCode).toUpperCase(); 
			altKey=window.event.altKey;
			ctrlKey=window.event.ctrlKey;
		}else{
			c=String.fromCharCode(e.charCode).toUpperCase();
			altKey=e.altKey;
			ctrlKey=e.ctrlKey;
		}
		if (window.event != null)
			target=window.event.srcElement;
		else
			target=e.originalTarget;
		if (target.nodeName.toUpperCase()=='INPUT' || target.nodeName.toUpperCase()=='TEXTAREA' || altKey || ctrlKey){
		}else{";
	reset($quickkeys);
	while (list($key,$val)=each($quickkeys)){
		$script.="\n			if (c == '".strtoupper($key)."') { $val; return false; }";
	}
	$script.="
		}
	}
	//-->
	</script>";
	

	$footer = $template['footer'];
	if (strpos($footer,"{paypal}") || strpos($header,"{paypal}")){ $palreplace="{paypal}"; }else{ $palreplace="{stats}"; }
	
	//NOTICE
	//NOTICE Although I will not deny you the ability to remove the below paypal link, I do request, as the author of this software
	//NOTICE that you leave it in.
	//NOTICE
	$paypalstr = '<table align="center"><tr><td>';
	$paypalstr .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="*****@*****.**">
<input type="hidden" name="item_name" value="Legend of the Green Dragon Author Donation from '.preg_replace("/[`]./","",$session['user']['name']).'">
<input type="hidden" name="item_number" value="'.htmlentities($session['user']['login']).":".$_SERVER['HTTP_HOST']."/".$_SERVER['REQUEST_URI'].'">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="cn" value="Your Character Name">
<input type="hidden" name="cs" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0">
<input type="image" src="images/paypal1.gif" border="0" name="submit" alt="Donate!">
</form>';
	$paysite = getsetting("paypalemail", "");
	if ($paysite != "") {
		$paypalstr .= '</td><td>';
		$paypalstr .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
		<input type="hidden" name="cmd" value="_xclick">
		<input type="hidden" name="business" value="'.$paysite.'">
<input type="hidden" name="item_name" value="Legend of the Green Dragon Site Donation from '.preg_replace("/[`]./","",$session['user']['name']).'">
<input type="hidden" name="item_number" value="'.htmlentities($session['user']['login']).":".$_SERVER['HTTP_HOST']."/".$_SERVER['REQUEST_URI'].'">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="cn" value="Your Character Name">
<input type="hidden" name="cs" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0">
<input type="image" src="images/paypal2.gif" border="0" name="submit" alt="Donate!">
</form>';
	}
    $paypalstr .= '</td></tr></table>';
	$footer=str_replace($palreplace,(strpos($palreplace,"paypal")?"":"{stats}").$paypalstr,$footer);
	$header=str_replace($palreplace,(strpos($palreplace,"paypal")?"":"{stats}").$paypalstr,$header);
	//NOTICE
	//NOTICE Although I will not deny you the ability to remove the above paypal link, I do request, as the author of this software
	//NOTICE that you leave it in.
	//NOTICE
	$header=str_replace("{nav}",$nav,$header);
	$footer=str_replace("{nav}",$nav,$footer);

	$header = str_replace("{motd}", motdlink(), $header);
	$footer = str_replace("{motd}", motdlink(), $footer);

	if ($session[user][acctid]>0) {
		$header=str_replace("{mail}",maillink(),$header);
		$footer=str_replace("{mail}",maillink(),$footer);
	}else{
		$header=str_replace("{mail}","",$header);
		$footer=str_replace("{mail}","",$footer);
	}
	$header=str_replace("{petition}","<a href='petition.php' onClick=\"".popup("petition.php").";return false;\" target='_blank' align='right' class='motd'>Petition for Help</a>",$header);
	$footer=str_replace("{petition}","<a href='petition.php' onClick=\"".popup("petition.php").";return false;\" target='_blank' align='right' class='motd'>Petition for Help</a>",$footer);
	if ($session['user']['superuser']>1){
		$sql = "SELECT count(petitionid) AS c,status FROM petitions GROUP BY status";
		$result = db_query($sql);
		$petitions=array(0=>0,1=>0,2=>0);
		for ($i=0;$i<db_num_rows($result);$i++){
			$row = db_fetch_assoc($result);
			$petitions[(int)$row['status']] = $row['c'];
		}
		db_free_result($result);
		$footer = "<table border='0' cellpadding='5' cellspacing='0' align='right'><tr><td><b>Petitions:</b> $petitions[0] Unseen, $petitions[1] Seen, $petitions[2] Closed.</td></tr></table>".$footer;
	}
	$footer=str_replace("{stats}",charstats(),$footer);
	$header=str_replace("{stats}",charstats(),$header);
	$header=str_replace("{script}",$script,$header);
	$footer=str_replace("{source}","<a href='source.php?url=".preg_replace("/[?].*/","",($_SERVER['REQUEST_URI']))."' target='_blank'>View PHP Source</a>",$footer);
	$header=str_replace("{source}","<a href='source.php?url=".preg_replace("/[?].*/","",($_SERVER['REQUEST_URI']))."' target='_blank'>View PHP Source</a>",$header);
	$footer=str_replace("{copyright}","Copyright 2002-2003, Game: Eric Stevens",$footer);
	$footer=str_replace("{version}", "Version: $logd_version", $footer);
	$gentime = getmicrotime()-$pagestarttime;
	$session[user][gentime]+=$gentime;
	$session[user][gentimecount]++;
	$footer=str_replace("{pagegen}","Page gen: ".round($gentime,2)."s, Ave: ".round($session[user][gentime]/$session[user][gentimecount],2)."s - ".round($session[user][gentime],2)."/".round($session[user][gentimecount],2)."",$footer);
	if (strpos($_SERVER['HTTP_HOST'],"lotgd.net")!==false){
		$footer=str_replace(
			"</html>",
			'<script language="JavaScript" type="text/JavaScript" src="http://www.reinvigorate.net/archive/app.bin/jsinclude.php?5193"></script></html>',
			$footer
			);
	}

	$output=$header.$output.$footer;
	$session['user']['gensize']+=strlen($output);
	$session[output]=$output;
	saveuser();

	session_write_close();
	//`mpg123 -g 100 -q hit.mp3 2>&1 > /dev/null`;
	echo $output;
	exit();
}