<?PHP
-include_once('../slack.php');
-include_once('security.php');
-include_once('/var/www/secure.php'); //outside webserver
-include_once('functions.php');
+global $order;
+$order = 'ASC';
+if (isset($_COOKIE['order'])){
+ $order = $_COOKIE['order'];
+}
+
+if (empty($_GET['run'])){
+ if ($_COOKIE['name'] == ''){
+ die('no name');
+ }
+ include_once('bots.php');
+ include_once('../slack.php');
+ include_once('security.php');
+ include_once('/var/www/secure.php'); //outside webserver
+ include_once('functions.php');
+}else{
+ include_once('../slack.php');
+ include_once('/var/www/secure.php'); //outside webserver
+ include_once('functions.php');
+}
+ob_start();
+
+$sign_email = $_COOKIE['sign_email'];
+if (isset($_GET['sign_email'])){
+ // here we use it, if it shows up next run, we block
+ $sign_email = $_GET['sign_email'];
+ $_COOKIE['sign_email'] = $sign_email;
+ setcookie("sign_email", $sign_email);
+
+}
+
+function js_redirect($page){ // now header - prep for full auto
+ $base = 'https://www.md-petition.com/admin/';
+ $url = $base.$page.'&run=1';
+ $pos = strpos($page, $_COOKIE['sign_email']);
+ global $order;
+ if ($pos === false) {
+ // email not found - good to redirect
+ //echo "<script>window.location.href = \"$url\";</script>";
+ slack_general('js_redirect('.$page.')','automation');
+ header('Location: '.$url);
+ //slack_general('CHECK COOKIE ('.$_COOKIE['sign_email'].') PAGE ('.$page.')','md-petition-admin');
+ $order = 'ASC';
+ setcookie("order", $order);
+ die();
+ } else {
+ slack_general('Loop Detected for '.$_COOKIE['sign_email'],'automation');
+ echo "<h1>Automated Loop Detected - Skip Setting - Reverse Sort (DESC)</h1>";
+ $order = 'DESC';
+ setcookie("order", $order);
+ }
+
+}
+
if ($_COOKIE['level'] == 'user'){
slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
header('Location: user_home.php');
}elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){
$php_session_id = $_GET['php_session_id'];
echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
- $q = "SELECT * FROM presign where php_session_id = '$php_session_id' order by id desc ";
+ $q = "SELECT * FROM presign where php_session_id = '$php_session_id' and email_for_follow_up <> '$_COOKIE[sign_email]' order by id DESC ";
$r = $petition->query($q);
while($d = mysqli_fetch_array($r)){
$color = 'white';
<td style='white-space:pre;'>$d[browser_string]</td>
</tr>";
}
- $petition->query("insert into follow_up (name, email, php_session, petition_id) values ('$name','$email','$php_session_id','$_GET[follow_up]') ");
+ $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')."') ");
$petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
$petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
echo "</table>";
echo "<h1>Review $VTRID</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";
$q = "SELECT * FROM signatures where VTRID = '$VTRID' and signature_status = 'verified' and petition_id = '$petition_id' order by petition_id, id DESC ";
$r = $petition->query($q);
+ $i=0;
while($d = mysqli_fetch_array($r)){
$color = 'white';
$pos = strpos($d['date_time_signed'], date('Y-m-d'));
<td><a href='?flag_phone=$d[contact_phone]'>contact phone</a></td>
<td><a href='?resign_requested=$d[id]'>resign requested</a></td>
<td><a href='?bot=$d[id]'>bot</a></td>
- </tr>";
+ </tr>";
+ if ($i == 0){
+ js_redirect("analytics.php?flag_duplicate=$d[id]");
+ }
+ $i++;
}
echo "</table>";
+ die();
}
?>
-<h1>Signature Analytics</h1>
+<h1>Signature Analytics - Server Clock: <?PHP echo date('r');?></h1>
<h2>NEVER NEVER NEVER CALL OR TEXT ANYONE - ONLY EMAIL!!!</h2>
<h3>SysOp Says: Transparency = Trust</h3>
<table>
<?PHP
$q="SELECT VTRID, petition_id, COUNT(*) as count FROM signatures where signature_status = 'verified' group by VTRID, petition_id";
$r = $petition->query($q);
+$i=0;
while($d = mysqli_fetch_array($r)){
if ($d['count'] > 1){
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>";
+ if ($i == 0){
+ js_redirect("analytics.php?VTRID=$d[VTRID]&petition_id=$d[petition_id]");
+ }
+ $i++;
}
+
}
?></ol>
</td></tr>
<div>Follow up requested - never signed.</div>
<form method='GET'><input name='email'><input type='submit' value='SEARCH E-MAIL'></form><table>
<?PHP
-$q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id desc";
+
+
+
+$q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id $order";
$r = $petition->query($q);
while($d = mysqli_fetch_array($r)){
$q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
$r2 = $petition->query($q2);
$d2 = mysqli_fetch_array($r2);
- echo "<tr><td>$d2[action_on]</td><td><a href='?php_session_id=$d2[php_session_id]'>$d2[name]</a></td><td>$d2[email_for_follow_up]</td><td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td></tr>";
+ $sig = '';
+ if ($d2['name'] != ''){
+ $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
+ $r3 = $petition->query($q3);
+ $d3 = mysqli_fetch_array($r3);
+ if ($d3['date_time_signed'] != ''){
+ $sig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b><br>";
+ js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
+ }
+ }
+ $presig='';
+ $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and php_page like '/sign.php%'";
+ $r4 = $petition->query($q4);
+ $d4 = mysqli_fetch_array($r4);
+ if ($d4['action_on']){
+ $presig = "<b><a href='?sign_email=$d2[email_for_follow_up]'>PRESIG $d4[action_on]</a></b><br>";
+ js_redirect("analytics.php?sign_email=$d2[email_for_follow_up]");
+ }
+ $invite_error='';
+ $q4="SELECT * FROM presign where email_for_follow_up = '$d2[email_for_follow_up]' and invite_error <> '' ";
+ $r4 = $petition->query($q4);
+ $d4 = mysqli_fetch_array($r4);
+ if ($d4['invite_error'] != ''){
+ $invite_error = "<b><a href='?clear_email=$d2[email_for_follow_up]'>$d4[invite_error]</a></b><br>";
+ js_redirect("analytics.php?clear_email=$d2[email_for_follow_up]");
+ }
+ $php_session_id = $d2['php_session_id'];
+ 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>
+ <td><a href='?php_session_id=$php_session_id&follow_up=X'>General</a>
+ - <a href='?php_session_id=$php_session_id&follow_up=1'>MGP</a>
+ - <a href='?php_session_id=$php_session_id&follow_up=2'>MLP</a>
+ - <a href='?php_session_id=$php_session_id&follow_up=3'>BTEC</a>
+ - <a href='?php_session_id=$php_session_id&follow_up=7'>PG</a>
+ - <a href='?php_session_id=$php_session_id&follow_up=8'>Ivey</a></td></tr>";
+ if( $presig == '' && $invite_error == '' && $sig == '' ){
+ if ($d2['invite'] == 'Ivey'){
+ js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=8");
+ die();
+ }
+ if ($d2['invite'] == 'mlp'){
+ js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=2");
+ die();
+ }
+ if ($d2['invite'] == 'BTEC'){
+ js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=3");
+ die();
+ }
+ if ($d2['invite'] == 'RestorePGTermLimits'){
+ js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
+ die();
+ }
+ if (id2petition($d2['petition']) == 'RESTORE TWO TERM (8 YEAR) TERM LIMITS IN PRINCE GEORGE'){
+ js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=7");
+ die();
+ }
+ if ($d2['invite'] == 'mgp'){
+ js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=1");
+ die();
+ }
+ js_redirect("analytics.php?php_session_id=$php_session_id&follow_up=X"); // no invite found no petition found - send general follow/up
+ }
}
?></table>
</td>
echo "<li>$d[date_time_signed] ".id2petition($d['petition_id'])." $d[signed_name_as]</li>";
}
?></ol>
+
</td>
</tr>
<?PHP
+// allow headers to be sent...
+$html = ob_get_clean();
+echo $html; // run javascript
+
include_once('footer.php');
?>