예제 |
ex1)
;;
;; /usr/local/lib/php.ini
;;
; automatically add files before or after any PHP document
auto_prepend_file = /any/path/to/header.php
auto_append_file = /any/path/to/fooer.php
ex2)
## or httpd.conf(virtualhost session or main config)
## or $DOCUMENT_ROOT/.htaccess
##
php_value auto_prepend_file /any/path/to/header.php
php_value auto_append_file /any/path/to/fooer.php
|
header.php source |
<?php // *** file save as UTF-8 // not UTF-8 BOM global $_start; $_start = microtime(); ?>
|
footer.php source |
<?php ## ## this file is 'footer.php' *** file save as UTF-8 // not UTF-8 BOM ## function __get_microtime($_start, $_end=NULL, $d=4) { $start = explode(' ', $_start); $end = explode(' ', $_end ?? microtime());
## (A+A')-(B+B') better than (A-B)+(A'-B') return sprintf("%.${d}f", ($end[1]+$end[0])-($start[1]+$start[0])); }
## ge user screen width, height by javascript ## ## function __get_js_putscreen($putfile) { $putfile = preg_replace(';/+$;','',$putfile); if(!file_exists($_SERVER['DOCUMENT_ROOT'].'/'.$putfile)) return;
return <<<__EOP \n<SCRIPT LANGUAGE='JavaScript' type='text/JavaScript'> <!-- var sw = screen.width; var sh = screen.height; document.write('<IMG SRC=$putfile/'+sw+'/'+sh+'/null.gif WIDTH=1 HEIGHT=1 BORDER=0>'); //--> </SCRIPT> __EOP; }
## put user referer ## function __dbs_put_referer($dbs, $table, $referer) { $adate = date('Y-m-d'); $ipv4 = get_hostname(); $agent = get_agent(); $rhost = preg_replace('/^www\./','',strtolower($referer[2]));
unset($referer[0],$referer[1],$referer[2]);
$ruri = '/'.implode('/',$referer); $sid = md5($adate.$ipv4.$ruri); /*** PRIMARY KEY or UNIQUE KEY ***/ $sql = "INSERT INTO $table SET sid = '$sid', adate = '$adate', ipv4 = '$ipv4', agent_br = '".$agent['br']."', agent_os = '".$agent['os']."', rhost = '$rhost', ruri = '$ruri', uri = '".$_SERVER['REQUEST_URI']."'";
return $dbs->query($sql); }
@error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
## close mysql resource ## //if(is_resource($CONT) && get_resource_type($CONT) == 'mysql link') //{ @mysqli_close($CONT); }
global $_start, $not, $_not;
$not ??= 0; $_not ??= 0;
if($not || $_not) { if(isset($CONT)) @mysqli_close($CONT); exit; // not return }
#################################################### ## execute main footer ####################################################
$_start ??= microtime(); $_end = microtime(); $not = $_not = 1; // do not self include
## print footer message ## echo __get_js_putscreen('/misc/putscreen.php'); $usec = __get_microtime($_start,$_end,2); //echo "<BR>\n<FONT SIZE=2><A HREF='/rstime/'>Result Server time : $usec secs</A></FONT>\n";
//$_js_utils_php = 1; //$_js_jquery_min_php = 1; //$_js_jquery_tablesorter_min_php = 1; //$_js_jquery_metadata_php = 1;
echo "<BR>\n"; echo "<span class=copy>Page loading: <span id=servertime>$usec</span>(server) + <span id=nettime></span>(network) + <span id=loadtime></span>(browser) seconds</span>\n";
if(!isset($_js_utils_php)) echo '<SCRIPT LANGUAGE="JavaScript" type="text/JavaScript" SRC="/_lib/js.utils.php"></SCRIPT>'."\n"; if(!isset($_js_jquery_min_php)) echo '<SCRIPT LANGUAGE="JavaScript" type="text/JavaScript" SRC="/_lib/js.jquery.min.php"></SCRIPT>'."\n"; ?> <SCRIPT LANGUAGE="JavaScript" type="text/JavaScript"> <!-- $(document).ready(function() { //$(window).unload(function() $('a').click(function() { setcookie('__clientatime',(new Date()).getTime()); // this session });
var nettime = getcookie('__clientatime'); setcookie('__clientatime',''); // forece to delete
// isset(starttime) if(typeof(starttime) == "undefined") return;
// page loading var endtime = (new Date()).getTime(); var loadtime = (endtime - starttime) / 1000;
loadtime = Math.round(loadtime*100) / 100; $('#loadtime').text(loadtime);
if(!nettime) return;
nettime = (starttime - nettime) / 1000; if(nettime < 30) { var servertime = $('#servertime').text(); nettime = Math.round((nettime-servertime)*100) / 100; $('#nettime').text(nettime); } }); //--> </SCRIPT> <?php ## put referer ## ob_start(); $referer = explode('/',$_SERVER['HTTP_REFERER'] ?? ''); $hhost = preg_replace('/^www\./i','',$_SERVER['HTTP_HOST']);
if(isset($referer[2]) && !preg_match(';'.$hhost.'$;i',$referer[2])) { require_once '_conf/adminconf.php'; require_once '_lib/class.mysql.dbs.php'; require_once '_lib/func.client.php';
global $CONT, $db;
## create mysql object with none debug mode ## $dbs = new mysql(); //if(!isset($CONT) OR !$dbs->ping($CONT)) //{ $dbs->connect($db['server'],$db['user'],$db['passwd'],$db['name'],$db['sock']); //} @__dbs_put_referer($dbs,'referer',$referer); //$dbs->close(); } //else if(isset($CONT)) @mysqli_close($CONT);
ob_end_clean();
exit; // not return ?>
|
|