[Phpfreechat-svn] SF.net SVN: phpfreechat: [662] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-08-01 18:31:50
|
Revision: 662 Author: kerphi Date: 2006-08-01 11:30:44 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=662&view=rev Log Message: ----------- Refactoring + Bug fix: the shownotice parameter was broken, this refactoring fixes it. I moved the commands parameters list into a indexed array in order to be able to add a new parameter easily (example: the flag parameter for the notice command). Modified Paths: -------------- trunk/src/commands/asknick.class.php trunk/src/commands/ban.class.php trunk/src/commands/banlist.class.php trunk/src/commands/clear.class.php trunk/src/commands/connect.class.php trunk/src/commands/debug.class.php trunk/src/commands/deop.class.php trunk/src/commands/error.class.php trunk/src/commands/getnewmsg.class.php trunk/src/commands/getonlinenick.class.php trunk/src/commands/identify.class.php trunk/src/commands/init.class.php trunk/src/commands/join.class.php trunk/src/commands/kick.class.php trunk/src/commands/leave.class.php trunk/src/commands/me.class.php trunk/src/commands/nick.class.php trunk/src/commands/notice.class.php trunk/src/commands/op.class.php trunk/src/commands/privmsg.class.php trunk/src/commands/quit.class.php trunk/src/commands/rehash.class.php trunk/src/commands/send.class.php trunk/src/commands/unban.class.php trunk/src/commands/update.class.php trunk/src/commands/updatemynick.class.php trunk/src/pfccommand.class.php trunk/src/pfcproxycommand.class.php trunk/src/phpfreechat.class.php trunk/src/proxys/auth.class.php trunk/src/proxys/censor.class.php trunk/src/proxys/lock.class.php trunk/src/proxys/noflood.class.php Modified: trunk/src/commands/asknick.class.php =================================================================== --- trunk/src/commands/asknick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/asknick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_asknick extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient) + 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; @@ -14,8 +20,10 @@ if ($c->frozen_nick) { // assign a random nick + $cmdp = $p; + $cmdp["param"] = $nicktochange."".rand(1,1000); $cmd =& pfcCommand::Factory("nick"); - $cmd->run($xml_reponse, $clientid, $nicktochange."".rand(1,1000)); + $cmd->run($xml_reponse, $cmdp); } else { Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/ban.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,7 +6,7 @@ { var $usage = "/ban {nickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; @@ -14,26 +14,27 @@ if (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } $container =& $c->getContainerInstance(); - $nickid = $container->getNickId($param); + $nickid = $container->getNickId($p["param"]); if ($nickid != "undefined") { $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $cmdtmp = array("leave", /* cmdname */ - $recipientid,/* param */ - $sender, /* sender */ - $recipient, /* recipient */ - $recipientid,/* recipientid */ + $p["recipientid"],/* param */ + $p["sender"], /* sender */ + $p["recipient"], /* recipient */ + $p["recipientid"],/* recipientid */ ); //_pfc("banished from %s by %s", $recipient, $sender); $cmdtoplay[] = $cmdtmp; // ban the user from the current channel @@ -41,13 +42,13 @@ } // update the recipient banlist - $banlist = $container->getMeta("banlist_nickid", "channel", $recipientid); + $banlist = $container->getMeta("banlist_nickid", "channel", $p["recipientid"]); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); $banlist[] = $nickid; // append the nickid to the banlist - $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $recipientid); + $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $p["recipientid"]); } } Modified: trunk/src/commands/banlist.class.php =================================================================== --- trunk/src/commands/banlist.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/banlist.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -11,13 +11,13 @@ { var $desc = "This command list the banished users on the given channel"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; $container =& $c->getContainerInstance(); - $banlist = $container->getMeta("banlist_nickid", "channel", $recipientid); + $banlist = $container->getMeta("banlist_nickid", "channel", $p["recipientid"]); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); $msg = ""; $msg .= "<p>"._pfc("The banished user's id list is:")."</p>"; Modified: trunk/src/commands/clear.class.php =================================================================== --- trunk/src/commands/clear.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/clear.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,7 +4,7 @@ class pfcCommand_clear extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/connect.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_connect extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; @@ -52,8 +58,6 @@ $container->setMeta($isadmin, "isadmin", "nickname", $nickid); // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); - - return $clientid; } } Modified: trunk/src/commands/debug.class.php =================================================================== --- trunk/src/commands/debug.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/debug.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,12 +4,12 @@ class pfcCommand_debug extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; - if ($param == "userconfig") + if ($p["param"] == "userconfig") { $msg = ""; $msg .= var_export($u, true); @@ -17,14 +17,14 @@ $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$msg."');"); } - if ($param == "globalconfig") + if ($p["param"] == "globalconfig") { $msg = ""; $msg .= var_export($c, true); $msg = str_replace("\n","",addslashes(nl2br($msg))); $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$msg."');"); } - if ($param == "phpserver") + if ($p["param"] == "phpserver") { $msg = ""; $msg .= var_export($_SERVER, true); Modified: trunk/src/commands/deop.class.php =================================================================== --- trunk/src/commands/deop.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/deop.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,23 +6,24 @@ { var $usage = "/deop {nickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; - if (trim($param) == "") + if (trim($p["param"]) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } // just change the "isadmin" meta flag - $nicktodeop = trim($param); + $nicktodeop = trim($p["param"]); $container =& $c->getContainerInstance(); $nicktodeopid = $container->getNickId($nicktodeop); $container->setMeta(false, "isadmin", "nickname", $nicktodeopid); Modified: trunk/src/commands/error.class.php =================================================================== --- trunk/src/commands/error.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/error.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,9 +4,10 @@ class pfcCommand_error extends pfcCommand { - function run(&$xml_reponse, $clientid, $errors, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; + $errors = $p["param"]; if (is_array($errors)) { $error_ids = ""; $error_str = ""; Modified: trunk/src/commands/getnewmsg.class.php =================================================================== --- trunk/src/commands/getnewmsg.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/getnewmsg.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,10 +4,15 @@ class pfcCommand_getnewmsg extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; - // do nothing if the recipient is not defined if ($recipient == "") return; Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/getonlinenick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_getonlinenick extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $container =& $c->getContainerInstance(); @@ -14,8 +20,11 @@ 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, $clientid, _pfc("%s quit (timeout)", $n), $sender, $recipient, $recipientid, 2); + $cmd->run($xml_reponse, $cmdp); } // get the cached nickname list Modified: trunk/src/commands/identify.class.php =================================================================== --- trunk/src/commands/identify.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/identify.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -31,8 +31,14 @@ { var $usage = "/identify {password}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; Modified: trunk/src/commands/init.class.php =================================================================== --- trunk/src/commands/init.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/init.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,13 +4,19 @@ class pfcCommand_init extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; $cmd =& pfcCommand::Factory("quit"); - $cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $p); $u->destroy(); } Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/join.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,8 +6,14 @@ { var $usage = "/join {channelname}"; - function run(&$xml_reponse, $clientid, &$param, &$sender, &$recipient, &$recipientid) + 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; @@ -17,10 +23,11 @@ if ($channame == "") { - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } @@ -36,8 +43,13 @@ } // show a join message + $cmdp = $p; + $cmdp["param"] = _pfc("%s joins %s",$u->nick, $channame); + $cmdp["recipient"] = $chanrecip; + $cmdp["recipientid"] = $chanid; + $cmdp["flag"] = 2; $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s joins %s",$u->nick, $channame), $sender, $chanrecip, $chanid, 1); + $cmd->run($xml_reponse, $cmdp); //$xml_reponse->addScript("alert('join: chan=".$channame.", from_id=".$from_id."');"); Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/kick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,18 +6,25 @@ { var $usage = "/kick {nickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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 (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } Modified: trunk/src/commands/leave.class.php =================================================================== --- trunk/src/commands/leave.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/leave.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,8 +6,14 @@ { var $usage = "/leave [{recipientid} {reason}]"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; @@ -54,10 +60,14 @@ if ($leavech) { // show a leave message with the showing the reason if present - $msg = _pfc("%s quit",$u->nick); - if ($reason != "") $msg .= " (".$reason.")"; + $cmdp = $p; + $cmdp["recipient"] = $leave_recip; + $cmdp["recipientid"] = $leave_id; + $cmdp["flag"] = 2; + $cmdp["param"] = _pfc("%s quit",$u->nick); + if ($reason != "") $cmdp["param"] .= " (".$reason.")"; $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $leave_recip, $leave_id, 1); + $cmd->run($xml_reponse, $cmdp); } // remove the nickname from the channel/pv @@ -71,10 +81,11 @@ else { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); } } } Modified: trunk/src/commands/me.class.php =================================================================== --- trunk/src/commands/me.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/me.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_me extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/nick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,18 +6,25 @@ { var $usage = "/nick {newnickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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 (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } @@ -61,12 +68,22 @@ $u->saveInCache(); // notify all the joined channels/privmsg + $cmdp = $p; + $cmdp["param"] = _pfc("%s changes his nickname to %s",$oldnick,$newnick); + $cmdp["flag"] = 1; $cmd =& pfcCommand::Factory("notice"); foreach($u->channels as $id => $chan) - $cmd->run($xml_reponse, $clientid, _pfc("%s changes his nickname to %s",$oldnick,$newnick), $sender, $chan["recipient"], $id, 1); + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } foreach( $u->privmsg as $id => $pv ) - $cmd->run($xml_reponse, $clientid, _pfc("%s changes his nickname to %s",$oldnick,$newnick), $sender, $pv["recipient"], $id, 1); - + { + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } $xml_reponse->addScript("pfc.handleResponse('nick', 'changed', '".$newnick."');"); } @@ -85,16 +102,7 @@ $u->active = true; $u->saveInCache(); - $xml_reponse->addScript("alert('join: u->nick=".$u->nick); - - /* - $cmd =& pfcCommand::Factory("notice"); - foreach($u->channels as $id => $chan) - $cmd->run($xml_reponse, $clientid, _pfc("%s is connected", $u->nick), $sender, $chan["recipient"], $id, 2); - foreach($u->privmsg as $id => $pv) - $cmd->run($xml_reponse, $clientid, _pfc("%s is connected", $u->nick), $sender, $pv["recipient"], $id, 2); - */ - + $xml_reponse->addScript("alert('TODO?! remove this unused code ?');"); $xml_reponse->addScript("pfc.handleResponse('nick', 'connected', '".$newnick."');"); if ($c->debug) Modified: trunk/src/commands/notice.class.php =================================================================== --- trunk/src/commands/notice.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/notice.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,19 +4,26 @@ class pfcCommand_notice extends pfcCommand { - function run(&$xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid, $flags = 3) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $msg = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $flag = isset($p["flag"]) ? $p["flag"] : 3; + $c =& $this->c; $u =& $this->u; - + if ($c->shownotice > 0 && - ($c->shownotice & $flags) == $flags) + ($c->shownotice & $flag) == $flag) { $container =& $c->getContainerInstance(); $msg = phpFreeChat::FilterSpecialChar($msg); $container->write($recipient, $u->nick, "notice", $msg); } - if ($c->debug) pxlog("/notice ".$msg." (flags=".$flags.")", "chat", $c->getId()); + if ($c->debug) pxlog("/notice ".$msg." (flag=".$flag.")", "chat", $c->getId()); } } Modified: trunk/src/commands/op.class.php =================================================================== --- trunk/src/commands/op.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/op.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,18 +6,25 @@ { var $usage = "/op {nickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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 (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/privmsg.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_privmsg extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; Modified: trunk/src/commands/quit.class.php =================================================================== --- trunk/src/commands/quit.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/quit.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_quit extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; @@ -21,15 +27,23 @@ foreach( $u->channels as $id => $chandetail ) if ($container->removeNick($chandetail["recipient"], $u->nick)) { + $cmdp = $p; + $cmdp["param"] = $id; + $cmdp["recipient"] = $chandetail["recipient"]; + $cmdp["recipientid"] = $id; $cmd =& pfcCommand::Factory("leave"); - $cmd->run($xml_reponse, $clientid, $id, $sender, $chandetail["recipient"], $id, 2); + $cmd->run($xml_reponse, $cmdp); } // from the private messages foreach( $u->privmsg as $id => $pvdetail ) if ($container->removeNick($pvdetail["recipient"], $u->nick)) { + $cmdp = $p; + $cmdp["param"] = $id; + $cmdp["recipient"] = $pvdetail["recipient"]; + $cmdp["recipientid"] = $id; $cmd =& pfcCommand::Factory("leave"); - $cmd->run($xml_reponse, $clientid, $id, $sender, $pvdetail["recipient"], $id, 2); + $cmd->run($xml_reponse, $cmdp); } // from the server $container->removeNick(NULL, $u->nick); Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/rehash.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -11,11 +11,19 @@ { var $desc = "This command deletes the cached configuration. Uses it to take into account new parameters."; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; - $destroyed = $c->destroyCache(); - $synchro = $c->synchronizeWithCache(); + // just destroy the cache + // do not synchronizeWithCache() because it will reload the same parameters as the current one + // the right way is to wait for the next page reload and the new parameters will be taken into account + $destroyed = $c->destroyCache(); if ($destroyed && $synchro) $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '');"); Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/send.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_send extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; $nick = phpFreeChat::FilterSpecialChar($sender); @@ -15,8 +21,10 @@ // send an error because the current user is not connected if (!$u->active) { + $cmdp = $p; + $cmdp["param"] = _pfc("Your must be connected to send a message"); $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, _pfc("Your must be connected to send a message"), $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } @@ -38,8 +46,10 @@ if (!in_array($pvnickid, $onlineusers["nickid"])) { // send an error because the user is not online + $cmdp = $p; + $cmdp["param"] = _pfc("Can't send the message, %s is offline", $pvnick); $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, _pfc("Can't send the message, %s is offline", $pvnick), $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); $can_send = false; } } @@ -54,8 +64,10 @@ // an error occured, just ignore the message and display errors foreach($errors as $e) if ($c->debug) pxlog("error /send, user can't send a message -> nick=".$u->nick." err=".$e, "chat", $c->getId()); + $cmdp = $p; + $cmdp["param"] = $errors; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $errors, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); if (isset($errors[$c->prefix."handle"])) // the nick is empty so give it focus $xml_reponse->addScript("$('".$c->prefix."handle').focus();"); $can_send = false; Modified: trunk/src/commands/unban.class.php =================================================================== --- trunk/src/commands/unban.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/unban.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,8 +6,14 @@ { var $usage = "/unban {id}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; @@ -16,10 +22,11 @@ if (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/update.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,35 +4,68 @@ class pfcCommand_update extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; // do not update if user isn't active (didn't connect) if ($u->active) - { + { + $cmdp = $p; // update the user nickname timestamp $cmd =& pfcCommand::Factory("updatemynick"); foreach( $u->channels as $id => $chan ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $chan["recipient"], $id); + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } foreach( $u->privmsg as $id => $pv ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $pv["recipient"], $id); - $cmd->run($xml_reponse, $clientid, $param, $sender, NULL, NULL); + { + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } + $cmdp["recipient"] = NULL; + $cmdp["recipientid"] = NULL; + $cmd->run($xml_reponse, $cmdp); // get other online users on each channels $cmd =& pfcCommand::Factory("getonlinenick"); foreach( $u->channels as $id => $chan ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $chan["recipient"], $id); + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } foreach( $u->privmsg as $id => $pv ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $pv["recipient"], $id); + { + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } // get new message posted on each channels $cmd =& pfcCommand::Factory("getnewmsg"); foreach( $u->channels as $id => $chan ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $chan["recipient"], $id); + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } foreach( $u->privmsg as $id => $pv ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $pv["recipient"], $id); + { + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } // take care to disconnect timeouted users on the server $container =& $c->getContainerInstance(); Modified: trunk/src/commands/updatemynick.class.php =================================================================== --- trunk/src/commands/updatemynick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/updatemynick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_updatemynick extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/pfccommand.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -121,7 +121,7 @@ * Virtual methode which must be implemented by concrete commands * It is called by the phpFreeChat::HandleRequest function to execute the wanted command */ - function run(&$xml_reponse, $clientid, &$param, &$sender, &$recipient, &$recipientid) + function run(&$xml_reponse, $p) { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } Modified: trunk/src/pfcproxycommand.class.php =================================================================== --- trunk/src/pfcproxycommand.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/pfcproxycommand.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -52,13 +52,6 @@ { $this->next = $cmd; } - - /* - function run(&$xml_reponse, $clientid, &$param, &$sender, &$recipient, &$recipientid) - { - die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); - } - */ } ?> \ No newline at end of file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/phpfreechat.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -375,10 +375,16 @@ // play the command $cmd =& pfcCommand::Factory($cmdtmp[0]); + $cmdp = array(); + $cmdp["clientid"] = $clientid; + $cmdp["param"] = $cmdtmp[1]; + $cmdp["sender"] = $cmdtmp[2]; + $cmdp["recipient"] = $cmdtmp[3]; + $cmdp["recipientid"] = $cmdtmp[4]; if ($c->debug) - $cmd->run($xml_reponse, $clientid, $cmdtmp[1], $cmdtmp[2], $cmdtmp[3], $cmdtmp[4]); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $clientid, $cmdtmp[1], $cmdtmp[2], $cmdtmp[3], $cmdtmp[4]); + @$cmd->run($xml_reponse, $cmdp); // if the cmdtoplay is a 'leave' command, then show an alert to the kicked or banished user if ($cmdtmp[0] == "leave") @@ -395,28 +401,35 @@ $morecmd = (count($cmdtoplay) > 0); } - - - - - $cmd =& pfcCommand::Factory($rawcmd); + $cmdp = array(); + $cmdp["clientid"] = $clientid; + $cmdp["param"] = $param; + $cmdp["sender"] = $sender; + $cmdp["recipient"] = $recipient; + $cmdp["recipientid"] = $recipientid; if ($cmd != NULL) { // call the command if ($c->debug) - $cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + @$cmd->run($xml_reponse, $cmdp); } else { $cmd =& pfcCommand::Factory("error"); + $cmdp = array(); + $cmdp["clientid"] = $clientid; + $cmdp["param"] = _pfc("Unknown command [%s]",stripslashes("/".$rawcmd." ".$param)); + $cmdp["sender"] = $sender; + $cmdp["recipient"] = $recipient; + $cmdp["recipientid"] = $recipientid; if ($c->debug) - $cmd->run($xml_reponse, $clientid, _pfc("Unknown command [%s]",stripslashes("/".$rawcmd." ".$param)), $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $clientid, _pfc("Unknown command [%s]",stripslashes("/".$rawcmd." ".$param)), $sender, $recipient, $recipientid); + @$cmd->run($xml_reponse, $cmdp); } // do not update twice @@ -428,10 +441,16 @@ // force an update just after a command is sent // thus the message user just poster is really fastly displayed $cmd =& pfcCommand::Factory("update"); + $cmdp = array(); + $cmdp["clientid"] = $clientid; + $cmdp["param"] = $param; + $cmdp["sender"] = $sender; + $cmdp["recipient"] = $recipient; + $cmdp["recipientid"] = $recipientid; if ($c->debug) - $cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + @$cmd->run($xml_reponse, $cmdp); } if ($c->debug) Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/proxys/auth.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -30,8 +30,14 @@ */ class pfcProxyCommand_auth extends pfcProxyCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; @@ -93,7 +99,12 @@ } // forward the command to the next proxy or to the final command - $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run(&$xml_reponse, $p); } } Modified: trunk/src/proxys/censor.class.php =================================================================== --- trunk/src/proxys/censor.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/proxys/censor.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -30,8 +30,14 @@ */ class pfcProxyCommand_censor extends pfcProxyCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; @@ -52,7 +58,12 @@ } // forward the command to the next proxy or to the final command - $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run(&$xml_reponse, $p); } } Modified: trunk/src/proxys/lock.class.php =================================================================== --- trunk/src/proxys/lock.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/proxys/lock.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -30,8 +30,14 @@ */ class pfcProxyCommand_lock extends pfcProxyCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; @@ -43,7 +49,12 @@ else { // forward the command to the next proxy or to the final command - $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run(&$xml_reponse, $p); } } } Modified: trunk/src/proxys/noflood.class.php =================================================================== --- trunk/src/proxys/noflood.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/proxys/noflood.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -30,8 +30,14 @@ */ class pfcProxyCommand_noflood extends pfcProxyCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + 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; @@ -52,18 +58,16 @@ if ($nbflood>$c->proxys_cfg[$this->proxyname]["limit"]) { - // kick the flooder + // warn the flooder $msg = _pfc("Please don't post so many message, flood is not tolerated"); $xml_reponse->addScript("alert('".addslashes($msg)."');"); - // @todo kick the user - - $msg = $recipientid." "; - $msg .=_pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], "noflood"); + // kick the flooder + $cmdp = $p; + $cmdp["param"] = $recipientid." "; + $cmdp["param"] .=_pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], "noflood"); $cmd =& pfcCommand::Factory("leave"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); - - + $cmd->run($xml_reponse, $cmdp); return; } @@ -73,7 +77,12 @@ } // forward the command to the next proxy or to the final command - $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run(&$xml_reponse, $p); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |