From: Matteo Nastasi (mop) Date: Sun, 2 Nov 2008 17:39:32 +0000 (+0000) Subject: js refact and first part of md5 login X-Git-Tag: 3.0.0~214 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=bc29696ba05142894c798c81931ab2bf23dae5c3;p=brisk.git js refact and first part of md5 login --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 6ee017f..2614137 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -27,7 +27,7 @@ define(BRISK_CONF, "brisk.conf.pho"); define(FTOK_PATH, "/var/lib/brisk"); define(LEGAL_PATH, "/tmp/legal_brisk"); define(PROXY_PATH, "/var/lib/brisk_proxy"); -define(TABLES_N, 32); +define(TABLES_N, 12); define(PLAYERS_N, 3); define(MAX_POINTS, 5); define(MAX_PLAYERS, (20 + (PLAYERS_N * TABLES_N))); @@ -987,9 +987,9 @@ class Room { $ret .= sprintf('$("myname").innerHTML = "%s";', xcape($user->name)); for ($i = 0 ; $i < TABLES_N ; $i++) { $ret .= $this->table_content($user, $i); - $act_content = table_act_content(($user->subst == 'standup'), + $ret .= table_act_content(($user->subst == 'standup'), $this->table[$i]->player_n, $i, $user->table); - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $i, $act_content); + // $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $i, $act_content); if ($this->table[$i]->wag_own != NULL) $ret .= sprintf('tra.add(%d, "%s: %s"); ', $i, $this->table[$i]->wag_own->name, $this->table[$i]->wag_com); else @@ -1067,8 +1067,8 @@ class Room { $ret .= $this->table_content($user_cur, $table_idx); $ret .= $this->standup_content($user_cur); - $act_content = table_act_content(FALSE, 0, $table_idx, $user->table); - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); + $ret .= table_act_content(FALSE, 0, $table_idx, $user->table); + // $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); if ($user_cur == $user) { @@ -1076,13 +1076,15 @@ class Room { $ret .= 'subst = "standup"; tra.show(); '; // clean the action buttons in other tables for ($e = 0 ; $e < TABLES_N ; $e++) { - if ($this->table[$e]->player_n < PLAYERS_N) - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, table_act_content(TRUE, 0, $e, $user->table)); + if ($this->table[$e]->player_n < PLAYERS_N) { + // $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, table_act_content(TRUE, 0, $e, $user->table)); + $ret .= table_act_content(TRUE, 0, $e, $user->table); + } } } else { - $act_content = table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table); - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); + $ret .= table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table); + // $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); } } log_wr("ROOM_WAKEUP: ".$ret); @@ -1156,8 +1158,8 @@ class Room { $ret .= $this->table_content($user_cur, $table_idx); $ret .= $this->standup_content($user_cur); - $act_content = table_act_content(FALSE, 0, $table_idx, $user_cur->table); - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); + $ret .= table_act_content(FALSE, 0, $table_idx, $user_cur->table); + // $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); for ($tab_idx = 0 ; $tab_idx < $user_tab_n ; $tab_idx++) if ($user_cur == $user_tab[$tab_idx]) @@ -1183,8 +1185,8 @@ class Room { log_main("JOIN_WAKEUP wup_idx ".$wup_idx." wup_n ".$user_wup_n); log_main("JOIN_WAKEUP more"); - $act_content = table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table); - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); + $ret .= table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table); + // $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); log_main("JOIN_WAKEUP end more"); } log_wr("ROOM_JOIN_WAKEUP: ".$ret); @@ -1264,14 +1266,14 @@ class Room { $ret .= 'subst = "sitdown"; tra.hide(); '; // clean the action buttons in other tables for ($e = 0 ; $e < TABLES_N ; $e++) { - $act_content = table_act_content(FALSE, 0, $e, $user_cur->table); - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, $act_content); + $ret .= table_act_content(FALSE, 0, $e, $user_cur->table); + // $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, $act_content); } } else if ($table_idx > -1) { if ($table->player_n == PLAYERS_N) { - $act_content = table_act_content(($user_cur->subst == 'standup'), PLAYERS_N, $table_idx, $user_cur->table); - $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); + $ret .= table_act_content(($user_cur->subst == 'standup'), PLAYERS_N, $table_idx, $user_cur->table); + // $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content); } } $user_cur->comm[$user_cur->step % COMM_N] = $ret; @@ -1683,7 +1685,6 @@ class Room { { GLOBAL $sess; - $ret = FALSE; $shm = FALSE; // var_dump($room); @@ -1711,7 +1712,7 @@ class Room { if ($shm) shm_detach($shm); - return ($ret); + return (FALSE); } function lock_data() @@ -1746,7 +1747,7 @@ class Room { return (sem_release($res)); } - function standup_content($user) + function standup_content_old($user) { $ret = ""; $content = ""; @@ -1791,8 +1792,53 @@ class Room { return ($ret); } + + + + function standup_content($user) + { + $ret = ""; + $content = ""; + + if ($user->stat != 'room') + return; + + for ($e = 0 , $ct = 0 ; $ct < 4 && $e < MAX_PLAYERS ; $e++) { + if ($this->user[$e]->sess == "" || $this->user[$e]->stat != "room" || $this->user[$e]->name == "") + continue; + $ct++; + } + + // $content .= sprintf('', $ct); + + $content = ' j_stand_cont( [ '; + + for ($e = 0 , $ct = 0 ; $e < MAX_PLAYERS ; $e++) { + if ($this->user[$e]->sess == "" || $this->user[$e]->stat != "room" || $this->user[$e]->name == "") + continue; + + $flags = 0; + + if ($this->user[$e]->subst == "standup") { + if ($this->user[$e] == $user) + { + $flags |= 1; + } + + $content .= sprintf('%s[ %d, \'%s\' ]',($ct > 0 ? ', ' : ''), $flags, xcape($this->user[$e]->name)); + $ct++; + } + } + $content .= ' ]);'; + + // $content2 = ''; + // $ret .= sprintf('$("standup").innerHTML = "%s"; $("esco").innerHTML = "%s";', + // $content, $content2); + + return ($content); + } - function table_content($user, $table_idx) + function table_content_old($user, $table_idx) { $content = ""; $ret = ""; @@ -1830,6 +1876,42 @@ class Room { } + function table_content($user, $table_idx) + { + $content = ""; + $ret = ""; + // TODO + // + // Si possono usare i dati nella classe table + // + + $sess = $user->sess; + $table = &$this->table[$table_idx]; + + if ($user->stat != 'room') + return; + + $content = "[ "; + for ($i = 0 ; $i < $table->player_n ; $i++) { + $user_cur = &$this->user[$table->player[$i]]; + + $flags = 0; + + if ($user_cur == $user) + $flags = 1; + + log_main($user_cur->name. sprintf(" IN TABLE [%d]", $table_idx)); + + $content .= sprintf('%s[ %d, \'%s\' ]',($i == 0 ? '' : ', '), $flags, xcape($user_cur->name)); + } + + $content .= ' ]'; + + $ret .= sprintf('j_tab_cont(%d, %s);', $table_idx, $content); + + return ($ret); + } + } // end class Room function make_seed() @@ -2088,7 +2170,7 @@ function unlock_banlist($res) return (sem_release($res)); } -function table_act_content($isstanding, $sitted, $table, $cur_table) +function table_act_content_old($isstanding, $sitted, $table, $cur_table) { $ret = ""; @@ -2106,6 +2188,27 @@ function table_act_content($isstanding, $sitted, $table, $cur_table) return ($ret); } +function table_act_content($isstanding, $sitted, $table, $cur_table) +{ + $ret = ""; + + if ($isstanding) { + if ($sitted < PLAYERS_N) { + $act = 'sit'; + } + } + else { + if ($table == $cur_table) + $act = 'wake'; + else + $act = 'none'; + } + + if ($act != '') + $ret = sprintf('j_tab_act_cont(%d, \'%s\');', $table, $act); + + return ($ret); +} function show_notify($text, $tout, $butt, $w, $h) { diff --git a/web/commons.js b/web/commons.js index 896d072..c950435 100644 --- a/web/commons.js +++ b/web/commons.js @@ -239,6 +239,26 @@ function send_mesg(mesg) } } +function server_request(mesg) +{ + var xhr_wr = createXMLHttpRequest(); + + var is_conn = (sess == "not_connected" ? false : true); + + console.log("server_request:preresp: "+xhr_wr.responseText); + + xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, false); + xhr_wr.onreadystatechange = function() { return; }; + xhr_wr.send(null); + + if (xhr_wr.responseText != null) { + console.log("server_request:resp: "+xhr_wr.responseText); + return (xhr_wr.responseText); + } + else + return (null); +} + /* Stat: CHAT and TABLE */ function chatt_checksend(obj,e) diff --git a/web/index.php b/web/index.php index e18625e..6949055 100644 --- a/web/index.php +++ b/web/index.php @@ -336,6 +336,7 @@ supported by:

+ @@ -376,15 +377,18 @@ supported by:




Digita il tuo nickname per accedere ai tavoli della briscola.
-
-
+ + +
user: - - + + +
pwd: +
(se usi firefox e qualcosa non funziona
prova a ricaricare la pagina con Ctrl + F5)
-
+



@@ -414,6 +418,7 @@ Digita il tuo nickname per accedere ai tavoli della briscola.
+ diff --git a/web/index_wr.php b/web/index_wr.php index 56fd416..974d345 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -25,6 +25,7 @@ */ require_once("Obj/brisk.phh"); +require_once("Obj/auth.phh"); // require_once("Obj/proxyscan.phh"); require_once("briskin5/Obj/briskin5.phh"); @@ -65,7 +66,39 @@ if (($user = &$room->get_user($sess, &$idx)) == FALSE) { Room::unlock_data($sem); $argz = explode('|', $mesg); - if ($argz[0] == 'help') { + if ($argz[0] == 'getchallenge') { + if (($a_sem = Challenges::lock_data()) != FALSE) { + log_main("chal lock data success"); + + if (($chal = &Challenges::load_data()) != FALSE) { + $chal_save = FALSE; + $curtime = time(); + + $chal_save |= $chal->garbage_manager(); + $token = uniqid(""); + // echo '2|'.$argz[1].'|'.$token.'|'.$_SERVER['REMOTE_ADDR'].'|'.$curtime.'|'; + // exit; + + if ($chal->add($argz[1], $token, $_SERVER['REMOTE_ADDR'], $curtime) != FALSE) { + echo '0|'.$token; + $chal_save = TRUE; + } + else { + echo '1|'; + } + if ($chal_save) { + Challenges::save_data(&$chal); + } + } + + + Challenges::unlock_data($a_sem); + } + } + else if ($argz[0] == 'auth') { + printf("challenge|ok"); + } + else if ($argz[0] == 'help') { echo show_notify(str_replace("\n", " ", $G_room_help), 0, "torna ai tavoli", 600, 500); } else if ($argz[0] == 'about') { @@ -79,7 +112,7 @@ if (($user = &$room->get_user($sess, &$idx)) == FALSE) { } else { log_wr("Get User Error"); - echo "Get User Error"; + echo "Get User Error:" + $argz[0]; } exit; } diff --git a/web/preload_img.js b/web/preload_img.js index 46e9fd4..85f669f 100644 --- a/web/preload_img.js +++ b/web/preload_img.js @@ -1,31 +1,33 @@ var g_preload_img_arr = new Array( "briskin5/img/brisk_table_sand0.jpg", "briskin5/img/brisk_table_sand4.jpg", "briskin5/img/brisk_table_sand1.jpg", "briskin5/img/brisk_table_sand3.jpg", - "briskin5/img/brisk_table_sand2.jpg", "img/bg_spawn2.jpg", + "briskin5/img/brisk_table_sand2.jpg", "img/scighera_big.png", "briskin5/img/brisk_caller_sand4.png", "briskin5/img/brisk_caller_sand0.png", "briskin5/img/brisk_caller_sand2.png", "briskin5/img/brisk_caller_sand1.png", "briskin5/img/brisk_caller_sand3.png", "img/virtualsky_big.png", - "img/brichi_big.png", "img/forumolimpia_big.png", - "briskin5/img/33_ea.png", "briskin5/img/33_we.png", - "briskin5/img/31_we.png", "img/dynamica_big.png", - "briskin5/img/35_ea.png", "briskin5/img/35_we.png", - "briskin5/img/31_ea.png", "briskin5/img/23_ea.png", - "briskin5/img/33.png", "briskin5/img/23_we.png", - "briskin5/img/31.png", "briskin5/img/35.png", - "briskin5/img/13_ea.png", "briskin5/img/23.png", - "briskin5/img/13_we.png", "briskin5/img/cover_ea.png", - "briskin5/img/cover_we.png", "briskin5/img/cover.png", - "briskin5/img/32_ea.png", "briskin5/img/32_we.png", - "briskin5/img/13.png", "briskin5/img/32.png", - "briskin5/img/10_we.png", "briskin5/img/10_ea.png", - "briskin5/img/27_we.png", "briskin5/img/27_ea.png", - "briskin5/img/30_we.png", "briskin5/img/34_we.png", - "briskin5/img/10.png", "briskin5/img/30_ea.png", - "briskin5/img/36_we.png", "briskin5/img/36_ea.png", - "briskin5/img/34_ea.png", "briskin5/img/30.png", - "briskin5/img/37_we.png", "briskin5/img/38_we.png", - "briskin5/img/36.png", "briskin5/img/37_ea.png", - "briskin5/img/38_ea.png", "briskin5/img/38.png", + "img/bcm_tor080517.gif", "img/brichi_big.png", + "img/forumolimpia_big.png", "img/brisk_meetingbig150.png", + "img/brisk_half.png", "briskin5/img/33_ea.png", + "briskin5/img/33_we.png", "briskin5/img/31_we.png", + "img/dynamica_big.png", "briskin5/img/35_ea.png", + "briskin5/img/35_we.png", "briskin5/img/31_ea.png", + "briskin5/img/23_ea.png", "briskin5/img/33.png", + "briskin5/img/23_we.png", "briskin5/img/31.png", + "briskin5/img/35.png", "briskin5/img/13_ea.png", + "briskin5/img/23.png", "briskin5/img/13_we.png", + "briskin5/img/cover_ea.png", "briskin5/img/cover_we.png", + "briskin5/img/cover.png", "briskin5/img/32_ea.png", + "briskin5/img/32_we.png", "briskin5/img/13.png", + "briskin5/img/32.png", "briskin5/img/10_we.png", + "briskin5/img/10_ea.png", "briskin5/img/27_we.png", + "briskin5/img/27_ea.png", "briskin5/img/30_we.png", + "briskin5/img/34_we.png", "briskin5/img/10.png", + "briskin5/img/30_ea.png", "briskin5/img/36_we.png", + "briskin5/img/36_ea.png", "briskin5/img/34_ea.png", + "briskin5/img/30.png", "briskin5/img/37_we.png", + "briskin5/img/38_we.png", "briskin5/img/36.png", + "briskin5/img/37_ea.png", "briskin5/img/38_ea.png", + "briskin5/img/38.png", "img/bug_bannerbig80.png", "briskin5/img/27.png", "briskin5/img/34.png", "briskin5/img/37.png", "img/virtualsky80x15a.gif", "briskin5/img/39_we.png", "briskin5/img/03_we.png", @@ -68,8 +70,11 @@ var g_preload_img_arr = new Array( "briskin5/img/18.png", "briskin5/img/15_ea.png", "briskin5/img/15_we.png", "briskin5/img/29_we.png", "briskin5/img/29_ea.png", "briskin5/img/29.png", - "briskin5/img/15.png", "img/brisk_logo64.png", - "img/download_now_flash.gif", "briskin5/img/asta3.png", + "briskin5/img/15.png", "img/brisk_meeting_title_hi.png", + "img/bug_bannermid.png", "img/brisk_meeting_title_low.png", + "img/brisk_logo64.png", "img/brisk_meeting60.png", + "img/bug_bannersmall.png", "img/download_now_flash.gif", + "briskin5/img/asta3.png", "img/brisk_meeting60_foto.gif", "briskin5/img/asta8.png", "briskin5/img/asta7.png", "briskin5/img/asta4.png", "briskin5/img/astapasso.png", "briskin5/img/asta3_ro.png", "briskin5/img/asta8_ro.png", @@ -91,29 +96,31 @@ var g_preload_img_arr = new Array( "briskin5/img/exitlock0n.png", "briskin5/img/exitlock3y.png", "briskin5/img/exitlock2y.png", "briskin5/img/exitlock0y.png", "img/brisk_start.png", "img/noimg.png", - "img/brisk_ico.png"); + "img/brisk_ico.png", "img/train.png", + "img/brisk_item6.png"); var g_preload_imgsz_arr = new Array( - "5.0", "10.1", "15.1", "20.2", "25.2", "27.9", "29.6", "31.2", - "32.9", "34.5", "36.1", "37.7", "38.9", "39.9", "40.4", "40.9", - "41.4", "42.0", "42.5", "43.0", "43.5", "44.0", "44.5", "45.1", - "45.6", "46.1", "46.6", "47.1", "47.6", "48.1", "48.6", "49.1", - "49.6", "50.1", "50.5", "51.0", "51.5", "52.0", "52.5", "53.0", - "53.4", "53.9", "54.4", "54.9", "55.3", "55.8", "56.3", "56.8", - "57.2", "57.7", "58.2", "58.7", "59.1", "59.6", "60.1", "60.5", - "61.0", "61.5", "61.9", "62.4", "62.9", "63.3", "63.8", "64.2", - "64.7", "65.1", "65.6", "66.0", "66.5", "66.9", "67.3", "67.8", - "68.2", "68.7", "69.1", "69.6", "70.0", "70.4", "70.9", "71.3", - "71.7", "72.2", "72.6", "73.1", "73.5", "73.9", "74.4", "74.8", - "75.2", "75.6", "76.1", "76.5", "76.9", "77.4", "77.8", "78.2", - "78.6", "79.0", "79.4", "79.8", "80.2", "80.7", "81.1", "81.5", - "81.9", "82.2", "82.6", "83.0", "83.4", "83.8", "84.2", "84.6", - "85.0", "85.4", "85.7", "86.1", "86.5", "86.9", "87.3", "87.6", - "88.0", "88.4", "88.8", "89.1", "89.5", "89.9", "90.3", "90.6", - "91.0", "91.4", "91.7", "92.1", "92.5", "92.8", "93.2", "93.5", - "93.9", "94.2", "94.6", "94.8", "95.0", "95.2", "95.4", "95.6", - "95.7", "95.9", "96.1", "96.2", "96.4", "96.5", "96.7", "96.8", - "97.0", "97.1", "97.2", "97.4", "97.5", "97.6", "97.7", "97.9", - "98.0", "98.1", "98.2", "98.3", "98.4", "98.6", "98.7", "98.8", - "98.9", "99.0", "99.0", "99.1", "99.2", "99.3", "99.3", "99.4", - "99.5", "99.5", "99.6", "99.7", "99.7", "99.8", "99.9", "99.9", - "100.0"); + "4.8", "9.6", "14.4", "19.2", "24.0", "26.6", "28.1", "29.7", + "31.3", "32.8", "34.4", "35.9", "37.2", "38.4", "39.3", "40.1", + "40.8", "41.3", "41.8", "42.3", "42.8", "43.3", "43.8", "44.3", + "44.8", "45.3", "45.8", "46.2", "46.7", "47.2", "47.7", "48.2", + "48.6", "49.1", "49.6", "50.0", "50.5", "51.0", "51.4", "51.9", + "52.4", "52.8", "53.3", "53.7", "54.2", "54.6", "55.1", "55.5", + "56.0", "56.5", "56.9", "57.4", "57.8", "58.3", "58.7", "59.1", + "59.6", "60.0", "60.5", "60.9", "61.4", "61.8", "62.3", "62.7", + "63.1", "63.6", "64.0", "64.4", "64.9", "65.3", "65.7", "66.1", + "66.6", "67.0", "67.4", "67.8", "68.2", "68.7", "69.1", "69.5", + "69.9", "70.3", "70.8", "71.2", "71.6", "72.0", "72.4", "72.8", + "73.2", "73.7", "74.1", "74.5", "74.9", "75.3", "75.7", "76.1", + "76.5", "76.9", "77.3", "77.7", "78.1", "78.5", "78.9", "79.3", + "79.7", "80.1", "80.4", "80.8", "81.2", "81.6", "81.9", "82.3", + "82.7", "83.1", "83.4", "83.8", "84.2", "84.5", "84.9", "85.3", + "85.6", "86.0", "86.3", "86.7", "87.1", "87.4", "87.8", "88.1", + "88.5", "88.8", "89.2", "89.5", "89.9", "90.2", "90.6", "90.9", + "91.3", "91.6", "91.9", "92.3", "92.6", "92.9", "93.3", "93.6", + "93.9", "94.2", "94.5", "94.7", "94.9", "95.1", "95.2", "95.4", + "95.6", "95.7", "95.9", "96.1", "96.2", "96.4", "96.5", "96.7", + "96.8", "96.9", "97.1", "97.2", "97.3", "97.5", "97.6", "97.7", + "97.8", "97.9", "98.0", "98.2", "98.3", "98.4", "98.5", "98.6", + "98.7", "98.8", "98.9", "99.0", "99.1", "99.1", "99.2", "99.3", + "99.3", "99.4", "99.5", "99.5", "99.6", "99.7", "99.7", "99.8", + "99.8", "99.9", "99.9", "99.9", "100.0");