2 include_once('../slack.php');
3 include_once('security.php');
4 include_once('/var/www/secure.php'); //outside webserver
5 include_once('functions.php');
7 function js_redirect($page){
8 $base = 'https://www.md-petition.com/admin/';
10 echo "<script>window.location.href = \"$url\";</script>";
14 if ($_COOKIE['level'] == 'user'){
15 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
16 header('Location: user_home.php');
18 if (isset($_GET['clear_php_session_id'])){
19 $id = $_GET['clear_php_session_id'];
20 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
21 header('Location: analytics.php');
23 if (isset($_GET['clear_email'])){
24 $email = $_GET['clear_email'];
25 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
26 header('Location: analytics.php');
28 if (isset($_GET['sign_email'])){
29 $email = $_GET['sign_email'];
30 $petition->query("update presign set presign_status = 'SIGNED' where email_for_follow_up = '$email' ");
31 header('Location: analytics.php');
33 if (isset($_GET['sign_php_session_id'])){
34 $id = $_GET['sign_php_session_id'];
35 $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
36 header('Location: analytics.php');
38 if ($_COOKIE['level'] == 'manager'){
39 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
40 header('Location: manager_home.php');
42 if (isset($_GET['flag_invalid_signature'])){
43 $id = $_GET['flag_invalid_signature'];
44 $petition->query("update signatures set signature_status = 'flag_invalid_signature' where id = '$id' ");
45 header('Location: analytics.php');
47 if (isset($_GET['flag_duplicate'])){
48 $id = $_GET['flag_duplicate'];
49 $petition->query("update signatures set signature_status = 'flag_duplicate' where id = '$id' ");
50 header('Location: analytics.php');
52 if (isset($_GET['flag_ip_address'])){
53 $ip = $_GET['flag_ip_address'];
54 $petition->query("update signatures set signature_status = 'flag_ip_address' where ip_address = '$ip' ");
55 header('Location: analytics.php');
57 if (isset($_GET['resign_requested'])){
58 $id = $_GET['resign_requested'];
59 $petition->query("update signatures set signature_status = 'resign_requested' where id = '$id' ");
60 header('Location: analytics.php');
62 if (isset($_GET['bot'])){
64 $petition->query("update signatures set signature_status = 'bot' where id = '$id' ");
65 header('Location: analytics.php');
67 if (isset($_GET['flag_VTRID'])){
68 $VTRID = $_GET['flag_VTRID'];
69 $petition->query("update signatures set signature_status = 'flag_VTRID' where VTRID = '$VTRID' ");
70 header('Location: analytics.php');
72 if (isset($_GET['flag_phone'])){
73 $flag_phone = $_GET['flag_phone'];
74 $petition->query("update signatures set signature_status = 'flag_phone' where contact_phone = '$flag_phone' ");
75 header('Location: analytics.php');
77 include_once('header.php');
78 if (isset($_GET['ip_address'])){
79 $ip = $_GET['ip_address'];
80 $petition_id = $_GET['petition_id'];
81 echo "<h1>Review $ip</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
82 $q = "SELECT * FROM signatures where ip_address = '$ip' and signature_status = 'verified' and petition_id = '$petition_id' order by signature_status desc ";
83 $r = $petition->query($q);
84 while($d = mysqli_fetch_array($r)){
86 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
90 echo "<tr style='background-color:$color;'>
91 <td><b>$d[date_time_signed]</b></td>
92 <td><a href='?VTRID=$d[VTRID]'>$d[VTRID]</a></td>
93 <td>".id2petition($d['petition_id'])."</td>
94 <td>$d[signed_name_as]</td>
95 <td>$d[signed_name_as_circulator]</td>
96 <td>$d[contact_phone]</td>
97 <td>$d[printed_status]</td>
98 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
99 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
100 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
101 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
102 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
103 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
104 <td><a href='?bot=$d[id]'>bot</a></td>
108 }elseif(isset($_GET['email'])){
109 $email = $_GET['email'];
110 echo "<h1>Review $email</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
111 $q = "SELECT * FROM presign where email_for_follow_up = '$email' order by id desc ";
112 $r = $petition->query($q);
113 while($d = mysqli_fetch_array($r)){
115 $test = date('Y-m-d',strtotime($d['action_on']));
116 $pos = strpos($test, date('Y-m-d'));
117 if ($pos !== false) {
120 echo "<tr style='background-color:$color;'>
121 <td style='white-space:pre;'><b>$d[action_on]</b></td>
122 <td style='white-space:pre;'><a href='?php_session_id=$d[php_session_id]'>$d[php_session_id]</a></td>
123 <td style='white-space:pre;'>$d[php_page]</td>
124 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
125 <td style='white-space:pre;'>$d[invite]</td>
126 <td style='white-space:pre;'>$d[invite_error]</td>
127 <td style='white-space:pre;'>$d[name]</td>
128 <td style='white-space:pre;'>$d[email_for_follow_up]</td>
129 <td style='white-space:pre;'>$d[phone_for_validation]</td>
130 <td style='white-space:pre;'>$d[presign_status]</td>
131 <td style='white-space:pre;'>$d[ip_address]</td>
132 <td style='white-space:pre;'>$d[browser_string]</td>
135 echo "</table><a href='?clear_email=$email'>CLEAR EMAIL</a> - <a href='?sign_email=$email'>SIGNATURE FOUND</a>";
136 }elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){
137 $php_session_id = $_GET['php_session_id'];
138 echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
139 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
140 $r = $petition->query($q);
141 while($d = mysqli_fetch_array($r)){
143 $test = date('Y-m-d',strtotime($d['action_on']));
144 $pos = strpos($test, date('Y-m-d'));
145 if ($pos !== false) {
148 echo "<tr style='background-color:$color;'>
149 <td style='white-space:pre;'><b>$d[action_on]</b></td>
150 <td style='white-space:pre;'>$d[php_page]</td>
151 <td style='white-space:pre;'>".id2petition($d['petition'])."</td>
152 <td style='white-space:pre;'>$d[invite]</td>
153 <td style='white-space:pre;'>$d[invite_error]</td>
154 <td style='white-space:pre;'>$d[name]</td>
155 <td style='white-space:pre;'><a href='?email=$d[email_for_follow_up]'>$d[email_for_follow_up]</a></td>
156 <td style='white-space:pre;'>$d[phone_for_validation]</td>
157 <td style='white-space:pre;'>$d[presign_status]</td>
158 <td style='white-space:pre;'>$d[ip_address]</td>
159 <td style='white-space:pre;'>$d[browser_string]</td>
162 echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR SESSION</a> -
163 <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a><br>
164 - <a href='?php_session_id=$php_session_id&follow_up=X'>ADD TO FOLLOW UP LIST Maryland General</a><br>
165 - <a href='?php_session_id=$php_session_id&follow_up=1'>ADD TO FOLLOW UP LIST MGP</a><br>
166 - <a href='?php_session_id=$php_session_id&follow_up=2'>ADD TO FOLLOW UP LIST MLP</a><br>
167 - <a href='?php_session_id=$php_session_id&follow_up=3'>ADD TO FOLLOW UP LIST BTEC</a><br>
168 - <a href='?php_session_id=$php_session_id&follow_up=7'>ADD TO FOLLOW UP LIST PG</a><br>
169 - <a href='?php_session_id=$php_session_id&follow_up=8'>ADD TO FOLLOW UP LIST Ivey</a>
171 }elseif(isset($_GET['php_session_id']) && isset($_GET['follow_up'])){
172 $php_session_id = $_GET['php_session_id'];
173 echo "<h1>Adding Follow up for $php_session_id to $_GET[follow_up]</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
174 $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
175 $r = $petition->query($q);
176 while($d = mysqli_fetch_array($r)){
179 $test = date('Y-m-d',strtotime($d['action_on']));
180 $pos = strpos($test, date('Y-m-d'));
181 if ($pos !== false) {
187 if ($d[email_for_follow_up
] != ''){
188 $email = $d[email_for_follow_up
];
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;'>$d[email_for_follow_up]</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 $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')."') ");
205 $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
206 $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
208 }elseif (isset($_GET['VTRID'])){
209 $VTRID = $_GET['VTRID'];
210 $petition_id = $_GET['petition_id'];
211 echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
212 $q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status = 'verified' and petition_id = '$petition_id' order by petition_id, id DESC ";
213 $r = $petition->query($q);
215 while($d = mysqli_fetch_array($r)){
217 $pos = strpos($d['date_time_signed'], date('Y-m-d'));
218 if ($pos !== false) {
221 echo "<tr style='background-color:$color;'>
222 <td><b>$d[date_time_signed]</b></td>
223 <td><a href='?ip_address=$d[ip_address]'>$d[ip_address]</a></td>
224 <td>".id2petition($d['petition_id'])."</td>
225 <td>$d[signed_name_as]</td>
226 <td>$d[signed_name_as_circulator]</td>
227 <td>$d[contact_phone]</td>
228 <td>$d[printed_status]</td>
229 <td><a href='?flag_invalid_signature=$d[id]'>flag invalid signature</a></td>
230 <td><a href='?flag_VTRID=$d[VTRID]'>flag VTRID</a></td>
231 <td><a href='?flag_ip_address=$d[ip_address]'>flag ip address</a></td>
232 <td><a href='?flag_duplicate=$d[id]'>flag duplicate</a></td>
233 <td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
234 <td><a href='?resign_requested=$d[id]'>resign requested</a></td>
235 <td><a href='?bot=$d[id]'>bot</a></td>
238 js_redirect("analytics.php?flag_duplicate=$d[id]");
247 <h1
>Signature Analytics
- Server Clock
: <?PHP
echo date('r');?
></h1
>
248 <h2
>NEVER NEVER NEVER CALL
OR TEXT ANYONE
- ONLY EMAIL
!!!</h2
>
249 <h3
>SysOp Says
: Transparency
= Trust
</h3
>
253 <td valign
="top" colspan
='2'><?PHP
/*
255 <div>Watching for duplicates.</div><ol>
257 $q="SELECT ip_address, petition_id,VTRID, COUNT(*) as count FROM signatures where signature_status = 'verified' group by ip_address, petition_id, VTRID";
258 $r = $petition->query($q);
259 while($d = mysqli_fetch_array($r)){
260 if ($d['count'] > 1){
261 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>";
265 </td><td valign="top"> */ ?
>
267 <div
>Watching
for duplicates
.</div
><ol
>
269 $q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
270 $r = $petition->query($q);
272 while($d = mysqli_fetch_array($r)){
273 if ($d['count'] > 1){
274 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>";
276 js_redirect("analytics.php?VTRID=$d[VTRID]&petition_id=$d[petition_id]");
287 <td valign
="top" colspan
='2'>
289 <div
>Follow up requested
- never signed
.</div
>
290 <form method
='GET'><input name
='email'><input type
='submit' value
='SEARCH E-MAIL'></form
><table
>
292 $q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id";
293 $r = $petition->query($q);
294 while($d = mysqli_fetch_array($r)){
295 $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
296 $r2 = $petition->query($q2);
297 $d2 = mysqli_fetch_array($r2);
299 if ($d2['name'] != ''){
300 $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
301 $r3 = $petition->query($q3);
302 $d3 = mysqli_fetch_array($r3);
303 if ($d3['date_time_signed'] != ''){
304 $sig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b><br>";
308 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and php_page like '/sign.php%'";
309 $r4 = $petition->query($q4);
310 $d4 = mysqli_fetch_array($r4);
311 if ($d4['action_on']){
312 $presig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>PRESIG $d4[action_on]</a></b><br>";
315 $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and invite_error <> '' ";
316 $r4 = $petition->query($q4);
317 $d4 = mysqli_fetch_array($r4);
318 if ($d4['invite_error'] != ''){
319 $invite_error = "<b><a href='?clear_email=$d2[email_for_follow_up]'>$d4[invite_error]</a></b><br>";
321 $php_session_id = $d2['php_session_id'];
322 echo "<tr><td><a href='?php_session_id=$php_session_id'>$d2[action_on]</a></td><td>$presig $sig $invite_error</td><td>$d2[name]</td><td><a href='?email=$d2[email_for_follow_up]'>$d2[email_for_follow_up]</a></td><td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td>
323 <td><a href='?php_session_id=$php_session_id&follow_up=X'>General</a>
324 - <a href='?php_session_id=$php_session_id&follow_up=1'>MGP</a>
325 - <a href='?php_session_id=$php_session_id&follow_up=2'>MLP</a>
326 - <a href='?php_session_id=$php_session_id&follow_up=3'>BTEC</a>
327 - <a href='?php_session_id=$php_session_id&follow_up=7'>PG</a>
328 - <a href='?php_session_id=$php_session_id&follow_up=8'>Ivey</a></td></tr>";
334 <td valign
="top" colspan
='2'>
336 <div
>Last
10</div
><ol
>
338 $q="SELECT * FROM signatures where signature_status = 'verified' order by id desc limit 0, 10";
339 $r = $petition->query($q);
340 while($d = mysqli_fetch_array($r)){
341 echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
347 <tr
><td valign
="top">
349 <div
>Watching
for 0</div
><ol
>
351 $q="SELECT * FROM signatures where VTRID = '0' and signature_status <> 'bot' and signature_status <> 'flag_invalid_signature' and signature_status <> 'resign_requested'";
352 $r = $petition->query($q);
353 while($d = mysqli_fetch_array($r)){
354 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>";
357 </td
><td valign
="top">
358 <h2
>Petition ID Bugs
</h2
>
359 <div
>Watching
for 0</div
><ol
>
361 $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'";
362 $r = $petition->query($q);
363 while($d = mysqli_fetch_array($r)){
364 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>";
367 </td
></tr
><tr
><td valign
="top">
369 <h2
>resign_requested
</h2
>
370 <div
>These are most likely from early bugs
</div
><ol
>
372 $q="SELECT * FROM signatures where signature_status = 'resign_requested' order by ip_address";
373 $r = $petition->query($q);
375 while($d = mysqli_fetch_array($r)){
377 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>";
380 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
386 <div
>These are bots on the site
.</div
><ol
>
388 $q="SELECT * FROM signatures where signature_status = 'bot' order by ip_address";
389 $r = $petition->query($q);
391 while($d = mysqli_fetch_array($r)){
393 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>";
396 <?PHP
$html = ob_get_clean(); if ( $show == 1 ){ echo $html; } ?
>
407 include_once('footer.php');