X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=4e765a1ecd784969b56e8176df4ae87ffeb2a29f;hb=8507128d38073666f0e778b16fb691a3bc9ef0e7;hp=c579ddc4089f4eb203ad2ed493dfd9261a3f2d32;hpb=b3a25067e48ac90ba83b01b8724cdb421e575826;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index c579ddc..4e765a1 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -28,7 +28,8 @@ define('FTOK_PATH', "/var/lib/brisk"); define('LEGAL_PATH', "/tmp/legal_brisk"); define('PROXY_PATH', "/var/lib/brisk_proxy"); define('TABLES_N', 36); -define('TABLES_AUTH_N', 4); +define('TABLES_AUTH_N', 8); +define('TABLES_CERT_N', 4); define('PLAYERS_N', 3); define('MAX_POINTS', 5); define('MAX_PLAYERS', (20 + (PLAYERS_N * TABLES_N))); @@ -59,7 +60,7 @@ define('WAKEUP_TIME', 12); // BAN_TIME da allineare anche in commons.js define('BAN_TIME', 3600); define('GARBAGE_TIMEOUT', 5); -define('NICKSERV', "BriskServ"); +define('NICKSERV', "BriskServ"); define('LOCK_SHARE_MAX', 10000); @@ -109,8 +110,8 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi', 'en' => '
The entered password is not correct.

'), 'alarret' => array( 'it' => '"Alarm \\"%s\\" inviato a %s."', 'en' => '"Alarm \\"%s\\" sent to %s."'), - 'authmust' => array( 'it' => 'Per autenticare qualcuno devi a tua volta essere autenticato.', - 'en' => 'To authenticate someone you have to be authenticated.'), // on your turn + 'authmust' => array( 'it' => 'Per autenticare qualcuno devi a tua volta essere autenticato e certificato.', + 'en' => 'To authenticate someone you have to be authenticated and certified.'), // on your turn 'mesgmust' => array( 'it' => 'Per inviare un messaggio devi essere autenticato.', 'en' => 'To send a message you have to be authenticated.'), 'nickmust' => array( 'it' => 'Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.', @@ -621,12 +622,17 @@ class Vect { } } +define('TABLE_AUTH_TY_PUBL', 0); +define('TABLE_AUTH_TY_AUTH', 1); +define('TABLE_AUTH_TY_CERT', 2); + + class Table { var $idx; var $player; var $player_n; - var $auth_only; // se tavolo riservato o libero + var $auth_type; // required authorization to sit down var $wag_own; var $wag_com; @@ -649,7 +655,13 @@ class Table { $thiz->idx = $idx; $thiz->player = array(); $thiz->player_n = 0; - $thiz->auth_only = FALSE; + + if ($idx < TABLES_CERT_N) + $thiz->auth_type = TABLE_AUTH_TY_CERT; + else if ($idx < TABLES_AUTH_N) + $thiz->auth_type = TABLE_AUTH_TY_AUTH; + else + $thiz->auth_type = TABLE_AUTH_TY_PUBL; $thiz->wag_own = -1; $thiz->wag_com = ""; @@ -673,7 +685,7 @@ class Table { log_main("PLAYER_N - parent::copy.".$this->player_n); - $this->auth_only = $from->auth_only; + $this->auth_type = $from->auth_type; $this->wag_own = $from->wag_own; $this->wag_com = $from->wag_com; @@ -706,7 +718,7 @@ class Table { $thiz->player[$i] = $i; $thiz->player_n = $from->player_n; - $thiz->auth_only = $from->auth_only; + $thiz->auth_type = $from->auth_type; $thiz->wag_own = $from->wag_own; $thiz->wag_com = $from->wag_com; @@ -777,12 +789,7 @@ class Table { } } - - - // $ret .= table_act_content(($user->subst == 'standup'), $this->table[$i]->player_n, $i, $user->table, - // ($this->table[$i]->auth_only == FALSE ? TRUE : $user->flags & USER_FLAG_AUTH)); - - // function act_content($isstanding, $sitted, $table, $cur_table, $allowed) + // Table->act_content - return 'id' of type of output required for table button function act_content($user) { $ret = ""; @@ -794,15 +801,23 @@ class Table { if ($isstanding) { if ($sitted < PLAYERS_N) { - if ($this->auth_only) { - if ($user->flags & USER_FLAG_AUTH) - $act = "sitreser"; - else - $act = 'reserved'; - } - else { - $act = 'sit'; - } + switch ($this->auth_type) { + case TABLE_AUTH_TY_CERT: + if ($user->is_cert()) + $act = "sitcert"; + else + $act = 'resercert'; + break; + case TABLE_AUTH_TY_AUTH: + if ($user->is_auth()) + $act = "sitreser"; + else + $act = 'reserved'; + break; + default: + $act = 'sit'; + break; + } } else { $act = 'none'; @@ -995,7 +1010,7 @@ class Brisk fprintf(STDERR, "ROOM FROM FILE\n"); rename($crystal_filename, $crystal_filename.".old"); - $brisk->reload(); + $brisk->reload($ban_list, $black_list); return($brisk); } @@ -1023,20 +1038,6 @@ class Brisk for ($i = 0 ; $i < TABLES_N ; $i++) { $thiz->table[$i] = Table::create($i); - /* OLD METHOD - if ($i < 12) { - $row = ( (((int)($i / 4)) % 2) == 0 ); - $col = ($i % 2 == 0); - $thiz->table[$i]->auth_only = (($row && $col) || (!$row && !$col)); - } - else { - $thiz->table[$i]->auth_only = FALSE; - } - */ - if ($i < TABLES_AUTH_N) - $thiz->table[$i]->auth_only = TRUE; - else - $thiz->table[$i]->auth_only = FALSE; } $thiz->garbage_timeout = 0; $thiz->shm_sz = SHM_DIMS_MIN; @@ -1114,7 +1115,7 @@ class Brisk } // if authorized not check if banlisted - if ($user_cur->flags & USER_FLAG_AUTH) { + if ($user_cur->is_auth()) { continue; } @@ -1364,8 +1365,7 @@ class Brisk for ($i = 0 ; $i < TABLES_N ; $i++) { $ret .= $this->table_content($user, $i); - // $ret .= table_act_content(($user->subst == 'standup'), $this->table[$i]->player_n, $i, $user->table, - // ($this->table[$i]->auth_only == FALSE ? TRUE : $user->flags & USER_FLAG_AUTH)); + $ret .= $this->table[$i]->act_content($user); if ($this->table[$i]->wag_own != -1) $ret .= sprintf('tra.add(%d, "%s: %s"); ', $i, $this->user[$this->table[$i]->wag_own]->name, $this->table[$i]->wag_com); @@ -1453,15 +1453,11 @@ class Brisk // clean the action buttons in other tables for ($e = 0 ; $e < TABLES_N ; $e++) { if ($this->table[$e]->player_n < PLAYERS_N) { - // $ret .= table_act_content(TRUE, 0, $e, $user->table, - // ($this->table[$e]->auth_only == FALSE ? TRUE : $user->flags & USER_FLAG_AUTH)); $ret .= $this->table[$e]->act_content($user); } } } else { - // $ret .= table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table, - // ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH)); $ret .= $table->act_content($user_cur); } } @@ -1536,8 +1532,6 @@ class Brisk $ret .= $this->table_content($user_cur, $table_idx); $ret .= $this->standup_content($user_cur); - // $ret .= table_act_content(FALSE, 0, $table_idx, $user_cur->table, - // ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH)); $ret .= $table->act_content($user_cur); @@ -1565,8 +1559,7 @@ class Brisk log_main("JOIN_WAKEUP wup_idx ".$wup_idx." wup_n ".$user_wup_n); log_main("JOIN_WAKEUP more"); - // $ret .= table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table, - // ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH)); + $ret .= $table->act_content($user_cur); log_main("JOIN_WAKEUP end more"); @@ -1709,8 +1702,7 @@ class Brisk } else if ($table_idx > -1) { if ($table->player_n == PLAYERS_N) { - // $ret .= table_act_content(($user_cur->subst == 'standup'), PLAYERS_N, $table_idx, $user_cur->table, - /// ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH)); + $ret .= $table->act_content($user_cur); } } @@ -1848,16 +1840,16 @@ class Brisk } } else if (strcmp($msg, "/authreq") == 0) { - if ($user->flags & USER_FLAG_AUTH) { - $to_user = sprintf('authbox(300,200);'); - } - else { - /* MLANG: "Per autenticare qualcuno devi a tua volta essere autenticato.", "Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.", "Nickname %s già in uso." */ - $to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['authmust'][$G_lang]); - } + if ($user->is_cert()) { + $to_user = sprintf('authbox(300,200);'); + } + else { + /* MLANG: "Per autenticare qualcuno devi a tua volta essere autenticato.", "Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.", "Nickname %s già in uso." */ + $to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['authmust'][$G_lang]); + } } else if (strncmp($msg, "/mesgtoadm", 8) == 0) { - if ($user->flags & USER_FLAG_AUTH) { + if ($user->is_auth()) { $to_user = sprintf('mesgtoadmbox(500,300);'); } else { @@ -1890,11 +1882,11 @@ class Brisk } /* MLANG: "Non puoi cambiare nick a un tavolo per soli autenticati.", "Il nickname \'%s\' è già registrato, se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghostN." */ - if ($user->flags & USER_FLAG_AUTH) { + if ($user->is_auth()) { if (strcasecmp($user->name,$name_new) != 0) { if (( ($user->flags & USER_FLAG_MAP_AUTH) != USER_FLAG_ISOLAUTH) && ($user->subst == 'standup' || - ($user->subst != 'standup' && $this->table[$user->table]->auth_only == FALSE) + ($user->subst != 'standup' && $this->table[$user->table]->auth_type == TABLE_AUTH_TY_PUBL) ) ) { $user->flags &= ~(USER_FLAG_AUTH | USER_FLAG_TY_ALL); // Remove auth if name changed @@ -1910,7 +1902,7 @@ class Brisk } $user->name = $name_new; // OK - nick changed /* se nome gia' in uso, segnala cosa potrebbe capitare */ - if (($user->flags & USER_FLAG_AUTH) == 0) { + if ( ! $user->is_auth() ) { if (($bdb = BriskDB::create()) != FALSE) { $bdb->users_load(); /* MLANG: "Il nickname \'%s\' è già registrato, se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghostN." */ @@ -2063,9 +2055,9 @@ class Brisk if ($is_normchat == TRUE) { // use MAP_AUTH to check if auth or isolation if ($user_cur->flags & USER_FLAG_MAP_AUTH) { - if (($user->flags & USER_FLAG_AUTH) == 0) { - continue; - } + if ( ! $user->is_auth() ) { + continue; + } } } /* @@ -2219,7 +2211,7 @@ class Brisk if (strcasecmp($this->user[$i]->name, $name_new) == 0) { if ($authenticate != FALSE) { $ghost = $i; - $ghost_auth = ($this->user[$i]->flags & USER_FLAG_AUTH); + $ghost_auth = $this->user[$i]->is_auth(); } else { $idx = $i; @@ -3033,7 +3025,7 @@ function log_legal($curtime, $addr, $user, $where, $mesg) if (($fp = @fopen(LEGAL_PATH."/legal.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->is_auth() ? 'A' : 'N'), $user->name, $addr, $where , $mesg)); fclose($fp); }