X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=5e4f790e5250772da1a44fda7e19a36f448040bb;hb=5216f8f047b265aa444efb7c3c9cf8acd66eee84;hp=8118b8cdee12629af791466c48ca06f168cbc6b9;hpb=fd19aa57f6308c957ae05bfaf5dd78822f2333dd;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 8118b8c..5e4f790 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -2,7 +2,7 @@ /* * brisk - brisk.phh * - * Copyright (C) 2006-2012 Matteo Nastasi + * Copyright (C) 2006-2013 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -133,20 +133,29 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi', 'tit_onisol'=>array( 'it' => '(isolam.to)', 'en' => '(isolation)'), 'db_failed' =>array('it' => '
Il collegamento al database è fallito.
Temporaneamente tutte le autenticazioni verranno sospese, accederai a Brisk come un utente normale.

Ci scusiamo per il disagio.', - 'en' => 'Connection to the database failed
All authentications are suspended temporarly, you login as normal user.
We are about the limitation') - - + 'en' => 'Connection to the database failed
All authentications are suspended temporarly, you login as normal user.
We are about the limitation'), + + 'tos_old' => array( 'it' => '%s ha sottoscritto dei Termini del Servizio antecedenti a quelli necessari per poter richiedere questa funzionalità.', + 'en' => 'EN %s ha sottoscritto dei Termini del Servizio antecedenti a quelli necessari per poter richiedere questa funzionalità.'), + 'gua_nfd' => array( 'it' => 'Non è stato trovato un garante per %s.', + 'en' => 'EN Non è stato trovato un garante per %s.'), + 'gua_self' => array( 'it' => '%s si è auto-garantito.', + 'en' => 'EN %s si è auto-garantito.'), + 'gua_info' => array( 'it' => 'Il garante di %s è %s.', + 'en' => 'EN Il garante di %s è %s.'), + 'gua_err' => array( 'it' => 'Error %d. Utilizzo: /guar <login>.', + 'en' => 'Error %d. Usage: /guar <login>.') ); $G_lng = langtolng($G_lang); $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "4.7.2"; +$G_brisk_version = "4.12.3"; /* MLANG: ALL THE INFO STRINGS IN brisk.phh */ -$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': prova il nuovo azioni->preferenze.', +$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': razionalizzato il menu, aggiunto il bottone LIKE di facebook per la nuova pagina del sito, e fix volanti.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ), - 'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NEWS: server-side infrastructure to manage user preferences added and S customization added.', + 'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NEWS: refactored vertical menu, facebook LIKE button added and dirty fixes.', 'If you want to subscribe our Mailing List, click it!' ) ); $G_room_help = array( 'it' => ' @@ -173,6 +182,8 @@ Dopo che è iniziata una partita per uscirne dovete chiedere agli altri gi
/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\\" +
/cont <id partita> - quando si è a un tavolo per garantiti, permette di proseguire una partita giocata in precedenza con gli stessi giocatori +
/guar <login> - mostra il garante dell\'utente con il login passato come argomento
/authreq - se si è autenticati permette di garantire per un utente fidato
/mesgtoadm - se si è autenticati permette di lasciare un messaggio all\'amministratore del sito
/listen <all or auth> - se si è autenticati permette leggere solo i messaggi degli altri autenticati (auth) o di tutti (all) @@ -185,7 +196,7 @@ Dopo che è iniziata una partita per uscirne dovete chiedere agli altri gi EN Descrizione
EN Questa è un\'implementazione della briscola in cinque, così come è spiegata su Wikipedia; in breve è la variante con l\'asta prima sulla carta e poi sui punti.

-EN Configurazione del browser.
+Configurazione del browser.
Occorre abilitare i cookies.

Uso del sito
@@ -204,6 +215,8 @@ Dopo che è iniziata una partita per uscirne dovete chiedere agli altri gi
/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\\" +
/cont <id partita> - quando si è a un tavolo per garantiti, permette di proseguire una partita giocata in precedenza con gli stessi giocatori +
/guar <login> - mostra il garante dell\'utente con il login passato come argomento
/authreq - se si è autenticati permette di garantire per un utente fidato
/mesgtoadm - se si è autenticati permette di lasciare un messaggio all\'amministratore del sito
/listen <all or auth> - se si è autenticati permette leggere solo i messaggi degli altri autenticati (auth) o di tutti (all) @@ -289,6 +302,36 @@ Copyright 2006-2012 Matteo Nasta
version '.$G_brisk_version.'

Copyright 2006-2012
Matteo Nastasi (aka mop)

'); +// return values +// -1 v1 < v2 +// 0 equal +// 1 v1 > v2 +function versions_cmp($v1, $v2) +{ + // printf("V1: [%s]\nV2: [%s]\n", $v1, $v2); + if ($v1 == $v2) + return 0; + + $v1_ar = split('\.', $v1); + $v2_ar = split('\.', $v2); + + $v2_ct = count($v2_ar); + + for ($i = 0 ; $i < count($v1_ar) ; $i++) { + if (($v2_ct - 1) < $i) { + break; + } + // printf("here [%s] [%s]\n", $v1_ar[$i], $v2_ar[$i]); + if ($v1_ar[$i] != $v2_ar[$i]) { + if (strval($v1_ar[$i]) < strval($v2_ar[$i])) + return -1; + else + return 1; + } + } + return 0; +} + function addrtoipv4($addr) { $ipv4addr_arr = explode(':' , $addr); @@ -364,10 +407,9 @@ function eschtml($s) function esclfhtml($s) { - return str_replace("\n", "
\n", htmlentities($s)); + return str_replace(" ", " ", str_replace("\n", "
", htmlspecialchars($s))); } - function langtolng($lang) { GLOBAL $G_lang; @@ -728,7 +770,7 @@ class Client_prefs { fprintf(STDERR, "QQ %s: %x\n", __FUNCTION__, $user->flags); $this->listen = ($user->flags & USER_FLAG_MAP_AUTH) >> 2; if ($user->rec != FALSE) { - $this->supp_comp = $user->rec->supp_comp; + $this->supp_comp = $user->rec->supp_comp_get(); } else { $this->supp_comp = "000000000000"; @@ -780,10 +822,10 @@ class Client_prefs { fprintf(STDERR, "QQ %s::%s %x\n", __CLASS__, __FUNCTION__, $user->flags); if ($user->is_supp_custom()) { - $user->rec->supp_comp = $this->supp_comp; + $user->rec->supp_comp_set($this->supp_comp); } if ($is_save) - $user->store_set(); + $user->prefs_store(); } } @@ -1256,6 +1298,63 @@ class Room } } + function guarantee_show($user, $user_login, $dt) + { + GLOBAL $G_lang, $mlang_brisk, $G_base; + + $user_code = -1; + $ret = 0; + + do { + if ($user_login == "") { + $ret = 1; + break; + } + if (($bdb = BriskDB::create()) == FALSE) { + $ret = 2; + break; + } + if (($user_item = $bdb->getitem_bylogin($user_login, $user_code)) == FALSE) { + $ret = 3; + break; + } + if (($guar_item = $bdb->getitem_bycode($user_item->guar_code_get())) != FALSE) { + $guar_login = $guar_item->login_get(); + } + else { + $guar_login = ""; + } + $user_tos_vers = $user_item->tos_vers_get(); + + if (versions_cmp($user_tos_vers, "1.2") < 0) { + $mesg = sprintf('chatt_sub("%s", [2, "%s"],"%s");', + $dt, NICKSERV, sprintf($mlang_brisk['tos_old'][$G_lang], xcape($user_login))); + } + else if ($guar_login == "") { + $mesg = sprintf('chatt_sub("%s", [2, "%s"],"%s");', + $dt, NICKSERV, sprintf($mlang_brisk['gua_nfd'][$G_lang], xcape($user_login))); + } + else if ($guar_login == $user_login) { + $mesg = sprintf('chatt_sub("%s", [2, "%s"],"%s");', + $dt, NICKSERV, sprintf($mlang_brisk['gua_self'][$G_lang], xcape($user_login))); + } + else { + $mesg = sprintf('chatt_sub("%s", [2, "%s"],"%s");', + $dt, NICKSERV, sprintf($mlang_brisk['gua_info'][$G_lang], + xcape($user_login), xcape($guar_login))); + } + } while (0); + + if ($ret > 0) { + $mesg = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, sprintf($mlang_brisk['gua_err'][$G_lang], $ret)); + } + + $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ".$mesg; + $user->step_inc(); + + return TRUE; + } + function room_outstandup($user) { $this->room_sitdown($user, -1); @@ -1292,54 +1391,53 @@ class Room function room_sitdown($user, $table_idx) { - log_main("room_sitdown ".($user == FALSE ? "USER: FALSE" : "USER: ".$user->name)); - - $train_app = ""; - - if ($table_idx > -1 && $table_idx < TABLES_N) { - $table = $this->table[$table_idx]; - - // wagon shutdown - if ($table->wag_own != -1 && $table->player_n == PLAYERS_N) { - for ($i = 0 ; $i < TABLES_N ; $i++) { - if ($table->wag_own == $table->player[$i]) { - $train_app = sprintf("tra.rem(%d); ", $table_idx); - $table->wag_reset(time()); - break; - } - } - } - } - - for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { - $ret = ""; - $user_cur = $this->user[$i]; - if ($user_cur->sess == '' || $user_cur->stat != 'room') - continue; + log_main("room_sitdown ".($user == FALSE ? "USER: FALSE" : "USER: ".$user->name)); - $ret = "gst.st = ".($user_cur->step+1)."; ".$train_app; - if ($table_idx > -1) - $ret .= $this->table_content($user_cur, $table_idx); - $ret .= $this->standup_content($user_cur); + $train_app = ""; - if ($user->idx_get() == $i) { - $ret .= 'subst = "sitdown"; tra.hide(); '; - // clean the action buttons in other tables - for ($e = 0 ; $e < TABLES_N ; $e++) { - // $ret .= table_act_content(FALSE, 0, $e, $user_cur->table, FALSE); - $ret .= $this->table[$e]->act_content($user_cur); - } + if ($table_idx > -1 && $table_idx < TABLES_N) { + $table = $this->table[$table_idx]; + + // wagon shutdown + if ($table->wag_own != -1 && $table->player_n == PLAYERS_N) { + for ($i = 0 ; $i < TABLES_N ; $i++) { + if ($table->wag_own == $table->player[$i]) { + $train_app = sprintf("tra.rem(%d); ", $table_idx); + $table->wag_reset(time()); + break; + } + } + } } - 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); - } + + for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { + $ret = ""; + $user_cur = $this->user[$i]; + if ($user_cur->sess == '' || $user_cur->stat != 'room') + continue; + + $ret = "gst.st = ".($user_cur->step+1)."; ".$train_app; + if ($table_idx > -1) + $ret .= $this->table_content($user_cur, $table_idx); + $ret .= $this->standup_content($user_cur); + + if ($user->idx_get() == $i) { + $ret .= 'subst = "sitdown"; tra.hide(); '; + // clean the action buttons in other tables + for ($e = 0 ; $e < TABLES_N ; $e++) { + $ret .= $this->table[$e]->act_content($user_cur); + } + } + 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); + } + } + $user_cur->comm[$user_cur->step % COMM_N] = $ret; + $user_cur->step_inc(); } - $user_cur->comm[$user_cur->step % COMM_N] = $ret; - $user_cur->step_inc(); - } } function chatt_send($user, $mesg) @@ -1549,7 +1647,11 @@ class Room $update_room = TRUE; } while (0); } // nick chat command + else if (strncmp($msg, "/guar ", 6) == 0 || $msg == "/guar") { + $guar_user = substr($msg, 6); + $this->guarantee_show($user, $guar_user, $dt); + } else if (strncmp($msg, "/st ", 4) == 0) { log_main("chatt_send BEGIN"); @@ -2232,7 +2334,7 @@ class Room // sql record exists AND last donate > 2013-01-01 if ($this->user[$i]->is_supp_custom()) { - $supp_comp_s = sprintf(', "%s"', $this->user[$i]->rec->supp_comp); + $supp_comp_s = sprintf(', "%s"', $this->user[$i]->rec->supp_comp_get()); } else { $supp_comp_s = ''; @@ -2280,7 +2382,7 @@ class Room log_main($user_cur->name. sprintf(" IN TABLE [%d]", $table_idx)); if ($user_cur->is_supp_custom()) - $supp_comp_s = sprintf(', "%s"', $user_cur->rec->supp_comp); + $supp_comp_s = sprintf(', "%s"', $user_cur->rec->supp_comp_get()); else $supp_comp_s = ''; @@ -2297,6 +2399,8 @@ class Room function request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie) { + GLOBAL $G_black_list; + printf("NEW_SOCKET (root): %d PATH [%s]\n", intval($new_socket), $path); $enc = get_encoding($header); @@ -2332,7 +2436,6 @@ class Room // from the socket, waiting if necessary // - fprintf(STDERR, "\n\nDENTRO QUI\n\n"); ob_start(); index_wr_main($this, $addr, $get, $post, $cookie); $content = ob_get_contents(); @@ -2342,12 +2445,15 @@ class Room return TRUE; break; - case "index_rd_ifra.php": + case "index_rd.php": + if (($transp = gpcs_var('transp', $get, $post, $cookie)) === FALSE) + $transp = "iframe"; + if ($transp == 'websocket') + $enc = 'plain'; + do { if (!isset($cookie['sess']) || (($user = $this->get_user($cookie['sess'], $idx)) == FALSE)) { - if (($transp = gpcs_var('transp', $get, $post, $cookie)) === FALSE) - $transp = "iframe"; $content = User::stream_fini($transp, $s_a_p->rndstr, TRUE); @@ -2365,9 +2471,8 @@ class Room } $content = ""; - $user->stream_init($s_a_p->rndstr, $enc, $header_out, $content, $get, $post, $cookie); - - $response = headers_render($header_out, -1).chunked_content($user->rd_zls_get(), $content); + $user->stream_init($s_a_p->rndstr, $enc, $header, $header_out, $content, $get, $post, $cookie); + $response = headers_render($header_out, -1).$user->chunked_content($content); $response_l = mb_strlen($response, "ASCII"); $wret = @fwrite($new_socket, $response, $response_l); @@ -2847,6 +2952,19 @@ function show_notify_ex($text, $tout, $butt, $w, $h, $is_opaque, $block_time) return sprintf('var noti = new notify_ex(gst,"%s",%d,"%s",%d,%d, %s, %d);', $text, $tout, $butt, $w, $h, ($is_opaque ? "true" : "false"), $block_time); } +function show_notify_document($text, $tout, $butt_arr, $confirm_func, $confirm_func_args, $w, $h, $is_opaque, $block_time) +{ + log_main("SHOW_NOTIFY OPAQUE: ".$text); + + $butts = ""; + for ($i = 0 ; $i < count($butt_arr) ; $i++) { + $butts .= sprintf("%s'%s'", ($i == 0 ? "" : ","), $butt_arr[$i]); + } + + return sprintf('g_nd = new notify_document(gst, "%s", %d, [ %s ], %s, %s, %d, %d, %s, %d);|', + escpush($text), $tout, $butts, ($confirm_func == NULL ? "null" : $confirm_func), (($confirm_func == NULL|| $confirm_func_args == NULL) ? "[]" : $confirm_func_args), $w, $h, ($is_opaque ? "true" : "false"), $block_time); +} + function root_welcome($user) {