Exemplo n.º 1
0
/* Disabled because the Android app might not be passing a cookie and hitting this page directly :(
if (!isset($_COOKIE["jlog-cid"])) {
	//Oops, you don't have a cookie, return to checkpoint registration
	#TODO: Disable this? We don't want someone guessing the url and registering with a checkpoint by accident
	header("Location: /agent/set/");
}
*/
if ($cid == "0" || $jlogCID == "0") {
    //print 'HEY LOOK YOU ARE CHECKPOINT 0';
    //header("Location: /agent/autoregistration/?rid=".$runner_id);
    include '_autoregistration.php';
    exit;
}
if ($runner_id) {
    //print "Look here motherfuckers, we're checking you into a checkpoint. Good job<br /><br />";
    print '<h2>Journey Log - Checkin<br>' . get_checkpoint_name($jlogCID) . '</h2>
	';
    //print 'Going to try to check in runner '.$runner_id.'<br />';
    //print $jlogCID.", ".$runner_id.",".$device_id.",".$lat.",".$long.",".$timestamp."<br />";
    if (check_runner_in($jlogCID, $runner_id, $device_id, $lat, $long, $timestamp)) {
        print '
		<p><strong><big>Runner ' . $runner_id . ' is checked in.</big></strong>
		<div style="font-size:14em;color:green;text-align: center;">&#10003;</div>
		';
    } else {
        //We should probably check and see if the runner's already been checked in and return a more descriptive message
        if (is_already_checked_in($jlogCID, $runner_id)) {
            print '
			<p><strong><big>Runner ' . $runner_id . ' is already checked in.</big></strong>
			<div style="font-size:14em;color:green;text-align: center;">&#10003;</div>
			';
Exemplo n.º 2
0
/*
Oh man is this quick and dirty. This makes way too many database calls and could be made
more efficient but we're assuming not many people are going to be using this. A quick
fix would be to cronjob this shit and pipe it to a static html file every 5 min or so.
*/
include 'functions.php';
$checkpoints = get_all_checkpoint_ids();
print "Total Runners in Database: " . total_runners() . "<br />";
print "Registered Runners: " . total_runners_registered(1) . "<br />";
print "Unregistered Runners: " . total_runners_registered(0) . "<br />";
print "<br />";
print "Runners that have been tagged: " . total_runners_tagged() . "<br />";
print "Registered Runners remaining: " . total_runners_registered_untagged(1) . "<br />";
print "Unregistered runners remaining: " . total_runners_registered_untagged(0) . "<br />";
print "<br />";
print "<b>Tag Stats</b><br />";
print "Active Taggers: " . active_chasers() . "<br />";
print "Active Taggers in last 30min: " . active_chasers(30) . "<br />";
print "<br />";
print "<b>Checkpoint Stats:</b><br />";
foreach ($checkpoints as $checkpoint_id) {
    print "<h2>" . get_checkpoint_name($checkpoint_id) . ":</h2>";
    print "&nbsp;&nbsp&nbsp;Checkins: " . total_checkpoint_checkins($checkpoint_id) . "<br />";
    $most_recent = most_recent_checkin($checkpoint_id);
    if (!empty($most_recent)) {
        print "&nbsp;&nbsp&nbsp;Most recent checkin: " . get_runner_name($most_recent['runner_id']) . " (" . $most_recent['runner_id'] . ") at " . $most_recent['checkin_time'] . "<br />";
        print "<img src=\"/photos/" . $most_recent['runner_id'] . ".jpg\" style=\"margin-left: 25px;\"><br />";
    }
    print "<br />";
}
print "<ost recent";
Exemplo n.º 3
0
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>index</title>
</head>
<body>
<h2>Journey Log</h2>
<?php 
if (isset($cid)) {
    ?>
<p>You are currently registered to: <?php 
    print get_checkpoint_name($cid);
    ?>
</p>
<?php 
} else {
    ?>
<p>You are not currently registered to a checkpoint</p>
<?php 
}
?>
<p>Set your checkpoint:</p>
<p>
<?php 
$all_checkpoints = get_all_checkpoint_ids();
foreach ($all_checkpoints as $checkpoint_id) {
    print '<h3><a href="/agent/set/' . $checkpoint_id . '">' . get_checkpoint_name($checkpoint_id) . '</a></h3>';
}
?>
</p>
<a href="/agent/set/9999">Clear your checkpoint cookies</a>
</body>
</html>
Exemplo n.º 4
0
function check_runner_in($cid, $rid, $device_id = "", $lat = "", $long = "", $timestamp = "")
{
    $device_id = "some device";
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    $ip_address = $_SERVER['REMOTE_ADDR'];
    $mysqli = connectdb();
    $stmt = $mysqli->prepare("INSERT INTO " . CHECKINS_TBL . " (runner_id, checkpoint_id, device_id, user_agent, ip_address, lat, lng, checkin_time) VALUES (?,?,?,?,?,?,?,?)");
    //print "INSERT INTO ".CHECKINS_TBL." (runner_id, checkpoint_id, device_id, user_agent, ip_address, lat, lng, checkin_time) VALUES ($rid,$cid,$device_id,$user_agent,$ip_address,$lat,$long,$timestamp)";
    $stmt->bind_param('sissssss', $rid, $cid, $device_id, $user_agent, $ip_address, $lat, $long, $timestamp);
    $stmt->execute();
    if ($stmt->affected_rows > 0) {
        $stmt->close();
        _logger(LOG_CHECKIN, LOG_SUCCESS, $rid . " checked in to " . get_checkpoint_name($cid) . " " . $lat . "," . $long . "  ts=" . $timestamp);
        return true;
    } else {
        $stmt->close();
        if (is_already_checked_in($cid, $rid)) {
            _logger(LOG_CHECKIN, "", $rid . " is already checked in to " . get_checkpoint_name($cid));
        } else {
            _logger(LOG_CHECKIN, LOG_FAILED, $rid . " failed to check in to " . get_checkpoint_name($cid) . " " . $lat . "," . $long);
        }
        return false;
    }
}
Exemplo n.º 5
0
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<?php 
include 'mobile-friendly.html';
include 'functions.php';
print '<h2>Journey Log</h2>';
$cid = $_GET['cid'];
// Get the cid
$possibleCIDs = get_all_checkpoint_ids();
$possibleCIDs[] = 9999;
if (!in_array($cid, $possibleCIDs)) {
    print '<h3>Checkpoint ID not found</h3>
	<div style="font-size:14em;color:red;text-align: center;">?</div>';
    die;
}
if ($cid == 9999) {
    //delete the cookie
    setcookie("jlog-cid", $cid, time() - 86400, "/", $_SERVER['SERVER_NAME']);
    print "Cookie removed";
} else {
    //set the cookie
    setcookie("jlog-cid", $cid, time() + 86400, "/", $_SERVER['SERVER_NAME']);
    //Set cookies
    print '<h3>Phone bound to ' . get_checkpoint_name($cid) . '</h3>
	<div style="font-size:14em;color:green;text-align: center;">&#9676;</div>';
}
Exemplo n.º 6
0
function checkin($rid, $cid, $checked_in_earlier)
{
    $mysqli = connectdb();
    $stmt = $mysqli->prepare("INSERT INTO " . CHECKINS_TBL . " (runner_id, checkpoint_id, checked_in_earlier, checkin_time) VALUES (?,?,?,NOW())");
    $stmt->bind_param('ssi', $rid, $cid, $checked_in_earlier);
    $stmt->execute();
    if ($stmt->affected_rows > 0) {
        $stmt->close();
        _logger(LOG_CHECKIN, LOG_SUCCESS, $rid . " checked in to " . get_checkpoint_name($cid));
        # update the number of people checked in to this checkpoint so far
        $stmt = $mysqli->prepare("UPDATE " . CHECKPOINTS_TBL . " SET checked_in_so_far = checked_in_so_far+1 WHERE checkpoint_id = ?");
        $stmt->bind_param('s', $cid);
        $stmt->execute();
        $stmt->close();
        # update the first checkin time
        $stmt = $mysqli->prepare("UPDATE " . CHECKPOINTS_TBL . " SET first_checkin_at = NOW(), first_runner=? WHERE first_checkin_at IS NULL AND checkpoint_id = ?");
        $stmt->bind_param('ss', $rid, $cid);
        $stmt->execute();
        $stmt->close();
        # update the most recent checkin time
        $stmt = $mysqli->prepare("UPDATE " . CHECKPOINTS_TBL . " SET most_recent_checkin_at = NOW(), most_recent_runner=? WHERE checkpoint_id = ?");
        $stmt->bind_param('ss', $rid, $cid);
        $stmt->execute();
        $stmt->close();
        return true;
    } else {
        if (is_already_checked_in($cid, $rid)) {
            _logger(LOG_CHECKIN, "", $rid . " is already checked in to " . get_checkpoint_name($cid));
            $stmt->close();
            return true;
        } else {
            _logger(LOG_CHECKIN, LOG_FAILED, $rid . " failed to check in to " . get_checkpoint_name($cid) . ": " . $stmt->error);
            $stmt->close();
            return false;
        }
    }
}
Exemplo n.º 7
0
            _logger(LOG_GAME, "START", "Journey has started!");
        }
        print "Start time recorded as:<br />" . get_start_time();
    } else {
        if ($_POST['action'] == "END") {
            print "<h1>The game has ended!</h1>";
            if (mysql_query("INSERT INTO " . OTHER_TBL . " (event, time) VALUES ('end',NOW())", $mysql)) {
                _logger(LOG_GAME, "END", "Journey has ended!");
            }
            print "End time recorded as:<br />" . get_end_time();
            print "<br />";
            print "<p>The game lasted: " . time_between(get_start_time(), get_end_time()) . "</p>";
            print "<p>Total Runners Tagged: " . total_runners_tagged() . "</p>";
            $checkpoints = get_all_checkpoint_ids();
            foreach ($checkpoints as $checkpoint_id) {
                print "<p>" . get_checkpoint_name($checkpoint_id) . ":<br />";
                print "&nbsp;&nbsp&nbsp;Checkins: " . total_checkpoint_checkins($checkpoint_id) . "</p>";
                print "<br />";
            }
        }
    }
} else {
    ?>
<h1>Are you ready?</h1>
<div align="center">
<form action="" method="post">
<input type="submit" name="action" value="START" style="width: 50%; height: 75px; font-size: 20pt;">
<br /><br /><br /><br />
<input type="submit" name="action" value="END" style="width: 50%; height: 75px; font-size: 20pt;">
</form>
</div>