|
| 1 | +<?php |
| 2 | +//----------------------------------------------------------------------------------------------- |
| 3 | +//My Program-O Version: 2.3.1 |
| 4 | +//Program-O chatbot admin area |
| 5 | +//Written by Elizabeth Perreau and Dave Morton |
| 6 | +//Aug 2011 |
| 7 | +//for more information and support please visit www.program-o.com |
| 8 | +//----------------------------------------------------------------------------------------------- |
| 9 | +// demochat.php |
| 10 | + $upperScripts = ''; |
| 11 | + $topNav = $template->getSection('TopNav'); |
| 12 | + $leftNav = $template->getSection('LeftNav'); |
| 13 | + $main = $template->getSection('Main'); |
| 14 | + $topNavLinks = makeLinks('top', $topLinks, 12); |
| 15 | + $navHeader = $template->getSection('NavHeader'); |
| 16 | + $leftNavLinks = makeLinks('left', $leftLinks, 12); |
| 17 | + $FooterInfo = getFooter(); |
| 18 | + $errMsgClass = (!empty($msg)) ? "ShowError" : "HideError"; |
| 19 | + $errMsgStyle = $template->getSection($errMsgClass); |
| 20 | + $noLeftNav = ''; |
| 21 | + $noTopNav = ''; |
| 22 | + $noRightNav = $template->getSection('NoRightNav'); |
| 23 | + $headerTitle = 'Actions:'; |
| 24 | + $pageTitle = 'My-Program O - Database Statistics'; |
| 25 | + $mainContent = "Database stats for $dbn"; |
| 26 | + $mainContent = showStats(); |
| 27 | + $mainTitle = 'DB Stats'; |
| 28 | + |
| 29 | + function showStats() |
| 30 | + { |
| 31 | + global $template, $dbn; |
| 32 | + $dbConn = db_open(); |
| 33 | + $stats = mysql_stat($dbConn); |
| 34 | + list($ut, $th, $q, $sq, $o, $ft, $ot, $qps) = explode(' ', $stats); |
| 35 | + $out = $template->getSection('DbStats'); |
| 36 | + list($nul, $utd) = explode(': ', $ut); |
| 37 | + list($nul, $thd) = explode(': ', $th); |
| 38 | + list($nul, $qd) = explode(': ', $q); |
| 39 | + list($nul, $sqd) = explode(': ', $sq); |
| 40 | + list($nul, $ftd) = explode(': ', $ft); |
| 41 | + list($nul, $otd) = explode(': ', $ot); |
| 42 | + list($nul, $qpsd) = explode(': ', $qps); |
| 43 | + |
| 44 | + $out = str_replace('[stats_uptime]', seconds2YDHMS($utd), $out); |
| 45 | + $out = str_replace('[stats_threads]', $thd, $out); |
| 46 | + $out = str_replace('[stats_query_count]', number_format($qd), $out); |
| 47 | + $out = str_replace('[stats_slow_queries]', $sqd, $out); |
| 48 | + $out = str_replace('[stats_flush_count]', $ftd, $out); |
| 49 | + $out = str_replace('[stats_tables_open]', $otd, $out); |
| 50 | + $out = str_replace('[stats_qps]', 0+$qpsd, $out); |
| 51 | + $out = str_replace('[dbn]', $dbn, $out); |
| 52 | + $out .= <<<endComment |
| 53 | +
|
| 54 | +<!-- Raw Stats: $stats --> |
| 55 | +endComment; |
| 56 | + return $out; |
| 57 | + } |
| 58 | + |
| 59 | + function seconds2YDHMS($seconds) |
| 60 | + { |
| 61 | + $secPerMin = 60; |
| 62 | + $secPerHour = 3600; |
| 63 | + $secPerDay = 86400; |
| 64 | + $secPerYear = 31557600; //Aproxomate - we're not splitting atoms, here. :) |
| 65 | + $years = (int)floor($seconds / $secPerYear); |
| 66 | + $seconds -= ($years * $secPerYear); |
| 67 | + $days = floor($seconds / $secPerDay); |
| 68 | + $seconds -= ($days * $secPerDay); |
| 69 | + $hours = floor($seconds / $secPerHour); |
| 70 | + $seconds -= ($hours * $secPerHour); |
| 71 | + $minutes = floor($seconds / $secPerMin); |
| 72 | + $seconds -= ($minutes * $secPerMin); |
| 73 | + $out = "$years years, $days days, $hours hours, $minutes minutes, $seconds seconds"; |
| 74 | + return $out; |
| 75 | + } |
| 76 | + |
| 77 | +?> |
0 commit comments