X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=aeb839a614a515502d6590277f3859cf217603e4;hb=dd16d683733bebd22757ec97dc7af1aa046e78e5;hp=622132c1c919f460d6a56149c60383ee327fe018;hpb=ed58ac6c50b5cafa86d03925b6eb14357c2e7a20;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 622132c..aeb839a 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -64,7 +64,8 @@ define(DBG_LOAD, 0x0100); define(DBG_AUTH, 0x0200); define(DBG_CRIT, 0x0400); -define(BRISK_DEBUG, 0); +// NOTE: BRISK DEBUG must be a numerical constant, not the result of operations on symbols +define(BRISK_DEBUG, 0xffffffff); define(BRISK_SINGLE_DEBUG,0); define(BRISK_SINGLE_SESS, ""); @@ -75,9 +76,10 @@ require_once("$DOCUMENT_ROOT/Etc/".BRISK_CONF); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "2.1.2 - trusty"; +$G_brisk_version = "2.1.4 - trusty"; -$root_wellarr = Array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': Autenticazione, tavoli riservati e ban efficaci.', +/* MLANG: ALL THE INFO STRINGS IN brisk.phh */ +$root_wellarr = Array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': Aggiunto un watchdog per la rete e il tasto "reload" in room.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); $table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloccano l\'uscita cliccando il lucchetto, chi esce non può risedersi a un qualunque tavolo per '.floor(BAN_TIME/60).' minuti.'); @@ -105,10 +107,14 @@ Dopo che è iniziata una partita per uscirne dovete chiedere agli altri gi
Comandi della chat
/nick <nuovo_nickname> - cambio di nickname
/tav <frase di invito> - invito per gli altri giocatori al tavolo dove si è seduti +
/st <stato> - cambia l\'icona associata al tuo user; stato può valere: \\"normale\\", \\"fuori\\", \\"pausa\\", \\"cibo\\", \\"cane\\", \\"lavoro\\", \\"presente\\" oppure \\"sigaretta\\" +
/garante - se si è autenticati permette di garantire per un utente fidato '; +// + $G_room_about= '
@@ -126,6 +132,13 @@ function xcape($s) return (str_replace($from, $to, htmlentities($s,ENT_COMPAT,"UTF-8"))); } +function xcapelt($s) +{ + $from = array ( '\\', '|' ); + $to = array ( '\\\\', '\\|' ); + + return (str_replace($from, $to, $s)); +} class Card { var $value; /* 0 - 39 card value */ @@ -591,6 +604,18 @@ class Table { // User flags define(USER_FLAG_AUTH, 0x02); +// user status +define(USER_FLAG_S_NORM, 0x000); // done +define(USER_FLAG_S_PAU, 0x100); // done +define(USER_FLAG_S_OUT, 0x200); // done +define(USER_FLAG_S_DOG, 0x300); // done +define(USER_FLAG_S_EAT, 0x400); // done +define(USER_FLAG_S_WRK, 0x500); // done +define(USER_FLAG_S_SMK, 0x600); // done +define(USER_FLAG_S_EYE, 0x700); // done + +define(USER_FLAG_S_ALL, 0xf00); // done + class User { var $name; // name of the user var $sess; // session of the user @@ -806,7 +831,7 @@ class User { function reset() { $curtime = time(); - log_legal($curtime, $this->sess, $this->name, "STAT:LOGOUT", ''); + log_legal($curtime, $this, "STAT:LOGOUT", ''); $tmp_sess = $this->sess; $this->sess = ""; @@ -955,7 +980,7 @@ class Room { $user_cur->bantime = $bri_user->bantime; } - log_legal($curtime, $user_cur->sess, $user_cur->name, "STAT:DESTROY_GAME", $plist); + log_legal($curtime, $user_cur, "STAT:DESTROY_GAME", $plist); $this->room_join_wakeup(&$user_cur, FALSE, 0); $table_cur->table_token = ""; @@ -991,7 +1016,7 @@ class Room { for ($i = 0 ; $i < $table_cur->player_n ; $i++) { $plist .= '|'.$this->user[$table_cur->player[$i]]->sess; } - log_legal($curtime, $user_cur->sess, $user_cur->name, "STAT:DESTROY_GAME(RECOVERY)", $plist); + log_legal($curtime, $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist); $this->room_join_wakeup(&$user_cur, TRUE, -2); $table_cur->table_token = ""; @@ -1035,6 +1060,7 @@ class Room { if ($user_cur->stat == 'room' && $user_cur->subst == 'sitdown') { $this->room_wakeup(&$user_cur); $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; "; + /* MLANG:
Sei stato inattivo per ".(EXPIRE_TIME_SMAMMA/60.0)." minuti.

Quindi ritorni tra i Giocatori in piedi.", "torna ai tavoli" */ $user_cur->comm[$user_cur->step % COMM_N] .= show_notify("
Sei stato inattivo per ".(EXPIRE_TIME_SMAMMA/60.0)." minuti.

Quindi ritorni tra i Giocatori in piedi.", 0, "torna ai tavoli", 400, 100); $user_cur->step_inc(); } @@ -1395,6 +1421,7 @@ class Room { strncmp($msg, "/tav ", 5) == 0) { do { if ($user->stat != 'room' || $user->subst != 'sitdown') { + /* MLANG: "
Per attivare il messaggio di segnalazione del tavolo occorre essere seduti.

", "
Il messaggio di segnalazione del tavolo è già attivato.

", "
Il messaggio di segnalazione del tavolo
è disattivato ancora per %d second%s.

" */ $msg = "
Per attivare il messaggio di segnalazione del tavolo occorre essere seduti.

"; $to_user = show_notify($msg, 0, "chiudi", 400, 100); @@ -1440,22 +1467,33 @@ class Room { } do { if (strncmp($msg, $alarm_check, strlen($alarm_check)) != 0) { + /* MLANG: "
La password digitata non è corretta.

" */ $msg = "
La password digitata non è corretta.

"; $to_user = show_notify($msg, 0, "chiudi", 400, 100); break; } + /* MLANG: "Alarm %s inviato a %s." */ $to_user = sprintf('chatt_sub("%s", [2, "%s"],"Alarm %s inviato a %s.");', $dt, NICKSERV, xcape(substr($msg, strlen($alarm_check))), ($target == "" ? "tutti" : xcape($target)) ); $msg = sprintf("
%s

%s


", $dt.NICKSERV, xcape(substr($msg, strlen($alarm_check)))); + /* MLANG: "chiudi" */ $to_all = show_notify($msg, 0, "chiudi", 400, 120); } while (0); } // /alarm chat command - + else if (strncmp($msg, "/garante", 8) == 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"],"Per autenticare qualcuno devi a tua volta essere autenticato.");', $dt, NICKSERV); + } + } else if (strncmp($msg, "/nick ", 6) == 0) { log_main("chatt_send BEGIN"); @@ -1479,6 +1517,7 @@ class Room { break; } + /* 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 (strcasecmp($user->name,$name_new) != 0) { if ($user->subst == 'standup' || ($user->subst != 'standup' && $this->table[$user->table]->auth_only == FALSE)) { @@ -1494,10 +1533,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(); + /* MLANG: "Il nickname \'%s\' è già registrato, se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghostN." */ if ($userdb->login_exists($name_new)) { $to_user .= sprintf('chatt_sub("%s", [2, "%s"],"Il nickname \'%s\' è già registrato, se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghostN.");', $dt, NICKSERV, xcape($name_new)); } @@ -1509,6 +1548,50 @@ class Room { } while (0); } // nick chat command + else if (strncmp($msg, "/st ", 4) == 0) { + log_main("chatt_send BEGIN"); + + do { + $st_str = substr($msg, 4); + + if (strcasecmp($st_str, "normale") == 0) { + $st = USER_FLAG_S_NORM; + } + else if (strcasecmp($st_str, "pausa") == 0) { + $st = USER_FLAG_S_PAU; + } + else if (strcasecmp($st_str, "fuori") == 0) { + $st = USER_FLAG_S_OUT; + } + else if (strcasecmp($st_str, "cane") == 0) { + $st = USER_FLAG_S_DOG; + } + else if (strcasecmp($st_str, "cibo") == 0) { + $st = USER_FLAG_S_EAT; + } + else if (strcasecmp($st_str, "lavoro") == 0) { + $st = USER_FLAG_S_WRK; + } + else if (strcasecmp($st_str, "sigaretta") == 0) { + $st = USER_FLAG_S_SMK; + } + else if (strcasecmp($st_str, "presente") == 0) { + $st = USER_FLAG_S_EYE; + } + else { + /* MLANG: "Questo stato non esiste." */ + $to_user = sprintf('chatt_sub("%s", [2,"%s"],"Questo stato non esiste.");', $dt, NICKSERV); + break; + } + + log_main("chatt_send start set"); + if (($user->flags & USER_FLAG_S_ALL) != $st) { + $update_room = TRUE; + $user->flags = ($user->flags & ~USER_FLAG_S_ALL) | $st; + } + } while (0); + } // nick chat command + else { // normal chat line if ($curtime < ($user->chat_ban + $user->chat_dlt)) { $only_you = TRUE; @@ -1538,7 +1621,7 @@ class Room { $to_room = $to_user; } - log_legal($curtime, $user->sess, $user->name, + log_legal($curtime, $user, ($user->stat == 'room' ? 'room' : 'table '.$user->table),$msg); $user->chat_lst = "$msg"; @@ -1962,13 +2045,11 @@ class Room { // echo "LOCK: ".FTOK_PATH."/main"; // exit; if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) { - echo "FTOK FAILED"; - exit; + return (FALSE); } // echo "FTOK ".$tok."
"; if (($res = sem_get($tok)) == FALSE) { - echo "SEM_GET FAILED"; - exit; + return (FALSE); } if (sem_acquire($res)) { log_lock("LOCK room"); @@ -2324,13 +2405,16 @@ function log_auth($sess, $log) { } -function log_legal($curtime, $sess, $name, $where, $mesg) +// function log_legal($curtime, $sess, $name, $where, $mesg) +function log_legal($curtime, &$user, $where, $mesg) { GLOBAL $_SERVER; 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|\n", $curtime, $sess, $name, $_SERVER['REMOTE_ADDR'], $where , $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); } } @@ -2504,6 +2588,7 @@ function show_table_info(&$room, &$table, $table_pos) $wol = game_result($table->old_asta_pnt, $table->old_pnt); if ($win != $fri) { + /* MLANG: "
Nell'ultima mano ha chiamato %s, il socio era %s,
", "hanno fatto cappotto EBBRAVI!.
", "dovevano fare %s punti e ne hanno fatti %d: hanno %s.
", "
Nell'ultima mano %s si è chiamato in mano,
", "ha fatto cappotto EBBRAVO!.
", "doveva fare %s punti e ne ha fatti %d: ha %s.
", ($table->old_asta_pnt > 61 ? "almeno ".$table->old_asta_pnt : 'più di 60'), $table->old_pnt, ($wol == 1 ? "vinto" : ($wol == 0 ? "pareggiato" : "perso" */ $noty .= sprintf("
Nell'ultima mano ha chiamato %s, il socio era %s,
", xcape($room->user[$win]->name), xcape($room->user[$fri]->name)); @@ -2531,6 +2616,7 @@ function show_table_info(&$room, &$table, $table_pos) } } } + /* MLANG: "Fai tu il mazzo,", "Il mazzo a $unam," */ if ($table->mazzo == $table_pos) $noty .= "Fai tu il mazzo,"; else { @@ -2548,7 +2634,7 @@ function show_table_info(&$room, &$table, $table_pos) $curplayer = ($table->gstart + $table->turn) % PLAYERS_N; } - + /* MLANG: " tocca a te giocare.", " tocca a $unam giocare.", " La partita vale %s.", "torna alla partita" */ if ($curplayer == $table_pos) { $noty .= " tocca a te giocare."; } @@ -2622,8 +2708,7 @@ function show_table(&$room, &$user, $sendstep, $is_transition, $is_again) $ret .= sprintf( 'gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;', $sendstep, $user->stat, $user->subst, $table_pos); - log_rd(sprintf( 'SHOW_TABLE: gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;', - $sendstep, $user->stat, $user->subst, $table_pos)); + log_rd(sprintf( 'SHOW_TABLE: gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;', $sendstep, $user->stat, $user->subst, $table_pos)); /* BACKGROUND */ $ret .= "background_set();"; @@ -2951,5 +3036,35 @@ function sharedmem_sz($tok) return ($shm_sz); } +class Warrant { + function lock_data() + { + GLOBAL $sess; + + if (($tok = @ftok(FTOK_PATH."/warrant", "B")) == -1) { + return (FALSE); + } + // echo "FTOK ".$tok."
"; + if (($res = sem_get($tok)) == FALSE) { + return (FALSE); + } + if (sem_acquire($res)) { + log_lock("LOCK room"); + return ($res); + } + else + return (FALSE); + } + + function unlock_data($res) + { + GLOBAL $sess; + + log_lock("UNLOCK room"); + + return (sem_release($res)); + } + +} ?>