<?php require_once "include/init.php"; $cIP = getenv('REMOTE_ADDR'); $cIP1 = getenv('HTTP_X_FORWARDED_FOR'); $cIP2 = getenv('HTTP_CLIENT_IP'); $cIP1 ? $cIP = $cIP1 : null; $cIP2 ? $cIP = $cIP2 : null; if (!isset($_SESSION[$cIP]) || time() - $_SESSION[$cIP] > 60 * 5) { //如果session不存在,或者超过5分钟,则记为一次有效访问 $_SESSION[$cIP] = time(); Countor::countNum(); }
<?php $total = Countor::total(); //历史访问总量 $today = -1; //今日访问量 $countors = Countor::query(10); $cntHtml = ""; if (!empty($countors)) { foreach ($countors as $one) { if ($one->countDate == date("Y.m.d")) { $today = $one->visitCount; } $cntHtml .= sprintf("<tr><td>%s</td><td>%s</td></tr>", $one->countDate, $one->visitCount); } } if ($today === -1) { $today = 0; } ?> <script> $(function(){ BS_Common.setMenu(".m_home"); }); </script> <div id="location">管理中心<b>></b><strong>首页</strong></div><!--location--> <div class="main" style="height: auto!important; height: 550px; min-height: 550px;"> <h3>今日访问量:<font color="#FF0000"><?php echo $today;