[Phpfreechat-svn] SF.net SVN: phpfreechat: [741] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-09-08 20:59:09
|
Revision: 741 http://svn.sourceforge.net/phpfreechat/?rev=741&view=rev Author: kerphi Date: 2006-09-08 13:58:59 -0700 (Fri, 08 Sep 2006) Log Message: ----------- [en] New checktimeout proxy used to disconnect timeouted users before playing a command. [fr] Nouveau proxy checktimeout dont la fonction est de d?\195?\169connecter les utilisateurs qui sont en timeout. Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/getonlinenick.class.php trunk/src/commands/update.class.php trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/proxys/checktimeout.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-08 20:56:24 UTC (rev 740) +++ trunk/src/commands/connect.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -14,10 +14,7 @@ $c =& $this->c; $u =& $this->u; - - // disconnect last connected users from the server if necessary $container =& $c->getContainerInstance(); - $disconnected_users = $container->removeObsoleteNick(NULL, $c->timeout); // reset the message id indicator (see getnewmsg.class.php) // i.e. be ready to re-get all last posted messages Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-09-08 20:56:24 UTC (rev 740) +++ trunk/src/commands/getonlinenick.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -14,18 +14,6 @@ $c =& $this->c; $container =& $c->getContainerInstance(); - - // take care to disconnect timeouted users on this channel - $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); - if (isset($disconnected_users["nick"])) - foreach ($disconnected_users["nick"] as $n) - { - $cmdp = $p; - $cmdp["param"] = _pfc("%s quit (timeout)", $n); - $cmdp["flag"] = 2; - $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $cmdp); - } // get the cached nickname list $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$recipientid; Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-09-08 20:56:24 UTC (rev 740) +++ trunk/src/commands/update.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -67,19 +67,7 @@ $cmd->run($xml_reponse, $cmdp); } - // take care to disconnect timeouted users on the server - $container =& $c->getContainerInstance(); - $disconnected_users = $container->removeObsoleteNick(NULL,$c->timeout); - // if whould be possible to echo these disconnected users on a server tab - // server tab is not yet available so I just commente the code - // foreach ($disconnected_users as $u) - // { - // $cmd =& pfcCommand::Factory("notice"); - // $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$u), $sender, $recipient, $recipientid, 2); - // } - - // do not send a response in order to save some bandwidth - // $xml_reponse->addScript("pfc.handleResponse('update', 'ok', '');"); + $xml_reponse->addScript("pfc.handleResponse('update', 'ok', '');"); } else $xml_reponse->addScript("pfc.handleResponse('update', 'ko', '');"); Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-08 20:56:24 UTC (rev 740) +++ trunk/src/pfcglobalconfig.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -41,7 +41,7 @@ var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked // these parameters are static (cached) - var $proxys = array("lock", "auth", "checknickchange", "noflood", "censor", "log"); + var $proxys = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log"); var $proxys_cfg = array("auth" => array(), "noflood" => array("limit"=>10,"delay"=>5), "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), Added: trunk/src/proxys/checktimeout.class.php =================================================================== --- trunk/src/proxys/checktimeout.class.php (rev 0) +++ trunk/src/proxys/checktimeout.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -0,0 +1,74 @@ +<?php +/** + * checktimeout.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ +require_once dirname(__FILE__)."/../pfci18n.class.php"; +require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_checktimeout + * this command disconnect obsolete users (timouted) + * an obsolete user is an user which didn't update his stats since more than 20 seconds (timeout value) + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_checktimeout extends pfcProxyCommand +{ + function run(&$xml_reponse, $p) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + + $c =& $this->c; + $u =& $this->u; + + if ( $this->name == 'update' || + $this->name == 'connect' ) + { + // disconnect users from the server pool + $container =& $c->getContainerInstance(); + $disconnected_users = $container->removeObsoleteNick(NULL,$c->timeout); + } + + if ( $this->name == 'getonlinenick' ) + { + // disconnect users from specific channels + $container =& $c->getContainerInstance(); + $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); + if (isset($disconnected_users["nick"])) + foreach ($disconnected_users["nick"] as $n) + { + $cmdp = $p; + $cmdp["param"] = _pfc("%s quit (timeout)", $n); + $cmdp["flag"] = 2; + $cmd =& pfcCommand::Factory("notice"); + $cmd->run($xml_reponse, $cmdp); + } + } + + // forward the command to the next proxy or to the final command + $this->next->run($xml_reponse, $p); + } +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |