X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=62946ed10a3d356c1d4468d355ad43920b67f16a;hb=b1bb4eedabda830bd520f773928cd848c5dcb11a;hp=af2a9012c57b6309e879eb4bca324ae9b2eaad5c;hpb=22d0d66d55607bc8941922fc1bf4d818664abbc2;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index af2a901..62946ed 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -2,7 +2,7 @@ /* * brisk - brisk.phh * - * Copyright (C) 2006-2011 Matteo Nastasi + * Copyright (C) 2006-2012 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -45,10 +45,13 @@ define('COMM_GEN_N', 50); define('CHAT_N', 3); define('CHAT_ILL_TIME', 6); +define('CHAT_ENABLED', TRUE); define('SESS_LEN', 13); define('STREAM_TIMEOUT', 60); /* FIXME: move to sac-a-push .phh */ +/* TIME_RD define the server-side timeout, after half of it a ping request + is sent to client, after this time the client is log out */ define('EXPIRE_TIME_RD', 180); define('EXPIRE_TIME_SMAMMA', 360); define('EXPIRE_TIME_WAG', 10); @@ -283,7 +286,7 @@ Copyright 2006-2012 Matteo Nasta declaration briscola in ajax sauce (Beta)
version '.$G_brisk_version.'

-Copyright 2006-2009
Matteo Nastasi (aka mop)

'); +Copyright 2006-2012 Matteo Nastasi (aka mop)

'); function mop_flush() { @@ -677,7 +680,7 @@ class Room { var $match; var $comm; // commands for many people var $step; // current step of the comm array - // externalized var $garbage_timeout; + var $garbage_timeout; var $shm_sz; function Room () { @@ -706,8 +709,7 @@ class Room { else $this->table[$i]->auth_only = FALSE; } - // externalized $this->garbage_timeout = 0; - Room::garbage_time_expire_set(0); + $this->garbage_timeout = 0; $this->shm_sz = SHM_DIMS_MIN; } @@ -722,8 +724,7 @@ class Room { /* Garbage collector degli utenti in timeout */ $curtime = time(); - // externalized if ($force || $this->garbage_timeout < $curtime) { - if (!$force && !Room::garbage_time_is_expired($curtime)) { + if (!$force && !($this->garbage_timeout < $curtime)) { return ($ismod); } @@ -871,8 +872,7 @@ class Room { } log_rd2("GARBAGE UPDATED!"); - // externalized $this->garbage_timeout = time() + GARBAGE_TIMEOUT; - Room::garbage_time_expire_set($curtime + GARBAGE_TIMEOUT); + $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT; $ismod = TRUE; return ($ismod); @@ -1478,7 +1478,7 @@ class Room { else { // normal chat line $is_normchat = TRUE; - if ($curtime < ($user->chat_ban + $user->chat_dlt)) { + if (CHAT_ENABLED && $curtime < ($user->chat_ban + $user->chat_dlt)) { $only_you = TRUE; $user->chat_dlt = $user->chat_dlt * 2; if ($user->chat_dlt > 120) @@ -1486,7 +1486,7 @@ class Room { } else if ($user->chat_lst == $msg) $only_you = TRUE; - else if ($curtime - $user->chattime[($user->chat_cur + 1) % CHAT_N] < CHAT_ILL_TIME) { + else if (CHAT_ENABLED && $curtime - $user->chattime[($user->chat_cur + 1) % CHAT_N] < CHAT_ILL_TIME) { $user->chat_ban = $curtime; $user->chat_dlt = 5; $only_you = TRUE; @@ -1652,9 +1652,9 @@ class Room { * if ($idx == -$idx && ret == user) => SUCCESS (but the login exists in the auth db) */ - function add_user(&$sess, &$idx, $name, $pass, $ip) + function add_user(&$sess, &$idx, $name, $pass, $ip, $cookie) { - GLOBAL $G_base, $CO_list; + GLOBAL $G_base; $idx = 0; @@ -1794,12 +1794,12 @@ class Room { $this->user[$idx]->code = $authenticate->code_get(); $this->user[$idx]->flags |= USER_FLAG_LISTAUTH; - if (isset($CO_list)) { - if (strcmp($CO_list, "auth") == 0) { + if (isset($cookie['CO_list'])) { + if (strcmp($cookie['CO_list'], "auth") == 0) { $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH; $this->user[$idx]->flags |= USER_FLAG_LISTAUTH; } - if (strcmp($CO_list, "isolation") == 0) { + if (strcmp($cookie['CO_list'], "isolation") == 0) { $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH; $this->user[$idx]->flags |= USER_FLAG_ISOLAUTH; } @@ -2132,52 +2132,12 @@ class Room { return ($ret); } - static function garbage_time_is_expired($tm) - { - $ret = TRUE; - $fp = FALSE; - do { - if (file_exists(PROXY_PATH) == FALSE) - mkdir(PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(PROXY_PATH."/garbage_time.expired", 'rb')) == FALSE) - break; - if (($s = fread($fp, 4)) == FALSE) - break; - if (mb_strlen($s, "ASCII") != 4) - break; - $arr = unpack('Le', $s); - if ($arr['e'] > $tm) - $ret = FALSE; - } while (0); - - if ($fp != FALSE) - fclose($fp); - - log_rd2("END: return ".($ret ? "TRUE" : "FALSE")); - - return ($ret); - } - - static function garbage_time_expire_set($tm) - { - do { - if (file_exists(PROXY_PATH) == FALSE) - mkdir(PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(PROXY_PATH."/garbage_time.expired", 'wb')) == FALSE) - break; - fwrite($fp, pack("L",$tm)); - fclose($fp); - - return (TRUE); - } while (0); - - return (FALSE); - } - function request_mgr(&$s_a_p, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie) { printf("NEW_SOCKET (root): %d\n", intval($new_socket)); + force_no_cache($header_out); + switch ($path) { case "": case "index.php": @@ -2186,8 +2146,6 @@ class Room { $content = ob_get_contents(); ob_end_clean(); - force_no_cache($header_out); - $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content); return TRUE; @@ -2198,8 +2156,6 @@ class Room { $content = ob_get_contents(); ob_end_clean(); - force_no_cache($header_out); - $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content); return TRUE;