X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Findex.php;h=70e1ddd37b5fed12cc92e185a451f3099317ac68;hb=7bccbb21239ca3cecf2914e9b307ab1e1b1aa46e;hp=09ee3877b2b69c525dea27a84df83e570fa73779;hpb=d0776ad61b6e5d15a0c57d20609abcd150998cef;p=brisk.git diff --git a/web/index.php b/web/index.php index 09ee387..70e1ddd 100644 --- a/web/index.php +++ b/web/index.php @@ -237,24 +237,71 @@ function poll_dom() { return ''; } -function carousel_top() +function sidebanners_init($sidebanner_idx) { - $what = rand(1,2); - if ($what == 1) { - $rn = rand(1, 3); - return (sprintf('il negozio virtuale di Brisk', $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; } - else { - return (sprintf('il nuovo blog di Brisk')); + $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_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; @@ -270,8 +317,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; } @@ -283,16 +332,17 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo if (isset($BRISK_SHOWHTML) == FALSE) { $is_table = FALSE; - log_main("lock Room"); + log_main("lock Brisk"); $curtime = time(); /* Actions */ 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) { + if (($user = &$brisk->get_user($sess, &$idx)) != FALSE) { + $brisk->sess_cur_set($user->sess); log_main("user stat: ".$user->stat); if ($user->stat == "table") { $cookies = new Cookies(); @@ -306,25 +356,33 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo } } + $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, $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") { @@ -337,7 +395,7 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo } // setcookie ("sess", "", time() + 180); - $room->standup_update(&$user); + $brisk->standup_update(&$user); } else { /* Login Rendering */ @@ -382,8 +440,8 @@ 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; @@ -817,7 +875,7 @@ google_color_url = "000000"; // MLANG garantisci .$mlang_room['tit_splash'][$G_lang]. '
-'.($user->flags & USER_FLAG_AUTH ? ' +'.($user->is_auth() ? ' 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; @@ -923,13 +982,8 @@ supported by:
g_withflash = DetectFlashVer(6,0,0); @@ -969,18 +1023,7 @@ supported by:
printf("
\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("%s", $G_sidebanner2); - } + sidebanners_render($G_sidebanner, $G_sidebanner_idx); printf("
"); ?> @@ -1056,6 +1099,7 @@ 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; @@ -1094,13 +1138,7 @@ 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, "", 80, 2, null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);}); @@ -1160,19 +1198,7 @@ if ($is_login) { printf("
\n"); 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("%s", $G_sidebanner2); - } + sidebanners_render($G_sidebanner, $G_sidebanner_idx); printf("
"); ?>