98 |
- |
1 |
<?php
|
|
|
2 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/dnsexit.php');
|
|
|
3 |
|
|
|
4 |
$minDate = 20190101;
|
|
|
5 |
$maxDate = date("Ymd");
|
|
|
6 |
$unique = false;
|
|
|
7 |
$plottype = "bars";
|
|
|
8 |
|
|
|
9 |
$startTS = 0;
|
|
|
10 |
$endTS = 0;
|
|
|
11 |
if (!empty($_GET['start']) && filter_var($_GET['start'], FILTER_VALIDATE_INT, array("options" => array("min_range"=>$minDate, "max_range"=>$maxDate)))) {
|
|
|
12 |
$date = $_GET['start'] . " 00:00:00 UTC";
|
|
|
13 |
$dateTime = new DateTime($date);
|
|
|
14 |
$startTS = $dateTime->format('U');
|
|
|
15 |
}
|
|
|
16 |
if (!empty($_GET['end']) && filter_var($_GET['end'], FILTER_VALIDATE_INT, array("options" => array("min_range"=>$minDate, "max_range"=>$maxDate)))) {
|
|
|
17 |
$date = $_GET['end'] . " 23:59:59 UTC";
|
|
|
18 |
$dateTime = new DateTime($date);
|
|
|
19 |
$endTS = $dateTime->format('U');
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
if (!empty($_GET['unique']) && ($_GET['unique'] == '0' || $_GET['unique'] == '1')) {
|
|
|
23 |
$unique = ($_GET['unique'] == '1');
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
$plottypes = array(
|
|
|
27 |
"area",
|
|
|
28 |
"bars",
|
|
|
29 |
"linepoints",
|
|
|
30 |
"lines",
|
|
|
31 |
"pie",
|
|
|
32 |
"points",
|
|
|
33 |
"squared",
|
|
|
34 |
"squaredarea",
|
|
|
35 |
"stackedarea",
|
|
|
36 |
"stackedbars",
|
|
|
37 |
"stackedsquaredarea",
|
|
|
38 |
"thinbarline");
|
|
|
39 |
if (!empty($_GET['type']) && in_array($_GET['type'], $plottypes)) {
|
|
|
40 |
$plottype = $_GET['type'];
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
$height = 1024;
|
|
|
44 |
if (!empty($_GET['height']) && $_GET['height'] > 0) {
|
|
|
45 |
$height = $_GET['height'];
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
$width = 768;
|
|
|
49 |
if (!empty($_GET['width']) && $_GET['width'] > 0) {
|
|
|
50 |
$width = $_GET['width'];
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/constants.php');
|
|
|
55 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/sessions_db.php');
|
|
|
56 |
include_once ($_SERVER['DOCUMENT_ROOT'] . '/php/cryptor.php');
|
|
|
57 |
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/phplot.php';
|
|
|
58 |
|
|
|
59 |
$configFile = parse_ini_file($_SERVER['DOCUMENT_ROOT'] . FCM_CONFIGFILE, true);
|
|
|
60 |
$crypt = Cryptor::getInstance($configFile['cryptor']);
|
|
|
61 |
$tmpSessionTab = (isset($_POST["sessionTab"]) && $_POST["sessionTab"] > 0 ? $_POST["sessionTab"] : null);
|
|
|
62 |
$handler = MySessionHandler::getInstance($tmpSessionTab, $configFile['mysqli']);
|
|
|
63 |
unset($configFile);
|
|
|
64 |
|
|
|
65 |
ini_set("session.cookie_httponly", 1);
|
|
|
66 |
ini_set("session.cookie_secure", 1);
|
|
|
67 |
session_set_save_handler($handler, true);
|
|
|
68 |
if (!empty($_COOKIE['PHPSESSID'])) {
|
|
|
69 |
session_id($_COOKIE['PHPSESSID']);
|
|
|
70 |
}
|
|
|
71 |
@session_start();
|
|
|
72 |
|
|
|
73 |
$_sess_db = MySessionHandler::getDBSessionId();
|
|
|
74 |
|
|
|
75 |
$countSql = ($unique ? "count(distinct(ip))" : "count(*)");
|
|
|
76 |
$whereSql = "";
|
|
|
77 |
if ($startTS > 0 && $endTS > 0) {
|
|
|
78 |
$whereSql .= " where access between " . $startTS . " and " . $endTS;
|
|
|
79 |
} else if ($startTS > 0) {
|
|
|
80 |
$whereSql .= " where access >= " . $startTS;
|
|
|
81 |
} else if ($endTS > 0) {
|
|
|
82 |
$whereSql .= " where access <= " . $endTS;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
$searches = [];
|
|
|
86 |
$sql = "select from_unixtime(access, '%m/%d/%Y') as day, " . $countSql . " as count from searches";
|
|
|
87 |
$sql .= $whereSql;
|
|
|
88 |
$sql .= " group by from_unixtime(access, '%m/%d/%Y') order by access";
|
|
|
89 |
|
|
|
90 |
$result = mysqli_query($_sess_db, $sql);
|
|
|
91 |
if (!$result) {
|
|
|
92 |
error_log("Error: " . $sql . " | " . mysqli_error($_sess_db));
|
|
|
93 |
} else {
|
|
|
94 |
if (mysqli_num_rows($result) > 0) {
|
|
|
95 |
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
96 |
$searches[] = array($row["day"], $row["count"]);
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
}
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
$transfers = [];
|
|
|
103 |
$sql = "select from_unixtime(access, '%m/%d/%Y') as day, " . $countSql . " as count from transfers";
|
|
|
104 |
$sql .= $whereSql;
|
|
|
105 |
$sql .= " group by from_unixtime(access, '%m/%d/%Y') order by access";
|
|
|
106 |
$result = mysqli_query($_sess_db, $sql);
|
|
|
107 |
if (!$result) {
|
|
|
108 |
error_log("Error: " . $sql . " | " . mysqli_error($_sess_db));
|
|
|
109 |
} else {
|
|
|
110 |
if (mysqli_num_rows($result) > 0) {
|
|
|
111 |
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
112 |
$transfers += array($row["day"] => $row["count"]);
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
}
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
$data = [];
|
|
|
119 |
foreach ($searches as list($k, $v)) {
|
|
|
120 |
$t = (array_key_exists($k, $transfers) ? $transfers[$k] : 0);
|
|
|
121 |
$data[] = array($k, $v, $t);
|
|
|
122 |
}
|
|
|
123 |
//echo"<pre>";print_r($data);echo "</pre>";
|
|
|
124 |
|
|
|
125 |
$plot = new PHPlot($width, $height);
|
|
|
126 |
$plot->SetImageBorderType('plain');
|
|
|
127 |
$title = 'Find Cheap Music';
|
|
|
128 |
if ($startTS || $endTS) {
|
|
|
129 |
$title .= "\n";
|
|
|
130 |
if ($startTS) {
|
|
|
131 |
$title .= "from " . gmdate("m/d/y", $startTS);
|
|
|
132 |
}
|
|
|
133 |
if ($endTS) {
|
|
|
134 |
$title .= " to " . gmdate("m/d/y", $endTS);
|
|
|
135 |
}
|
|
|
136 |
}
|
|
|
137 |
$plot->SetTitle($title);
|
|
|
138 |
$plot->SetPlotType($plottype);
|
|
|
139 |
//$plot->SetShading(0);
|
|
|
140 |
$plot->SetDataValues($data);
|
|
|
141 |
$plot->SetLegend(array('Search', 'Transfer'));
|
|
|
142 |
$plot->SetXDataLabelAngle(90);
|
|
|
143 |
$plot->SetYTitle(($unique ? "Unique" : "All") . " Requests");
|
|
|
144 |
$plot->SetYTickIncrement(1);
|
|
|
145 |
$plot->DrawGraph();
|