X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Findex.php;h=52d878f9e4ccead20bccd42bc906d6c24be6bc24;hb=6aaadfdf64934a162818929b331b7d9a20d29994;hp=0b3076ae0b81782db4fb3a5919ba0867e50ef47d;hpb=17b73d1ef533eccc7ee71961c76b9a33e19d452f;p=brisk.git diff --git a/web/index.php b/web/index.php index 0b3076a..52d878f 100644 --- a/web/index.php +++ b/web/index.php @@ -3,7 +3,7 @@ * brisk - index.php * * Copyright (C) 2006-2012 Matteo Nastasi - * mailto: nastasi@alternativeoutput.it + * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it * @@ -22,6 +22,7 @@ * */ +require_once("Obj/user.phh"); require_once("Obj/brisk.phh"); require_once("Obj/auth.phh"); require_once("Obj/proxyscan.phh"); @@ -38,8 +39,20 @@ $mlang_room = array( 'userpasserr' => array('it' => 'Utente e/o password errati 'en' => 'Standing players'), 'headline' => array('it' => 'briscola chiamata in salsa ajax', 'en' => 'declaration briscola in ajax sauce (Beta)'), - 'welcome' => array('it' => 'Digita il tuo nickname per accedere ai tavoli della briscola', - 'en' => 'Enter your nickname to access to the tables of briscola'), + 'welcome' => array('it' => 'Digita il tuo nickname per accedere ai tavoli della briscola.', + 'en' => 'Enter your nickname to access to the tables of briscola.'), + 'reas_unkn' => array('it' => 'Logout per motivi sconosciuti.', + 'en' => 'Logout with unknown reason.'), + 'reas_lout' => array('it' => 'Orevoire.', + 'en' => 'EN Orevoire.'), + 'reas_tout' => array('it' => 'Abbiamo perso le tue tracce, quindi ti abbiamo disconnesso.', + 'en' => 'EN Abbiamo perso le tue tracce, quindi ti abbiamo disconnesso.'), + 'reas_ttot' => array('it' => 'Abbiamo perso le tue tracce mentre stavi giocando, quindi ti abbiamo disconnesso.', + 'en' => 'EN Abbiamo perso le tue tracce mentre stavi giocando, quindi ti abbiamo disconnesso.'), + 'reas_anon' => array('it' => 'L\' accesso attraverso sistemi di anonimizzazione non è consentito.', + 'en' => 'EN L\' accesso attraverso sistemi di anonimizzazione non è consentito.'), + 'reas_anot' => array('it' => 'La tua sessione è stata assegnata ad un altro browser.', + 'en' => 'EN La tua sessione è stata assegnata ad un altro browser.'), 'btn_enter' => array('it' => 'entra', 'en' => 'enter'), 'passwarn' => array('it' => 'Se non hai ancora una password, lascia il campo in bianco ed entra.', @@ -96,7 +109,7 @@ $mlang_room = array( 'userpasserr' => array('it' => 'Utente e/o password errati 'en' => 'mop'), 'st_visch_desc' => array('it' => 'vischio', 'en' => 'mop'), - + 'tit_ticker' => array('it' => 'scrivi un invito al tavolo e clicca', 'en' => 'write an invitation at the table and click'), 'itm_warr' => array('it' => 'garantisci', @@ -185,6 +198,10 @@ $mlang_room = array( 'userpasserr' => array('it' => 'Utente e/o password errati 'en' => 'user\'s placings'), 'itm_cla' => array('it' => 'classifiche', 'en' => 'placings'), + 'tit_mnu' => array('it' => 'minuta giornaliera', + 'en' => 'daily report'), + 'itm_mnu' => array('it' => 'minuta', + 'en' => 'daily deport'), 'tit_rmap' => array('it' => 'prossime funzionalità implementate', 'en' => 'roadmap of next functionalities'), 'itm_rmap' => array('it' => 'roadmap', @@ -233,23 +250,76 @@ function poll_dom() { return ''; } -function carousel_top() +function sidebanners_init($sidebanner_idx) { - $rn = rand(1, 3); - return (sprintf('', $rn)); + for ($i = 0 ; $i < count($sidebanner_idx) ; $i++) { + printf(" sidebanner_init(%d);\n", $i); + } +} + +function sidebanners_render($sidebanner, $sidebanner_idx) +{ + $sb_n = count($sidebanner_idx); + if ($sb_n == 0) { + return; + } + + if ($sb_n == 1) { + printf("

"); + } + + for ($i = 0 ; $i < $sb_n ; $i++) { + $idx = $sidebanner_idx[$i]; + $sb = $sidebanner[$idx]; + if (!array_key_exists('link', $sb) + || !array_key_exists('title', $sb) + || !array_key_exists('icon_big', $sb)) { + continue; + } + $sb_type = (array_key_exists('type', $sb) ? $sb['type'] : 'meeting'); + if (array_key_exists('icon', $sb)) { + $sb_icon = $sb['icon']; + } + else { + if ($sb_type == 'meeting') { + if ($sb_n < 3) { + $sb_icon = 'img/brisk_meeting60.gif'; + } + else { + $sb_icon = 'img/brisk_meeting35.gif'; + } + } + else { + // no standard icon for other type of events please add them + continue; + } + } + $sb_dx = (array_key_exists('dx', $sb) ? $sb['dx'] : 100); + $sb_dy = (array_key_exists('dy', $sb) ? $sb['dy'] : -230); + + printf('
', $i); + printf('', $sb['link']); + printf('%s
', $tit, $tit); + printf("\n"); + printf('', $i, $sb['icon_big']); + printf("\n"); + } } -function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $cookie) +function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_full, $get, $post, $cookie) { GLOBAL $G_with_donors, $G_donors_cur, $G_donors_all; GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local; - GLOBAL $G_with_sidebanner, $G_sidebanner; - GLOBAL $G_with_sidebanner2, $G_sidebanner2; + GLOBAL $G_sidebanner, $G_sidebanner_idx; GLOBAL $G_with_poll; GLOBAL $G_lang, $G_lng, $mlang_room; GLOBAL $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER; - if (($sess = gpcs_var('sess', $get, $post, $cookie)) === FALSE) + if (($sess = gpcs_var('sess', $get, $post, $cookie)) === FALSE) $sess = ""; if (($name = gpcs_var('name', $get, $post, $cookie)) === FALSE) unset($name); @@ -260,8 +330,10 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo if (($table_token = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE) unset ($table_token); + $remote_addr = addrtoipv4($remote_addr_full); + // Use of proxies isn't allowed. - if (!$G_is_local && is_proxy($addr)) { + if (!$G_is_local && is_proxy($remote_addr)) { return FALSE; } @@ -270,54 +342,85 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo $tables = ""; $standup = ""; $ACTION = "login"; - + $last_msg = ""; + if (isset($BRISK_SHOWHTML) == FALSE) { $is_table = FALSE; - log_main("lock Room"); + log_main("lock Brisk"); $curtime = time(); - + /* Actions */ - + if (($ghost_sess = $brisk->ghost_sess->pop($sess)) != FALSE) { + switch ($ghost_sess->reas) { + case GHOST_SESS_REAS_LOUT: + $last_msg = $mlang_room['reas_lout'][$G_lang]; + break; + case GHOST_SESS_REAS_ANOT: + $last_msg = $mlang_room['reas_anot'][$G_lang]; + break; + case GHOST_SESS_REAS_TOUT: + $last_msg = $mlang_room['reas_tout'][$G_lang]; + break; + case GHOST_SESS_REAS_TTOT: + $last_msg = $mlang_room['reas_ttot'][$G_lang]; + break; + case GHOST_SESS_REAS_ANON: + $last_msg = $mlang_room['reas_anon'][$G_lang]; + break; + default: + $last_msg = $mlang_room['reas_unkn'][$G_lang]; + break; + } + } if (validate_sess($sess)) { log_main("pre garbage_manager UNO"); - $room->garbage_manager(TRUE); + $brisk->garbage_manager(TRUE); log_main("post garbage_manager"); - if (($user = &$room->get_user($sess, &$idx)) != FALSE) { - log_main("user stat: ".$user->stat); - if ($user->stat == "table") { - $cookies = new Cookies(); - $cookies->add("table_token", $user->table_token, $curtime + 31536000); - $cookies->add("table_idx", $user->table, $curtime + 31536000); - $header_out['cookies'] = $cookies; - $header_out['Location'] = "briskin5/index.php"; - return TRUE; + if (($user = &$brisk->get_user($sess, &$idx)) != FALSE) { + if ($user->the_end == FALSE) { + $brisk->sess_cur_set($user->sess); + log_main("user stat: ".$user->stat); + if ($user->stat == "table") { + $cookies = new Cookies(); + $cookies->add("table_token", $user->table_token, $curtime + 31536000); + $cookies->add("table_idx", $user->table, $curtime + 31536000); + $header_out['cookies'] = $cookies; + $header_out['Location'] = "briskin5/index.php"; + return TRUE; + } + $ACTION = "room"; } - $ACTION = "room"; } - } - + + $banned = FALSE; if ($ACTION == "login" && isset($name)) { - log_main("pre garbage_manager DUE"); - - if (isset($pass_private) == FALSE) { + + if (isset($pass_private) == FALSE || $pass_private == "") { $pass_private = FALSE; + + if ($brisk->ban_check($remote_addr)) { + // TODO: find a way to add a nonblocking sleep(5) here + $banned = TRUE; + $idx = -1; + } } - - $room->garbage_manager(TRUE); + + $brisk->garbage_manager(TRUE); /* try login */ - $ipv4addr = addrtoipv4($addr); - if (($user = $room->add_user(&$sess, &$idx, $name, $pass_private, $ipv4addr, $cookie)) != FALSE) { + if ($banned == FALSE && + ($user = $brisk->add_user(&$sess, &$idx, $name, $pass_private, $remote_addr, $header, $cookie)) != FALSE) { + $brisk->sess_cur_set($user->sess); $ACTION = "room"; if ($idx < 0) { $idx = -$idx - 1; $is_login = TRUE; } - - log_legal($curtime, $ipv4addr, $user, "STAT:LOGIN", ''); - + + log_legal($curtime, $remote_addr, $user, "STAT:LOGIN", ''); + // recovery lost game if ($user->stat == "table") { $cookies = new Cookies(); @@ -327,38 +430,33 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo $header_out['Location'] = "briskin5/index.php"; return TRUE; } - - - // setcookie ("sess", "", time() + 180); - $room->standup_update(&$user); - } else { /* Login Rendering */ /* MLANG: "Utente e/o password errati.", "Il nickname deve contenere almeno una lettera o una cifra.", "Spiacenti, non ci sono più posti liberi. Riprova più tardi.", "Il tuo nickname è già in uso." */ /* - if ($idx == -3) + if ($idx == -3) $body .= '
'.$mlang_room['userpasserr'][$G_lang].'
'; else if ($idx == -2) // $body .= '
Il nickname deve contenere almeno una lettera o una cifra.
'; $body .= '
'.$mlang_room['userpassmust'][$G_lang].'
'; - else if ($idx == -1) + else if ($idx == -1) // $body .= '
Spiacenti, non ci sono più posti liberi. Riprova più tardi.
'; $body .= '
'.$mlang_room['userpassend'][$G_lang].'
'; else // $body .= '
Il tuo nickname è già in uso.
'; $body .= '
'.$mlang_room['userpassuse'][$G_lang].'
'; */ - - if ($idx == -3) + + if ($idx == -3) $sfx = 'err'; else if ($idx == -2) $sfx = 'must'; - else if ($idx == -1) + else if ($idx == -1) $sfx = 'end'; else $sfx = 'use'; - + $body .= '
'.$mlang_room['userpass'.$sfx][$G_lang].'
'; } } @@ -376,17 +474,17 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo $tables .= '
'; $tables .= ''; for ($ii = 0 ; $ii < TABLES_N ; $ii++) { - if ($user->flags & USER_FLAG_AUTH) - $i = $ii; + if ($user->is_auth()) + $i = $ii; else $i = TABLES_N - $ii - 1; - + if ($ii % 4 == 0) { $tables .= ''; } if (TRUE || !($user->flags & USER_FLAG_ISOLAUTH) || $ii < TABLES_AUTH_N) { $tables .= '
'; - + $tables .= '
'.$mlang_room['tit_tabl'][$G_lang].$i.'
'; $tables .= sprintf('
', $i); $tables .= sprintf('
', $i); @@ -398,14 +496,13 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo } } $tables .= '
'; - - + $standup .= '
'; $standup .= '
'; /* MLANG: "Giocatori in piedi" */ // $standup .= '
Giocatori in piedi - Come ottenere user e password -
'; $standup .= '
'.$mlang_room['standing'][$G_lang].'
'; - + $standup .= sprintf('
'); // MLANG Esco. $standup .= '
'; @@ -473,9 +570,12 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo - - - $brisk_donate = file_get_contents(FTOK_PATH."/brisk_donate.txt"); + /* NOTE: Brisk donate or donate fake if local */ + if (!$G_is_local) + $brisk_donate = file_get_contents(FTOK_PATH."/brisk_donate.txt"); + else + $brisk_donate = '
BRISK_DONATE
'; + if ($brisk_donate == FALSE) $brisk_donate = ""; @@ -611,6 +711,10 @@ google_color_url = "000000"; onmouseover="menu_hide(0,1);" title="'.$mlang_room['tit_cla'][$G_lang].'" onclick="act_placing();">'.$mlang_room['itm_cla'][$G_lang].'
+'.$mlang_room['itm_mnu'][$G_lang].'
+ '.$mlang_room['itm_rmap'][$G_lang].'
@@ -805,7 +909,7 @@ google_color_url = "000000"; // MLANG garantisci .$mlang_room['tit_splash'][$G_lang]. '
-'.($user->flags & USER_FLAG_AUTH ? ' +'.($user->is_auth() ? ' '.$altout_support_big.'
-
-
-


+' . ( /* NOTE: here facebook or fake facebook */ +! $G_is_local ? +'
+' : '
FACEBOOK HERE
+' ) . '
+ %s %s -
-'; +'; /* Templates. */ if ($ACTION == 'login') { @@ -884,13 +990,15 @@ supported by:
var g_lng = ""; var g_tables_n = ; var g_tables_auth_n = ; + var g_tables_cert_n = ; var g_prefs, g_prefs_new = null; var g_listen; var g_withflash = false; var g_is_spawn = 0; + var g_nd = null; + var g_brow = null; var gst = new globst(); var topbanner_sfx, topbanner_dx; - var g_brow = null; var xstm = null; var sess = "not_connected"; var spo_slide, sup_slide; @@ -908,13 +1016,8 @@ supported by:
g_withflash = DetectFlashVer(6,0,0); @@ -928,39 +1031,46 @@ supported by:
//--> + + +
+ + +
\n"); printf($brisk_vertical_menu, '', ''); - if ($G_with_sidebanner xor $G_with_sidebanner2) { - printf("

"); - } - - if ($G_with_sidebanner) { - printf("%s", $G_sidebanner); - if ($G_with_sidebanner2) { - printf("
"); - } - } - - - if ($G_with_sidebanner2) { - printf("%s", $G_sidebanner2); - } + sidebanners_render($G_sidebanner, $G_sidebanner_idx); printf("
"); ?> -
-


+
+
+


@@ -1025,19 +1135,21 @@ echo "$body"; ?> var g_lng = ""; var g_tables_n = ; var g_tables_auth_n = ; + var g_tables_cert_n = ; var g_prefs, g_prefs_new = null; var g_listen; + var g_is_spawn = 0; + var g_withflash = false; + var g_imgct = 0; + var g_imgtot = g_preload_img_arr.length; + var g_brow = null; + var g_nd = null; var tra = null; var stat = ""; var subst = ""; var gst = new globst(); - var g_is_spawn = 0; var topbanner_sfx, topbanner_dx; // var nonunload = false; - var g_withflash = false; - var g_imgct = 0; - var g_imgtot = g_preload_img_arr.length; - var g_brow = null; var spo_slide, sup_slide; window.onload = function() { @@ -1062,16 +1174,10 @@ else { if ($G_with_topbanner) { printf(" topbanner_init();\n"); } - if ($G_with_sidebanner) { - printf(" sidebanner_init();\n"); - } - if ($G_with_sidebanner2) { - printf(" sidebanner2_init();\n"); - } - + sidebanners_init($G_sidebanner_idx); ?> sess = ""; -xstm = new xynt_streaming(window, "", null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);}); +xstm = new xynt_streaming(window, "", 80, 2, null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);}); xstm.hbit_set(heartbit); tra = new train($('room_tit')); window.onunload = onunload_cb; @@ -1102,37 +1208,36 @@ if ($is_login) { //--> + + +
+ + +
\n"); - /* printf($brisk_vertical_menu, '



', - $brisk_donate); - printf($brisk_vertical_menu, '

', - $brisk_donate);*/ - printf($brisk_vertical_menu, '
', - $brisk_donate); + printf($brisk_vertical_menu, '', $brisk_donate); - - if ($G_with_sidebanner xor $G_with_sidebanner2) { - printf("

"); - } - - if ($G_with_sidebanner) { - printf("%s", $G_sidebanner); - if ($G_with_sidebanner2) { - printf("
"); - } - } - - - if ($G_with_sidebanner2) { - printf("%s", $G_sidebanner2); - } + sidebanners_render($G_sidebanner, $G_sidebanner_idx); printf("
"); -?> +?> sess"; ?>">