'tit_onauth'=>array( 'it' => '(solo aut.)',
'en' => '(only aut.)'),
'tit_onisol'=>array( 'it' => '(isolam.to)',
- 'en' => '(isolation)')
+ 'en' => '(isolation)'),
+ 'db_failed' =>array('it' => '<br>Il collegamento al database è fallito.<br>Temporaneamente tutte le autenticazioni verranno sospese, accederai a Brisk come un utente normale.<br><br>Ci scusiamo per il disagio.',
+ 'en' => 'Connection to the database failed<br>All authentications are suspended temporarly, you login as normal user.<br>We are about the limitation')
);
$G_lng = langtolng($G_lang);
$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "2.5.0";
+$G_brisk_version = "3.2.0";
/* MLANG: ALL THE INFO STRINGS IN brisk.phh */
$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: informazioni al tavolo sul chiamante, nuovo stato di supporter del sito.',
define(USER_FLAG_AUTH, 0x02);
define(USER_FLAG_MAP_AUTH, 0x0c);
-
define(USER_FLAG_LISTAUTH, 0x04);
define(USER_FLAG_ISOLAUTH, 0x08);
+define(USER_FLAG_DBFAILED, 0x10);
+
// user status
define(USER_FLAG_S_NORM, 0x000); // done
define(USER_FLAG_S_PAU, 0x100); // done
$ret .= sprintf('stat = "%s";', $user->stat);
$ret .= root_wellcome($user);
+ if ($user->flags & USER_FLAG_DBFAILED) {
+ $ret .= "gst.st = ".($user->step+1)."; ";
+ $ret .= show_notify($mlang_brisk['db_failed'][$G_lang], 0, $mlang_brisk['btn_close'][$G_lang], 400, 140);
+ }
+
$ret .= sprintf('subst = "%s";', $user->subst);
$itin = ($user->flags & USER_FLAG_AUTH ? "<i>" : "");
$itou = ($user->flags & USER_FLAG_AUTH ? "</i>" : "");
$user->name = $name_new; // OK - nick changed
/* se nome gia' in uso, segnala cosa potrebbe capitare */
if (($user->flags & USER_FLAG_AUTH) == 0) {
- // 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)) {
- $prestr = sprintf($mlang_brisk['nickjust'][$G_lang], xcape($name_new));
- $to_user .= sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $prestr);
- }
+ if (($bdb = BriskDB::create()) != FALSE) {
+ $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)) {
+ $prestr = sprintf($mlang_brisk['nickjust'][$G_lang], xcape($name_new));
+ $to_user .= sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $prestr);
+ }
+ }
}
log_main("chatt_send start set");
return ($G_false);
}
-
-
/*
* function &add_user(&$room, &$sess, &$idx, $name, $pass, $ip)
*
* if ($idx == -3 && ret == FALSE) => wrong password
* if ($idx == -1 && ret == FALSE) => no space left
* if ($idx == 0 && ret == user) => SUCCESS
- * if ($idx == -$idx && ret == user) => SUCCESS (but the login exists in the auth db
+ * if ($idx == -$idx && ret == user) => SUCCESS (but the login exists in the auth db)
*/
-
-
function &add_user(&$sess, &$idx, $name, $pass, $ip)
{
GLOBAL $G_base, $G_false, $CO_list;
/* if pass != FALSE verify the login with pass */
log_auth("XXX", "auth1");
- // FIXME: now create can return FALSE
- if (($bdb = BriskDB::create()) != 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"));
-
- if ($authenticate != FALSE) {
- $user_type = $authenticate->type_get();
- }
- else {
- $idx = -3;
- return ($G_false);
- }
+ if ($pass != 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"));
+
+ if ($authenticate != FALSE) {
+ $user_type = $authenticate->type_get();
+ }
+ else {
+ $idx = -3;
+ return ($G_false);
+ }
+ }
+ else {
+ $login_exists = $bdb->login_exists($name_new);
+ }
}
else {
- $login_exists = $bdb->login_exists($name_new);
+ // if db is down, send a warning and verify only current users
+ // no actions at this moment
}
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
/* free user ? */
if ($idx == -1)
$idx = $i;
}
- if ($idfree == -1 && strcmp("", $this->user[$i]->sess) == 0) {
+ if ($idfree == -1 && strcmp($this->user[$i]->sess, "") == 0) {
$idfree = $i;
continue; // NOTE: CHECK IT !!
}
log_auth("XXX", sprintf("TROVATO A QUESTO PUNTO [%d] sess [%s] name [%s]", $idx, $sess, $name_new));
+ /* there is another user logged with your account and you and him have authenticated => che new user
+ get the session of the old user */
if ($ghost > -1 && $ghost_auth && ($authenticate != FALSE)) {
/* swap session */
$this->user[$idx]->bantime = 0;
$this->user[$idx]->ip = $ip;
- $this->user[$idx]->flags = ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00) | $user_type;
-
+ $this->user[$idx]->flags = $user_type;
+ $this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
+ $this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags));
if (DBConn::$dbcnnx == FALSE) {
if (!(DBConn::$dbcnnx = @pg_connect ($G_dbauth))) {
- return FALSE;
+ return ($ret);
}
}
break;
}
- // FIXME: now create can return FALSE
- $newdb = BriskDB::create();
+ if (($newdb = BriskDB::create()) == FALSE) {
+ $cont .= sprintf("Database connection failed.<br>\n");
+ break;
+ }
$newdb->users_load();
if ($newdb->addusers_from_olddb($olddb, $cont) == FALSE) {
$cont .= sprintf("Insert failed.<br>\n");
break;
}
- // FIXME: now create can return FALSE
- $newdb = BriskDB::create();
+ if (($newdb = BriskDB::create()) == FALSE) {
+ $cont .= sprintf("Database connection failed.<br>\n");
+ break;
+ }
+
$newdb->users_load();
$dbconn = $newdb->getdbconn();
for ($pts_n = 0 ; !feof($fp) ; $pts_n++) {
function placing_time_pgsql()
{
GLOBAL $G_dbpfx;
- // FIXME: now create can return FALSE
- $bdb = BriskDB::create();
+
+ if (($bdb = BriskDB::create()) == FALSE) {
+ log_crit("placing: database connection failed");
+ return (FALSE);
+ }
$mti_sql = sprintf("SELECT CAST(EXTRACT(EPOCH FROM mtime) AS INTEGER) as mtime
FROM %sbin5_places_mtime WHERE code = 0;", $G_dbpfx);
{
GLOBAL $G_dbpfx;
- // FIXME: now create can return FALSE
- $bdb = BriskDB::create();
+ if (($bdb = BriskDB::create()) == FALSE) {
+ log_crit("placing: database connection failed");
+ return ("");
+ }
if ($user != FALSE) {
$pla_sql = sprintf("SELECT * from %sbin5_places where type = %d AND (rank <= %d OR ucode = '%s');",
if ($user->table_orig < TABLES_AUTH_N) {
require_once("../Obj/dbase_".$G_dbasetype.".phh");
+ if (($bdb = BriskDB::create()) != FALSE) {
+ $bdb->bin5_points_save($curtime, $table->table_token, $user->table_orig, $ucodes, $pt_cur);
+ unset($bdb);
+ }
+ else {
+ log_points($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", "DATABASE CONNECTION FAILED");
+ }
log_points($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", $plist);
- // 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);
}
$table->game_next();
fclose($fp_start);
}
- // FIXME: now create can return FALSE
- $bdb = BriskDB::create();
+ if (($bdb = BriskDB::create()) == FALSE) {
+ echo "database connection failed";
+ exit;
+ }
+
$bdb->users_load();
for ($i = 0 ; $i < $bdb->count() ; $i++) {
{
GLOBAL $G_dbpfx;
- // FIXME: now create can return FALSE
- $bdb = BriskDB::create();
+ if (($bdb = BriskDB::create()) == FALSE) {
+ echo "database connection failed";
+ exit;
+ }
$limi = array( TRI_LIMIT, MON_LIMIT, WEE_LIMIT );
$ming = array( TRI_MIN_GAMES, MON_MIN_GAMES, WEE_MIN_GAMES );
'en' => 'close' ),
'commerr' => array( 'it' => '<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>',
'en' => '<b>An error was occurred during the saving, try again or contact the administrator.</b>'),
+ 'coerrdb' => array( 'it' => '<b>Il database è temporaneamente irraggiungibile, riprova più tardi o contatta l\'amministratore.</b>',
+ 'en' => '<b>The database is temporarly unavailable, retry to later or conctact the administrator.</b>'),
'warrmust' => array( 'it' => '<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>',
'en' => 'To authenticate somebody you have to be authenticated in your turn'),
'mesgrepl' => array( 'it' => '<br><br>Il messaggio è stato inoltrato all\'amministratore.',
log_mop(0, 'index_wr.php: COMM: '.xcapemesg($mesg));
log_wr('COMM: '.xcapemesg($mesg));
+$curtime = time();
+$dt = date("H:i ", $curtime);
+
$sem = Room::lock_data();
if (($room = &Room::load_data()) == FALSE) {
echo "Load data error";
log_main("chal lock data success");
if (($chals = &Challenges::load_data()) != FALSE) {
- $curtime = time();
$token = uniqid("");
// echo '2|'.$argz[1].'|'.$token.'|'.$_SERVER['REMOTE_ADDR'].'|'.$curtime.'|';
else if ($argz[0] == 'warranty') {
GLOBAL $cli_name, $cli_email;
- $curtime = time();
$mesg_to_user = "";
log_wr("INFO:SKIP:argz == warranty name: [".$cli_name."] AUTH: ".($user->flags & USER_FLAG_AUTH));
if ($mesg_to_user != "") {
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $dt = date("H:i ", $curtime);
$user->comm[$user->step % COMM_N] .= $mesg_to_user;
$user->step_inc();
}
}
else if ($argz[0] == 'mesgtoadm') {
- GLOBAL $cli_subj, $cli_mesg;
-
- $curtime = time();
- $mesg_to_user = "";
-
- 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) {
- // FIXME: now create can return FALSE
- $bdb = BriskDB::create();
- $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));
- }
-
- if (($fp = @fopen(LEGAL_PATH."/messages.txt", 'a')) != FALSE) {
- /* Unix time | session | nickname | IP | where was | mesg */
- fwrite($fp, sprintf("%ld|%s|%s|%s\n", $curtime, $user->name,
- xcapelt(urldecode($cli_subj)), xcapelt(urldecode($cli_mesg))));
- fclose($fp);
- }
- Warrant::unlock_data($wa_lock);
- $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- /* MLANG: "" */
- $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['mesgrepl'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110);
- $user->step_inc();
- echo "1";
+ GLOBAL $cli_subj, $cli_mesg;
+
+ $mesg_to_user = "";
+
+ log_wr("INFO:SKIP:argz == mesgtoadm name: [".$user->name."] AUTH: ".($user->flags & USER_FLAG_AUTH));
+ if ($user->flags & USER_FLAG_AUTH) {
+ if (($wa_lock = Warrant::lock_data()) != FALSE) {
+ if (($bdb = BriskDB::create()) != FALSE) {
+ $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));
+ }
+
+ if (($fp = @fopen(LEGAL_PATH."/messages.txt", 'a')) != FALSE) {
+ /* Unix time | session | nickname | IP | where was | mesg */
+ fwrite($fp, sprintf("%ld|%s|%s|%s\n", $curtime, $user->name,
+ xcapelt(urldecode($cli_subj)), xcapelt(urldecode($cli_mesg))));
+ fclose($fp);
+ }
+ Warrant::unlock_data($wa_lock);
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ /* MLANG: "" */
+ $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['mesgrepl'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110);
+ $user->step_inc();
+ echo "1";
+ }
+ else {
+ /* MLANG: "<b>Il database è temporaneamente irraggiungibile, riprova più tardi o contatta l\'amministratore.</b>" */
+ $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['coerrdb'][$G_lang]);
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ }
+ }
+ else {
+ /* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
+ $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
+ }
+
}
else {
- /* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
- $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
+ /* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>" */
+ $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mesgmust'][$G_lang]);
}
- }
- else {
- /* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>" */
- $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mesgmust'][$G_lang]);
- }
-
- if ($mesg_to_user != "") {
- $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
-
- $dt = date("H:i ", $curtime);
- $user->comm[$user->step % COMM_N] .= $mesg_to_user;
- $user->step_inc();
- }
+ if ($mesg_to_user != "") {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+
+ $user->comm[$user->step % COMM_N] .= $mesg_to_user;
+ $user->step_inc();
+ }
}
GLOBAL $G_with_poll, $G_poll_name, $cli_choose, $cli_poll_name;
$poll_lock = FALSE;
- $curtime = time();
$mesg_to_user = "";
$fp = FALSE;
if ($mesg_to_user != "") {
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $dt = date("H:i ", $curtime);
$user->comm[$user->step % COMM_N] .= $mesg_to_user;
$user->step_inc();
}
$table_idx = $argz[1];
$table = &$room->table[$table_idx];
- $curtime = time();
-
if ($G_shutdown || $table->wakeup_time > $curtime ||
($table->auth_only && (($user->flags & USER_FLAG_AUTH) == 0)) ) {
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $dt = date("H:i ", $curtime);
/* MLANG: "<b>Il server sta per essere riavviato, non possono avere inizio nuove partite.</b>", "<b>Il tavolo a cui volevi sederti richiede autentifica.</b>", "<b>Il tavolo si è appena liberato, ci si potrà sedere tra %d secondi.</b>" */
if ($G_shutdown) {
$user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['shutmsg'][$G_lang]);
// START THE SPAWN HERE!!!!
//
- $curtime = time();
-
// Create new spawned table
$bri_sem = Briskin5::lock_data($table_idx);
$table_token = uniqid("");