This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathviewer.php
130 lines (125 loc) · 3.99 KB
/
viewer.php
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<?php
/*
* xyzanalytics - A small analytics script
* Written in 2018 by cmp [email protected]
* To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
* You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
// ******** CONFIG ********
$SECRET_KEY = "sha256 hashed secret key";
$USER = "analytics";
$PASS = "pass";
$DB = "analytics";
$TB = "con";
$GEO = true;
// ************************
?>
<title>xyznalytics viewer</title>
<style>
body { font-family: Arial, Helvetica, sans-serif; }
.c { text-align: center; }
table {
border-collapse: collapse;
margin: 0 auto;
}
table, th, td {
border: 2px solid black;
padding: 5px;
}
</style>
</head>
<body>
<?php
if (isset($_POST["key"])) {
$key = hash('sha256', $_POST["key"]);
if ($key !== $SECRET_KEY) {
echo "Incorrect key.";
exit();
}
echo '<script src="script.js"></script>';
echo '<p id="filtDom">Filter domain: <input id="site" type="text"><button type="button" onclick="filterSite()">Filter</button></p>';
echo '<p id="filtDomA"></p>';
if ($GEO === true) {
echo '<p><input type="checkbox" id="filtBot" onchange="hideBots()"> Hide bots</p>';
}
$sql = new mysqli("127.0.0.1", $USER, $PASS, $DB);
if (!$sql) {
echo 'MySQL error';
exit();
}
$q = "SELECT * FROM {$TB}";
$res = $sql->query($q);
if (!$res) {
echo 'MySQL error';
exit();
}
if ($res->num_rows == 0) {
echo 'Nothing here.';
exit();
}
$x = new stdClass();
while ($r = $res->fetch_assoc()) {
$x->col[$r["id"] - 1]->ip = $r["ip"];
$x->col[$r["id"] - 1]->time = $r["time"];
$x->col[$r["id"] - 1]->pretty_time = $r["pretty_time"];
$x->col[$r["id"] - 1]->location = $r["location"];
$x->col[$r["id"] - 1]->domain = $r["domain"];
if ($GEO === true) {
$x->col[$r["id"] - 1]->geo_city = $r["geo_city"];
$x->col[$r["id"] - 1]->geo_region = $r["geo_region"];
$x->col[$r["id"] - 1]->geo_country = $r["geo_country"];
$x->col[$r["id"] - 1]->geo_location = $r["geo_location"];
$x->col[$r["id"] - 1]->geo_isp = $r["geo_isp"];
}
$x->col[$r["id"] - 1]->user_agent = $r["user_agent"];
}
echo "<table>";
echo '<tr>';
echo '<th>IP</th>';
echo '<th>Unix Time</th>';
echo '<th>Pretty Time</th>';
echo '<th>Location</th>';
echo '<th>Domain</th>';
if ($GEO === true) {
echo '<th>Geo:City</th>';
echo '<th>Geo:Region</th>';
echo '<th>Geo:Country</th>';
echo '<th>Geo:Location</th>';
echo '<th>Geo:ISP</th>';
}
echo '<th>User Agent</th>';
echo '</tr>';
for ($i = 1; $i <= sizeof($x->col); $i++) {
echo '<tr>';
echo '<td>' . htmlspecialchars($x->col[$i]->ip) . '</td>';
echo '<td>' . htmlspecialchars($x->col[$i]->time) . '</td>';
echo '<td>' . htmlspecialchars($x->col[$i]->pretty_time) . '</td>';
echo '<td>' . htmlspecialchars($x->col[$i]->location) . '</td>';
echo '<td data-domain="1">' . htmlspecialchars($x->col[$i]->domain) . '</td>';
if ($GEO === true) {
echo '<td>' . htmlspecialchars($x->col[$i]->geo_city) . '</td>';
echo '<td>' . htmlspecialchars($x->col[$i]->geo_region) . '</td>';
echo '<td>' . htmlspecialchars($x->col[$i]->geo_country) . '</td>';
echo '<td>' . htmlspecialchars($x->col[$i]->geo_location) . '</td>';
echo '<td data-isp="1">' . htmlspecialchars($x->col[$i]->geo_isp) . '</td>';
}
echo '<td>' . htmlspecialchars($x->col[$i]->user_agent) . '</td>';
echo '</tr>';
}
echo "</table>";
exit();
}
?>
<div class="c">
<h3>xyzanalytics</h3>
<form action="" method="post">
<input type="text" placeholder="Access key" name="key">
<input type="submit" value="Login">
</form>
<br>
</div>
</body>
</html>