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