4 if (isset($_COOKIE['order'])){
5 $order = $_COOKIE['order'];
8 if (empty($_GET['run'])){
9 if ($_COOKIE['name'] == ''){
12 include_once('bots.php');
13 include_once('../slack.php');
14 slack_general('run 1','meps-auto');
15 include_once('security.php');
16 include_once('/var/www/secure.php'); //outside webserver
17 include_once('functions.php');
19 include_once('../slack.php');
20 slack_general('run 2','meps-auto');
21 include_once('/var/www/secure.php'); //outside webserver
22 include_once('functions.php');
26 $sign_email = $_COOKIE['sign_email'];
27 if (isset($_GET['sign_email'])){
28 // here we use it, if it shows up next run, we block
29 $sign_email = $_GET['sign_email'];
30 $_COOKIE['sign_email'] = $sign_email;
31 setcookie("sign_email", $sign_email);
35 function js_redirect($page){ // now header - prep for full auto
37 $base = 'https://www.md-petition.com/admin/';
38 $url = $base.$page.'&run=1';
39 $pos = strpos($page, $_COOKIE['sign_email']);
42 // email not found - good to redirect
43 //echo "<script>window.location.href = \"$url\";</script>";
44 slack_general('js_redirect('.$page.')','automation');
45 header('Location: '.$url);
46 //slack_general('CHECK COOKIE ('.$_COOKIE['sign_email'].') PAGE ('.$page.')','md-petition-admin');
48 setcookie("order", $order);
51 $q = "select id from presign where email_for_follow_up <> '' and presign_status = 'NEW' limit 0,1 ";
52 $r = $petition->query($q);
53 $d = mysqli_fetch_array($r);
55 $petition->query("update presign set presign_status = 'LOOP' where id = '$id'");
56 slack_general('Loop Detected for '.$_COOKIE['sign_email'].' clearing '.$id,'fatal_errors');
57 echo "<h1>Automated Loop Detected - Skip Setting - Reverse Sort (DESC)</h1>";
59 setcookie("order", $order);
64 if ($_COOKIE['level'] == 'user'){
65 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
66 header('Location: user_home.php');
68 if (isset($_GET['clear_php_session_id'])){
69 $id = $_GET['clear_php_session_id'];
70 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
71 header('Location: analytics.php');
73 if (isset($_GET['clear_email'])){
74 $email = $_GET['clear_email'];
75 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
76 header('Location: analytics.php');
78 if (isset($_GET['sign_email'])){
79 $email = $_GET['sign_email'];
80 $petition->query("update presign set presign_status = 'SIGNED' where email_for_follow_up = '$email' ");
81 header('Location: analytics.php');
83 if (isset($_GET['sign_php_session_id'])){
84 $id = $_GET['sign_php_session_id'];
85 $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
86 header('Location: analytics.php');
88 if ($_COOKIE['level'] == 'manager'){
89 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
90 header('Location: manager_home.php');
92 if (isset($_GET['flag_invalid_signature'])){
93 $id = $_GET['flag_invalid_signature'];
94 $petition->query("update signatures set signature_status = 'flag_invalid_signature' where id = '$id' ");
95 header('Location: analytics.php');
97 if (isset($_GET['flag_duplicate'])){
98 $id = $_GET['flag_duplicate'];
99 $petition->query("update signatures set signature_status = 'flag_duplicate' where id = '$id' ");
100 header('Location: analytics.php');
102 if (isset($_GET['flag_ip_address'])){
103 $ip = $_GET['flag_ip_address'];
104 $petition->query("update signatures set signature_status = 'flag_ip_address' where ip_address = '$ip' ");
105 header('Location: analytics.php');
107 if (isset($_GET['resign_requested'])){
108 $id = $_GET['resign_requested'];
109 $petition->query("update signatures set signature_status = 'resign_requested' where id = '$id' ");
110 header('Location: analytics.php');
112 if (isset($_GET['bot'])){
114 $petition->query("update signatures set signature_status = 'bot' where id = '$id' ");
115 header('Location: analytics.php');
117 if (isset($_GET['flag_VTRID'])){
118 $VTRID = $_GET['flag_VTRID'];
119 $petition->query("update signatures set signature_status = 'flag_VTRID' where VTRID = '$VTRID' ");
120 header('Location: analytics.php');
122 if (isset($_GET['flag_phone'])){
123 $flag_phone = $_GET['flag_phone'];
124 $petition->query("update signatures set signature_status = 'flag_phone' where contact_phone = '$flag_phone' ");
125 header('Location: analytics.php');
127 include_once('header.php');
128 if (isset($_GET['ip_address'])){
129 $ip = $_GET['ip_address'];
130 $petition_id = $_GET['petition_id'];
131 echo "<h1>Review $ip</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
132 $q = "SELECT * FROM signatures where ip_address = '$ip' and signature_status = 'verified' and petition_id = '$petition_id' order by signature_status desc ";
133 $r = $petition->query($q);
134 while($d = mysqli_fetch_array($r)){
136 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
137 if ($pos !== false) {
140 echo "<tr style='background-color:$color;'>
141 <td><b>$d[date_time_signed]</b></td>
142 <td><a href='?VTRID=$d[VTRID]'>$d[VTRID]</a></td>
143 <td>".id2petition($d['petition_id'])."</td>
144 <td>$d[signed_name_as]</td>
145 <td>$d[signed_name_as_circulator]</td>
146 <td>$d[contact_phone]</td>
147 <td>$d[printed_status]</td>
148 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
149 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
150 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
151 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
152 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
153 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
154 <td><a href='?bot=$d[id]'>bot</a></td>
158 }elseif(isset($_GET['email'])){
159 $email = $_GET['email'];
160 echo "<h1>Review $email</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
161 $q = "SELECT * FROM presign where email_for_follow_up = '$email' order by id desc ";
162 $r = $petition->query($q);
163 while($d = mysqli_fetch_array($r)){
165 $test = date('Y-m-d',strtotime($d['action_on']));
166 $pos = strpos($test, date('Y-m-d'));
167 if ($pos !== false) {
170 echo "<tr style='background-color:$color;'>
171 <td style='white-space:pre;'><b>$d[action_on]</b></td>
172 <td style='white-space:pre;'><a href='?php_session_id=$d[php_session_id]'>$d[php_session_id]</a></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;'>$d[email_for_follow_up]</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_email=$email'>CLEAR EMAIL</a> - <a href='?sign_email=$email'>SIGNATURE FOUND</a>";
186 }elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){
187 $php_session_id = $_GET['php_session_id'];
188 echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
189 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' and email_for_follow_up <> '$_COOKIE[sign_email]' order by id DESC ";
190 $r = $petition->query($q);
191 while($d = mysqli_fetch_array($r)){
193 $test = date('Y-m-d',strtotime($d['action_on']));
194 $pos = strpos($test, date('Y-m-d'));
195 if ($pos !== false) {
198 echo "<tr style='background-color:$color;'>
199 <td style='white-space:pre;'><b>$d[action_on]</b></td>
200 <td style='white-space:pre;'>$d[php_page]</td>
201 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
202 <td style='white-space:pre;'>$d[invite]</td>
203 <td style='white-space:pre;'>$d[invite_error]</td>
204 <td style='white-space:pre;'>$d[name]</td>
205 <td style='white-space:pre;'><a href='?email=$d[email_for_follow_up]'>$d[email_for_follow_up]</a></td>
206 <td style='white-space:pre;'>$d[phone_for_validation]</td>
207 <td style='white-space:pre;'>$d[presign_status]</td>
208 <td style='white-space:pre;'>$d[ip_address]</td>
209 <td style='white-space:pre;'>$d[browser_string]</td>
212 echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR SESSION</a> -
213 <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a><br>
214 - <a href='?php_session_id=$php_session_id&follow_up=X'>ADD TO FOLLOW UP LIST Maryland General</a><br>
215 - <a href='?php_session_id=$php_session_id&follow_up=1'>ADD TO FOLLOW UP LIST MGP</a><br>
216 - <a href='?php_session_id=$php_session_id&follow_up=2'>ADD TO FOLLOW UP LIST MLP</a><br>
217 - <a href='?php_session_id=$php_session_id&follow_up=3'>ADD TO FOLLOW UP LIST BTEC</a><br>
218 - <a href='?php_session_id=$php_session_id&follow_up=7'>ADD TO FOLLOW UP LIST PG</a><br>
219 - <a href='?php_session_id=$php_session_id&follow_up=8'>ADD TO FOLLOW UP LIST Ivey</a>
221 }elseif(isset($_GET['php_session_id']) && isset($_GET['follow_up'])){
222 $php_session_id = $_GET['php_session_id'];
223 echo "<h1>Adding Follow up for $php_session_id to $_GET[follow_up]</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
224 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
225 $r = $petition->query($q);
226 while($d = mysqli_fetch_array($r)){
229 $test = date('Y-m-d',strtotime($d['action_on']));
230 $pos = strpos($test, date('Y-m-d'));
231 if ($pos !== false) {
237 if ($d[email_for_follow_up
] != ''){
238 $email = $d[email_for_follow_up
];
240 echo "<tr style='background-color:$color;'>
241 <td style='white-space:pre;'><b>$d[action_on]</b></td>
242 <td style='white-space:pre;'>$d[php_page]</td>
243 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
244 <td style='white-space:pre;'>$d[invite]</td>
245 <td style='white-space:pre;'>$d[invite_error]</td>
246 <td style='white-space:pre;'>$d[name]</td>
247 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
248 <td style='white-space:pre;'>$d[phone_for_validation]</td>
249 <td style='white-space:pre;'>$d[presign_status]</td>
250 <td style='white-space:pre;'>$d[ip_address]</td>
251 <td style='white-space:pre;'>$d[browser_string]</td>
254 $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')."') ");
255 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
256 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
258 }elseif (isset($_GET['VTRID'])){
259 $VTRID = $_GET['VTRID'];
260 $petition_id = $_GET['petition_id'];
261 echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
262 $q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status = 'verified' and petition_id = '$petition_id' order by petition_id, id DESC ";
263 $r = $petition->query($q);
265 while($d = mysqli_fetch_array($r)){
267 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
268 if ($pos !== false) {
271 echo "<tr style='background-color:$color;'>
272 <td><b>$d[date_time_signed]</b></td>
273 <td><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a></td>
274 <td>".id2petition($d['petition_id'])."</td>
275 <td>$d[signed_name_as]</td>
276 <td>$d[signed_name_as_circulator]</td>
277 <td>$d[contact_phone]</td>
278 <td>$d[printed_status]</td>
279 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
280 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
281 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
282 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
283 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
284 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
285 <td><a href='?bot=$d[id]'>bot</a></td>
288 js_redirect("analytics.php?flag_duplicate=$d[id]");
297 <h1
>Signature Analytics
- Server Clock
: <?PHP
echo date('r');?
></h1
>
298 <h2
>NEVER NEVER NEVER CALL
OR TEXT ANYONE
- ONLY EMAIL
!!!</h2
>
299 <h3
>SysOp Says
: Transparency
= Trust
</h3
>
303 <td valign
="top" colspan
='2'><?PHP
/*
305 <div>Watching for duplicates.</div><ol>
307 $q="SELECT ip_address, petition_id,VTRID, COUNT(*) as count FROM signatures where signature_status = 'verified' group by ip_address, petition_id, VTRID";
308 $r = $petition->query($q);
309 while($d = mysqli_fetch_array($r)){
310 if ($d['count'] > 1){
311 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>";
315 </td><td valign="top"> */ ?
>
317 <div
>Watching
for duplicates
.</div
><ol
>
319 $q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
320 $r = $petition->query($q);
322 while($d = mysqli_fetch_array($r)){
323 if ($d['count'] > 1){
324 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>";
326 js_redirect("analytics.php?VTRID=$d[VTRID]&petition_id=$d[petition_id]");
337 <td valign
="top" colspan
='2'>
339 <div
>Follow up requested
- never signed
.</div
>
340 <form method
='GET'><input name
='email'><input type
='submit' value
='SEARCH E-MAIL'></form
><table
>
345 $q="SELECT distinct php_session_id, email_for_follow_up FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id $order";
346 $r = $petition->query($q);
347 while($d = mysqli_fetch_array($r)){
348 $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
349 $r2 = $petition->query($q2);
350 $d2 = mysqli_fetch_array($r2);
352 if ($d2['name'] != ''){
353 $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
354 $r3 = $petition->query($q3);
355 $d3 = mysqli_fetch_array($r3);
356 if ($d3['date_time_signed'] != ''){
357 $sig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b><br>";
358 js_redirect("analytics.php?r=1&sign_email=$d2[email_for_follow_up]");
362 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and php_page like '/sign.php%'";
363 $r4 = $petition->query($q4);
364 $d4 = mysqli_fetch_array($r4);
365 if ($d4['action_on']){
366 $presig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>PRESIG $d4[action_on]</a></b><br>";
367 js_redirect("analytics.php?r=2&sign_email=$d2[email_for_follow_up]");
370 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and invite_error <> '' and email_for_follow_up <> '$_COOKIE[sign_email]' ";
371 $r4 = $petition->query($q4);
372 $d4 = mysqli_fetch_array($r4);
373 $php_session_id = $d2['php_session_id'];
374 if ($d4['invite_error'] != ''){
375 $invite_error = "<b>$d4[invite_error]</b><br>";
376 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
377 //js_redirect("analytics.php?r=3&clear_email=$d2[email_for_follow_up]");
379 echo "<tr><td><a href='?php_session_id=$php_session_id'>$d2[action_on]</a></td><td>$presig $sig $invite_error</td>
380 <td>$d2[name]</td><td><a href='?email=$d2[email_for_follow_up]'>$d2[email_for_follow_up]</a></td>
381 <td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td>
382 <td><a href='?php_session_id=$php_session_id&follow_up=X'>General</a>
383 - <a href='?php_session_id=$php_session_id&follow_up=1'>MGP</a>
384 - <a href='?php_session_id=$php_session_id&follow_up=2'>MLP</a>
385 - <a href='?php_session_id=$php_session_id&follow_up=3'>BTEC</a>
386 - <a href='?php_session_id=$php_session_id&follow_up=7'>PG</a>
387 - <a href='?php_session_id=$php_session_id&follow_up=8'>Ivey</a></td></tr>";
388 if( $presig == '' && $invite_error == '' && $sig == '' ){
389 if ($d2['invite'] == 'Ivey'){
390 js_redirect("analytics.php?r=4&php_session_id=$php_session_id&follow_up=8");
393 if ($d2['invite'] == 'mlp'){
394 js_redirect("analytics.php?r=5&php_session_id=$php_session_id&follow_up=2");
397 if ($d2['invite'] == 'BTEC'){
398 js_redirect("analytics.php?r=6&php_session_id=$php_session_id&follow_up=3");
401 if ($d2['invite'] == 'RestorePGTermLimits'){
402 js_redirect("analytics.php?r=7&php_session_id=$php_session_id&follow_up=7");
405 if (id2petition($d2['petition']) == 'RESTORE TWO TERM (8 YEAR) TERM LIMITS IN PRINCE GEORGE'){
406 js_redirect("analytics.php?r=8&php_session_id=$php_session_id&follow_up=7");
409 if ($d2['invite'] == 'mgp'){
410 js_redirect("analytics.php?r=9&php_session_id=$php_session_id&follow_up=1");
413 js_redirect("analytics.php?r=10&php_session_id=$php_session_id&follow_up=X"); // no invite found no petition found - send general follow/up
420 <td valign
="top" colspan
='2'>
422 <div
>Last
10</div
><ol
>
424 $q="SELECT * FROM signatures where signature_status = 'verified' order by id desc limit 0, 10";
425 $r = $petition->query($q);
426 while($d = mysqli_fetch_array($r)){
427 echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
434 <tr
><td valign
="top">
436 <div
>Watching
for 0</div
><ol
>
438 $q="SELECT * FROM signatures where VTRID = '0' and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
439 $r = $petition->query($q);
440 while($d = mysqli_fetch_array($r)){
441 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>";
444 </td
><td valign
="top">
445 <h2
>Petition ID Bugs
</h2
>
446 <div
>Watching
for 0</div
><ol
>
448 $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'";
449 $r = $petition->query($q);
450 while($d = mysqli_fetch_array($r)){
451 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>";
454 </td
></tr
><tr
><td valign
="top">
456 <h2
>resign_requested
</h2
>
457 <div
>These are most likely from early bugs
</div
><ol
>
459 $q="SELECT * FROM signatures where signature_status = 'resign_requested' order by ip_address";
460 $r = $petition->query($q);
462 while($d = mysqli_fetch_array($r)){
464 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>";
467 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
473 <div
>These are bots on the site
.</div
><ol
>
475 $q="SELECT * FROM signatures where signature_status = 'bot' order by ip_address";
476 $r = $petition->query($q);
478 while($d = mysqli_fetch_array($r)){
480 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>";
483 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
494 // allow headers to be sent...
495 $html = ob_get_clean();
496 echo $html; // run javascript
497 slack_general('done','meps-auto');
498 include_once('footer.php');