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 include_once('security.php');
15 include_once('/var/www/secure.php'); //outside webserver
16 include_once('functions.php');
18 include_once('../slack.php');
19 include_once('/var/www/secure.php'); //outside webserver
20 include_once('functions.php');
24 $sign_email = $_COOKIE['sign_email'];
25 if (isset($_GET['sign_email'])){
26 // here we use it, if it shows up next run, we block
27 $sign_email = $_GET['sign_email'];
28 $_COOKIE['sign_email'] = $sign_email;
29 setcookie("sign_email", $sign_email);
33 function js_redirect($page){ // now header - prep for full auto
34 $base = 'https://www.md-petition.com/admin/';
35 $url = $base.$page.'&run=1';
36 $pos = strpos($page, $_COOKIE['sign_email']);
39 // email not found - good to redirect
40 //echo "<script>window.location.href = \"$url\";</script>";
41 //slack_general('js_redirect('.$page.')','automation');
42 // header('Location: '.$url);
43 //slack_general('CHECK COOKIE ('.$_COOKIE['sign_email'].') PAGE ('.$page.')','md-petition-admin');
45 setcookie("order", $order);
48 //slack_general('Loop Detected for '.$_COOKIE['sign_email'],'automation');
49 echo "<h1>Automated Loop Detected - Skip Setting - Reverse Sort (DESC)</h1>";
51 setcookie("order", $order);
56 if ($_COOKIE['level'] == 'user'){
57 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
58 header('Location: user_home.php');
60 if (isset($_GET['clear_php_session_id'])){
61 $id = $_GET['clear_php_session_id'];
62 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
63 header('Location: analytics.php');
65 if (isset($_GET['clear_email'])){
66 $email = $_GET['clear_email'];
67 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
68 header('Location: analytics.php');
70 if (isset($_GET['sign_email'])){
71 $email = $_GET['sign_email'];
72 $petition->query("update presign set presign_status = 'SIGNED' where email_for_follow_up = '$email' ");
73 header('Location: analytics.php');
75 if (isset($_GET['sign_php_session_id'])){
76 $id = $_GET['sign_php_session_id'];
77 $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
78 header('Location: analytics.php');
80 if ($_COOKIE['level'] == 'manager'){
81 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
82 header('Location: manager_home.php');
84 if (isset($_GET['flag_invalid_signature'])){
85 $id = $_GET['flag_invalid_signature'];
86 $petition->query("update signatures set signature_status = 'flag_invalid_signature' where id = '$id' ");
87 header('Location: analytics.php');
89 if (isset($_GET['flag_duplicate'])){
90 $id = $_GET['flag_duplicate'];
91 $petition->query("update signatures set signature_status = 'flag_duplicate' where id = '$id' ");
92 header('Location: analytics.php');
94 if (isset($_GET['flag_ip_address'])){
95 $ip = $_GET['flag_ip_address'];
96 $petition->query("update signatures set signature_status = 'flag_ip_address' where ip_address = '$ip' ");
97 header('Location: analytics.php');
99 if (isset($_GET['resign_requested'])){
100 $id = $_GET['resign_requested'];
101 $petition->query("update signatures set signature_status = 'resign_requested' where id = '$id' ");
102 header('Location: analytics.php');
104 if (isset($_GET['bot'])){
106 $petition->query("update signatures set signature_status = 'bot' where id = '$id' ");
107 header('Location: analytics.php');
109 if (isset($_GET['flag_VTRID'])){
110 $VTRID = $_GET['flag_VTRID'];
111 $petition->query("update signatures set signature_status = 'flag_VTRID' where VTRID = '$VTRID' ");
112 header('Location: analytics.php');
114 if (isset($_GET['flag_phone'])){
115 $flag_phone = $_GET['flag_phone'];
116 $petition->query("update signatures set signature_status = 'flag_phone' where contact_phone = '$flag_phone' ");
117 header('Location: analytics.php');
119 include_once('header.php');
120 if (isset($_GET['ip_address'])){
121 $ip = $_GET['ip_address'];
122 $petition_id = $_GET['petition_id'];
123 echo "<h1>Review $ip</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
124 $q = "SELECT * FROM signatures where ip_address = '$ip' and signature_status = 'verified' and petition_id = '$petition_id' order by signature_status desc ";
125 $r = $petition->query($q);
126 while($d = mysqli_fetch_array($r)){
128 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
129 if ($pos !== false) {
132 echo "<tr style='background-color:$color;'>
133 <td><b>$d[date_time_signed]</b></td>
134 <td><a href='?VTRID=$d[VTRID]'>$d[VTRID]</a></td>
135 <td>".id2petition($d['petition_id'])."</td>
136 <td>$d[signed_name_as]</td>
137 <td>$d[signed_name_as_circulator]</td>
138 <td>$d[contact_phone]</td>
139 <td>$d[printed_status]</td>
140 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
141 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
142 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
143 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
144 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
145 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
146 <td><a href='?bot=$d[id]'>bot</a></td>
150 }elseif(isset($_GET['email'])){
151 $email = $_GET['email'];
152 echo "<h1>Review $email</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
153 $q = "SELECT * FROM presign where email_for_follow_up = '$email' order by id desc ";
154 $r = $petition->query($q);
155 while($d = mysqli_fetch_array($r)){
157 $test = date('Y-m-d',strtotime($d['action_on']));
158 $pos = strpos($test, date('Y-m-d'));
159 if ($pos !== false) {
162 echo "<tr style='background-color:$color;'>
163 <td style='white-space:pre;'><b>$d[action_on]</b></td>
164 <td style='white-space:pre;'><a href='?php_session_id=$d[php_session_id]'>$d[php_session_id]</a></td>
165 <td style='white-space:pre;'>$d[php_page]</td>
166 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
167 <td style='white-space:pre;'>$d[invite]</td>
168 <td style='white-space:pre;'>$d[invite_error]</td>
169 <td style='white-space:pre;'>$d[name]</td>
170 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
171 <td style='white-space:pre;'>$d[phone_for_validation]</td>
172 <td style='white-space:pre;'>$d[presign_status]</td>
173 <td style='white-space:pre;'>$d[ip_address]</td>
174 <td style='white-space:pre;'>$d[browser_string]</td>
177 echo "</table><a href='?clear_email=$email'>CLEAR EMAIL</a> - <a href='?sign_email=$email'>SIGNATURE FOUND</a>";
178 }elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){
179 $php_session_id = $_GET['php_session_id'];
180 echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
181 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
182 $r = $petition->query($q);
183 while($d = mysqli_fetch_array($r)){
185 $test = date('Y-m-d',strtotime($d['action_on']));
186 $pos = strpos($test, date('Y-m-d'));
187 if ($pos !== false) {
190 echo "<tr style='background-color:$color;'>
191 <td style='white-space:pre;'><b>$d[action_on]</b></td>
192 <td style='white-space:pre;'>$d[php_page]</td>
193 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
194 <td style='white-space:pre;'>$d[invite]</td>
195 <td style='white-space:pre;'>$d[invite_error]</td>
196 <td style='white-space:pre;'>$d[name]</td>
197 <td style='white-space:pre;'><a href='?email=$d[email_for_follow_up]'>$d[email_for_follow_up]</a></td>
198 <td style='white-space:pre;'>$d[phone_for_validation]</td>
199 <td style='white-space:pre;'>$d[presign_status]</td>
200 <td style='white-space:pre;'>$d[ip_address]</td>
201 <td style='white-space:pre;'>$d[browser_string]</td>
204 echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR SESSION</a> -
205 <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a><br>
206 - <a href='?php_session_id=$php_session_id&follow_up=X'>ADD TO FOLLOW UP LIST Maryland General</a><br>
207 - <a href='?php_session_id=$php_session_id&follow_up=1'>ADD TO FOLLOW UP LIST MGP</a><br>
208 - <a href='?php_session_id=$php_session_id&follow_up=2'>ADD TO FOLLOW UP LIST MLP</a><br>
209 - <a href='?php_session_id=$php_session_id&follow_up=3'>ADD TO FOLLOW UP LIST BTEC</a><br>
210 - <a href='?php_session_id=$php_session_id&follow_up=7'>ADD TO FOLLOW UP LIST PG</a><br>
211 - <a href='?php_session_id=$php_session_id&follow_up=8'>ADD TO FOLLOW UP LIST Ivey</a>
213 }elseif(isset($_GET['php_session_id']) && isset($_GET['follow_up'])){
214 $php_session_id = $_GET['php_session_id'];
215 echo "<h1>Adding Follow up for $php_session_id to $_GET[follow_up]</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
216 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
217 $r = $petition->query($q);
218 while($d = mysqli_fetch_array($r)){
221 $test = date('Y-m-d',strtotime($d['action_on']));
222 $pos = strpos($test, date('Y-m-d'));
223 if ($pos !== false) {
229 if ($d[email_for_follow_up
] != ''){
230 $email = $d[email_for_follow_up
];
232 echo "<tr style='background-color:$color;'>
233 <td style='white-space:pre;'><b>$d[action_on]</b></td>
234 <td style='white-space:pre;'>$d[php_page]</td>
235 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
236 <td style='white-space:pre;'>$d[invite]</td>
237 <td style='white-space:pre;'>$d[invite_error]</td>
238 <td style='white-space:pre;'>$d[name]</td>
239 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
240 <td style='white-space:pre;'>$d[phone_for_validation]</td>
241 <td style='white-space:pre;'>$d[presign_status]</td>
242 <td style='white-space:pre;'>$d[ip_address]</td>
243 <td style='white-space:pre;'>$d[browser_string]</td>
246 $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')."') ");
247 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
248 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
250 }elseif (isset($_GET['VTRID'])){
251 $VTRID = $_GET['VTRID'];
252 $petition_id = $_GET['petition_id'];
253 echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
254 $q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status = 'verified' and petition_id = '$petition_id' order by petition_id, id DESC ";
255 $r = $petition->query($q);
257 while($d = mysqli_fetch_array($r)){
259 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
260 if ($pos !== false) {
263 echo "<tr style='background-color:$color;'>
264 <td><b>$d[date_time_signed]</b></td>
265 <td><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a></td>
266 <td>".id2petition($d['petition_id'])."</td>
267 <td>$d[signed_name_as]</td>
268 <td>$d[signed_name_as_circulator]</td>
269 <td>$d[contact_phone]</td>
270 <td>$d[printed_status]</td>
271 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
272 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
273 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
274 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
275 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
276 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
277 <td><a href='?bot=$d[id]'>bot</a></td>
280 js_redirect("analytics.php?flag_duplicate=$d[id]");
289 <h1
>Signature Analytics
- Server Clock
: <?PHP
echo date('r');?
></h1
>
290 <h2
>NEVER NEVER NEVER CALL
OR TEXT ANYONE
- ONLY EMAIL
!!!</h2
>
291 <h3
>SysOp Says
: Transparency
= Trust
</h3
>
295 <td valign
="top" colspan
='2'><?PHP
/*
297 <div>Watching for duplicates.</div><ol>
299 $q="SELECT ip_address, petition_id,VTRID, COUNT(*) as count FROM signatures where signature_status = 'verified' group by ip_address, petition_id, VTRID";
300 $r = $petition->query($q);
301 while($d = mysqli_fetch_array($r)){
302 if ($d['count'] > 1){
303 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>";
307 </td><td valign="top"> */ ?
>
309 <div
>Watching
for duplicates
.</div
><ol
>
311 $q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
312 $r = $petition->query($q);
314 while($d = mysqli_fetch_array($r)){
315 if ($d['count'] > 1){
316 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>";
318 js_redirect("analytics.php?VTRID=$d[VTRID]&petition_id=$d[petition_id]");
329 <td valign
="top" colspan
='2'>
331 <div
>Follow up requested
- never signed
.</div
>
332 <form method
='GET'><input name
='email'><input type
='submit' value
='SEARCH E-MAIL'></form
><table
>
337 $q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id $order";
338 $r = $petition->query($q);
339 while($d = mysqli_fetch_array($r)){
340 $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
341 $r2 = $petition->query($q2);
342 $d2 = mysqli_fetch_array($r2);
344 if ($d2['name'] != ''){
345 $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
346 $r3 = $petition->query($q3);
347 $d3 = mysqli_fetch_array($r3);
348 if ($d3['date_time_signed'] != ''){
349 $sig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b><br>";
350 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
354 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and php_page like '/sign.php%'";
355 $r4 = $petition->query($q4);
356 $d4 = mysqli_fetch_array($r4);
357 if ($d4['action_on']){
358 $presig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>PRESIG $d4[action_on]</a></b><br>";
359 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
362 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and invite_error <> '' ";
363 $r4 = $petition->query($q4);
364 $d4 = mysqli_fetch_array($r4);
365 if ($d4['invite_error'] != ''){
366 $invite_error = "<b><a href='?clear_email=$d2[email_for_follow_up]'>$d4[invite_error]</a></b><br>";
367 js_redirect("analytics.php?clear_email=$d2[email_for_follow_up]");
369 $php_session_id = $d2['php_session_id'];
370 echo "<tr><td><a href='?php_session_id=$php_session_id'>$d2[action_on]</a></td><td>$presig $sig $invite_error</td>
371 <td>$d2[name]</td><td><a href='?email=$d2[email_for_follow_up]'>$d2[email_for_follow_up]</a></td>
372 <td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td>
373 <td><a href='?php_session_id=$php_session_id&follow_up=X'>General</a>
374 - <a href='?php_session_id=$php_session_id&follow_up=1'>MGP</a>
375 - <a href='?php_session_id=$php_session_id&follow_up=2'>MLP</a>
376 - <a href='?php_session_id=$php_session_id&follow_up=3'>BTEC</a>
377 - <a href='?php_session_id=$php_session_id&follow_up=7'>PG</a>
378 - <a href='?php_session_id=$php_session_id&follow_up=8'>Ivey</a></td></tr>";
379 if( $presig == '' && $invite_error == '' && $sig == '' ){
380 if ($d2['invite'] == 'Ivey'){
381 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=8");
384 if ($d2['invite'] == 'mlp'){
385 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=2");
388 if ($d2['invite'] == 'BTEC'){
389 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=3");
392 if ($d2['invite'] == 'RestorePGTermLimits'){
393 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
396 if (id2petition($d2['petition']) == 'RESTORE TWO TERM (8 YEAR) TERM LIMITS IN PRINCE GEORGE'){
397 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
400 if ($d2['invite'] == 'mgp'){
401 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=1");
404 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=X"); // no invite found no petition found - send general follow/up
411 <td valign
="top" colspan
='2'>
413 <div
>Last
10</div
><ol
>
415 $q="SELECT * FROM signatures where signature_status = 'verified' order by id desc limit 0, 10";
416 $r = $petition->query($q);
417 while($d = mysqli_fetch_array($r)){
418 echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
425 <tr
><td valign
="top">
427 <div
>Watching
for 0</div
><ol
>
429 $q="SELECT * FROM signatures where VTRID = '0' and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
430 $r = $petition->query($q);
431 while($d = mysqli_fetch_array($r)){
432 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>";
435 </td
><td valign
="top">
436 <h2
>Petition ID Bugs
</h2
>
437 <div
>Watching
for 0</div
><ol
>
439 $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'";
440 $r = $petition->query($q);
441 while($d = mysqli_fetch_array($r)){
442 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>";
445 </td
></tr
><tr
><td valign
="top">
447 <h2
>resign_requested
</h2
>
448 <div
>These are most likely from early bugs
</div
><ol
>
450 $q="SELECT * FROM signatures where signature_status = 'resign_requested' order by ip_address";
451 $r = $petition->query($q);
453 while($d = mysqli_fetch_array($r)){
455 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>";
458 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
464 <div
>These are bots on the site
.</div
><ol
>
466 $q="SELECT * FROM signatures where signature_status = 'bot' order by ip_address";
467 $r = $petition->query($q);
469 while($d = mysqli_fetch_array($r)){
471 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>";
474 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
485 // allow headers to be sent...
486 $html = ob_get_clean();
487 echo $html; // run javascript
489 include_once('footer.php');