<?php

//1.1.2.2用户登录VPN次数小时段汇总
require '../../include/init.inc.php';
$width = $height = $start_date = $end_date = $top = $search = '';
$_GET['start_date'] = empty($_GET['start_date']) ? date("Y-m-d", time() - 86400) : $_GET['start_date'];
$_GET['end_date'] = empty($_GET['end_date']) ? date("Y-m-d", time()) : $_GET['end_date'];
$_GET['width'] = empty($_GET['width']) ? 800 : $_GET['width'];
$_GET['height'] = empty($_GET['height']) ? 720 : $_GET['height'];
extract($_GET, EXTR_IF_EXISTS);
if ($search) {
    $count = VpnCount::getUserLoginHoursCount($start_date, $end_date, $width, $height);
    $jpg = $count[0]['IMAGE'];
    if (!empty($jpg)) {
        $filename = 'loginTimesHoursCount.png';
        $file = file_put_contents(ADMIN_BASE_RIMAGE . $filename, $jpg);
        //打开文件准备写入
        $imgurl = ADMIN_URL_RIMAGE . $filename . '?' . microtime(true);
        $img = "<center><img src=\"{$imgurl}\"></center>";
    } else {
        if (count($count) > 0) {
            $img = "无数据!";
        } else {
            $img = "图片加载失败";
        }
    }
    exit($img);
} else {
    $img = "请点击\"检索\"按钮进行查询";
}
Template::assign('img', $img);