From 35e1a863f6404d5630c3000b720f6ba99bf8548e Mon Sep 17 00:00:00 2001 From: Snap Date: Sun, 3 May 2015 23:00:34 -0700 Subject: Login fixes and matches progress --- ajax/match.ajax.php | 63 ++++++++++++++++++++++- pages/login.php | 20 +++----- pages/matches.php | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+), 14 deletions(-) create mode 100644 pages/matches.php diff --git a/ajax/match.ajax.php b/ajax/match.ajax.php index 391c69e..3a4bfae 100644 --- a/ajax/match.ajax.php +++ b/ajax/match.ajax.php @@ -8,11 +8,19 @@ session_start(); //header_remove(); - require_once('../includes/sqlEmbedded.php'); +//Prep response $r = ''; +//Gamelist request? +if (isset($_REQUEST['getGameList'])) { + $r['matches'] = getMatchList(); + echo json_encode($r); + exit; +} + + if (is_int($_GET['matchID'])) { $matchID = $_GET['matchID']; } @@ -129,6 +137,59 @@ function getPlayersForMatch($matchID) { return $array; } +function getMatchList() { + global $mysqli; + + if (!is_object($mysqli)) die("mysqli is not an object"); + + if ($res = $mysqli->query(" + SELECT + matches.ID, + matches.creatorUserID, + matches.mapID, + matches.isComplete, + matches.isStarted, + + TIME_TO_SEC(TIMEDIFF(NOW(), matches.dateCreated)) as secondsSinceCreated, + + matches.dateExpires, + matches.dateStarted, + matches.requiredPlayers, + + COUNT(matchUsers.matchID) as currentPlayers, + + matches.secondsGiven, + matches.useSmartTime, + + users.displayName, + users.displayColor, + users.wallColor, + users.wallEmblem, + users.wallOrientation + FROM `matches` + JOIN `matchUsers` + ON matchUsers.matchID = matches.ID + JOIN `users` + ON matches.creatorUserID = users.ID + GROUP BY matches.ID + ")) { + $array = array(); + if ($res->num_rows == 0) { + $res->close(); + return false; + } + while ($response = $res->fetch_assoc()) { + $array[] = $response; + } + $res->close(); + if (count($array) < 1) return false; + return $array; + } else { + printf("DB Error: %s\n", $mysqli->error); + return false; + } +} + function getMatchStatus($matchID) { global $mysqli; diff --git a/pages/login.php b/pages/login.php index d698527..b0caf07 100644 --- a/pages/login.php +++ b/pages/login.php @@ -19,13 +19,14 @@ include_once('./includes/HybridAuth/Auth.php'); $hybrid_config_file = 'includes/HybridAuth/HybridAuthConfig.php'; +//TODO: SQL needs to be updated to sqli instead. + try { + //OpenID 2.0 Method - if (!$_GET['op'] || $_GET['op'] == 'steam' || $_GET['op'] == 'yahoo') { $openid = new LightOpenID; - //Require Email, and first name. $openid->required = array('namePerson/first', 'contact/email'); @@ -68,26 +69,19 @@ try { DoRedirect("Login failed. Back to the home page with you!"); } - //Google's OpenID Connect method + //Google's OpenID Connect method } else if ($_GET['op'] == 'google') { - - echo "ello..."; - include_once('./includes/google-api-php-client-master/src/Google/autoload.php'); $redirect_uri = $mydomain . "login?op=google"; - //echo "$redirect_uri $google_client_id $google_client_secret "; - $client = new Google_Client(); $client->setClientId($google_client_id); $client->setClientSecret($google_client_secret); $client->setRedirectUri($redirect_uri); $client->setScopes('email'); - //echo 'Tests running'; - if (isset($_GET['code'])) { //echo 'code recpt'; $client->authenticate($_GET['code']); @@ -174,7 +168,7 @@ function createNewUser($claimedid, $display, $email, $oldID = NULL) $sql = "SELECT `ID`, `isAdmin`, `openID`, `displayName`, `dateJoined` FROM `users` WHERE `openID` = '$claimedid' OR `email` = '$email'"; if (isset($oldID)) { - $sql = $sql." OR `openID` = '$oldID'"; + $sql = $sql." OR `openID` = '" . $oldID . "'"; } $result = mysql_query($sql); @@ -237,7 +231,7 @@ function createNewUser($claimedid, $display, $email, $oldID = NULL) if ($result) { $userID = mysql_insert_id(); $dateJoined = date(DateTime::ISO8601); - + //Tutorial done? if (isset($_SESSION['preCompletedTutorial'])) { if ($_SESSION['preCompletedTutorial'] == true) { @@ -280,7 +274,7 @@ function createNewUser($claimedid, $display, $email, $oldID = NULL) $refTo = $_GET['ref']; //DoRedirect("Thank you $display.", $_GET['ref']); DoRedirect("", $refTo, 0); - exit; + return true; } function sendNewUserEmail($userID, $email, $display, $dateJoined) { diff --git a/pages/matches.php b/pages/matches.php new file mode 100644 index 0000000..7fd8559 --- /dev/null +++ b/pages/matches.php @@ -0,0 +1,140 @@ + + + + + + +
+

Available Matches

+ +
+ +
+
+
+
+ -- cgit v1.2.3