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);
22 function js_redirect($page){ // now header - prep for full auto
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($url,'automation');
30 header('Location: '.$url);
31 //slack_general('CHECK COOKIE ('.$_COOKIE['sign_email'].') PAGE ('.$page.')','md-petition-admin');
34 slack_general('Loop Detected for '.$_COOKIE['sign_email'],'automation');
35 echo "<h1>Automated Loop Detected - Skip</h1>";
40 if ($_COOKIE['level'] == 'user'){
41 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
42 header('Location: user_home.php');
44 if (isset($_GET['clear_php_session_id'])){
45 $id = $_GET['clear_php_session_id'];
46 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
47 header('Location: analytics.php');
49 if (isset($_GET['clear_email'])){
50 $email = $_GET['clear_email'];
51 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
52 header('Location: analytics.php');
54 if (isset($_GET['sign_email'])){
55 $email = $_GET['sign_email'];
56 $petition->query("update presign set presign_status = 'SIGNED' where email_for_follow_up = '$email' ");
57 header('Location: analytics.php');
59 if (isset($_GET['sign_php_session_id'])){
60 $id = $_GET['sign_php_session_id'];
61 $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
62 header('Location: analytics.php');
64 if ($_COOKIE['level'] == 'manager'){
65 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
66 header('Location: manager_home.php');
68 if (isset($_GET['flag_invalid_signature'])){
69 $id = $_GET['flag_invalid_signature'];
70 $petition->query("update signatures set signature_status = 'flag_invalid_signature' where id = '$id' ");
71 header('Location: analytics.php');
73 if (isset($_GET['flag_duplicate'])){
74 $id = $_GET['flag_duplicate'];
75 $petition->query("update signatures set signature_status = 'flag_duplicate' where id = '$id' ");
76 header('Location: analytics.php');
78 if (isset($_GET['flag_ip_address'])){
79 $ip = $_GET['flag_ip_address'];
80 $petition->query("update signatures set signature_status = 'flag_ip_address' where ip_address = '$ip' ");
81 header('Location: analytics.php');
83 if (isset($_GET['resign_requested'])){
84 $id = $_GET['resign_requested'];
85 $petition->query("update signatures set signature_status = 'resign_requested' where id = '$id' ");
86 header('Location: analytics.php');
88 if (isset($_GET['bot'])){
90 $petition->query("update signatures set signature_status = 'bot' where id = '$id' ");
91 header('Location: analytics.php');
93 if (isset($_GET['flag_VTRID'])){
94 $VTRID = $_GET['flag_VTRID'];
95 $petition->query("update signatures set signature_status = 'flag_VTRID' where VTRID = '$VTRID' ");
96 header('Location: analytics.php');
98 if (isset($_GET['flag_phone'])){
99 $flag_phone = $_GET['flag_phone'];
100 $petition->query("update signatures set signature_status = 'flag_phone' where contact_phone = '$flag_phone' ");
101 header('Location: analytics.php');
103 include_once('header.php');
104 if (isset($_GET['ip_address'])){
105 $ip = $_GET['ip_address'];
106 $petition_id = $_GET['petition_id'];
107 echo "<h1>Review $ip</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
108 $q = "SELECT * FROM signatures where ip_address = '$ip' and signature_status = 'verified' and petition_id = '$petition_id' order by signature_status desc ";
109 $r = $petition->query($q);
110 while($d = mysqli_fetch_array($r)){
112 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
113 if ($pos !== false) {
116 echo "<tr style='background-color:$color;'>
117 <td><b>$d[date_time_signed]</b></td>
118 <td><a href='?VTRID=$d[VTRID]'>$d[VTRID]</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[printed_status]</td>
124 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
125 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
126 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
127 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
128 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
129 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
130 <td><a href='?bot=$d[id]'>bot</a></td>
134 }elseif(isset($_GET['email'])){
135 $email = $_GET['email'];
136 echo "<h1>Review $email</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
137 $q = "SELECT * FROM presign where email_for_follow_up = '$email' order by id desc ";
138 $r = $petition->query($q);
139 while($d = mysqli_fetch_array($r)){
141 $test = date('Y-m-d',strtotime($d['action_on']));
142 $pos = strpos($test, date('Y-m-d'));
143 if ($pos !== false) {
146 echo "<tr style='background-color:$color;'>
147 <td style='white-space:pre;'><b>$d[action_on]</b></td>
148 <td style='white-space:pre;'><a href='?php_session_id=$d[php_session_id]'>$d[php_session_id]</a></td>
149 <td style='white-space:pre;'>$d[php_page]</td>
150 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
151 <td style='white-space:pre;'>$d[invite]</td>
152 <td style='white-space:pre;'>$d[invite_error]</td>
153 <td style='white-space:pre;'>$d[name]</td>
154 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
155 <td style='white-space:pre;'>$d[phone_for_validation]</td>
156 <td style='white-space:pre;'>$d[presign_status]</td>
157 <td style='white-space:pre;'>$d[ip_address]</td>
158 <td style='white-space:pre;'>$d[browser_string]</td>
161 echo "</table><a href='?clear_email=$email'>CLEAR EMAIL</a> - <a href='?sign_email=$email'>SIGNATURE FOUND</a>";
162 }elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){
163 $php_session_id = $_GET['php_session_id'];
164 echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
165 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
166 $r = $petition->query($q);
167 while($d = mysqli_fetch_array($r)){
169 $test = date('Y-m-d',strtotime($d['action_on']));
170 $pos = strpos($test, date('Y-m-d'));
171 if ($pos !== false) {
174 echo "<tr style='background-color:$color;'>
175 <td style='white-space:pre;'><b>$d[action_on]</b></td>
176 <td style='white-space:pre;'>$d[php_page]</td>
177 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
178 <td style='white-space:pre;'>$d[invite]</td>
179 <td style='white-space:pre;'>$d[invite_error]</td>
180 <td style='white-space:pre;'>$d[name]</td>
181 <td style='white-space:pre;'><a href='?email=$d[email_for_follow_up]'>$d[email_for_follow_up]</a></td>
182 <td style='white-space:pre;'>$d[phone_for_validation]</td>
183 <td style='white-space:pre;'>$d[presign_status]</td>
184 <td style='white-space:pre;'>$d[ip_address]</td>
185 <td style='white-space:pre;'>$d[browser_string]</td>
188 echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR SESSION</a> -
189 <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a><br>
190 - <a href='?php_session_id=$php_session_id&follow_up=X'>ADD TO FOLLOW UP LIST Maryland General</a><br>
191 - <a href='?php_session_id=$php_session_id&follow_up=1'>ADD TO FOLLOW UP LIST MGP</a><br>
192 - <a href='?php_session_id=$php_session_id&follow_up=2'>ADD TO FOLLOW UP LIST MLP</a><br>
193 - <a href='?php_session_id=$php_session_id&follow_up=3'>ADD TO FOLLOW UP LIST BTEC</a><br>
194 - <a href='?php_session_id=$php_session_id&follow_up=7'>ADD TO FOLLOW UP LIST PG</a><br>
195 - <a href='?php_session_id=$php_session_id&follow_up=8'>ADD TO FOLLOW UP LIST Ivey</a>
197 }elseif(isset($_GET['php_session_id']) && isset($_GET['follow_up'])){
198 $php_session_id = $_GET['php_session_id'];
199 echo "<h1>Adding Follow up for $php_session_id to $_GET[follow_up]</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
200 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
201 $r = $petition->query($q);
202 while($d = mysqli_fetch_array($r)){
205 $test = date('Y-m-d',strtotime($d['action_on']));
206 $pos = strpos($test, date('Y-m-d'));
207 if ($pos !== false) {
213 if ($d[email_for_follow_up
] != ''){
214 $email = $d[email_for_follow_up
];
216 echo "<tr style='background-color:$color;'>
217 <td style='white-space:pre;'><b>$d[action_on]</b></td>
218 <td style='white-space:pre;'>$d[php_page]</td>
219 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
220 <td style='white-space:pre;'>$d[invite]</td>
221 <td style='white-space:pre;'>$d[invite_error]</td>
222 <td style='white-space:pre;'>$d[name]</td>
223 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
224 <td style='white-space:pre;'>$d[phone_for_validation]</td>
225 <td style='white-space:pre;'>$d[presign_status]</td>
226 <td style='white-space:pre;'>$d[ip_address]</td>
227 <td style='white-space:pre;'>$d[browser_string]</td>
230 $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')."') ");
231 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
232 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
234 }elseif (isset($_GET['VTRID'])){
235 $VTRID = $_GET['VTRID'];
236 $petition_id = $_GET['petition_id'];
237 echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
238 $q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status = 'verified' and petition_id = '$petition_id' order by petition_id, id DESC ";
239 $r = $petition->query($q);
241 while($d = mysqli_fetch_array($r)){
243 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
244 if ($pos !== false) {
247 echo "<tr style='background-color:$color;'>
248 <td><b>$d[date_time_signed]</b></td>
249 <td><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a></td>
250 <td>".id2petition($d['petition_id'])."</td>
251 <td>$d[signed_name_as]</td>
252 <td>$d[signed_name_as_circulator]</td>
253 <td>$d[contact_phone]</td>
254 <td>$d[printed_status]</td>
255 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
256 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
257 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
258 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
259 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
260 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
261 <td><a href='?bot=$d[id]'>bot</a></td>
264 js_redirect("analytics.php?flag_duplicate=$d[id]");
273 <h1
>Signature Analytics
- Server Clock
: <?PHP
echo date('r');?
></h1
>
274 <h2
>NEVER NEVER NEVER CALL
OR TEXT ANYONE
- ONLY EMAIL
!!!</h2
>
275 <h3
>SysOp Says
: Transparency
= Trust
</h3
>
279 <td valign
="top" colspan
='2'><?PHP
/*
281 <div>Watching for duplicates.</div><ol>
283 $q="SELECT ip_address, petition_id,VTRID, COUNT(*) as count FROM signatures where signature_status = 'verified' group by ip_address, petition_id, VTRID";
284 $r = $petition->query($q);
285 while($d = mysqli_fetch_array($r)){
286 if ($d['count'] > 1){
287 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>";
291 </td><td valign="top"> */ ?
>
293 <div
>Watching
for duplicates
.</div
><ol
>
295 $q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
296 $r = $petition->query($q);
298 while($d = mysqli_fetch_array($r)){
299 if ($d['count'] > 1){
300 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>";
302 js_redirect("analytics.php?VTRID=$d[VTRID]&petition_id=$d[petition_id]");
313 <td valign
="top" colspan
='2'>
315 <div
>Follow up requested
- never signed
.</div
>
316 <form method
='GET'><input name
='email'><input type
='submit' value
='SEARCH E-MAIL'></form
><table
>
318 $q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id";
319 $r = $petition->query($q);
320 while($d = mysqli_fetch_array($r)){
321 $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
322 $r2 = $petition->query($q2);
323 $d2 = mysqli_fetch_array($r2);
325 if ($d2['name'] != ''){
326 $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
327 $r3 = $petition->query($q3);
328 $d3 = mysqli_fetch_array($r3);
329 if ($d3['date_time_signed'] != ''){
330 $sig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b><br>";
331 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
335 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and php_page like '/sign.php%'";
336 $r4 = $petition->query($q4);
337 $d4 = mysqli_fetch_array($r4);
338 if ($d4['action_on']){
339 $presig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>PRESIG $d4[action_on]</a></b><br>";
340 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
343 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and invite_error <> '' ";
344 $r4 = $petition->query($q4);
345 $d4 = mysqli_fetch_array($r4);
346 if ($d4['invite_error'] != ''){
347 $invite_error = "<b><a href='?clear_email=$d2[email_for_follow_up]'>$d4[invite_error]</a></b><br>";
348 js_redirect("analytics.php?clear_email=$d2[email_for_follow_up]");
350 $php_session_id = $d2['php_session_id'];
351 echo "<tr><td><a href='?php_session_id=$php_session_id'>$d2[action_on]</a></td><td>$presig $sig $invite_error</td>
352 <td>$d2[name]</td><td><a href='?email=$d2[email_for_follow_up]'>$d2[email_for_follow_up]</a></td>
353 <td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td>
354 <td><a href='?php_session_id=$php_session_id&follow_up=X'>General</a>
355 - <a href='?php_session_id=$php_session_id&follow_up=1'>MGP</a>
356 - <a href='?php_session_id=$php_session_id&follow_up=2'>MLP</a>
357 - <a href='?php_session_id=$php_session_id&follow_up=3'>BTEC</a>
358 - <a href='?php_session_id=$php_session_id&follow_up=7'>PG</a>
359 - <a href='?php_session_id=$php_session_id&follow_up=8'>Ivey</a></td></tr>";
360 if( $presig == '' && $invite_error == '' && $sig == '' ){
361 if ($d2['invite'] == 'Ivey'){
362 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=8");
364 if ($d2['invite'] == 'mlp'){
365 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=2");
367 if ($d2['invite'] == 'BTEC'){
368 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=3");
370 if ($d2['invite'] == 'RestorePGTermLimits'){
371 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
373 if (id2petition($d2['petition']) == 'RESTORE TWO TERM (8 YEAR) TERM LIMITS IN PRINCE GEORGE'){
374 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
376 if ($d2['invite'] == 'mgp'){
377 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=1");
385 <td valign
="top" colspan
='2'>
387 <div
>Last
10</div
><ol
>
389 $q="SELECT * FROM signatures where signature_status = 'verified' order by id desc limit 0, 10";
390 $r = $petition->query($q);
391 while($d = mysqli_fetch_array($r)){
392 echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
399 <tr
><td valign
="top">
401 <div
>Watching
for 0</div
><ol
>
403 $q="SELECT * FROM signatures where VTRID = '0' and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
404 $r = $petition->query($q);
405 while($d = mysqli_fetch_array($r)){
406 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>";
409 </td
><td valign
="top">
410 <h2
>Petition ID Bugs
</h2
>
411 <div
>Watching
for 0</div
><ol
>
413 $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'";
414 $r = $petition->query($q);
415 while($d = mysqli_fetch_array($r)){
416 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>";
419 </td
></tr
><tr
><td valign
="top">
421 <h2
>resign_requested
</h2
>
422 <div
>These are most likely from early bugs
</div
><ol
>
424 $q="SELECT * FROM signatures where signature_status = 'resign_requested' order by ip_address";
425 $r = $petition->query($q);
427 while($d = mysqli_fetch_array($r)){
429 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>";
432 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
438 <div
>These are bots on the site
.</div
><ol
>
440 $q="SELECT * FROM signatures where signature_status = 'bot' order by ip_address";
441 $r = $petition->query($q);
443 while($d = mysqli_fetch_array($r)){
445 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>";
448 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
459 // allow headers to be sent...
460 $html = ob_get_clean();
461 echo $html; // run javascript
463 include_once('footer.php');