Пример #1
0
<?php

require_once 'functions.php';
$cid = $command[1];
list($checkpoint_name, $checked_in_so_far) = get_checkpoint_name_and_status($cid);
$cookie_rid = $_COOKIE["jlog-rid"];
# echo "got cid ", $cid, " with runner id in cookie ", $cookie_rid, " and name ", $checkpoint_name, " and checked in so far ", $checked_in_so_far, "<br />\n";
if (!$cookie_rid) {
    echo "<p>You need to log in first!  Scan your QR code.</p>";
} elseif (!$checkpoint_name) {
    # TODO: this should never happen, unless someone tries entering a bad checkpoint code, so a confusing redirect/not mentioning the error is probably okay...but printing errors is usually better
    redirect_to('/instructions');
} else {
    if (is_chaser($cookie_rid)) {
        echo "<p>Sorry...you're a chaser.  We're glad you made it to this checkpoint, but your goal is now to tag runners.</p>";
        echo "<p><a href='/runners/{$cookie_rid}'>Check your stats</a></p>";
    } else {
        if (checkin($cookie_rid, $cid, $checked_in_so_far)) {
            echo "<p>You successfully checked in at ", $checkpoint_name, ". Only ", $checked_in_so_far, " runners checked in here before you did.</p>";
            $seconds_since_start = time() - $game_start_time;
            $m = (int) ($seconds_since_start / 60);
            $s = $seconds_since_start % 60;
            $h = (int) ($m / 60);
            $m = $m % 60;
            $timestring = str_pad($h, 2, '0', STR_PAD_LEFT) . ":" . str_pad($m, 2, '0', STR_PAD_LEFT) . ":" . str_pad($s, 2, '0', STR_PAD_LEFT);
            $twitterString = "I survived to {$checkpoint_name}! Made it in {$timestring}, with only {$checked_in_so_far} runners ahead of me. #sxsw #jtteotn";
            echo "<p><a href='http://twitter.com/intent/tweet?text=" . clean_tweet($twitterString) . "'>Tweet it!</a> {$twitterString}</p>";
            echo "<p><a href='/runners/{$cookie_rid}'>Check your stats</a></p>";
        } else {
            echo "<p>You FAILED to check in at ", $checkpoint_name, "!</p>";
        }
Пример #2
0
function tag($runner_id, $chaser_id)
{
    $runner_id = clean_runner_id($runner_id);
    $chaser_id = clean_runner_id($chaser_id);
    if (!$chaser_id) {
        $chaser_id = '';
    }
    # mark as tagged
    $mysqli = connectdb();
    $stmt = $mysqli->prepare("UPDATE " . RUNNERS_TBL . " SET is_tagged = 1 WHERE runner_id = ?");
    $stmt->bind_param('s', $runner_id);
    $stmt->execute();
    $stmt->close();
    # record tag in the table
    $stmt = $mysqli->prepare("INSERT INTO " . TAGS_TBL . " (runner_id, tagger_id, tag_time) VALUES (?, ?, NOW())");
    $stmt->bind_param('ss', $runner_id, $chaser_id);
    $stmt->execute();
    $stmt->close();
    # update the tagger's stats, if there is one
    if (is_chaser($chaser_id)) {
        $stmt = $mysqli->prepare("UPDATE " . RUNNERS_TBL . " SET num_tagged = num_tagged + 1 WHERE runner_id = ?");
        $stmt->bind_param('s', $chaser_id);
        $stmt->execute();
        $stmt->close();
    }
    _logger('TAG', LOG_SUCCESS, "{$runner_id} was tagged by {$chaser_id}");
}
Пример #3
0
<?php

require_once 'functions.php';
$target_id = $command[1];
# NOTE: $chaser_id may be empty
$chaser_id = $command[2];
$cookie_rid = $_COOKIE["jlog-rid"];
if (is_chaser($target_id)) {
    echo "<p>Runner {$target_id} has been marked as tagged.</p>";
} else {
    tag($target_id, $chaser_id);
    $num_tagged = '';
    if ($chaser_id) {
        $num_tagged = get_num_tagged_by($chaser_id);
    }
    echo "<p>Runner {$target_id} has been tagged.</p>";
    if ($cookie_rid == $chaser_id) {
        $tagged_twitter = get_runner_twitter($target_id);
        if ($tagged_twitter) {
            $twitterString = "I just tagged @{$tagged_twitter} -- victim number {$num_tagged}! #sxsw #jtteotn";
        } else {
            $tagged_name = get_runner_name($target_id);
            if ($tagged_name) {
                $twitterString = "I just tagged {$tagged_name} -- victim number {$num_tagged}! #sxsw #jtteotn";
            } else {
                $twitterString = "I just tagged victim number {$num_tagged}! #sxsw #jtteotn";
            }
        }
        echo "<p><a href='http://twitter.com/intent/tweet?text=" . clean_tweet($twitterString) . "'>Tweet it!</a> {$twitterString}</p>";
    } elseif ($cookie_rid == $target_id) {
        if ($chaser_id) {
$cookie_rid = $_COOKIE["jlog-rid"];
# check to make sure you're logged in as you and not let other players see your info
if ($cookie_rid != $rid) {
    echo "<p>If you are trying to tag this person, you must first <a href='/tagged/" . $cookie_rid . "'>mark yourself as tagged</a>.</p>";
    echo "<p>If you are trying to log in as this person, you must first <a href='/logout'>logout</a>.</p>";
} else {
    $dtzone = new DateTimeZone($tz);
    $runner_name = get_runner_name($rid);
    echo "<br />player profile for runner id ", $rid, " (", $runner_name, ")";
    $checkin_stats = get_runner_checkin_info($rid);
    if (sizeof($checkin_stats) > 0) {
        echo "<p><table><tr><th>Checkpoint name</th><th>Checked in Before You</th><th>Checkin Time</th></tr>\n";
        foreach ($checkin_stats as &$row) {
            $dt = new DateTime($row[2], $dtzone);
            echo "<tr><td>", $row[0], "</td><td>", $row[1], "</td><td>", $dt->format("h:i:s"), "</td></tr>\n";
        }
        echo "</table></p>\n";
    } else {
        echo "<p>No checkins yet.</p>";
    }
    if (is_chaser($rid)) {
        $num_tagged = get_num_tagged_by($rid);
        echo "<br />You have recorded {$num_tagged} tags so far.\n";
        echo "<br />To record that you tagged someone, scan their QR code.\n";
        echo "<br />Or, if you accidentally marked yourself as tagged, you can <a href='/resurrected'>un-tag yourself</a>.";
    } else {
        echo "<br /><a href='/tagged/", $rid, "'>I Got Tagged</a>\n";
    }
    echo "<br /><a href='/logout'>Logout</a>\n";
    echo "<br /><a href='/edit'>Edit Info</a>\n";
}