db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); } if (!is_object($eTraffic)) { $eTraffic = new e107_traffic; $eTraffic->Bump('Lost Traffic Counters'); } if(varset($e107_popup)!=1){ // // B.1 Clear cache if over a week old // if (ADMIN == TRUE) { if ($pref['cachestatus']) { if (!$sql->db_Select('generic', '*', "gen_type='empty_cache'")) { $sql->db_Insert('generic', "0,'empty_cache','".time()."','0','','0',''"); } else { $row = $sql->db_Fetch(); if (($row['gen_datestamp']+604800) < time()) // If cache not cleared in last 7 days, clear it. { require_once(e_HANDLER."cache_handler.php"); $ec = new ecache; $ec->clear(); $sql->db_Update('generic', "gen_datestamp='".time()."' WHERE gen_type='empty_cache'"); } } } } // // B.2 Send footer template, stop timing, send simple page stats // if (strpos(e_SELF.'?'.e_QUERY, 'menus.php?configure') === FALSE) { parse_admin($ADMIN_FOOTER); } $eTimingStop = microtime(); global $eTimingStart; $clockTime = $eTraffic->TimeDelta( $eTimingStart, $eTimingStop ); $dbPercent = 100.0 * $db_time / $clockTime; // Format for display or logging $rendertime = number_format($clockTime, 2); // Clock time during page render $db_time = number_format($db_time,2); // Clock time in DB render $dbPercent = number_format($dbPercent,0); // DB as percent of clock $memuse = $e107->get_memory_usage(); // Memory at end, in B/KB/MB/GB ;) $rinfo = ''; if ( function_exists( 'getrusage' ) ) { $ru = getrusage(); $cpuUTime = $ru['ru_utime.tv_sec'] + ($ru['ru_utime.tv_usec'] * 1e-6); $cpuSTime = $ru['ru_stime.tv_sec'] + ($ru['ru_stime.tv_usec'] * 1e-6); $cpuUStart = $eTimingStartCPU['ru_utime.tv_sec'] + ($eTimingStartCPU['ru_utime.tv_usec'] * 1e-6); $cpuSStart = $eTimingStartCPU['ru_stime.tv_sec'] + ($eTimingStartCPU['ru_stime.tv_usec'] * 1e-6); $cpuStart = $cpuUStart + $cpuSStart; $cpuTot = $cpuUTime + $cpuSTime; $cpuTime = $cpuTot - $cpuStart; $cpuPct = 100.0 * $cpuTime / $rendertime; /* CPU load during known clock time */ // Format for display or logging (Uncomment as needed for logging) //$cpuUTime = number_format($cpuUTime, 3); // User cpu //$cpuSTime = number_format($cpuSTime, 3); // System cpu //$cpuTot = number_format($cpuTot, 3); // Total (User+System) $cpuStart = number_format($cpuStart, 3); // Startup time (i.e. CPU used before class2.php) $cpuTime = number_format($cpuTime, 3); // CPU while we were measuring the clock (cpuTot-cpuStart) $cpuPct = number_format($cpuPct,0); // CPU Load (CPU/Clock) } // // Here's a good place to log CPU usage in case you want graphs and/or your host cares about that // e.g. (on a typical vhosted linux host) // // $logname = "/home/mysite/public_html/queryspeed.log"; // $logfp = fopen($logname, 'a+'); fwrite($logfp, "$cpuTot,$cpuPct,$cpuStart,$rendertime,$db_time\n"); fclose($logfp); if($pref['displayrendertime']) { $rinfo .= CORE_LAN11; if (isset($cpuTime)) { // $rinfo .= "{$cpuTime} cpu sec ({$cpuPct}% load, {$cpuStart} startup). Clock: "; $rinfo .= sprintf(CORE_LAN14,$cpuTime,$cpuPct,$cpuStart); } $rinfo .= $rendertime.CORE_LAN12.$dbPercent.CORE_LAN13; } if($pref['displaysql']){ $rinfo .= CORE_LAN15.$sql -> db_QueryCount().". "; } if(isset($pref['display_memory_usage']) && $pref['display_memory_usage']){ $rinfo .= CORE_LAN16.$memuse; } if(isset($pref['displaycacheinfo']) && $pref['displaycacheinfo']){ $rinfo .= $cachestring."."; } if (function_exists('theme_renderinfo')) { theme_renderinfo($rinfo); } else { echo ($rinfo ? "\n
ID | SQL Queries | \n
{$c} | {$infovalue} | \n