[Phpfreechat-svn] SF.net SVN: phpfreechat: [771] trunk
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-09-19 21:33:10
|
Revision: 771 http://svn.sourceforge.net/phpfreechat/?rev=771&view=rev Author: kerphi Date: 2006-09-19 14:32:46 -0700 (Tue, 19 Sep 2006) Log Message: ----------- [en] Big containers refactoring: this make possible to handle easily user's metadata, fix a bug related to undisconnected but timeouted users and fix some memory leak in the default file container. [fr] Grosse reorganisation des containers : ceci rend possible le travail sur les metadonnees utilisateurs, regle un bug qui fesait que des utilisateurs deconnectes en timeout n'etait pas correctement deconnecte et resoud une fuitte de memoire dans le conteneur File. Modified Paths: -------------- trunk/src/commands/ban.class.php trunk/src/commands/banlist.class.php trunk/src/commands/connect.class.php trunk/src/commands/deop.class.php trunk/src/commands/identify.class.php trunk/src/commands/kick.class.php trunk/src/commands/op.class.php trunk/src/commands/privmsg.class.php trunk/src/commands/quit.class.php trunk/src/commands/unban.class.php trunk/src/commands/updatemynick.class.php trunk/src/containers/file.class.php trunk/src/phpfreechat.class.php trunk/src/proxys/auth.class.php trunk/src/proxys/checknickchange.class.php trunk/src/proxys/checktimeout.class.php trunk/src/proxys/noflood.class.php trunk/testcase/container_file.php trunk/testcase/container_generic.php Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/ban.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -31,9 +31,9 @@ $container =& $c->getContainerInstance(); $nickid = $container->getNickId($param); - if ($nickid != "undefined") + if ($nickid != "") { - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $cmdtmp = array("leave", /* cmdname */ @@ -44,17 +44,17 @@ ); //_pfc("banished from %s by %s", $recipient, $sender); $cmdtoplay[] = $cmdtmp; // ban the user from the current channel - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); + $container->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); } // update the recipient banlist - $banlist = $container->getMeta("banlist_nickid", "channel", $recipientid); + $banlist = $container->getChanMeta($recipient, 'banlist_nickid'); 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->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); } } Modified: trunk/src/commands/banlist.class.php =================================================================== --- trunk/src/commands/banlist.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/banlist.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -17,7 +17,7 @@ $u =& $this->u; $container =& $c->getContainerInstance(); - $banlist = $container->getMeta("banlist_nickid", "channel", $p["recipientid"]); + $banlist = $container->getChanMeta($p["recipientid"], 'banlist_nickid'); 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/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/connect.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -50,9 +50,9 @@ // setup some user meta $nickid = $u->nickid; // store the user ip - $container->setMeta($_SERVER["REMOTE_ADDR"], "ip", "nickname", $nickid); + $container->setUserMeta($nickid, 'ip', $_SERVER["REMOTE_ADDR"]); // store the admin flag - $container->setMeta($isadmin, "isadmin", "nickname", $nickid); + $container->setUserMeta($nickid, 'isadmin', $isadmin); // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); } Modified: trunk/src/commands/deop.class.php =================================================================== --- trunk/src/commands/deop.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/deop.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -26,7 +26,7 @@ $nicktodeop = trim($p["param"]); $container =& $c->getContainerInstance(); $nicktodeopid = $container->getNickId($nicktodeop); - $container->setMeta(false, "isadmin", "nickname", $nicktodeopid); + $container->setUserMeta($nicktodeopid, 'isadmin', false); } } Modified: trunk/src/commands/identify.class.php =================================================================== --- trunk/src/commands/identify.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/identify.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -58,7 +58,7 @@ { // ok the current user is an admin, just save the isadmin flag in the metadata $container =& $c->getContainerInstance(); - $container->setMeta($isadmin, "isadmin", "nickname", $u->nickid); + $container->setUserMeta($u->nickid, 'isadmin' $isadmin); $msg .= _pfc("Succesfully identified"); $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$msg."');"); Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/kick.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -31,9 +31,9 @@ // kicking a user just add a command to play to the aimed user metadata. $container =& $c->getContainerInstance(); $nickid = $container->getNickId($param); - if ($nickid != "undefined") + if ($nickid != "") { - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $reason = _pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], $sender); $cmdtmp = array("leave", /* cmdname */ @@ -43,7 +43,7 @@ $recipientid,/* recipientid */ ); $cmdtoplay[] = $cmdtmp; // kick the user from the current channel - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); + $container->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); } } } Modified: trunk/src/commands/op.class.php =================================================================== --- trunk/src/commands/op.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/op.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -32,7 +32,7 @@ $nicktoop = trim($param); $container =& $c->getContainerInstance(); $nicktoopid = $container->getNickId($nicktoop); - $container->setMeta(true, "isadmin", "nickname", $nicktoopid); + $container->setUserMeta($nicktoopid, 'isadmin', true); } } Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/privmsg.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -30,7 +30,7 @@ } // error: can't speak to unknown - if ($pvnickid == "undefined") + if ($pvnickid == '') { // remove this old pv from the privmsg list $pvid_to_remove = ""; Modified: trunk/src/commands/quit.class.php =================================================================== --- trunk/src/commands/quit.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/quit.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -25,7 +25,7 @@ // from the channels foreach( $u->channels as $id => $chandetail ) - if ($container->removeNick($chandetail["recipient"], $u->nick)) + if ($container->removeNick($chandetail["recipient"], $u->nickid)) { $cmdp = $p; $cmdp["param"] = $id; @@ -36,7 +36,7 @@ } // from the private messages foreach( $u->privmsg as $id => $pvdetail ) - if ($container->removeNick($pvdetail["recipient"], $u->nick)) + if ($container->removeNick($pvdetail["recipient"], $u->nickid)) { $cmdp = $p; $cmdp["param"] = $id; @@ -46,9 +46,8 @@ $cmd->run($xml_reponse, $cmdp); } // from the server - $container->removeNick(NULL, $u->nick); + $container->removeNick(NULL, $u->nickid); - $xml_reponse->addScript("pfc.handleResponse('quit', 'ok', '');"); if ($c->debug) pxlog("/quit (a user just quit -> nick=".$u->nick.")", "chat", $c->getId()); Modified: trunk/src/commands/unban.class.php =================================================================== --- trunk/src/commands/unban.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/unban.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -34,7 +34,7 @@ $msg = "<p>"._pfc("Nobody has been unbanished")."</p>"; // update the recipient banlist - $banlist = $container->getMeta("banlist_nickid", "channel", $recipientid); + $banlist = $container->getChanMeta($recipient, 'banlist_nickid'); if ($banlist == NULL) $banlist = array(); else @@ -44,14 +44,14 @@ if (in_array($param, $banlist)) { $banlist = array_diff($banlist, array($param)); - $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $recipientid); + $container->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); $updated = true; $msg = "<p>"._pfc("%s has been unbanished", $param)."</p>"; } else if ($param == "all") { $banlist = array(); - $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $recipientid); + $container->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); $updated = true; $msg = "<p>"._pfc("%s users have been unbanished", $nb)."</p>"; } Modified: trunk/src/commands/updatemynick.class.php =================================================================== --- trunk/src/commands/updatemynick.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/updatemynick.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -16,7 +16,9 @@ $u =& $this->u; $container =& $c->getContainerInstance(); - $was_there = $container->updateNick($recipient, $u->nick); + $container->updateNick($u->nickid); + + $was_there = ($container->isNickOnline($recipient, $nickid) >=0); if (!$was_there) { // if the user were not in the list, it must be created in order to refresh his metadata Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/containers/file.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -101,7 +101,7 @@ $this->setMeta2("channelid-to-nickid", $this->_encode($chan), $nickid); // update the SERVER channel - $this->updateNick($nickid); + if ($chan != 'SERVER') $this->updateNick($nickid); return true; } @@ -117,44 +117,30 @@ { if ($chan == NULL) $chan = 'SERVER'; - $ret = $this->getMeta2("channelid-to-nickid", $this->_encode('SERVER'), $nickid); - $timestamp = $ret["timestamp"][0]; + $timestamp = $this->getMeta2("channelid-to-nickid", $this->_encode('SERVER'), $nickid); + $timestamp = $timestamp["timestamp"][0]; $deleted_user = array(); $deleted_user["nick"][] = $this->getNickname($nickid); $deleted_user["nickid"][] = $nickid; $deleted_user["timestamp"][] = $timestamp; + // remove the nickid from the channel list + $this->rmMeta2('channelid-to-nickid', $this->_encode($chan), $nickid); + $this->rmMeta2('nickid-to-channelid', $nickid, $this->_encode($chan)); - // @todo ne supprimer l'utilisateur que du channel donne en parametres - // car la commande /leave va simplement supprimer l'utilisateur du channel courant - // il faut par contre faire un test sur les channels de l'utilisateur et dans le cas ou l'utilisateur - // est deconnecte du dernier channel (il se peut que ce soit SERVER) alors on supprime ses metadata. - - // il faudrait egalement adapter removeObsoleteNick pour qu'elle appel N fois removeNick - // N etant le nombre de channel de l'utilisateur. Ainsi l'utilisateur dera vraiment deconnecte - - - - // get the user's disconnected channels - $channels = array(); - $ret2 = $this->getMeta2("nickid-to-channelid",$nickid); - foreach($ret2["value"] as $v) - $channels[] = $this->_decode($v); - $deleted_user["channels"][] = $channels; - - // get the user nickname - $nick = $this->getNickname($nickid); - // loop on user channels - foreach($channels as $ch) + // get the current user's channels list + $channels = $this->getMeta2("nickid-to-channelid",$nickid); + $channels = $channels["value"]; + // no more joined channel, just remove the user's metadata + if (count($channels) == 0) { // remove the nickname to nickid correspondance - $this->rmMeta2("metadata-to-nickid", 'nick', $this->_encode($nick)); + $this->rmMeta2('metadata-to-nickid', 'nick', $this->_encode($this->getNickname($nickid))); // remove disconnected nickname metadata - $this->rmMeta2("nickid-to-metadata", $nickid); - // remove the nickid from the channel list - $this->rmMeta2("channelid-to-nickid", $this->_encode($ch), $nickid); + $this->rmMeta2('nickid-to-metadata', $nickid); } + return $deleted_user; } @@ -221,7 +207,7 @@ function getNickname($nickid) { $nick = $this->getMeta2("nickid-to-metadata", $nickid, 'nick', true); - $nick = isset($nick["value"][0]) ? $nick["value"][0] : ""; + $nick = isset($nick["value"][0]) ? $this->_decode($nick["value"][0]) : ""; return $nick; } @@ -249,11 +235,19 @@ $nickid = $ret['value'][$i]; if (time() > ($timestamp+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity { - $du = $this->removeNick($nickid); + // get the current user's channels list + $channels = array(); + $ret2 = $this->getMeta2("nickid-to-channelid",$nickid); + foreach($ret2["value"] as $userchan) + { + // disconnect the user from each joined channels + $du = $this->removeNick($this->_decode($userchan), $nickid); + $channels[] = $this->_decode($userchan); + } $deleted_user["nick"] = array_merge($deleted_user["nick"], $du["nick"]); $deleted_user["nickid"] = array_merge($deleted_user["nickid"], $du["nickid"]); - $deleted_user["timestamp"] = array_merge($deleted_user["timestamp"], $du["timestamp"]); - $deleted_user["channels"] = array_merge($deleted_user["channels"], $du["channels"]); + $deleted_user["timestamp"] = array_merge($deleted_user["timestamp"], $du["timestamp"]); + $deleted_user["channels"] = array_merge($deleted_user["channels"], array($channels)); } } @@ -496,7 +490,7 @@ if ($leafvalue == NULL) { if (file_exists($leaffilename) && - filesize($leaffilename)>0) unlink($leaffilename); + filesize($leaffilename)>0) unlink($leaffilename); touch($leaffilename); } else @@ -520,12 +514,7 @@ * @return ... */ function getMeta2($group, $subgroup = null, $leaf = null, $withleafvalue = false) - //($key, $type, $subtype = NULL) { - // @todo read the value from the memory cache - //if (isset($this->_meta[$enc_type][$enc_subtype][$enc_key])) - // return $this->_meta[$enc_type][$enc_subtype][$enc_key]; - // read data from metadata file $ret = array(); $ret["timestamp"] = array(); @@ -557,7 +546,6 @@ if (is_dir($dir)) { $dh = opendir($dir); - $ret = array(); while (false !== ($file = readdir($dh))) { if ($file == "." || $file == "..") continue; // skip . and .. generic files @@ -572,15 +560,11 @@ if (!file_exists($leaffilename)) return $ret; if ($withleafvalue) - { $ret["value"][] = file_get_contents($leaffilename); - } + else + $ret["value"][] = NULL; $ret["timestamp"][] = filemtime($leaffilename); - // @todo - // store the result in the memory cache - //$this->_meta[$enc_type][$enc_subtype][$enc_key] = $ret; - return $ret; } @@ -623,7 +607,31 @@ return true; } - + + function getUserMeta($nickid, $key) + { + $ret = $this->getMeta2("nickid-to-metadata", $nickid, $key, true); + return isset($ret['value'][0]) ? $ret['value'][0] : NULL; + } + + function setUserMeta($nickid, $key, $value) + { + $ret = $this->setMeta2("nickid-to-metadata", $nickid, $key, $value); + return $ret; + } + + function getChanMeta($chan, $key) + { + $ret = $this->getMeta2("channelid-to-metadata", $this->_encode($chan), $key, true); + return isset($ret['value'][0]) ? $ret['value'][0] : NULL; + } + + function setChanMeta($chan, $key, $value) + { + $ret = $this->setMeta2("channelid-to-metadata", $this->_encode($chan), $key, $value); + return $ret; + } + } ?> \ No newline at end of file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/phpfreechat.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -355,7 +355,7 @@ // alert the other from the new pv // (warn other user that someone talk to him) $container =& $c->getContainerInstance(); - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + $cmdtoplay = $container->getUserMeta($u->privmsg[$recipientid]["pvnickid"], 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $cmdtmp = array("privmsg2", /* cmdname */ $u->nick, /* param */ @@ -366,7 +366,7 @@ if (!in_array($cmdtmp, $cmdtoplay)) { $cmdtoplay[] = $cmdtmp; - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + $container->setUserMeta($u->privmsg[$recipientid]["pvnickid"], 'cmdtoplay', serialize($cmdtoplay)); //$xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); } } @@ -382,13 +382,13 @@ while($morecmd) { // take a command from the list - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $cmdtmp = array_pop($cmdtoplay); if ($cmdtmp != NULL) { // store the new cmdtoplay list (-1 item) - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); + $container->setUserMeta($nickid, "cmdtoplay", serialize($cmdtoplay)); // play the command $cmd =& pfcCommand::Factory($cmdtmp[0]); @@ -411,7 +411,7 @@ } // check if there is other command to play - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); } Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/proxys/auth.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -47,7 +47,7 @@ { $container =& $c->getContainerInstance(); $nickid = $u->nickid; - $isadmin = $container->getMeta("isadmin", "nickname", $nickid); + $isadmin = $container->getUserMeta($nickid, 'isadmin'); if (!$isadmin) { $xml_reponse->addScript("alert('".addslashes(_pfc("You are not allowed to run '%s' command", $this->name))."');"); @@ -62,8 +62,9 @@ $channame = $param; // check the user is not listed in the banished channel list + $chan = pfcCommand_join::GetRecipient($channame); $chanid = pfcCommand_join::GetRecipientId($channame); - $banlist = $container->getMeta("banlist_nickid", "channel", $chanid); + $banlist = $container->getChanMeta($chan, 'banlist_nickid'); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); $nickid = $u->nickid; if (in_array($nickid,$banlist)) Modified: trunk/src/proxys/checknickchange.class.php =================================================================== --- trunk/src/proxys/checknickchange.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/proxys/checknickchange.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -87,7 +87,7 @@ $nick_in_use = true; } } - if ($nick_in_use || $newnickid != "undefined") + if ($nick_in_use || $newnickid != '') { $xml_reponse->addScript("pfc.handleResponse('nick', 'isused', '".addslashes($newnick)."');"); if ($c->debug) Modified: trunk/src/proxys/checktimeout.class.php =================================================================== --- trunk/src/proxys/checktimeout.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/proxys/checktimeout.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -42,28 +42,26 @@ $c =& $this->c; $u =& $this->u; - if ( $this->name == 'update' || - $this->name == 'connect' ) + // disconnect users from specific channels + $container =& $c->getContainerInstance(); + $disconnected_users = $container->removeObsoleteNick($c->timeout); + for($i=0; $i<count($disconnected_users["nick"]); $i++) { - // 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) + $nick = $disconnected_users["nick"][$i]; + for($j=0; $j<count($disconnected_users["channels"][$i]); $j++) + { + $chan = $disconnected_users["channels"][$i][$j]; + if ($chan != 'SERVER') { $cmdp = $p; - $cmdp["param"] = _pfc("%s quit (timeout)", $n); + $cmdp["param"] = _pfc("%s quit (timeout)", $nick); $cmdp["flag"] = 2; + $cmdp["recipient"] = $chan; + $cmdp["recipientid"] = md5($chan); // @todo: clean the recipient/recipientid notion $cmd =& pfcCommand::Factory("notice"); $cmd->run($xml_reponse, $cmdp); } + } } // forward the command to the next proxy or to the final command Modified: trunk/src/proxys/noflood.class.php =================================================================== --- trunk/src/proxys/noflood.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/proxys/noflood.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -46,9 +46,9 @@ { $container =& $c->getContainerInstance(); $nickid = $u->nickid; - $isadmin = $container->getMeta("isadmin", "nickname", $nickid); - $lastfloodtime = $container->getMeta("floodtime", "nickname", $nickid); - $nbflood = $container->getMeta("nbflood", "nickname", $nickid); + $isadmin = $container->getUserMeta($nickid, 'isadmin'); + $lastfloodtime = $container->getUserMeta($nickid, 'floodtime'); + $nbflood = $container->getUserMeta($nickid, 'nbflood'); $floodtime = time(); if ($floodtime - $lastfloodtime <= $c->proxys_cfg[$this->proxyname]["delay"]) @@ -72,8 +72,8 @@ } if ($nbflood == 0) - $container->setMeta($floodtime, "floodtime", "nickname", $nickid); - $container->setMeta($nbflood, "nbflood", "nickname", $nickid); + $container->setUserMeta($nickid, 'floodtime', $floodtime); + $container->setUserMeta($nickid, 'nbflood', $nbflood); } // forward the command to the next proxy or to the final command Modified: trunk/testcase/container_file.php =================================================================== --- trunk/testcase/container_file.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/testcase/container_file.php 2006-09-19 21:32:46 UTC (rev 771) @@ -275,7 +275,6 @@ $ret = $ct->getMeta2($group, $subgroup, $leaf, true); $this->assertEquals($ret['value'][0], $leafvalue, "the leaf value is wrong"); } - } // on desactive le timeout car se script peut mettre bcp de temps a s'executer Modified: trunk/testcase/container_generic.php =================================================================== --- trunk/testcase/container_generic.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/testcase/container_generic.php 2006-09-19 21:32:46 UTC (rev 771) @@ -27,13 +27,14 @@ // here function setUp() { + // echo "setUp<br>"; require_once dirname(__FILE__)."/../src/pfcglobalconfig.class.php"; $params = array(); $params["title"] = "testcase -> pfccontainer_".$this->type; $params["serverid"] = md5(__FILE__/* . time()*/); $params["container_type"] = $this->type; - $this->c =& pfcGlobalConfig::Instance($params); - $this->ct =& $this->c->getContainerInstance(); + $this->c = new pfcGlobalConfig($params); + $this->ct = $this->c->getContainerInstance(); } // called after the test functions are executed @@ -41,11 +42,11 @@ // here function tearDown() { + // echo "tearDown<br>"; $this->ct->clear(); $this->c->destroyCache(); } - function testCreateNick_Generic() { $c =& $this->c; @@ -66,7 +67,7 @@ $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertTrue($isonline, "nickname should be online on the server"); } - + function testRemoveNick_Generic() { $c =& $this->c; @@ -78,18 +79,17 @@ // on the channel $this->ct->createNick($chan, $nick, $nickid); - $this->ct->removeNick($nickid); + $this->ct->removeNick($chan, $nickid); $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertFalse($isonline, "nickname shouldn't be online on the channel"); + $isonline2 = ($this->ct->isNickOnline(NULL, $nickid) >= 0); + $this->assertTrue($isonline2, "nickname should be online on the server"); - // on the server - $chan = NULL; - $this->ct->createNick($chan, $nick, $nickid); - $this->ct->removeNick($nickid); - $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); - $this->assertFalse($isonline, "nickname shouldn't be online on the server"); + $this->ct->removeNick(NULL, $nickid); + $isonline = ($this->ct->isNickOnline(NULL, $nickid) >= 0); + $this->assertFalse($isonline, "nickname shouldn't be online on the server"); } - + function testGetNickId_Generic() { $c =& $this->c; @@ -104,7 +104,6 @@ $this->assertEquals($nickid, $ret, "created nickname doesn't have a correct nickid"); } - function testGetNickname_Generic() { $c =& $this->c; @@ -156,7 +155,8 @@ $this->ct->createNick($chan, $nick, $nickid); sleep(2); $ret = $this->ct->removeObsoleteNick(1000); - $this->assertEquals(count($ret["nickid"]), 1, "1 nickname should be obsolete"); + $this->assertEquals(1, count($ret["nickid"]), "1 nickname should be obsolete"); + $this->assertEquals(2, count($ret["channels"][0]), "nickname should be disconnected from two channels"); $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertFalse($isonline, "nickname shouldn't be online anymore"); } @@ -276,7 +276,6 @@ $this->assertEquals($msg."9", $res["data"][10]["param"] ,"messages data is not the same as the sent one"); $this->assertEquals($res["new_from_id"], 10 ,"new_from_id is not correct"); } - } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |