function TouchValidSession($sessionID) { $expectedDBVersion = $_POST['DBVersion']; if (!CheckDBVersion($expectedDBVersion)) { //Invalid DB Version return 0; } $sessionResults = mysql_query("\r\n SELECT\r\n p_ID\r\n FROM\r\n tblSessions\r\n WHERE\r\n\t\t\tADDTIME(TouchTime, '00:15:00.000000') > CURRENT_TIMESTAMP\r\n LIMIT 1\r\n "); if (!$sessionResults) { //Error with query return 0; } $sessionIDCount = mysql_num_rows($sessionResults); if ($sessionIDCount == 0) { //No valid session return 0; } //If we got this far, there is a valid session TouchSession($sessionID); return 1; }
<?php //Functions include_once 'scripts/account_functions.php'; include_once 'scripts/session_functions.php'; //Startup include_once 'scripts/connect_to_mysql.php'; $username = $_POST['username']; $password = $_POST['password']; $success = 0; //Check DB Version $expectedDBVersion = $_POST['DBVersion']; if (!CheckDBVersion($expectedDBVersion)) { //Invalid DB Version print "Success={$success}&Error='Invalid DB version'"; return; } //Check if username is being used already if (AccountExists($username) != 0) { print "Success={$success}&Error='Username already in use'"; return; } //Login $userID = CreateNewAccount($username, $password); if ($userID == -1) { print "Success={$success}&Error='Unable to create new user'"; return; } //There will never be an existing session for a new user, no sense in even checking for it $sessionID = CreateNewSession($userID); if ($sessionID == 0) {