$theend = $request->GetVar('theend', 'session'); $thestart = $request->GetVar('thestart', 'session'); $thecat1 = $request->GetVar('thecat1', 'session'); $thecat2 = $request->GetVar('thecat2', 'session'); $thecat3 = $request->GetVar('thecat3', 'session'); $from_clock1 = $request->GetVar('from_clock1', 'session'); $till_clock1 = $request->GetVar('till_clock1', 'session'); $from_clock2 = $request->GetVar('from_clock2', 'session'); $till_clock2 = $request->GetVar('till_clock2', 'session'); $from_clock3 = $request->GetVar('from_clock3', 'session'); $till_clock3 = $request->GetVar('till_clock3', 'session'); if ($what == 'thedate') { list($day, $month, $year) = split('[.]', $thedate); $thestart = "{$year}-{$month}-{$day} 00:00:00"; $theend = "{$year}-{$month}-{$day} 23:59:59"; $data = $statistics->get($thestart, $theend, $thecat1, $from_clock1, $till_clock1); $timeline = "vom {$day}.{$month}.{$year}"; } elseif ($what == 'timeline') { list($day, $month, $year) = split('[.]', $thestart1); $thestart1 = "{$year}-{$month}-{$day} 00:00:00"; $timeline = "vom {$day}.{$month}.{$year} "; list($day, $month, $year) = split('[.]', $theend1); $theend1 = "{$year}-{$month}-{$day} 23:59:59"; $data = $statistics->get($thestart1, $theend1, $thecat2, $from_clock2, $till_clock2); $timeline .= "bis {$day}.{$month}.{$year} "; } else { list($month, $year) = split('[/]', $thestart); $thestart = "{$year}-{$month}-01 00:00:00"; $timeline = "vom 1.{$month}.{$year} "; list($month, $year) = split('[/]', $theend); $theend = "{$year}-{$month}-01 00:00:00";
$smarty->assign('tpl_theotherend', $theotherend); $smarty->assign('tpl_theend', $theend); $sess->SetVar('theend', $theend); $smarty->assign('tpl_theotherstart', $theotherstart); $smarty->assign('tpl_thestart', $thestart); $sess->SetVar('thestart', $thestart); $smarty->assign('tpl_start1', $thestart1); $sess->SetVar('thestart1', $thestart1); $smarty->assign('tpl_theotherstart1', $theotherstart1); $smarty->assign('tpl_end1', $theend1); $sess->SetVar('theend1', $theend1); $smarty->assign('tpl_theotherend1', $theotherend1); if ($what == 'thedate') { list($day, $month, $year) = split('[.]', $thedate); $thestart = "{$year}-{$month}-{$day} 00:00:00"; $theend = "{$year}-{$month}-{$day} 23:59:59"; $smarty->assign('tpl_statistics', $statistics->get($thestart, $theend, $thecat1, $from_clock1, $till_clock1)); } elseif ($what == 'timeline') { list($day, $month, $year) = split('[.]', $theend1); $theend1 = "{$year}-{$month}-{$day} 23:59:59"; list($day, $month, $year) = split('[.]', $thestart1); $thestart1 = "{$year}-{$month}-{$day} 00:00:00"; $smarty->assign('tpl_statistics', $statistics->get($thestart1, $theend1, $thecat2, $from_clock2, $till_clock2)); } else { list($month, $year) = split('[/]', $theend); $theend = "{$year}-{$month}-01 00:00:00"; list($month, $year) = split('[/]', $thestart); $thestart = "{$year}-{$month}-01 00:00:00"; $smarty->assign('tpl_statistics', $statistics->get($thestart, $theend, $thecat3, $from_clock3, $till_clock3)); } $smarty->display('statistics.tpl');
<?php /** * To get the statistics infomation with html format * * @file /lib/weixin/admin/statistics/get.php * @author KavMors(kavmors@163.com) * @version 2015-2-5 */ include_once dirname(__FILE__) . '/statistics.php'; $statistics = new Statistics(); $key = isset($_GET['key']) ? $_GET['key'] : 'menu'; $statistics->get($key); while ($value = $statistics->fetch()) { ?> <li> <div class="date"><?php echo $value['date']; ?> </div> <div class="num"><?php echo $value[$key]; ?> </div> </li> <?php }
} $thestart = str_replace('-', '/', $thestart); $theend = str_replace('-', '/', $theend); $thestart1 = str_replace('-', '/', $thestart1); $theend1 = str_replace('-', '/', $theend1); $thedate = str_replace('-', '.', $thedate); if ($request->GetVar('what', 'get') !== $request->undefined) { $what = $request->GetVar('what', 'get'); } else { $what = 'thedate'; } if ($what == 'thedate') { list($day, $month, $year) = split('[.]', $thedate); $thestart = "{$year}-{$month}-{$day} 00:00:00"; $theend = "{$year}-{$month}-{$day} 23:59:59"; $statarr = $statistics->get($thestart, $theend, $thecat1); $rtfdate = "am {$day}.{$month}.{$year}"; } elseif ($what == 'timeline') { list($day, $month, $year) = split('[/]', $theend1); $theend = "{$year}-{$month}-{$day} 23:59:59"; $rtfdate = "bis {$day}.{$month}.{$year} "; list($day, $month, $year) = split('[/]', $thestart1); $thestart = "{$year}-{$month}-{$day} 00:00:00"; $rtfdate = "vom {$day}.{$month}.{$year} " . $rtfdate; $statarr = $statistics->get($thestart, $theend, $thecat2); } else { list($month, $year) = split('[/]', $theend); $theend = "{$year}-{$month}-01 00:00:00"; $rtfdate = "bis 01.{$month}.{$year} "; list($month, $year) = split('[/]', $thestart); $thestart = "{$year}-{$month}-01 00:00:00";
function staticGet($p, $k = false) { $cl = new Statistics(); $cl->get($p, $k); return $cl; }
} } else { p('None'); } ?> <li><strong>Last Query:</strong> <?php if ($monitor->getStatus() == STATUS_UNPOLLED) { p('N/A'); } else { p(GuiHelpers::formatDateLong($monitor->getLastQuery())); } ?> </li> <?php list($total, $week, $day) = Statistics::get('monitor' . $monitor->getId()); ?> <li> <strong>Uptime (Day):</strong> <?php p($day['total'] > 0 ? round(100 * $day['online'] / $day['total'], 2) . '% (' . $day['online'] . ' of ' . $day['total'] . ')' : 'N/A'); ?> </li> <li> <strong>Uptime (Week):</strong> <?php p($week['total'] > 0 ? round(100 * $week['online'] / $week['total'], 2) . '% (' . $week['online'] . ' of ' . $week['total'] . ')' : 'N/A'); ?> </li> <li> <strong>Uptime (All):</strong> <?php p($total['total'] > 0 ? round(100 * $total['online'] / $total['total'], 2) . '% (' . $total['online'] . ' of ' . $total['total'] . ')' : 'N/A'); ?>