Jaxel |
04-02-2010 02:07 PM |
FIXED!
I'm awesome... this is the new plugin... DONT JUST CUT AND PASTE THIS CODE, READ MY COMMENT BELOW FIRST!
Code:
// Microstats 1.2.1 Plugin
$pageendtime = microtime();
$starttime = explode(' ', TIMESTART);
$endtime = explode(' ', $pageendtime);
$totaltime = vb_number_format($endtime[0] - $starttime[0] + $endtime[1] - $starttime[1], 5);
$debughtml = '<center><span class="smallfont">Page generated in <b>' . $totaltime . '</b> seconds with <b>' . $vbulletin->db->querycount . '</b> queries';
if ($vbulletin->userinfo['usergroupid'] == 6) {
if ($loadavg = @file_get_contents("/proc/loadavg")) {
$regs = explode(" ",$loadavg);
$serverload = ' [Server Loads: <b>' . $regs[0] .'</b> ' . $regs[1] . ' : ' . $regs[2] . ']';
}elseif ($stats=@exec(uptime)) {
preg_match('/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/',$stats,$regs);
$serverload = ' [Server Loads: <b>' . $regs[1] .'</b> ' . $regs[2] . ' : ' . $regs[3] . ']';
}elseif ($loadavg = @'sysctl vm.loadavg|cut -d" " -f3-5') {
$regs = explode(" ",$loadavg);
$serverload = ' [Server Loads: <b>' . $regs[0] .'</b> ' . $regs[1] . ' : ' . $regs[2] . ']';
}
$tempusagecache = vB_Template::$template_usage;
$_TEMPLATEQUERIES = vB_Template::$template_queries;
$debughtml .= iif($_TEMPLATEQUERIES, ' (<b>' . sizeof($_TEMPLATEQUERIES) . '</b> queries for uncached templates)', '') . "$serverload";
ksort($tempusagecache);
foreach ($tempusagecache AS $tempname => $times) {
if ($_TEMPLATEQUERIES["$tempname"]){
$debughtml .= '<center><span class="smallfont">Uncached templates: <font color="red"><b>' . $tempname . '</b></font> (' . $times . ')</span></center>';
}
}
}
$debughtml .= "</span></center>";
if (!$vbulletin->config['Microstats']['replacementvariable']) {
$vbulletin->config['Microstats']['replacementvariable'] = '</body>';
}
if (($vbulletin->config['Microstats']['adminonly'] and $vbulletin->userinfo['usergroupid'] == 6) or !$vbulletin->config['Microstats']['adminonly']){
$output = str_replace($vbulletin->config['Microstats']['replacementvariable'], $debughtml . $vbulletin->config['Microstats']['replacementvariable'], $output);
}
// Microstats 1.2.1 Plugin
OKAY... right now the code above ISN'T working, vb.org is giving me errors with a single line of code when I'm trying to post it here, so let me explain what you need to do to fix it. Search for the following piece of text in the code above:
Add SINGLE QUOTES around the word 'uptime'. It looks like VB.ORG is having problems with executing the exec function inside of posts. VB.ORG people, if you are reading this, you need to fix this IMMEDIATELY! Someone could potentially execute code from posts with this error.
A comment about copyright with code... History has shown us, that if you give two engineers the same problem and unlimited amount of time, they will both eventually come up with the same solution; especially if there is only ONE way to fix the problem. With this modification, there is really only ONE way to do it. I mean I could rewrite the code, come up with new variable names and everything... but its pretty much going to be the same exact code, even though I wrote it from scratch. If I rewrite the code, can I post it as a new mod? Even though its going to look pretty much the same?
|