X-Git-Url: http://git.pjr.cc/?p=ga4php.git;a=blobdiff_plain;f=gaas%2Flib%2FgaasdLib.php;h=e9809869db105ffa204b69f2d3d8d19e895f2632;hp=5cfe52fc6afa2087753c21cae3b79fe670653c3f;hb=40dc7f97626a703a943e27cdcd1a3d6a332a8f27;hpb=1d6adec6039a635e97e31592bbbcbf4357e33c28 diff --git a/gaas/lib/gaasdLib.php b/gaas/lib/gaasdLib.php index 5cfe52f..e980986 100644 --- a/gaas/lib/gaasdLib.php +++ b/gaas/lib/gaasdLib.php @@ -1,23 +1,23 @@ query($sql); + + // check the result + //echo "next1\n"; + if(!$result) return false; + + // now just retreieve all the data (there should only be one, but whatever) + //echo "next2\n"; + $tokendata = false; + foreach($result as $row) { + $tokendata = $row["users_tokendata"]; + } + + //echo "next3, $username, $tokendata\n"; + // now we have our data, we just return it. If we got no data + // we'll just return false by default + return $tokendata; + + // and there you have it, simple eh? } - function putData($username, $data) - { + function putData($username, $data) { + // get our database connection + $dbObject = getDB(); + + // we need to check if the user exists, and if so put the data, if not create the data + $sql = "select * from users where users_username='$username'"; + $res = $dbObject->query($sql); + if($res->fetchColumn() > 0) { + // do update + //error_log("doing userdata update"); + $sql = "update users set users_tokendata='$data' where users_username='$username'"; + } else { + // do insert + //error_log("doing user data create"); + $sql = "insert into users values (NULL, '$username', '', '', '$data', '')"; + } + + if($dbObject->query($sql)) { + return true; + } else { + return false; + } + } - - function getUsers() - { + function getUsers() { + // get our database connection + $dbObject = getDB(); + + // now the sql again + $sql = "select users_username from users"; + + // run the query + $result = $dbObject->query($sql); + + // iterate over the results - we expect a simple array containing + // a list of usernames + $i = 0; + $users = array(); + foreach($result as $row) { + $users[$i] = $row["username"]; + $i++; + } + + // now return the list + return $users; } } ?> \ No newline at end of file