= 1; $d--, $ex-=3 ) { if (isset($GLOBALS['byteUnits'][$d]) && $value >= $li * pow(10, $ex)) { $value = round($value / ( pow(1024, $d) / $dh) ) /$dh; $unit = $GLOBALS['byteUnits'][$d]; break 1; } // end if } // end for if ($unit != $GLOBALS['byteUnits'][0]) { $return_value = number_format($value, $comma, '.', ','); } else { $return_value = number_format($value, 0, '.', ','); } return array($return_value, $unit); } // end of the 'formatByteDown' function /** * Returns a given timespan value in a readable format. * * @param int the timespan * * @return string the formatted value */ function timespanFormat($seconds) { $return_string = ''; $days = floor($seconds / 86400); if ($days > 0) { $seconds -= $days * 86400; } $hours = floor($seconds / 3600); if ($days > 0 || $hours > 0) { $seconds -= $hours * 3600; } $minutes = floor($seconds / 60); if ($days > 0 || $hours > 0 || $minutes > 0) { $seconds -= $minutes * 60; } return (string)$days." Days ". (string)$hours." Hours ". (string)$minutes." Minutes ". (string)$seconds." Seconds "; } /** * Writes localised date * * @param string the current timestamp * * @return string the formatted date * * @access public */ function localisedDate($timestamp = -1, $format = '') { global $datefmt, $month, $day_of_week; if ($format == '') { $format = $datefmt; } if ($timestamp == -1) { $timestamp = time(); } $date = preg_replace('@%[aA]@', $day_of_week[(int)strftime('%w', $timestamp)], $format); $date = preg_replace('@%[bB]@', $month[(int)strftime('%m', $timestamp)-1], $date); return strftime($date, $timestamp); } // end of the 'localisedDate()' function ////////////////////// END FUNCTION LIST ///////////////////////////////////// stdhead("Stats"); /** * Displays the sub-page heading */ echo '

' . "\n" . ' Mysql Server Status' . "\n" . '

' . "\n"; /** * Sends the query and buffers the result */ $res = @sql_query('SHOW STATUS') or Die(mysql_error()); while ($row = mysql_fetch_row($res)) { $serverStatus[$row[0]] = $row[1]; } @mysql_free_result($res); unset($res); unset($row); /** * Displays the page */ //Uptime calculation $res = @sql_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime']); $row = mysql_fetch_row($res); //echo sprintf("Server Status Uptime", timespanFormat($serverStatus['Uptime']), localisedDate($row[0])) . "\n"; ?>
$value) { if (substr($name, 0, 4) == 'Com_') { $queryStats[str_replace('_', ' ', substr($name, 4))] = $value; unset($serverStatus[$name]); } } unset($tmp_array); ?>