-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
statistics.php
224 lines (212 loc) · 10.2 KB
/
statistics.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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
require __DIR__ . '/vendor/autoload.php';
use Antsstyle\NFTCryptoBlocker\Core\Core;
use Antsstyle\NFTCryptoBlocker\Core\CoreDB;
use Antsstyle\NFTCryptoBlocker\Core\Config;
use Antsstyle\NFTCryptoBlocker\Core\Session;
Session::checkSession();
if (!$_SESSION['usertwitterid']) {
$errorURL = Config::HOMEPAGE_URL . "error";
header("Location: $errorURL", true, 302);
exit();
}
$userInfo = CoreDB::getUserInfo($_SESSION['usertwitterid']);
if ($userInfo === false) {
$errorURL = Config::HOMEPAGE_URL . "error";
header("Location: $errorURL", true, 302);
exit();
} else if ($userInfo === null) {
$errorURL = Config::HOMEPAGE_URL . "error";
header("Location: $errorURL", true, 302);
exit();
}
$userStats = CoreDB::getUserStats($_SESSION['usertwitterid']);
if ($userStats !== false) {
if (isset($userStats['Block'])) {
$blockCount = $userStats['Block'];
} else {
$blockCount = 0;
}
if (isset($userStats['Mute'])) {
$muteCount = $userStats['Mute'];
} else {
$muteCount = 0;
}
if (isset($userStats['queueBlock'])) {
$queuedBlockCount = $userStats['queueBlock'];
} else {
$queuedBlockCount = 0;
}
if (isset($userStats['queueMute'])) {
$queuedMuteCount = $userStats['queueMute'];
} else {
$queuedMuteCount = 0;
}
$totalQueueCount = $queuedBlockCount + $queuedMuteCount;
}
$pageNum = filter_input(INPUT_GET, "page", FILTER_VALIDATE_INT);
if (is_null($pageNum) || $pageNum === false) {
$pageNum = 1;
}
$userBlockRecords = CoreDB::getUserBlockRecords($_SESSION['usertwitterid'], $pageNum);
$userBlockRecordsCount = CoreDB::getUserBlockRecordsCount($_SESSION['usertwitterid']);
$pageCount = ceil($userBlockRecordsCount / 100);
if ($pageNum > $pageCount) {
$pageNum = $pageCount;
}
if ($pageNum < 1) {
$pageNum = 1;
}
$nextPage = $pageNum + 1;
$prevPage = $pageNum - 1;
$blockListInfo = CoreDB::getBlockLists();
$blockListMap = [];
if (!is_null($blockListInfo)) {
foreach ($blockListInfo as $blockListInfoEntry) {
$blockListMap[$blockListInfoEntry['id']] = $blockListInfoEntry;
}
} else {
$blockListMap = null;
}
?>
<html>
<script src="src/ajax/tables.js"></script>
<script src="src/ajax/dbsearch.js"></script>
<head>
<link rel="stylesheet" href="main.css" type="text/css">
<link rel="stylesheet" href=<?php echo Config::WEBSITE_STYLE_DIRECTORY . "sidebar.css"; ?> type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@antsstyle" />
<meta name="twitter:title" content="NFT Artist & Cryptobro Blocker" />
<meta name="twitter:description" content="Auto-blocks or auto-mutes NFT artists and cryptobros on your timeline and/or in your mentions." />
<meta name="twitter:image" content="<?php echo Config::CARD_IMAGE_URL; ?>" />
</head>
<title>
NFT Artist & Cryptobro Blocker
</title>
<body onload="storeSearchResults()">
<div class="main">
<script src=<?php echo Config::WEBSITE_STYLE_DIRECTORY . "sidebar.js"; ?>></script>
<h1>NFT Artist & Cryptobro Blocker</h1>
<h2>Statistics</h2>
Below are statistics about how many accounts this app has blocked/muted for you so far.<br/><br/>
<?php
if ($userStats === false) {
echo "A database error occurred retrieving statistics, try again later.";
} else {
if ($totalQueueCount > 100) {
echo "Queued operations are done in batches of 45, once per 15 minutes, per user. As such, if you have many queued operations, "
. "expect them to take a while; check back again in a few hours to see how it is progressing.<br/><br/>";
}
// echo "<b>There is currently a very large backlog of queued actions to process; as such, actions will take longer to process than the above.</b><br/><br/>";
echo "Blocked accounts: $blockCount (Currently queued for blocking: $queuedBlockCount)</br>";
echo "Muted accounts: $muteCount (Currently queued for muting: $queuedMuteCount)</br>";
}
?>
<br/><br/><br/>
<h2>Your block/mute records</h2>
<p>
This is the list of users the app has blocked or muted for you in the last 30 days, sorted by date processed.
Click a column header to sort this page of results.
</p>
<p>
You can search the whole list (not just this page) by twitter handle using the search box below.
</p>
This is page <?php echo "$pageNum of $pageCount"; ?>.
<?php
if ($prevPage >= 1) {
echo "<button onclick=\"window.location.href = '" . Config::HOMEPAGE_URL . "statistics?page=" . $prevPage . "';\">"
. "Previous page"
. "</button>";
} else {
echo "<button onclick=\"window.location.href = '" . Config::HOMEPAGE_URL . "statistics?page=" . $prevPage . "';\" disabled>"
. "Previous page"
. "</button>";
}
echo " ";
if ($nextPage <= $pageCount) {
echo "<button onclick=\"window.location.href = '" . Config::HOMEPAGE_URL . "statistics?page=" . $nextPage . "';\">"
. "Next page"
. "</button>";
} else {
echo "<button onclick=\"window.location.href = '" . Config::HOMEPAGE_URL . "statistics?page=" . $nextPage . "';\" disabled>"
. "Next page"
. "</button>";
}
?>
<br/><br/>
<input type="text" id="dbsearch" placeholder="Search by twitter handle...">
<button type="button" id="searchbutton" onclick="dbSearch('dbsearch', 'user')">Search</button>
<button type="button" id="resetbutton" onclick="resetSearchTable()">Reset</button>
<br/><br/>
<div id="searchresultstextdiv">
</div>
<div id="searchresultsdiv">
<table id="maintable" class="dblisttable">
<tr>
<th onclick="sortTable(0, 'maintable')">Twitter Handle</th>
<th onclick="sortTable(1, 'maintable')">Added from</th>
<th onclick="sortTable(2, 'maintable')">Matched filter type</th>
<th onclick="sortTable(3, 'maintable')">Matched filter content</th>
<th onclick="sortTable(4, 'maintable')">Date processed</th>
</tr>
<?php
if (is_null($userBlockRecords)) {
echo "An error occurred retrieving your block and mute records, check back later.";
} else if (count($userBlockRecords) === 0) {
echo "You do not have any blocked or muted users from the app yet.";
} else {
foreach ($userBlockRecords as $userBlockRecord) {
$dateProcessed = substr($userBlockRecord['dateprocessed'], 0, 10);
$addedFrom = $userBlockRecord['addedfrom'];
$matchedFilterType = $userBlockRecord['matchedfiltertype'];
$matchedFilterContent = $userBlockRecord['matchedfiltercontent'];
if (is_null($matchedFilterType)) {
$matchedFilterType = "N/A";
}
if (is_null($matchedFilterContent)) {
$matchedFilterContent = "N/A";
}
if ($addedFrom == "blocklist" || $addedFrom == "Unknown") {
if (is_null($blockListMap)) {
$addedFrom = "Blocklist (DB error)";
} else {
$blockListEntry = $blockListMap[$userBlockRecord['blocklistid']];
$addedFrom = "Blocklist (" . $blockListEntry['shortname'] . ")";
}
} else if ($addedFrom == "centraldb") {
$addedFrom = "Central blocklist";
} else if ($addedFrom == "statuses/home_timeline") {
$addedFrom = "Home timeline";
} else if ($addedFrom == "users/:id/followers") {
$addedFrom = "Followers";
} else if ($addedFrom == "users/:id/mentions") {
$addedFrom = "Mentions timeline";
}
echo "<tr>";
echo "<td>@" . $userBlockRecord['username'] . "</td>";
echo "<td>" . $addedFrom . "</td>";
if ($userBlockRecord['matchedfiltertype'] === "nftprofilepictures") {
$content = $userBlockRecord['matchedfiltercontent'];
$href = "<a href=\"$content\" target=\"_blank\">Link to image</a>";
echo "<td>" . $userBlockRecord['matchedfiltertype'] . "</td>";
echo "<td>" . $href . "</td>";
} else {
echo "<td>" . $matchedFilterType . "</td>";
echo "<td>" . $matchedFilterContent . "</td>";
}
echo "<td>" . $dateProcessed . "</td>";
echo "</tr>";
}
}
?>
</table>
</div>
<div id="tablecachediv" class="hiddendiv" hidden>
"Say if a duck went 'quack', but not at the angle if it went 'FOX!'"
</div>
</div>
</body>
<script src="Collapsibles.js"></script>
</html>