function most_recent_checkin($checkpoint_id) { $checkpoint_id = clean_checkpoint_id($checkpoint_id); $mysql = connectdb(true); $query = "SELECT * from " . CHECKINS_TBL . " WHERE checkpoint_id=" . $checkpoint_id . " ORDER BY checkin_time DESC LIMIT 1"; $result = mysql_query($query, $mysql); $row = mysql_fetch_array($result, MYSQL_BOTH); return $row; }
$device_id = $_GET['did']; $lat = $_GET['lat']; $long = $_GET['lon']; if (empty($long)) { $long = $_GET['long']; } if (empty($long)) { $long = $_GET['lng']; } $timestamp = $_GET['ts']; $user_agent = $_SERVER['HTTP_USER_AGENT']; //Hello iPhone app!! if (strpos($user_agent, "JourneyLog") === 0) { _logger(LOG_DEBUGGING, "", "Hello iPhone app! Fetching POST: runner_id=" . $_POST['rid']); if (empty($cid)) { $cid = clean_checkpoint_id($_POST['cid']); } if (empty($runner_id)) { $runner_id = clean_runner_id($_POST['rid']); } #TODO: Clean this shit against injections $device_id = $_POST['did']; $lat = $_POST['lat']; $long = $_POST['lon']; if (empty($long)) { $long = $_POST['long']; } if (empty($long)) { $long = $_POST['lng']; } $timestamp = $_POST['ts'];
function is_already_checked_in($cid, $rid) { $cid = clean_checkpoint_id($cid); $rid = clean_runner_id($rid); $mysqli = connectdb(); $query = "SELECT COUNT(*) FROM " . CHECKINS_TBL . " WHERE checkpoint_id = ? and runner_id = ?"; $stmt = $mysqli->prepare($query); $stmt->bind_param('ss', $cid, $rid); $stmt->execute(); $stmt->bind_result($is_checkedin_already); $stmt->fetch(); $stmt->close(); if ($is_checkedin_already) { return true; } else { return false; } }