5 include_once('bots.php');
6 include_once('../slack.php');
7 include_once('security.php');
8 include_once('/var/www/secure.php'); //outside webserver
9 include_once('functions.php');
13 $sign_email = $_COOKIE['sign_email'];
14 if (isset($_GET['sign_email'])){
15 // here we use it, if it shows up next run, we block
16 $sign_email = $_GET['sign_email'];
17 $_COOKIE['sign_email'] = $sign_email;
18 setcookie("sign_email", $sign_email);
19 slack_general('SETTING COOKIE ('.$_COOKIE['sign_email'].') FROM ('.$_GET['sign_email'].')','md-petition-admin');
22 function js_redirect($page){
23 $base = 'https://www.md-petition.com/admin/';
25 $pos = strpos($page, $_COOKIE['sign_email']);
27 // email not found - good to redirect
28 echo "<script>window.location.href = \"$url\";</script>";
29 slack_general('CHECK COOKIE ('.$_COOKIE['sign_email'].') PAGE ('.$page.')','md-petition-admin');
32 echo "<h1>Automated Loop Detected - Skip</h1>";
37 if ($_COOKIE['level'] == 'user'){
38 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
39 header('Location: user_home.php');
41 if (isset($_GET['clear_php_session_id'])){
42 $id = $_GET['clear_php_session_id'];
43 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
44 header('Location: analytics.php');
46 if (isset($_GET['clear_email'])){
47 $email = $_GET['clear_email'];
48 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
49 header('Location: analytics.php');
51 if (isset($_GET['sign_email'])){
52 $email = $_GET['sign_email'];
53 $petition->query("update presign set presign_status = 'SIGNED' where email_for_follow_up = '$email' ");
54 header('Location: analytics.php');
56 if (isset($_GET['sign_php_session_id'])){
57 $id = $_GET['sign_php_session_id'];
58 $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
59 header('Location: analytics.php');
61 if ($_COOKIE['level'] == 'manager'){
62 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
63 header('Location: manager_home.php');
65 if (isset($_GET['flag_invalid_signature'])){
66 $id = $_GET['flag_invalid_signature'];
67 $petition->query("update signatures set signature_status = 'flag_invalid_signature' where id = '$id' ");
68 header('Location: analytics.php');
70 if (isset($_GET['flag_duplicate'])){
71 $id = $_GET['flag_duplicate'];
72 $petition->query("update signatures set signature_status = 'flag_duplicate' where id = '$id' ");
73 header('Location: analytics.php');
75 if (isset($_GET['flag_ip_address'])){
76 $ip = $_GET['flag_ip_address'];
77 $petition->query("update signatures set signature_status = 'flag_ip_address' where ip_address = '$ip' ");
78 header('Location: analytics.php');
80 if (isset($_GET['resign_requested'])){
81 $id = $_GET['resign_requested'];
82 $petition->query("update signatures set signature_status = 'resign_requested' where id = '$id' ");
83 header('Location: analytics.php');
85 if (isset($_GET['bot'])){
87 $petition->query("update signatures set signature_status = 'bot' where id = '$id' ");
88 header('Location: analytics.php');
90 if (isset($_GET['flag_VTRID'])){
91 $VTRID = $_GET['flag_VTRID'];
92 $petition->query("update signatures set signature_status = 'flag_VTRID' where VTRID = '$VTRID' ");
93 header('Location: analytics.php');
95 if (isset($_GET['flag_phone'])){
96 $flag_phone = $_GET['flag_phone'];
97 $petition->query("update signatures set signature_status = 'flag_phone' where contact_phone = '$flag_phone' ");
98 header('Location: analytics.php');
100 include_once('header.php');
101 if (isset($_GET['ip_address'])){
102 $ip = $_GET['ip_address'];
103 $petition_id = $_GET['petition_id'];
104 echo "<h1>Review $ip</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
105 $q = "SELECT * FROM signatures where ip_address = '$ip' and signature_status = 'verified' and petition_id = '$petition_id' order by signature_status desc ";
106 $r = $petition->query($q);
107 while($d = mysqli_fetch_array($r)){
109 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
110 if ($pos !== false) {
113 echo "<tr style='background-color:$color;'>
114 <td><b>$d[date_time_signed]</b></td>
115 <td><a href='?VTRID=$d[VTRID]'>$d[VTRID]</a></td>
116 <td>".id2petition($d['petition_id'])."</td>
117 <td>$d[signed_name_as]</td>
118 <td>$d[signed_name_as_circulator]</td>
119 <td>$d[contact_phone]</td>
120 <td>$d[printed_status]</td>
121 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
122 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
123 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
124 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
125 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
126 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
127 <td><a href='?bot=$d[id]'>bot</a></td>
131 }elseif(isset($_GET['email'])){
132 $email = $_GET['email'];
133 echo "<h1>Review $email</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
134 $q = "SELECT * FROM presign where email_for_follow_up = '$email' order by id desc ";
135 $r = $petition->query($q);
136 while($d = mysqli_fetch_array($r)){
138 $test = date('Y-m-d',strtotime($d['action_on']));
139 $pos = strpos($test, date('Y-m-d'));
140 if ($pos !== false) {
143 echo "<tr style='background-color:$color;'>
144 <td style='white-space:pre;'><b>$d[action_on]</b></td>
145 <td style='white-space:pre;'><a href='?php_session_id=$d[php_session_id]'>$d[php_session_id]</a></td>
146 <td style='white-space:pre;'>$d[php_page]</td>
147 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
148 <td style='white-space:pre;'>$d[invite]</td>
149 <td style='white-space:pre;'>$d[invite_error]</td>
150 <td style='white-space:pre;'>$d[name]</td>
151 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
152 <td style='white-space:pre;'>$d[phone_for_validation]</td>
153 <td style='white-space:pre;'>$d[presign_status]</td>
154 <td style='white-space:pre;'>$d[ip_address]</td>
155 <td style='white-space:pre;'>$d[browser_string]</td>
158 echo "</table><a href='?clear_email=$email'>CLEAR EMAIL</a> - <a href='?sign_email=$email'>SIGNATURE FOUND</a>";
159 }elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){
160 $php_session_id = $_GET['php_session_id'];
161 echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
162 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
163 $r = $petition->query($q);
164 while($d = mysqli_fetch_array($r)){
166 $test = date('Y-m-d',strtotime($d['action_on']));
167 $pos = strpos($test, date('Y-m-d'));
168 if ($pos !== false) {
171 echo "<tr style='background-color:$color;'>
172 <td style='white-space:pre;'><b>$d[action_on]</b></td>
173 <td style='white-space:pre;'>$d[php_page]</td>
174 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
175 <td style='white-space:pre;'>$d[invite]</td>
176 <td style='white-space:pre;'>$d[invite_error]</td>
177 <td style='white-space:pre;'>$d[name]</td>
178 <td style='white-space:pre;'><a href='?email=$d[email_for_follow_up]'>$d[email_for_follow_up]</a></td>
179 <td style='white-space:pre;'>$d[phone_for_validation]</td>
180 <td style='white-space:pre;'>$d[presign_status]</td>
181 <td style='white-space:pre;'>$d[ip_address]</td>
182 <td style='white-space:pre;'>$d[browser_string]</td>
185 echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR SESSION</a> -
186 <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a><br>
187 - <a href='?php_session_id=$php_session_id&follow_up=X'>ADD TO FOLLOW UP LIST Maryland General</a><br>
188 - <a href='?php_session_id=$php_session_id&follow_up=1'>ADD TO FOLLOW UP LIST MGP</a><br>
189 - <a href='?php_session_id=$php_session_id&follow_up=2'>ADD TO FOLLOW UP LIST MLP</a><br>
190 - <a href='?php_session_id=$php_session_id&follow_up=3'>ADD TO FOLLOW UP LIST BTEC</a><br>
191 - <a href='?php_session_id=$php_session_id&follow_up=7'>ADD TO FOLLOW UP LIST PG</a><br>
192 - <a href='?php_session_id=$php_session_id&follow_up=8'>ADD TO FOLLOW UP LIST Ivey</a>
194 }elseif(isset($_GET['php_session_id']) && isset($_GET['follow_up'])){
195 $php_session_id = $_GET['php_session_id'];
196 echo "<h1>Adding Follow up for $php_session_id to $_GET[follow_up]</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
197 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
198 $r = $petition->query($q);
199 while($d = mysqli_fetch_array($r)){
202 $test = date('Y-m-d',strtotime($d['action_on']));
203 $pos = strpos($test, date('Y-m-d'));
204 if ($pos !== false) {
210 if ($d[email_for_follow_up
] != ''){
211 $email = $d[email_for_follow_up
];
213 echo "<tr style='background-color:$color;'>
214 <td style='white-space:pre;'><b>$d[action_on]</b></td>
215 <td style='white-space:pre;'>$d[php_page]</td>
216 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
217 <td style='white-space:pre;'>$d[invite]</td>
218 <td style='white-space:pre;'>$d[invite_error]</td>
219 <td style='white-space:pre;'>$d[name]</td>
220 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
221 <td style='white-space:pre;'>$d[phone_for_validation]</td>
222 <td style='white-space:pre;'>$d[presign_status]</td>
223 <td style='white-space:pre;'>$d[ip_address]</td>
224 <td style='white-space:pre;'>$d[browser_string]</td>
227 $petition->query("insert into follow_up (name, email, php_session, petition_id, date_sent) values ('$name','$email','$php_session_id','$_GET[follow_up]','".date('Y-m-d')."') ");
228 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
229 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
231 }elseif (isset($_GET['VTRID'])){
232 $VTRID = $_GET['VTRID'];
233 $petition_id = $_GET['petition_id'];
234 echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
235 $q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status = 'verified' and petition_id = '$petition_id' order by petition_id, id DESC ";
236 $r = $petition->query($q);
238 while($d = mysqli_fetch_array($r)){
240 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
241 if ($pos !== false) {
244 echo "<tr style='background-color:$color;'>
245 <td><b>$d[date_time_signed]</b></td>
246 <td><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a></td>
247 <td>".id2petition($d['petition_id'])."</td>
248 <td>$d[signed_name_as]</td>
249 <td>$d[signed_name_as_circulator]</td>
250 <td>$d[contact_phone]</td>
251 <td>$d[printed_status]</td>
252 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
253 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
254 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
255 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
256 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
257 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
258 <td><a href='?bot=$d[id]'>bot</a></td>
261 js_redirect("analytics.php?flag_duplicate=$d[id]");
270 <h1
>Signature Analytics
- Server Clock
: <?PHP
echo date('r');?
></h1
>
271 <h2
>NEVER NEVER NEVER CALL
OR TEXT ANYONE
- ONLY EMAIL
!!!</h2
>
272 <h3
>SysOp Says
: Transparency
= Trust
</h3
>
276 <td valign
="top" colspan
='2'><?PHP
/*
278 <div>Watching for duplicates.</div><ol>
280 $q="SELECT ip_address, petition_id,VTRID, COUNT(*) as count FROM signatures where signature_status = 'verified' group by ip_address, petition_id, VTRID";
281 $r = $petition->query($q);
282 while($d = mysqli_fetch_array($r)){
283 if ($d['count'] > 1){
284 echo "<li><a href='?ip_address=$d[ip_address]&petition_id=$d[petition_id]'>$d[ip_address]</a> ".id2petition($d['petition_id'])." <b>$d[count]</b> $d[signed_name_as]</li>";
288 </td><td valign="top"> */ ?
>
290 <div
>Watching
for duplicates
.</div
><ol
>
292 $q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
293 $r = $petition->query($q);
295 while($d = mysqli_fetch_array($r)){
296 if ($d['count'] > 1){
297 echo "<li><a href='?VTRID=$d[VTRID]&petition_id=$d[petition_id]'>$d[VTRID]</a> ".id2petition($d['petition_id'])." <b>$d[count]</b> $d[signed_name_as]</li>";
299 js_redirect("analytics.php?VTRID=$d[VTRID]&petition_id=$d[petition_id]");
310 <td valign
="top" colspan
='2'>
312 <div
>Follow up requested
- never signed
.</div
>
313 <form method
='GET'><input name
='email'><input type
='submit' value
='SEARCH E-MAIL'></form
><table
>
315 $q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id";
316 $r = $petition->query($q);
317 while($d = mysqli_fetch_array($r)){
318 $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
319 $r2 = $petition->query($q2);
320 $d2 = mysqli_fetch_array($r2);
322 if ($d2['name'] != ''){
323 $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
324 $r3 = $petition->query($q3);
325 $d3 = mysqli_fetch_array($r3);
326 if ($d3['date_time_signed'] != ''){
327 $sig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b><br>";
328 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
332 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and php_page like '/sign.php%'";
333 $r4 = $petition->query($q4);
334 $d4 = mysqli_fetch_array($r4);
335 if ($d4['action_on']){
336 $presig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>PRESIG $d4[action_on]</a></b><br>";
337 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
340 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and invite_error <> '' ";
341 $r4 = $petition->query($q4);
342 $d4 = mysqli_fetch_array($r4);
343 if ($d4['invite_error'] != ''){
344 $invite_error = "<b><a href='?clear_email=$d2[email_for_follow_up]'>$d4[invite_error]</a></b><br>";
345 js_redirect("analytics.php?clear_email=$d2[email_for_follow_up]");
347 $php_session_id = $d2['php_session_id'];
348 echo "<tr><td><a href='?php_session_id=$php_session_id'>$d2[action_on]</a></td><td>$presig $sig $invite_error</td>
349 <td>$d2[name]</td><td><a href='?email=$d2[email_for_follow_up]'>$d2[email_for_follow_up]</a></td>
350 <td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td>
351 <td><a href='?php_session_id=$php_session_id&follow_up=X'>General</a>
352 - <a href='?php_session_id=$php_session_id&follow_up=1'>MGP</a>
353 - <a href='?php_session_id=$php_session_id&follow_up=2'>MLP</a>
354 - <a href='?php_session_id=$php_session_id&follow_up=3'>BTEC</a>
355 - <a href='?php_session_id=$php_session_id&follow_up=7'>PG</a>
356 - <a href='?php_session_id=$php_session_id&follow_up=8'>Ivey</a></td></tr>";
357 if( $presig == '' && $invite_error == '' && $sig == '' ){
358 if ($d2['invite'] == 'Ivey'){
359 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=8");
361 if ($d2['invite'] == 'mlp'){
362 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=2");
364 if ($d2['invite'] == 'BTEC'){
365 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=3");
367 if ($d2['invite'] == 'RestorePGTermLimits'){
368 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
370 if ($d2['invite'] == 'mgp'){
371 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=1");
379 <td valign
="top" colspan
='2'>
381 <div
>Last
10</div
><ol
>
383 $q="SELECT * FROM signatures where signature_status = 'verified' order by id desc limit 0, 10";
384 $r = $petition->query($q);
385 while($d = mysqli_fetch_array($r)){
386 echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
393 <tr
><td valign
="top">
395 <div
>Watching
for 0</div
><ol
>
397 $q="SELECT * FROM signatures where VTRID = '0' and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
398 $r = $petition->query($q);
399 while($d = mysqli_fetch_array($r)){
400 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>";
403 </td
><td valign
="top">
404 <h2
>Petition ID Bugs
</h2
>
405 <div
>Watching
for 0</div
><ol
>
407 $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'";
408 $r = $petition->query($q);
409 while($d = mysqli_fetch_array($r)){
410 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>";
413 </td
></tr
><tr
><td valign
="top">
415 <h2
>resign_requested
</h2
>
416 <div
>These are most likely from early bugs
</div
><ol
>
418 $q="SELECT * FROM signatures where signature_status = 'resign_requested' order by ip_address";
419 $r = $petition->query($q);
421 while($d = mysqli_fetch_array($r)){
423 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>";
426 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
432 <div
>These are bots on the site
.</div
><ol
>
434 $q="SELECT * FROM signatures where signature_status = 'bot' order by ip_address";
435 $r = $petition->query($q);
437 while($d = mysqli_fetch_array($r)){
439 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>";
442 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
453 // allow headers to be sent...
454 $html = ob_get_clean();
455 echo $html; // run javascript
457 include_once('footer.php');