X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=authserver%2Flib%2Flib.php;h=c3ac220ccfb6085762ed837351662a7913b9e4b2;hb=590f7600a8319d4ae08c32a32e7713ea6f9e2edb;hp=689389a5079dcd8668bb111dc4e910df942aebb0;hpb=1e9b1b3a5c4dd1f033ae5f3145d7bb7bcd73a4d6;p=ga4php.git diff --git a/authserver/lib/lib.php b/authserver/lib/lib.php index 689389a..c3ac220 100644 --- a/authserver/lib/lib.php +++ b/authserver/lib/lib.php @@ -15,10 +15,15 @@ define("MSG_SET_USER_TOKEN_TYPE", 8); define("MSG_GET_USERS", 9); define("MSG_GET_OTK_PNG", 10); define("MSG_GET_OTK_ID", 11); +define("MSG_DELETE_USER_TOKEN", 12); +define("MSG_SYNC_TOKEN", 13); -if(file_exists("../../lib/ga4php.php")) require_once("../../lib/ga4php.php"); -if(file_exists("../lib/ga4php.php")) require_once("../lib/ga4php.php"); +// BASE_DIR = +$BASE_DIR = realpath(dirname(__FILE__)."/../../"); +global $BASE_DIR; +// messy +require_once(dirname(__FILE__)."/../../lib/ga4php.php"); function generateRandomString() { @@ -35,15 +40,16 @@ function generateRandomString() function getDatabase() { $dbobject = false; - if(file_exists("gaasdata.sqlite")) { + global $BASE_DIR; + if(file_exists("$BASE_DIR/authserver/authd/gaasdata.sqlite")) { try { - $dbobject = new PDO("sqlite:gaasdata.sqlite"); + $dbobject = new PDO("sqlite:$BASE_DIR/authserver/authd/gaasdata.sqlite"); } catch(PDOException $exep) { error_log("execpt on db open"); } } else { try { - $dbobject = new PDO("sqlite:gaasdata.sqlite"); + $dbobject = new PDO("sqlite:$BASE_DIR/authserver/authd/gaasdata.sqlite"); } catch(PDOException $exep) { error_log("execpt on db open"); } @@ -100,9 +106,11 @@ class gaasGA extends GoogleAuthenticator { $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', '')"; }