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