X-Git-Url: http://git.pjr.cc/?p=ga4php.git;a=blobdiff_plain;f=authserver%2Flib%2Flib.php;h=9737566cc96daa7a61c48440bc526b2fd0b7566c;hp=dbdd35f8c9683cfbf6590afae611186903c06152;hb=34cbcba6d0f7c0a92c849545712cc5ce7ec03f97;hpb=07e42724b584df5d317a72b0e0ed1bafbc744b8f diff --git a/authserver/lib/lib.php b/authserver/lib/lib.php index dbdd35f..9737566 100644 --- a/authserver/lib/lib.php +++ b/authserver/lib/lib.php @@ -13,10 +13,25 @@ define("MSG_SET_USER_REALNAME", 6); define("MSG_SET_USER_TOKEN", 7); define("MSG_SET_USER_TOKEN_TYPE", 8); define("MSG_GET_USERS", 9); +define("MSG_GET_OTK_PNG", 10); if(file_exists("../../lib/ga4php.php")) require_once("../../lib/ga4php.php"); if(file_exists("../lib/ga4php.php")) require_once("../lib/ga4php.php"); + +function generateRandomString() +{ + $str = ""; + $strpos = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + + for($i=0; $i<128; $i++) { + $str .= $strpos[rand(0, strlen($strpos)-1)]; + } + + return $str; +} + + function getDatabase() { $dbobject = false; if(file_exists("gaasdata.sqlite")) { @@ -31,7 +46,7 @@ function getDatabase() { } catch(PDOException $exep) { error_log("execpt on db open"); } - $sql = 'CREATE TABLE "users" ("users_id" INTEGER PRIMARY KEY AUTOINCREMENT,"users_username" TEXT, "users_realname" TEXT, "users_password" TEXT, "users_tokendata" TEXT);'; + $sql = 'CREATE TABLE "users" ("users_id" INTEGER PRIMARY KEY AUTOINCREMENT,"users_username" TEXT, "users_realname" TEXT, "users_password" TEXT, "users_tokendata" TEXT, "users_otk" TEXT);'; $dbobject->query($sql); } @@ -87,7 +102,7 @@ class gaasGA extends GoogleAuthenticator { $sql = "update users set users_tokendata='$data' where users_username='$username'"; } else { // do insert - $sql = "insert into users values (NULL, '$username', '', '', '$data')"; + $sql = "insert into users values (NULL, '$username', '', '', '$data', '')"; } if($dbObject->query($sql)) {