2 include_once('bots.php');
3 include_once('../slack.php');
4 include_once('security.php');
5 include_once('/var/www/secure.php'); //outside webserver
6 include_once('functions.php');
9 $sign_email = $_COOKIE['sign_email'];
10 if (isset($_GET['sign_email'])){
11 // here we use it, if it shows up next run, we block
12 $sign_email = $_GET['sign_email'];
13 $_COOKIE['sign_email'] = $sign_email;
14 setcookie("sign_email", $sign_email);
15 slack_general('SETTING COOKIE ('.$_COOKIE['sign_email'].') FROM ('.$_GET['sign_email'].')','md-petition-admin');
18 function js_redirect($page){
19 $base = 'https://www.md-petition.com/admin/';
21 $pos = strpos($page, $_COOKIE['sign_email']);
23 // email not found - good to redirect
24 echo "<script>window.location.href = \"$url\";</script>";
25 slack_general('CHECK COOKIE ('.$_COOKIE['sign_email'].') PAGE ('.$page.')','md-petition-admin');
28 echo "<h1>Automated Loop Detected - Skip</h1>";
33 if ($_COOKIE['level'] == 'user'){
34 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
35 header('Location: user_home.php');
37 if (isset($_GET['clear_php_session_id'])){
38 $id = $_GET['clear_php_session_id'];
39 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
40 header('Location: analytics.php');
42 if (isset($_GET['clear_email'])){
43 $email = $_GET['clear_email'];
44 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
45 header('Location: analytics.php');
47 if (isset($_GET['sign_email'])){
48 $email = $_GET['sign_email'];
49 $petition->query("update presign set presign_status = 'SIGNED' where email_for_follow_up = '$email' ");
50 header('Location: analytics.php');
52 if (isset($_GET['sign_php_session_id'])){
53 $id = $_GET['sign_php_session_id'];
54 $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
55 header('Location: analytics.php');
57 if ($_COOKIE['level'] == 'manager'){
58 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
59 header('Location: manager_home.php');
61 if (isset($_GET['flag_invalid_signature'])){
62 $id = $_GET['flag_invalid_signature'];
63 $petition->query("update signatures set signature_status = 'flag_invalid_signature' where id = '$id' ");
64 header('Location: analytics.php');
66 if (isset($_GET['flag_duplicate'])){
67 $id = $_GET['flag_duplicate'];
68 $petition->query("update signatures set signature_status = 'flag_duplicate' where id = '$id' ");
69 header('Location: analytics.php');
71 if (isset($_GET['flag_ip_address'])){
72 $ip = $_GET['flag_ip_address'];
73 $petition->query("update signatures set signature_status = 'flag_ip_address' where ip_address = '$ip' ");
74 header('Location: analytics.php');
76 if (isset($_GET['resign_requested'])){
77 $id = $_GET['resign_requested'];
78 $petition->query("update signatures set signature_status = 'resign_requested' where id = '$id' ");
79 header('Location: analytics.php');
81 if (isset($_GET['bot'])){
83 $petition->query("update signatures set signature_status = 'bot' where id = '$id' ");
84 header('Location: analytics.php');
86 if (isset($_GET['flag_VTRID'])){
87 $VTRID = $_GET['flag_VTRID'];
88 $petition->query("update signatures set signature_status = 'flag_VTRID' where VTRID = '$VTRID' ");
89 header('Location: analytics.php');
91 if (isset($_GET['flag_phone'])){
92 $flag_phone = $_GET['flag_phone'];
93 $petition->query("update signatures set signature_status = 'flag_phone' where contact_phone = '$flag_phone' ");
94 header('Location: analytics.php');
96 include_once('header.php');
97 if (isset($_GET['ip_address'])){
98 $ip = $_GET['ip_address'];
99 $petition_id = $_GET['petition_id'];
100 echo "<h1>Review $ip</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
101 $q = "SELECT * FROM signatures where ip_address = '$ip' and signature_status = 'verified' and petition_id = '$petition_id' order by signature_status desc ";
102 $r = $petition->query($q);
103 while($d = mysqli_fetch_array($r)){
105 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
106 if ($pos !== false) {
109 echo "<tr style='background-color:$color;'>
110 <td><b>$d[date_time_signed]</b></td>
111 <td><a href='?VTRID=$d[VTRID]'>$d[VTRID]</a></td>
112 <td>".id2petition($d['petition_id'])."</td>
113 <td>$d[signed_name_as]</td>
114 <td>$d[signed_name_as_circulator]</td>
115 <td>$d[contact_phone]</td>
116 <td>$d[printed_status]</td>
117 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
118 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
119 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
120 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
121 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
122 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
123 <td><a href='?bot=$d[id]'>bot</a></td>
127 }elseif(isset($_GET['email'])){
128 $email = $_GET['email'];
129 echo "<h1>Review $email</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
130 $q = "SELECT * FROM presign where email_for_follow_up = '$email' order by id desc ";
131 $r = $petition->query($q);
132 while($d = mysqli_fetch_array($r)){
134 $test = date('Y-m-d',strtotime($d['action_on']));
135 $pos = strpos($test, date('Y-m-d'));
136 if ($pos !== false) {
139 echo "<tr style='background-color:$color;'>
140 <td style='white-space:pre;'><b>$d[action_on]</b></td>
141 <td style='white-space:pre;'><a href='?php_session_id=$d[php_session_id]'>$d[php_session_id]</a></td>
142 <td style='white-space:pre;'>$d[php_page]</td>
143 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
144 <td style='white-space:pre;'>$d[invite]</td>
145 <td style='white-space:pre;'>$d[invite_error]</td>
146 <td style='white-space:pre;'>$d[name]</td>
147 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
148 <td style='white-space:pre;'>$d[phone_for_validation]</td>
149 <td style='white-space:pre;'>$d[presign_status]</td>
150 <td style='white-space:pre;'>$d[ip_address]</td>
151 <td style='white-space:pre;'>$d[browser_string]</td>
154 echo "</table><a href='?clear_email=$email'>CLEAR EMAIL</a> - <a href='?sign_email=$email'>SIGNATURE FOUND</a>";
155 }elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){
156 $php_session_id = $_GET['php_session_id'];
157 echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
158 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
159 $r = $petition->query($q);
160 while($d = mysqli_fetch_array($r)){
162 $test = date('Y-m-d',strtotime($d['action_on']));
163 $pos = strpos($test, date('Y-m-d'));
164 if ($pos !== false) {
167 echo "<tr style='background-color:$color;'>
168 <td style='white-space:pre;'><b>$d[action_on]</b></td>
169 <td style='white-space:pre;'>$d[php_page]</td>
170 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
171 <td style='white-space:pre;'>$d[invite]</td>
172 <td style='white-space:pre;'>$d[invite_error]</td>
173 <td style='white-space:pre;'>$d[name]</td>
174 <td style='white-space:pre;'><a href='?email=$d[email_for_follow_up]'>$d[email_for_follow_up]</a></td>
175 <td style='white-space:pre;'>$d[phone_for_validation]</td>
176 <td style='white-space:pre;'>$d[presign_status]</td>
177 <td style='white-space:pre;'>$d[ip_address]</td>
178 <td style='white-space:pre;'>$d[browser_string]</td>
181 echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR SESSION</a> -
182 <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a><br>
183 - <a href='?php_session_id=$php_session_id&follow_up=X'>ADD TO FOLLOW UP LIST Maryland General</a><br>
184 - <a href='?php_session_id=$php_session_id&follow_up=1'>ADD TO FOLLOW UP LIST MGP</a><br>
185 - <a href='?php_session_id=$php_session_id&follow_up=2'>ADD TO FOLLOW UP LIST MLP</a><br>
186 - <a href='?php_session_id=$php_session_id&follow_up=3'>ADD TO FOLLOW UP LIST BTEC</a><br>
187 - <a href='?php_session_id=$php_session_id&follow_up=7'>ADD TO FOLLOW UP LIST PG</a><br>
188 - <a href='?php_session_id=$php_session_id&follow_up=8'>ADD TO FOLLOW UP LIST Ivey</a>
190 }elseif(isset($_GET['php_session_id']) && isset($_GET['follow_up'])){
191 $php_session_id = $_GET['php_session_id'];
192 echo "<h1>Adding Follow up for $php_session_id to $_GET[follow_up]</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
193 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
194 $r = $petition->query($q);
195 while($d = mysqli_fetch_array($r)){
198 $test = date('Y-m-d',strtotime($d['action_on']));
199 $pos = strpos($test, date('Y-m-d'));
200 if ($pos !== false) {
206 if ($d[email_for_follow_up
] != ''){
207 $email = $d[email_for_follow_up
];
209 echo "<tr style='background-color:$color;'>
210 <td style='white-space:pre;'><b>$d[action_on]</b></td>
211 <td style='white-space:pre;'>$d[php_page]</td>
212 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
213 <td style='white-space:pre;'>$d[invite]</td>
214 <td style='white-space:pre;'>$d[invite_error]</td>
215 <td style='white-space:pre;'>$d[name]</td>
216 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
217 <td style='white-space:pre;'>$d[phone_for_validation]</td>
218 <td style='white-space:pre;'>$d[presign_status]</td>
219 <td style='white-space:pre;'>$d[ip_address]</td>
220 <td style='white-space:pre;'>$d[browser_string]</td>
223 $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')."') ");
224 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
225 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
227 }elseif (isset($_GET['VTRID'])){
228 $VTRID = $_GET['VTRID'];
229 $petition_id = $_GET['petition_id'];
230 echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
231 $q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status = 'verified' and petition_id = '$petition_id' order by petition_id, id DESC ";
232 $r = $petition->query($q);
234 while($d = mysqli_fetch_array($r)){
236 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
237 if ($pos !== false) {
240 echo "<tr style='background-color:$color;'>
241 <td><b>$d[date_time_signed]</b></td>
242 <td><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a></td>
243 <td>".id2petition($d['petition_id'])."</td>
244 <td>$d[signed_name_as]</td>
245 <td>$d[signed_name_as_circulator]</td>
246 <td>$d[contact_phone]</td>
247 <td>$d[printed_status]</td>
248 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
249 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
250 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
251 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
252 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
253 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
254 <td><a href='?bot=$d[id]'>bot</a></td>
257 js_redirect("analytics.php?flag_duplicate=$d[id]");
266 <h1
>Signature Analytics
- Server Clock
: <?PHP
echo date('r');?
></h1
>
267 <h2
>NEVER NEVER NEVER CALL
OR TEXT ANYONE
- ONLY EMAIL
!!!</h2
>
268 <h3
>SysOp Says
: Transparency
= Trust
</h3
>
272 <td valign
="top" colspan
='2'><?PHP
/*
274 <div>Watching for duplicates.</div><ol>
276 $q="SELECT ip_address, petition_id,VTRID, COUNT(*) as count FROM signatures where signature_status = 'verified' group by ip_address, petition_id, VTRID";
277 $r = $petition->query($q);
278 while($d = mysqli_fetch_array($r)){
279 if ($d['count'] > 1){
280 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>";
284 </td><td valign="top"> */ ?
>
286 <div
>Watching
for duplicates
.</div
><ol
>
288 $q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
289 $r = $petition->query($q);
291 while($d = mysqli_fetch_array($r)){
292 if ($d['count'] > 1){
293 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>";
295 js_redirect("analytics.php?VTRID=$d[VTRID]&petition_id=$d[petition_id]");
306 <td valign
="top" colspan
='2'>
308 <div
>Follow up requested
- never signed
.</div
>
309 <form method
='GET'><input name
='email'><input type
='submit' value
='SEARCH E-MAIL'></form
><table
>
311 $q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id";
312 $r = $petition->query($q);
313 while($d = mysqli_fetch_array($r)){
314 $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
315 $r2 = $petition->query($q2);
316 $d2 = mysqli_fetch_array($r2);
318 if ($d2['name'] != ''){
319 $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
320 $r3 = $petition->query($q3);
321 $d3 = mysqli_fetch_array($r3);
322 if ($d3['date_time_signed'] != ''){
323 $sig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b><br>";
324 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
328 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and php_page like '/sign.php%'";
329 $r4 = $petition->query($q4);
330 $d4 = mysqli_fetch_array($r4);
331 if ($d4['action_on']){
332 $presig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>PRESIG $d4[action_on]</a></b><br>";
333 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
336 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and invite_error <> '' ";
337 $r4 = $petition->query($q4);
338 $d4 = mysqli_fetch_array($r4);
339 if ($d4['invite_error'] != ''){
340 $invite_error = "<b><a href='?clear_email=$d2[email_for_follow_up]'>$d4[invite_error]</a></b><br>";
341 js_redirect("analytics.php?clear_email=$d2[email_for_follow_up]");
343 $php_session_id = $d2['php_session_id'];
344 echo "<tr><td><a href='?php_session_id=$php_session_id'>$d2[action_on]</a></td><td>$presig $sig $invite_error</td>
345 <td>$d2[name]</td><td><a href='?email=$d2[email_for_follow_up]'>$d2[email_for_follow_up]</a></td>
346 <td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td>
347 <td><a href='?php_session_id=$php_session_id&follow_up=X'>General</a>
348 - <a href='?php_session_id=$php_session_id&follow_up=1'>MGP</a>
349 - <a href='?php_session_id=$php_session_id&follow_up=2'>MLP</a>
350 - <a href='?php_session_id=$php_session_id&follow_up=3'>BTEC</a>
351 - <a href='?php_session_id=$php_session_id&follow_up=7'>PG</a>
352 - <a href='?php_session_id=$php_session_id&follow_up=8'>Ivey</a></td></tr>";
353 if( $presig == '' && $invite_error == '' && $sig == '' ){
354 if ($d2['invite'] == 'Ivey'){
355 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=8");
357 if ($d2['invite'] == 'mlp'){
358 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=2");
360 if ($d2['invite'] == 'BTEC'){
361 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=3");
363 if ($d2['invite'] == 'RestorePGTermLimits'){
364 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
366 if ($d2['invite'] == 'mgp'){
367 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=1");
375 <td valign
="top" colspan
='2'>
377 <div
>Last
10</div
><ol
>
379 $q="SELECT * FROM signatures where signature_status = 'verified' order by id desc limit 0, 10";
380 $r = $petition->query($q);
381 while($d = mysqli_fetch_array($r)){
382 echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
389 <tr
><td valign
="top">
391 <div
>Watching
for 0</div
><ol
>
393 $q="SELECT * FROM signatures where VTRID = '0' and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
394 $r = $petition->query($q);
395 while($d = mysqli_fetch_array($r)){
396 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>";
399 </td
><td valign
="top">
400 <h2
>Petition ID Bugs
</h2
>
401 <div
>Watching
for 0</div
><ol
>
403 $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'";
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
></tr
><tr
><td valign
="top">
411 <h2
>resign_requested
</h2
>
412 <div
>These are most likely from early bugs
</div
><ol
>
414 $q="SELECT * FROM signatures where signature_status = 'resign_requested' order by ip_address";
415 $r = $petition->query($q);
417 while($d = mysqli_fetch_array($r)){
419 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>";
422 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
428 <div
>These are bots on the site
.</div
><ol
>
430 $q="SELECT * FROM signatures where signature_status = 'bot' order by ip_address";
431 $r = $petition->query($q);
433 while($d = mysqli_fetch_array($r)){
435 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>";
438 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
449 include_once('footer.php');