$lat = $_POST['lat']; $long = $_POST['lon']; if (empty($long)) { $long = $_POST['long']; } if (empty($long)) { $long = $_POST['lng']; } $timestamp = $_POST['ts']; $timestamp = $timestamp - 25200; //fix for Pacific time zone, i.e. GMT -7 //convert timestamp to datetime $timestamp = time_php2sql($timestamp); } if (empty($timestamp)) { _logger(LOG_DEBUGGING, "", "Timestamp not passed, generate one"); $timestamp = date('Y-m-d H:i:s'); } //Get checkpoint id cookie value $jlogCID = intval($_COOKIE["jlog-cid"]); /* 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';
function update_runner($runner_id, $runner_name, $email_address) { if (!is_valid_runner($runner_id)) { print "Not a valid runner<br />"; return false; } $mysqli = connectdb(); $query = "UPDATE " . RUNNERS_TBL . " SET player_name=?, player_email=?, is_registered=1 WHERE runner_id=?"; $stmt = $mysqli->prepare($query); $stmt->bind_param('sss', $runner_name, $email_address, $runner_id); $stmt->execute(); if ($stmt->affected_rows > 0) { $stmt->close(); _logger(LOG_USERREGISTER, LOG_SUCCESS, $runner_id . " updated their info. player_name='" . $runner_name . "' player_email=" . $email_address); return true; } else { $stmt->close(); _logger(LOG_USERREGISTER, LOG_SUCCESS, $runner_id . " failed to update their info. player_name='" . $runner_name . "' player_email=" . $email_address); return false; } }
function update_or_create_new_runner($rid, $name, $email, $twitter, $password) { $mysqli = connectdb(); $hash = generate_password_hash($password); $query = "INSERT INTO " . RUNNERS_TBL . " (runner_id, player_name, player_email, player_twitter_handle, hashed_password, created_at) VALUES (?,?,?,?,?,NOW()) ON DUPLICATE KEY UPDATE player_name=?, player_email=?, player_twitter_handle=?, hashed_password=?"; $stmt = $mysqli->prepare($query); $stmt->bind_param('sssssssss', $rid, $name, $email, $twitter, $hash, $name, $email, $twitter, $hash); $stmt->execute(); if ($stmt->affected_rows > 0) { $stmt->close(); _logger(LOG_USERREGISTER, LOG_SUCCESS, $rid . " updated or created their info. player_name='" . $name . "' player_email=" . $email); return true; } else { $stmt->close(); _logger(LOG_USERREGISTER, LOG_SUCCESS, $rid . " failed to update or create their info. player_name='" . $name . "' player_email=" . $email); return false; } }
} if ($_FILES["player_photo"]["error"] > 0) { echo "Error Code: " . $_FILES["player_photo"]["error"] . "<br />"; } else { if (move_uploaded_file($_FILES["player_photo"]["tmp_name"], "photos/" . $photo_name)) { _logger(LOG_REGISTER, LOG_SUCCESS, $photo_name . " uploaded"); print "Successfully processed image<br />"; } else { _logger(LOG_REGISTER, LOG_FAIL, $photo_name . " failed to upload"); print "Error processing image<br />"; die; } } if (is_runner_registered($runner_id)) { print "Runner is already registered<br />"; _logger(LOG_REGISTER, LOG_FAIL, $runner_id . " was already registered."); } else { #Register runner if (register_runner_app($runner_id)) { print "Runner successfully registered<br />"; } else { print "Failed to register runner<br />"; } } /* $_FILES["file"]["name"] - the name of the uploaded file $_FILES["file"]["type"] - the type of the uploaded file $_FILES["file"]["size"] - the size in bytes of the uploaded file $_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server $_FILES["file"]["error"] - the error code resulting from the file upload */
<?php include 'mobile-friendly.html'; require_once 'functions.php'; $jlogRID = $_COOKIE["jlog-rid"]; $request_str = $_SERVER['REQUEST_URI']; $param_pos = strpos($request_str, '?'); if ($param_pos > 0) { $request_str = substr($request_str, 0, $param_pos); } $command = explode('/', substr($request_str, 1)); #echo 'got request ' , $_SERVER['REQUEST_URI'] , '<br />'; #echo 'switching on command ' , $command[0] , '<br />'; _logger('REQUEST', 'SUCCESS', "cookie {$jlogRID} requested {$request_str}"); switch ($command[0]) { # Instructions page case 'instructions': include 'instructions.php'; break; # Checkpoint Redirect page # Checkpoint Redirect page case 'c': include 'checkin.php'; break; # Player Profile page # Player Profile page case 'runners': include 'player_profile.php'; break; # Runner Generate New Runner Id -- in case we don't print unique QR codes on manifests or need a backup # Runner Generate New Runner Id -- in case we don't print unique QR codes on manifests or need a backup
include 'mobile-friendly.html'; include 'functions.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $mysql = connectdb(true); if ($_POST['action'] == "START") { //start the game print "<h1>Start running bitches!</h1>"; if (mysql_query("INSERT INTO " . OTHER_TBL . " (event, time) VALUES ('start',NOW())", $mysql)) { _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 "   Checkins: " . total_checkpoint_checkins($checkpoint_id) . "</p>"; print "<br />"; } } } } else { ?>