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');
8 function js_redirect($page){
9 $base = 'https://www.md-petition.com/admin/';
11 echo "<script>window.location.href = \"$url\";</script>";
15 if ($_COOKIE['level'] == 'user'){
16 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
17 header('Location: user_home.php');
19 if (isset($_GET['clear_php_session_id'])){
20 $id = $_GET['clear_php_session_id'];
21 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
22 header('Location: analytics.php');
24 if (isset($_GET['clear_email'])){
25 $email = $_GET['clear_email'];
26 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
27 header('Location: analytics.php');
29 if (isset($_GET['sign_email'])){
30 $email = $_GET['sign_email'];
31 $petition->query("update presign set presign_status = 'SIGNED' where email_for_follow_up = '$email' ");
32 header('Location: analytics.php');
34 if (isset($_GET['sign_php_session_id'])){
35 $id = $_GET['sign_php_session_id'];
36 $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
37 header('Location: analytics.php');
39 if ($_COOKIE['level'] == 'manager'){
40 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
41 header('Location: manager_home.php');
43 if (isset($_GET['flag_invalid_signature'])){
44 $id = $_GET['flag_invalid_signature'];
45 $petition->query("update signatures set signature_status = 'flag_invalid_signature' where id = '$id' ");
46 header('Location: analytics.php');
48 if (isset($_GET['flag_duplicate'])){
49 $id = $_GET['flag_duplicate'];
50 $petition->query("update signatures set signature_status = 'flag_duplicate' where id = '$id' ");
51 header('Location: analytics.php');
53 if (isset($_GET['flag_ip_address'])){
54 $ip = $_GET['flag_ip_address'];
55 $petition->query("update signatures set signature_status = 'flag_ip_address' where ip_address = '$ip' ");
56 header('Location: analytics.php');
58 if (isset($_GET['resign_requested'])){
59 $id = $_GET['resign_requested'];
60 $petition->query("update signatures set signature_status = 'resign_requested' where id = '$id' ");
61 header('Location: analytics.php');
63 if (isset($_GET['bot'])){
65 $petition->query("update signatures set signature_status = 'bot' where id = '$id' ");
66 header('Location: analytics.php');
68 if (isset($_GET['flag_VTRID'])){
69 $VTRID = $_GET['flag_VTRID'];
70 $petition->query("update signatures set signature_status = 'flag_VTRID' where VTRID = '$VTRID' ");
71 header('Location: analytics.php');
73 if (isset($_GET['flag_phone'])){
74 $flag_phone = $_GET['flag_phone'];
75 $petition->query("update signatures set signature_status = 'flag_phone' where contact_phone = '$flag_phone' ");
76 header('Location: analytics.php');
78 include_once('header.php');
79 if (isset($_GET['ip_address'])){
80 $ip = $_GET['ip_address'];
81 $petition_id = $_GET['petition_id'];
82 echo "<h1>Review $ip</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
83 $q = "SELECT * FROM signatures where ip_address = '$ip' and signature_status = 'verified' and petition_id = '$petition_id' order by signature_status desc ";
84 $r = $petition->query($q);
85 while($d = mysqli_fetch_array($r)){
87 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
91 echo "<tr style='background-color:$color;'>
92 <td><b>$d[date_time_signed]</b></td>
93 <td><a href='?VTRID=$d[VTRID]'>$d[VTRID]</a></td>
94 <td>".id2petition($d['petition_id'])."</td>
95 <td>$d[signed_name_as]</td>
96 <td>$d[signed_name_as_circulator]</td>
97 <td>$d[contact_phone]</td>
98 <td>$d[printed_status]</td>
99 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
100 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
101 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
102 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
103 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
104 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
105 <td><a href='?bot=$d[id]'>bot</a></td>
109 }elseif(isset($_GET['email'])){
110 $email = $_GET['email'];
111 echo "<h1>Review $email</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
112 $q = "SELECT * FROM presign where email_for_follow_up = '$email' order by id desc ";
113 $r = $petition->query($q);
114 while($d = mysqli_fetch_array($r)){
116 $test = date('Y-m-d',strtotime($d['action_on']));
117 $pos = strpos($test, date('Y-m-d'));
118 if ($pos !== false) {
121 echo "<tr style='background-color:$color;'>
122 <td style='white-space:pre;'><b>$d[action_on]</b></td>
123 <td style='white-space:pre;'><a href='?php_session_id=$d[php_session_id]'>$d[php_session_id]</a></td>
124 <td style='white-space:pre;'>$d[php_page]</td>
125 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
126 <td style='white-space:pre;'>$d[invite]</td>
127 <td style='white-space:pre;'>$d[invite_error]</td>
128 <td style='white-space:pre;'>$d[name]</td>
129 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
130 <td style='white-space:pre;'>$d[phone_for_validation]</td>
131 <td style='white-space:pre;'>$d[presign_status]</td>
132 <td style='white-space:pre;'>$d[ip_address]</td>
133 <td style='white-space:pre;'>$d[browser_string]</td>
136 echo "</table><a href='?clear_email=$email'>CLEAR EMAIL</a> - <a href='?sign_email=$email'>SIGNATURE FOUND</a>";
137 }elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){
138 $php_session_id = $_GET['php_session_id'];
139 echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
140 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
141 $r = $petition->query($q);
142 while($d = mysqli_fetch_array($r)){
144 $test = date('Y-m-d',strtotime($d['action_on']));
145 $pos = strpos($test, date('Y-m-d'));
146 if ($pos !== false) {
149 echo "<tr style='background-color:$color;'>
150 <td style='white-space:pre;'><b>$d[action_on]</b></td>
151 <td style='white-space:pre;'>$d[php_page]</td>
152 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
153 <td style='white-space:pre;'>$d[invite]</td>
154 <td style='white-space:pre;'>$d[invite_error]</td>
155 <td style='white-space:pre;'>$d[name]</td>
156 <td style='white-space:pre;'><a href='?email=$d[email_for_follow_up]'>$d[email_for_follow_up]</a></td>
157 <td style='white-space:pre;'>$d[phone_for_validation]</td>
158 <td style='white-space:pre;'>$d[presign_status]</td>
159 <td style='white-space:pre;'>$d[ip_address]</td>
160 <td style='white-space:pre;'>$d[browser_string]</td>
163 echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR SESSION</a> -
164 <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a><br>
165 - <a href='?php_session_id=$php_session_id&follow_up=X'>ADD TO FOLLOW UP LIST Maryland General</a><br>
166 - <a href='?php_session_id=$php_session_id&follow_up=1'>ADD TO FOLLOW UP LIST MGP</a><br>
167 - <a href='?php_session_id=$php_session_id&follow_up=2'>ADD TO FOLLOW UP LIST MLP</a><br>
168 - <a href='?php_session_id=$php_session_id&follow_up=3'>ADD TO FOLLOW UP LIST BTEC</a><br>
169 - <a href='?php_session_id=$php_session_id&follow_up=7'>ADD TO FOLLOW UP LIST PG</a><br>
170 - <a href='?php_session_id=$php_session_id&follow_up=8'>ADD TO FOLLOW UP LIST Ivey</a>
172 }elseif(isset($_GET['php_session_id']) && isset($_GET['follow_up'])){
173 $php_session_id = $_GET['php_session_id'];
174 echo "<h1>Adding Follow up for $php_session_id to $_GET[follow_up]</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
175 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
176 $r = $petition->query($q);
177 while($d = mysqli_fetch_array($r)){
180 $test = date('Y-m-d',strtotime($d['action_on']));
181 $pos = strpos($test, date('Y-m-d'));
182 if ($pos !== false) {
188 if ($d[email_for_follow_up
] != ''){
189 $email = $d[email_for_follow_up
];
191 echo "<tr style='background-color:$color;'>
192 <td style='white-space:pre;'><b>$d[action_on]</b></td>
193 <td style='white-space:pre;'>$d[php_page]</td>
194 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
195 <td style='white-space:pre;'>$d[invite]</td>
196 <td style='white-space:pre;'>$d[invite_error]</td>
197 <td style='white-space:pre;'>$d[name]</td>
198 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
199 <td style='white-space:pre;'>$d[phone_for_validation]</td>
200 <td style='white-space:pre;'>$d[presign_status]</td>
201 <td style='white-space:pre;'>$d[ip_address]</td>
202 <td style='white-space:pre;'>$d[browser_string]</td>
205 $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')."') ");
206 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
207 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
209 }elseif (isset($_GET['VTRID'])){
210 $VTRID = $_GET['VTRID'];
211 $petition_id = $_GET['petition_id'];
212 echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
213 $q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status = 'verified' and petition_id = '$petition_id' order by petition_id, id DESC ";
214 $r = $petition->query($q);
216 while($d = mysqli_fetch_array($r)){
218 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
219 if ($pos !== false) {
222 echo "<tr style='background-color:$color;'>
223 <td><b>$d[date_time_signed]</b></td>
224 <td><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a></td>
225 <td>".id2petition($d['petition_id'])."</td>
226 <td>$d[signed_name_as]</td>
227 <td>$d[signed_name_as_circulator]</td>
228 <td>$d[contact_phone]</td>
229 <td>$d[printed_status]</td>
230 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
231 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
232 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
233 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
234 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
235 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
236 <td><a href='?bot=$d[id]'>bot</a></td>
239 js_redirect("analytics.php?flag_duplicate=$d[id]");
248 <h1
>Signature Analytics
- Server Clock
: <?PHP
echo date('r');?
></h1
>
249 <h2
>NEVER NEVER NEVER CALL
OR TEXT ANYONE
- ONLY EMAIL
!!!</h2
>
250 <h3
>SysOp Says
: Transparency
= Trust
</h3
>
254 <td valign
="top" colspan
='2'><?PHP
/*
256 <div>Watching for duplicates.</div><ol>
258 $q="SELECT ip_address, petition_id,VTRID, COUNT(*) as count FROM signatures where signature_status = 'verified' group by ip_address, petition_id, VTRID";
259 $r = $petition->query($q);
260 while($d = mysqli_fetch_array($r)){
261 if ($d['count'] > 1){
262 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>";
266 </td><td valign="top"> */ ?
>
268 <div
>Watching
for duplicates
.</div
><ol
>
270 $q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
271 $r = $petition->query($q);
273 while($d = mysqli_fetch_array($r)){
274 if ($d['count'] > 1){
275 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>";
277 js_redirect("analytics.php?VTRID=$d[VTRID]&petition_id=$d[petition_id]");
288 <td valign
="top" colspan
='2'>
290 <div
>Follow up requested
- never signed
.</div
>
291 <form method
='GET'><input name
='email'><input type
='submit' value
='SEARCH E-MAIL'></form
><table
>
293 $q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id";
294 $r = $petition->query($q);
295 while($d = mysqli_fetch_array($r)){
296 $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
297 $r2 = $petition->query($q2);
298 $d2 = mysqli_fetch_array($r2);
300 if ($d2['name'] != ''){
301 $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
302 $r3 = $petition->query($q3);
303 $d3 = mysqli_fetch_array($r3);
304 if ($d3['date_time_signed'] != ''){
305 $sig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b><br>";
306 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
310 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and php_page like '/sign.php%'";
311 $r4 = $petition->query($q4);
312 $d4 = mysqli_fetch_array($r4);
313 if ($d4['action_on']){
314 $presig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>PRESIG $d4[action_on]</a></b><br>";
315 js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
318 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and invite_error <> '' ";
319 $r4 = $petition->query($q4);
320 $d4 = mysqli_fetch_array($r4);
321 if ($d4['invite_error'] != ''){
322 $invite_error = "<b><a href='?clear_email=$d2[email_for_follow_up]'>$d4[invite_error]</a></b><br>";
323 js_redirect("analytics.php?clear_email=$d2[email_for_follow_up]");
325 $php_session_id = $d2['php_session_id'];
326 echo "<tr><td><a href='?php_session_id=$php_session_id'>$d2[action_on]</a></td><td>$presig $sig $invite_error</td>
327 <td>$d2[name]</td><td><a href='?email=$d2[email_for_follow_up]'>$d2[email_for_follow_up]</a></td>
328 <td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td>
329 <td><a href='?php_session_id=$php_session_id&follow_up=X'>General</a>
330 - <a href='?php_session_id=$php_session_id&follow_up=1'>MGP</a>
331 - <a href='?php_session_id=$php_session_id&follow_up=2'>MLP</a>
332 - <a href='?php_session_id=$php_session_id&follow_up=3'>BTEC</a>
333 - <a href='?php_session_id=$php_session_id&follow_up=7'>PG</a>
334 - <a href='?php_session_id=$php_session_id&follow_up=8'>Ivey</a></td></tr>";
335 if( $presig == '' && $invite_error == '' && $sig == '' ){
336 if ($d2['invite'] == 'Ivey'){
337 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=8");
339 if ($d2['invite'] == 'mlp'){
340 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=2");
342 if ($d2['invite'] == 'BTEC'){
343 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=3");
345 if ($d2['invite'] == 'RestorePGTermLimits'){
346 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
348 if ($d2['invite'] == 'mgp'){
349 js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=1");
357 <td valign
="top" colspan
='2'>
359 <div
>Last
10</div
><ol
>
361 $q="SELECT * FROM signatures where signature_status = 'verified' order by id desc limit 0, 10";
362 $r = $petition->query($q);
363 while($d = mysqli_fetch_array($r)){
364 echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
371 <tr
><td valign
="top">
373 <div
>Watching
for 0</div
><ol
>
375 $q="SELECT * FROM signatures where VTRID = '0' and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
376 $r = $petition->query($q);
377 while($d = mysqli_fetch_array($r)){
378 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>";
381 </td
><td valign
="top">
382 <h2
>Petition ID Bugs
</h2
>
383 <div
>Watching
for 0</div
><ol
>
385 $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'";
386 $r = $petition->query($q);
387 while($d = mysqli_fetch_array($r)){
388 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>";
391 </td
></tr
><tr
><td valign
="top">
393 <h2
>resign_requested
</h2
>
394 <div
>These are most likely from early bugs
</div
><ol
>
396 $q="SELECT * FROM signatures where signature_status = 'resign_requested' order by ip_address";
397 $r = $petition->query($q);
399 while($d = mysqli_fetch_array($r)){
401 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>";
404 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
410 <div
>These are bots on the site
.</div
><ol
>
412 $q="SELECT * FROM signatures where signature_status = 'bot' order by ip_address";
413 $r = $petition->query($q);
415 while($d = mysqli_fetch_array($r)){
417 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>";
420 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
431 include_once('footer.php');