From ad62ecf88ef0d5e5fa03d6461ac4510314fc2b50 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 10 Feb 2011 19:24:25 +0100 Subject: [PATCH] LoginDB renamed to more general BriskDB and separate the creation of the class with the loading of users data --- web/Obj/brisk.phh | 12 +++++++----- web/Obj/dbase_file.phh | 23 ++++++++++++++--------- web/Obj/dbase_pgsql.phh | 16 ++++++++++------ web/briskin5/statadm.php | 9 +++++---- web/index_wr.php | 7 ++++--- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index ed630ce..e7e7ac7 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1614,9 +1614,10 @@ class Room { $user->name = $name_new; // OK - nick changed /* se nome gia' in uso, segnala cosa potrebbe capitare */ if (($user->flags & USER_FLAG_AUTH) == 0) { - $userdb = new LoginDB(); + $bdb = new BriskDB(); + $bdb->users_load(); /* MLANG: "Il nickname \'%s\' è già registrato, se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghostN." */ - if ($userdb->login_exists($name_new)) { + if ($bdb->login_exists($name_new)) { $prestr = sprintf($mlang_brisk['nickjust'][$G_lang], xcape($name_new)); $to_user .= sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $prestr); } @@ -1890,10 +1891,11 @@ class Room { /* if pass != FALSE verify the login with pass */ log_auth("XXX", "auth1"); - $userdb = new LoginDB(); + $bdb = new BriskDB(); + $bdb->users_load(); if ($pass != FALSE) { log_auth("XXX", "auth2"); - $authenticate = $userdb->login_verify($name_new, $pass); + $authenticate = $bdb->login_verify($name_new, $pass, $code); log_auth("XXX", "authenticate: ".($authenticate != FALSE ? "TRUE" : "FALSE")); if ($authenticate != FALSE) { @@ -1905,7 +1907,7 @@ class Room { } } else { - $login_exists = $userdb->login_exists($name_new); + $login_exists = $bdb->login_exists($name_new); } for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { /* free user ? */ diff --git a/web/Obj/dbase_file.phh b/web/Obj/dbase_file.phh index d09f5df..12ae750 100644 --- a/web/Obj/dbase_file.phh +++ b/web/Obj/dbase_file.phh @@ -26,15 +26,21 @@ require_once("${G_base}Obj/dbase_base.phh"); define(BRISK_AUTH_CONF, "brisk_auth.conf.pho"); -class LoginDB { +class BriskDB { var $item; var $item_n; - function LoginDB() + function BriskDB() + { + log_main("BriskDB create:start"); + + log_main("BriskDB create:end"); + } + + function users_load() { GLOBAL $DOCUMENT_ROOT; - log_main("LoginDB create:start"); if (file_exists("$DOCUMENT_ROOT/Etc/".BRISK_AUTH_CONF)) { require("$DOCUMENT_ROOT/Etc/".BRISK_AUTH_CONF); @@ -46,7 +52,6 @@ class LoginDB { new LoginDBItem(4, "tre", md5("three"), "pippo@pluto.com", USER_FLAG_TY_NORM) ); } $this->item_n = count($this->item); - log_main("LoginDB create:end"); } function count() @@ -58,7 +63,7 @@ class LoginDB { { log_main("login_exists: ".$login); - /* check the existence of the nick in the LoginDB */ + /* check the existence of the nick in the BriskDB */ for ($i = 0 ; $i < $this->item_n ; $i++) { if (strcasecmp($this->item[$i]->login, $login) == 0) { log_main("login[".$i."]: ".$this->item[$i]->login); @@ -81,7 +86,7 @@ class LoginDB { log_main("login_exists: ".$login); - /* check the existence of the nick in the LoginDB */ + /* check the existence of the nick in the BriskDB */ for ($i = 0 ; $i < $this->item_n ; $i++) { if (strcasecmp($this->item[$i]->login, $login) == 0) { log_main("login[".$i."]: ".$this->item[$i]->login); @@ -98,7 +103,7 @@ class LoginDB { { log_main("getmail"); - /* check the existence of the nick in the LoginDB */ + /* check the existence of the nick in the BriskDB */ for ($i = 0 ; $i < $this->item_n ; $i++) { if (strcasecmp($this->item[$i]->login, $login) == 0) { log_main("login[".$i."]: ".$this->item[$i]->login); @@ -112,7 +117,7 @@ class LoginDB { { log_main("getmail"); - /* check the existence of the nick in the LoginDB */ + /* check the existence of the nick in the BriskDB */ for ($i = 0 ; $i < $this->item_n ; $i++) { if (strcasecmp($this->item[$i]->login, $login) == 0) { log_main("login[".$i."]: ".$this->item[$i]->login); @@ -130,7 +135,7 @@ class LoginDB { log_main("login_verify: ".$login); - /* check the existence of the nick in the LoginDB */ + /* check the existence of the nick in the BriskDB */ for ($i = 0 ; $i < $this->item_n ; $i++) { log_main("login_verify: LOOP"); if (strcasecmp($this->item[$i]->login, $login) == 0) { diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index 2c274dd..b91d932 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -59,27 +59,31 @@ class DBConn } } -class LoginDB +class BriskDB { var $dbconn; var $item; var $item_n; - function LoginDB() + function BriskDB() { GLOBAL $DOCUMENT_ROOT, $G_dbpfx, $G_false; - log_main("LoginDB create:start"); + log_main("BriskDB create:start"); $this->dbconn = new DBConn(); - log_main("LoginDB create:end"); + log_main("BriskDB create:end"); + } + + function users_load() + { } function login_exists($login) { GLOBAL $G_dbpfx; - /* check the existence of the nick in the LoginDB */ + /* check the existence of the nick in the BriskDB */ log_main("login_exists: ".$login); $user_sql = sprintf("SELECT * FROM %susers WHERE login = lower('%s');", $G_dbpfx, escsql($login)); @@ -116,7 +120,7 @@ class LoginDB log_main("login_verify: ".$login); - //O /* check the existence of the nick in the LoginDB */ + //O /* check the existence of the nick in the BriskDB */ //O for ($i = 0 ; $i < $this->item_n ; $i++) { //O log_main("login_verify: BEGIN"); diff --git a/web/briskin5/statadm.php b/web/briskin5/statadm.php index 257bf3f..96b79cd 100644 --- a/web/briskin5/statadm.php +++ b/web/briskin5/statadm.php @@ -67,10 +67,11 @@ function main() fclose($fp_start); } - $userdb = new LoginDB(); + $bdb = new BriskDB(); + $bdb->users_load(); - for ($i = 0 ; $i < $userdb->count() ; $i++) { - $login = $userdb->getlogin_byidx($i); + for ($i = 0 ; $i < $bdb->count() ; $i++) { + $login = $bdb->getlogin_byidx($i); $tri[$i] = new Ptsgam($login); $mon[$i] = new Ptsgam($login); $wee[$i] = new Ptsgam($login); @@ -125,7 +126,7 @@ function main() for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) { // echo $p." i) ".$i."
"; $username = $ar[9+($i*2)]; - if (($item = $userdb->getitem_bylogin($username, &$id)) == FALSE) { + if (($item = $bdb->getitem_bylogin($username, &$id)) == FALSE) { echo "WARNING: the user [".$username."] NOT EXISTS!
"; continue; } diff --git a/web/index_wr.php b/web/index_wr.php index 0db96eb..b030aff 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -246,9 +246,10 @@ else if ($argz[0] == 'mesgtoadm') { log_wr("INFO:SKIP:argz == mesgtoadm name: [".$cli_name."] AUTH: ".($user->flags & USER_FLAG_AUTH)); if ($user->flags & USER_FLAG_AUTH) { if (($wa_lock = Warrant::lock_data()) != FALSE) { - $userdb = new LoginDB(); - - if (($ema = $userdb->getmail($user->name)) != FALSE) { + $bdb = new BriskDB(); + $bdb->users_load(); + + if (($ema = $bdb->getmail($user->name)) != FALSE) { // mail("nastasi", mail("brisk@alternativeoutput.it", urldecode($cli_subj), urldecode($cli_mesg), sprintf("From: %s <%s>", $user->name, $ema)); } -- 2.17.1