BriskDB and DBConn classes now have a static constructor method that can be failed
[brisk.git] / web / Obj / brisk.phh
index e51304d..480f3a2 100644 (file)
@@ -1627,7 +1627,8 @@ 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) {
-          $bdb = new BriskDB();
+            // FIXME: now create can return FALSE
+          $bdb = BriskDB::create();
           $bdb->users_load();
           /* MLANG: "Il nickname <b>\'%s\'</b> &egrave; gi&agrave; registrato, <b>se il suo proprietario si autentificher&agrave; verrai rinominato d\'ufficio come ghost<i>N</i>.</b>" */
           if ($bdb->login_exists($name_new)) {
@@ -1905,9 +1906,11 @@ class Room {
 
     /* 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"));
@@ -2560,21 +2563,6 @@ function log_legal($curtime, &$user, $where, $mesg)
   }
 }
 
-function log_points($curtime, &$user, $where, $mesg) 
-{
-  GLOBAL $_SERVER;
-
-  if (($fp = @fopen(LEGAL_PATH."/points.log", 'a')) != FALSE) {
-    /* Unix time | session | nickname | IP | where was | mesg */
-    fwrite($fp, sprintf("%ld|%s|%s|%s|%s|%s|%s|\n", $curtime, $user->sess,
-                        ($user->flags & USER_FLAG_AUTH ? 'A' : 'N'),
-                        $user->name, $_SERVER['REMOTE_ADDR'], $where , $mesg));
-    fclose($fp);
-  }
-}
-
-
-
 
 function lock_banlist()
 {