hxp
2025-06-09 6c3f6335c70859ded94a1ad8d218acb0ac34239c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
include_once "/serverrep/report.php";
 
\Logging\CreateLogging("rep.dailyuser.php");
$Permission = \User\Permission::P_REP_DailyUser;
 
$alertMsg = "";
$channel = $_SESSION['spid'];
$UserAccount = $_SESSION['UserAccount'];
$user = new \User\User($UserAccount);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
$startDate = array_key_exists("startDate", $_POST) ? $_POST["startDate"] : date("Y-m-d", strtotime("-30 days"));
$endDate = array_key_exists("endDate", $_POST) ? $_POST["endDate"] : date("Y-m-d");
 
$reportDict = \Report\GetDailyReport($channel, $startDate, $endDate, true);
 
$showTime = strtotime($startDate);
$endTime = strtotime($endDate);
 
$showLabelInfo = array(
    "活跃用户DAU" => "DAU",
    "新增用户DNU" => "DNU",
    "充值用户DPU" => "DPU",
    "新增充值用户DNPU" => "DNPU",
);
$xLabels = array(); // x轴为日期
$dataArray = array();
 
$doCount = 0;
while ($showTime <= $endTime && $doCount < 1440) {
    $doCount += 1;
    $dateStr = date("Y-m-d", $showTime);
    array_push($xLabels, $dateStr);
    foreach ($showLabelInfo as $key => $value) {
        if (!isset($dataArray[$key])) {
            $dataArray[$key] = array();
        }
        $dataList = $dataArray[$key];
        array_push($dataList, $reportDict[$dateStr] ? $reportDict[$dateStr][$value] : 0);
        $dataArray[$key] = $dataList;
    }
    $showTime = strtotime("+1 day", $showTime);
}
?>
 
<!DOCTYPE html>
<html>
 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo \Lang\gettext("全服每日用户"); ?></title>
    <link rel="gettext" type="application/x-po" href="../language/<?php echo \Lang\getLang(); ?>/LC_MESSAGES/<?php echo \Lang\getjspodomain(); ?>.po" />
</head>
 
<body>
    <center>
        <p><b><?php echo \Lang\gettext("全服每日用户"); ?></b></P>
    </center>
    <form method="post">
        <?php echo \Lang\gettext("查询时间"); ?>:
        <input type="text" name="startDate" id="startDate" onclick="new Calendar().show(this);" readonly value="<?php echo $startDate; ?>" size="8" />
        ~
        <input type="text" name="endDate" id="endDate" onclick="new Calendar().show(this);" readonly value="<?php echo $endDate; ?>" size="8" />
        <input type="submit" value="<?php echo \Lang\gettext("查询"); ?>" />
        <hr />
        <div id="MyChart"></div>
        <hr />
    </form>
</body>
<script type='text/javascript' src='/language/gettext.js'></script>
<script type='text/javascript' src="/js/calendar.js"></script>
<script type='text/javascript' src="/js/common.js"></script>
<script type='text/javascript' src="/js/chart.min.js"></script>
<script type="text/javascript">
    window.onload = function() {
        let chartID = "myChart0";
        let insHtml = "";
        // insHtml += "<hr />";
        insHtml += "<canvas id=\"" + chartID + "\" ></canvas>"; // 插入画布
        document.getElementById("MyChart").insertAdjacentHTML("beforeEnd", insHtml);
 
        var xLabels = JSON.parse('<?php echo json_encode($xLabels); ?>');
        var dataArray = JSON.parse('<?php echo json_encode($dataArray); ?>');
        const chartText = "每日用户数";
        const xText = "日期";
        const yText = "人数";
        drawChart_Line(chartID, chartText, xText, yText, xLabels, Object.values(dataArray), Object.keys(dataArray));
    }
</script>
 
</html>