$user->name = $name_new; // OK - nick changed
/* se nome gia' in uso, segnala cosa potrebbe capitare */
if (($user->flags & USER_FLAG_AUTH) == 0) {
- $bdb = new BriskDB();
+ // FIXME: now create can return FALSE
+ $bdb = BriskDB::create();
$bdb->users_load();
/* MLANG: "Il nickname <b>\'%s\'</b> è già registrato, <b>se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghost<i>N</i>.</b>" */
if ($bdb->login_exists($name_new)) {
/* if pass != FALSE verify the login with pass */
log_auth("XXX", "auth1");
- $bdb = new BriskDB();
- $bdb->users_load();
- if ($pass != FALSE) {
+
+ // FIXME: now create can return FALSE
+ if (($bdb = BriskDB::create()) != FALSE)
+ $bdb->users_load();
+ if ($pass != FALSE && $bdb != FALSE) { // TODO: here add a method to $bdb to check if the db is available.
log_auth("XXX", "auth2");
$authenticate = $bdb->login_verify($name_new, $pass, $code);
log_auth("XXX", "authenticate: ".($authenticate != FALSE ? "TRUE" : "FALSE"));
log_main("BriskDB create:end");
}
+ static function &create()
+ {
+ $ret = new BriskDB();
+
+ return ($ret);
+ }
+
function users_load()
{
GLOBAL $DOCUMENT_ROOT;
function DBConn()
{
- GLOBAL $G_dbauth;
+ $this->db = DBConn::$dbcnnx;
+ }
+
+ static function &create()
+ {
+ GLOBAL $G_dbauth, $G_false;
+ $ret = &$G_false;
+
if (DBConn::$dbcnnx == FALSE) {
if (!(DBConn::$dbcnnx = @pg_connect ($G_dbauth))) {
- echo "DB connection failed.";
- exit;
+ return FALSE;
}
}
- $this->db = DBConn::$dbcnnx;
- return;
+ $ret = new DBConn();
+
+ return $ret;
}
function db()
{
var $item;
var $item_n;
- function BriskDB()
+ function BriskDB($dbconn)
+ {
+ $this->dbconn = $dbconn;
+ }
+
+ static function &create()
{
GLOBAL $DOCUMENT_ROOT, $G_dbpfx, $G_false;
+
+ $dbconn = $G_false;
+ $ret = $G_false;
+
log_main("BriskDB create:start");
- $this->dbconn = new DBConn();
+ do {
+ if (($dbconn = DBConn::create()) == FALSE)
+ break;
+
+ $ret = new BriskDB($dbconn);
+ } while (0);
log_main("BriskDB create:end");
+ return ($ret);
}
function users_load()
$cont .= sprintf("Loading failed.<br>\n");
break;
}
- $newdb = new BriskDB();
+
+ // FIXME: now create can return FALSE
+ $newdb = BriskDB::create();
$newdb->users_load();
if ($newdb->addusers_from_olddb($olddb, $cont) == FALSE) {
$cont .= sprintf("Insert failed.<br>\n");
break;
}
- $newdb = new BriskDB();
+ // FIXME: now create can return FALSE
+ $newdb = BriskDB::create();
$newdb->users_load();
$dbconn = $newdb->getdbconn();
for ($pts_n = 0 ; !feof($fp) ; $pts_n++) {
function placing_time_pgsql()
{
GLOBAL $G_dbpfx;
- $bdb = new BriskDB();
+ // FIXME: now create can return FALSE
+ $bdb = BriskDB::create();
$mti_sql = sprintf("SELECT CAST(EXTRACT(EPOCH FROM mtime) AS INTEGER) as mtime
FROM %sbin5_places_mtime WHERE code = 0;", $G_dbpfx);
function placing_show_pgsql(&$user, $ty, $subty)
{
GLOBAL $G_dbpfx;
-
- $bdb = new BriskDB();
+
+ // FIXME: now create can return FALSE
+ $bdb = BriskDB::create();
if ($user != FALSE) {
$pla_sql = sprintf("SELECT * from %sbin5_places where type = %d AND (rank <= %d OR ucode = '%s');",
require_once("../Obj/dbase_".$G_dbasetype.".phh");
log_points($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", $plist);
- $bdb = new BriskDB();
+ // FIXME: now create can return FALSE
+ $bdb = BriskDB::create();
$bdb->bin5_points_save($curtime, $table->table_token, $user->table_orig, $ucodes, $pt_cur);
unset($bdb);
}
fclose($fp_start);
}
- $bdb = new BriskDB();
+ // FIXME: now create can return FALSE
+ $bdb = BriskDB::create();
$bdb->users_load();
for ($i = 0 ; $i < $bdb->count() ; $i++) {
{
GLOBAL $G_dbpfx;
- $bdb = new BriskDB();
+ // FIXME: now create can return FALSE
+ $bdb = BriskDB::create();
$limi = array( TRI_LIMIT, MON_LIMIT, WEE_LIMIT );
$ming = array( TRI_MIN_GAMES, MON_MIN_GAMES, WEE_MIN_GAMES );
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) {
- $bdb = new BriskDB();
+ // FIXME: now create can return FALSE
+ $bdb = BriskDB::create();
$bdb->users_load();
if (($ema = $bdb->getmail($user->name)) != FALSE) {