-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.php
More file actions
167 lines (121 loc) · 4.63 KB
/
analytics.php
File metadata and controls
167 lines (121 loc) · 4.63 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sessions.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-db-connection.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-functions.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-header.php");
?>
<main>
<?php $user = getUsersDetails($member); ?>
<?php
if (!$user || $user['member_is_admin'] != "yes") {
stderr("<strong>Protected</strong> page.");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
die();
}
?>
<?php if (!is_writable("uploads")) { stderr('Your <strong>uploads</strong> folder is not writable, please make the permissions <strong>777</strong> before we can upload new images.'); } ?>
<div class="row">
<div class="col-md-3">
<div class="card">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-dashboard.php"); ?>
</div>
<div class="card">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-dashboard-extended.php"); ?>
</div>
</div>
<div class="col-md-9">
<?php
if (isset($_POST['submitIPRange'])) {
$i = DB::getInstance()->insert(
'ips',
[
'ip_range' => $_POST['ip_range'],
'ip_date' => date('Y-m-d H:i:s')
]);
stdmsg("A new <strong>IP Range</strong> has been <strong>added</strong> and will be blocked.");
}
?>
<div class="card">
<div class="card-header"><i class="fa-solid fa-computer-mouse"></i> Clicks</div>
<div class="card-body">
<?php
if (isset($_GET['delete'])) {
try {
if (isset($_GET['clickId'])) {
$delete = DB::getInstance()->remove('clicks', 'click_id', $_GET['clickId']);
if ($delete) {
stdmsg("The <strong>click</strong> has been <strong>deleted</strong>.");
}
}
if (isset($_GET['ip'])) {
$delete = DB::getInstance()->remove('clicks', 'click_ip', $_GET['ip']);
if ($delete) {
stdmsg("The <strong>IP</strong> has been <strong>deleted</strong>.");
}
}
} catch (Exception $e) {
stdErr($e->getMessage());
}
}
?>
<?php $clicks = DB::getInstance()->select("SELECT * FROM `clicks`"); ?>
<!-- DataTables -->
<div class="table-responsive">
<table class="table table-striped" id="tableClicks" width="100%" cellspacing="0">
<thead>
<tr>
<th>ID</th>
<th>Product</th>
<th>IP</th>
<th>Country</th>
<th>Added</th>
<th> </th>
<th> </th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>Product</th>
<th>IP</th>
<th>Country</th>
<th>Added</th>
<th> </th>
<th> </th>
</tr>
</tfoot>
<tbody>
<?php foreach ($clicks as $click) { ?>
<tr>
<td><?= $click['click_id']; ?></td>
<td><span class="text-primary"><?= $click['click_page']; ?></span></td>
<td><?= $click['click_ip']; ?></td>
<td> </td>
<td><?= date("m.d.y", strtotime($click['click_date'])); ?></td>
<td class="text-center"><a href="analytics.php?delete=1&clickId=<?= $click['click_id']; ?>" onClick="return confirm('Delete the click?')" class="btn btn-danger btn-sm" role="button" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Delete click"><i class="far fa-trash-alt"></i></a></td>
<td class="text-center"><a href="analytics.php?delete=1&ip=<?= $click['click_ip']; ?>" onClick="return confirm('Delete the IP?')" class="btn btn-warning btn-sm" role="button" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Delete IP"><i class="far fa-trash-alt"></i></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="card">
<div class="card-header"><i class="fa-solid fa-computer-mouse"></i> Block IP Range</div>
<div class="card-body">
<form action="analytics.php" method="post">
<div class="mb-3">
<label for="category_name" class="form-label"><strong>Block IP Range:</strong></label>
<input type="text" class="form-control" id="ip_range" name="ip_range" required>
</div>
<button type="submit" name="submitIPRange" class="btn btn-success float-end"><i class="fas fa-plus"></i> Block IP Range</button>
</form>
</div>
</div>
</div>
</div>
</main>
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
?>