Update abuse.php
[clinton/MarylandElectronicPetitionSignature.git] / admin / abuse.php
CommitLineData
5623205d
PM
1<?PHP
2include_once('../slack.php');
3include_once('security.php');
c7d45ac6 4include_once('/var/www/secure.php'); //outside webserver
6c9432fc 5include_once('functions.php');
5623205d
PM
6if ($_COOKIE['level'] == 'user'){
7 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
8 header('Location: user_home.php');
9}
28de89d0
PM
10if (isset($_GET['clear_php_session_id'])){
11 $id = $_GET['clear_php_session_id'];
12 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
13 header('Location: abuse.php');
14}
9e6d5e27
PM
15if (isset($_GET['sign_php_session_id'])){
16 $id = $_GET['sign_php_session_id'];
17 $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
18 header('Location: abuse.php');
19}
5623205d
PM
20if ($_COOKIE['level'] == 'manager'){
21 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
22 header('Location: manager_home.php');
23}
73a94d3f 24if (isset($_GET['flag_invalid_signature'])){
68e387b9 25 $id = $_GET['flag_invalid_signature'];
73a94d3f 26 $petition->query("update signatures set signature_status = 'flag_invalid_signature' where id = '$id' ");
c7d45ac6 27 header('Location: abuse.php');
73a94d3f 28}
68e387b9
PM
29if (isset($_GET['flag_duplicate'])){
30 $id = $_GET['flag_duplicate'];
31 $petition->query("update signatures set signature_status = 'flag_duplicate' where id = '$id' ");
c7d45ac6 32 header('Location: abuse.php');
68e387b9
PM
33}
34if (isset($_GET['flag_ip_address'])){
35 $ip = $_GET['flag_ip_address'];
36 $petition->query("update signatures set signature_status = 'flag_ip_address' where ip_address = '$ip' ");
c7d45ac6 37 header('Location: abuse.php');
68e387b9 38}
dcc3fc26
PM
39if (isset($_GET['resign_requested'])){
40 $id = $_GET['resign_requested'];
41 $petition->query("update signatures set signature_status = 'resign_requested' where id = '$id' ");
42 header('Location: abuse.php');
43}
3f8c226b
PM
44if (isset($_GET['bot'])){
45 $id = $_GET['bot'];
46 $petition->query("update signatures set signature_status = 'bot' where id = '$id' ");
47 header('Location: abuse.php');
48}
68e387b9
PM
49if (isset($_GET['flag_VTRID'])){
50 $VTRID = $_GET['flag_VTRID'];
51 $petition->query("update signatures set signature_status = 'flag_VTRID' where VTRID = '$VTRID' ");
c7d45ac6 52 header('Location: abuse.php');
68e387b9 53}
587d1da3
PM
54if (isset($_GET['flag_phone'])){
55 $flag_phone = $_GET['flag_phone'];
56 $petition->query("update signatures set signature_status = 'flag_phone' where contact_phone = '$flag_phone' ");
57 header('Location: abuse.php');
58}
c7d45ac6 59include_once('header.php');
f49d1b19
PM
60if (isset($_GET['ip_address'])){
61 $ip = $_GET['ip_address'];
68e387b9 62 echo "<h1>Review $ip</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
6c50c9f6 63 $q = "SELECT * FROM signatures where ip_address = '$ip' order by signature_status desc ";
45bc6a1e 64 $r = $petition->query($q);
7ce3d9ec 65 while($d = mysqli_fetch_array($r)){
4fca24b9
PM
66 $color = 'white';
67 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
68 if ($pos !== false) {
69 $color= 'yellow';
70 }
71 echo "<tr style='background-color:$color;'>
68e387b9
PM
72 <td><b>$d[date_time_signed]</b></td>
73 <td><a href='?VTRID=$d[VTRID]'>$d[VTRID]</a></td>
6c9432fc 74 <td>".id2petition($d['petition_id'])."</td>
68e387b9
PM
75 <td>$d[signed_name_as]</td>
76 <td>$d[signed_name_as_circulator]</td>
77 <td>$d[contact_phone]</td>
78 <td>$d[signature_status]</td>
79 <td>$d[printed_status]</td>
dcc3fc26
PM
80 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
81 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
82 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
83 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
84 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
ff3013b8 85 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
3f8c226b 86 <td><a href='?bot=$d[id]'>bot</a></td>
68e387b9 87 </tr>";
7ce3d9ec 88 }
3a0177c8 89 echo "</table>";
b331a809
PM
90}elseif(isset($_GET['php_session_id'])){
91 $php_session_id = $_GET['php_session_id'];
92 echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
93 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
94 $r = $petition->query($q);
95 while($d = mysqli_fetch_array($r)){
96 $color = 'white';
eea234c3
PM
97 $test = date('Y-m-d',strtotime($d['action_on']));
98 $pos = strpos($test, date('Y-m-d'));
b331a809
PM
99 if ($pos !== false) {
100 $color= 'yellow';
101 }
102 echo "<tr style='background-color:$color;'>
eea234c3
PM
103 <td style='white-space:pre;'><b>$d[action_on]</b></td>
104 <td style='white-space:pre;'>$d[php_page]</td>
105 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
106 <td style='white-space:pre;'>$d[invite]</td>
973dd966 107 <td style='white-space:pre;'>$d[invite_error]</td>
eea234c3
PM
108 <td style='white-space:pre;'>$d[name]</td>
109 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
110 <td style='white-space:pre;'>$d[phone_for_validation]</td>
111 <td style='white-space:pre;'>$d[presign_status]</td>
112 <td style='white-space:pre;'>$d[ip_address]</td>
113 <td style='white-space:pre;'>$d[browser_string]</td>
b331a809
PM
114 </tr>";
115 }
9e6d5e27 116 echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR ALERT</a> - <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a>";
f49d1b19
PM
117}elseif (isset($_GET['VTRID'])){
118 $VTRID = $_GET['VTRID'];
68e387b9 119 echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
783d17ee 120 $q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status <> 'deleted' order by petition_id, id DESC ";
45bc6a1e 121 $r = $petition->query($q);
7ce3d9ec 122 while($d = mysqli_fetch_array($r)){
4fca24b9
PM
123 $color = 'white';
124 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
125 if ($pos !== false) {
126 $color= 'yellow';
127 }
128 echo "<tr style='background-color:$color;'>
68e387b9
PM
129 <td><b>$d[date_time_signed]</b></td>
130 <td><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a></td>
b6545efe 131 <td>".id2petition($d['petition_id'])."</td>
68e387b9
PM
132 <td>$d[signed_name_as]</td>
133 <td>$d[signed_name_as_circulator]</td>
134 <td>$d[contact_phone]</td>
135 <td>$d[signature_status]</td>
136 <td>$d[printed_status]</td>
dcc3fc26
PM
137 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
138 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
139 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
140 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
141 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
ff3013b8 142 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
3f8c226b 143 <td><a href='?bot=$d[id]'>bot</a></td>
68e387b9 144 </tr>";
7ce3d9ec 145 }
3a0177c8 146 echo "</table>";
f49d1b19 147}
5623205d 148?>
4b205268 149
72744e34 150<h1>Signature Quality Control</h1>
d5dffc27 151<h2>NEVER NEVER NEVER CALL OR TEXT ANYONE - ONLY EMAIL!!!</h2>
797efc8e
PM
152<table><tr>
153
154 <td valign="top">
e0bd2eda 155<h2>IP Address</h2>
cc84dbb5 156<div>Watch for duplicates.</div><ol>
5623205d 157<?PHP
babf0707 158$q="SELECT ip_address, petition_id,VTRID, COUNT(*) as count FROM signatures where signature_status = 'verified' group by ip_address, petition_id, VTRID";
5623205d
PM
159$r = $petition->query($q);
160while($d = mysqli_fetch_array($r)){
4b205268 161 if ($d['count'] > 1){
55fd7459 162 echo "<li><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a> <a target='_Blank' href='https://ipinfo.io/$d[ip_address]'>IP INFO</a> <a href='?VTRID=$d[VTRID]'>$d[VTRID]</a> $d[petition_id] <b>$d[count]</b> $d[signed_name_as]</li>";
4b205268 163 }
5623205d 164}
cc84dbb5 165?></ol>
797efc8e 166 </td><td valign="top">
e0bd2eda 167<h2>VTRID</h2>
cc84dbb5 168<div>Watch for duplicates.</div><ol>
1b0319d4 169<?PHP
870eafe2 170$q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
1b0319d4 171$r = $petition->query($q);
4b205268
PM
172while($d = mysqli_fetch_array($r)){
173 if ($d['count'] > 1){
ea380aa9 174 echo "<li><a href='?VTRID=$d[VTRID]'>$d[VTRID]</a> $d[petition_id] <b>$d[count]</b> $d[signed_name_as]</li>";
4b205268 175 }
1b0319d4 176}
cc84dbb5 177 ?></ol>
e8d1541d 178 </td></tr><tr><td valign="top">
e0bd2eda 179<h2>VTRID</h2>
cc84dbb5 180<div>Watch for 0</div><ol>
e0bd2eda 181<?PHP
e8d1541d 182$q="SELECT * FROM signatures where VTRID = '0' and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
e0bd2eda
PM
183$r = $petition->query($q);
184while($d = mysqli_fetch_array($r)){
55fd7459 185 echo "<li>$d[date_time_signed] <a href='?ip_address=$d[ip_address]'>$d[ip_address]</a> <a target='_Blank' href='https://ipinfo.io/$d[ip_address]'>IP INFO</a> $d[petition_id] $d[signed_name_as]</li>";
9b75965d 186}
cc84dbb5 187?></ol>
797efc8e 188 </td><td valign="top">
9b75965d 189<h2>petition_id</h2>
cc84dbb5 190<div>Watch for 0</div><ol>
9b75965d 191<?PHP
e8d1541d 192$q="SELECT * FROM signatures where (petition_id = '0' or petition_id = '') and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
9b75965d 193$r = $petition->query($q);
4931af50 194while($d = mysqli_fetch_array($r)){
55fd7459 195 echo "<li>$d[date_time_signed] <a href='?ip_address=$d[ip_address]'>$d[ip_address]</a> <a target='_Blank' href='https://ipinfo.io/$d[ip_address]'>IP INFO</a> $d[petition_id] $d[signed_name_as]</li>";
4931af50
PM
196}
197?></ol>
e8d1541d 198 </td></tr><tr><td valign="top">
4931af50 199<h2>resign_requested</h2>
3f8c226b 200<div>These are most likely from early bugs</div><ol>
4931af50 201<?PHP
68fde5b1 202$q="SELECT * FROM signatures where signature_status = 'resign_requested' order by ip_address";
4931af50 203$r = $petition->query($q);
9b75965d 204while($d = mysqli_fetch_array($r)){
55fd7459 205 echo "<li>$d[date_time_signed] <a href='?ip_address=$d[ip_address]'>$d[ip_address]</a> <a target='_Blank' href='https://ipinfo.io/$d[ip_address]'>IP INFO</a> <a href='?VTRID=$d[VTRID]'>$d[VTRID]</a> $d[petition_id] $d[signed_name_as]</li>";
e0bd2eda 206}
3f8c226b
PM
207?></ol>
208 </td>
209
210 <td valign="top">
211<h2>bots</h2>
212<div>These are bots on the site.</div><ol>
213<?PHP
68fde5b1 214$q="SELECT * FROM signatures where signature_status = 'bot' order by ip_address";
3f8c226b
PM
215$r = $petition->query($q);
216while($d = mysqli_fetch_array($r)){
ab89bfc5 217 echo "<li>$d[date_time_signed] <a href='?ip_address=$d[ip_address]'>$d[ip_address]</a> <a target='_Blank' href='https://ipinfo.io/$d[ip_address]'>IP INFO</a> <a href='?VTRID=$d[VTRID]'>$d[VTRID]</a> $d[petition_id] $d[signed_name_as]</li>";
3f8c226b 218}
cc84dbb5 219?></ol>
797efc8e 220 </td>
5623205d 221
9b75965d 222
05fddd22
PM
223</tr>
224<tr>
225<td valign="top">
bdc1dd01 226<h2>Pre-Sign</h2>
9fa521d8 227<div>Follow up requested - never signed.</div><ol>
05fddd22 228<?PHP
f39f7ebc 229$q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id desc";
05fddd22
PM
230$r = $petition->query($q);
231while($d = mysqli_fetch_array($r)){
f39f7ebc
PM
232 $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
233 $r2 = $petition->query($q2);
234 $d2 = mysqli_fetch_array($r2);
65949501 235 echo "<li><a href='?php_session_id=$d2[php_session_id]'>$d2[name] $d2[email_for_follow_up] ".id2petition($d2['petition'])." $d2[invite]</a></li>";
05fddd22
PM
236}
237?></ol>
238 </td>
239<td valign="top">
bdc1dd01
PM
240<h2>Signature</h2>
241<div>Last 10</div><ol>
05fddd22 242<?PHP
7b154908 243$q="SELECT * FROM signatures where signature_status = 'verified' order by id desc limit 0, 10";
05fddd22
PM
244$r = $petition->query($q);
245while($d = mysqli_fetch_array($r)){
9390413f 246 echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
05fddd22
PM
247}
248?></ol>
249 </td>
250
251 </tr>
252</table>
9b75965d
PM
253
254
5623205d
PM
255<?PHP
256include_once('footer.php');
257?>