[Phpfreechat-svn] SF.net SVN: phpfreechat: [849] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-10-29 10:42:18
|
Revision: 849 http://svn.sourceforge.net/phpfreechat/?rev=849&view=rev Author: kerphi Date: 2006-10-29 02:42:05 -0800 (Sun, 29 Oct 2006) Log Message: ----------- [en] Bug fix: when frozen_nick was true and the choosen nickname was allready used, the chat looped forever [2h30] [fr] Bug fix : lorsque frozen_nick ?\195?\169tait ?\195?\160 true et que le pseudonyme choisi ?\195?\169tait d?\195?\169j?\195?\160 utilis?\195?\169 alors le chat bouclait ?\195?\160 l'infini. [2h30] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/commands/nick.class.php trunk/src/proxies/checknickchange.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-10-29 10:36:26 UTC (rev 848) +++ trunk/src/client/chat.js.tpl.php 2006-10-29 10:42:05 UTC (rev 849) @@ -77,6 +77,7 @@ "Send", // _pfc "You are not allowed to speak to yourself", // _pfc "Close", // _pfc + "Choosen nickname is not allowed", // _pfc ); foreach($labels_to_load as $l) { Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-10-29 10:36:26 UTC (rev 848) +++ trunk/src/client/pfcclient.js 2006-10-29 10:42:05 UTC (rev 849) @@ -290,7 +290,7 @@ this.sendRequest("/privmsg", pfc_userprivmsg[i]); } } - + if (resp == "ok" || resp == "notchanged" || resp == "changed" || resp == "connected") { this.el_handle.innerHTML = param; @@ -306,8 +306,21 @@ this.setError(this.res.getLabel('Choosen nickname is allready used'), Array()); this.askNick(param); } - else - alert(cmd + "-"+resp+"-"+param); + else if (resp == "notallowed") + { + // when frozen_nick is true and the nickname is allready used, server will return + // the 'notallowed' status. It will display a message and stop chat update. + // if the chat update is not stopped, this will loop forever + // as long as the forced nickname is not changed + + // display a message + this.setError(this.res.getLabel('Choosen nickname is not allowed'), Array()); + // then stop chat updates + this.updateChat(false); + this.isconnected = false; + this.refresh_loginlogout(); + } + } else if (cmd == "update") { @@ -437,7 +450,7 @@ { var nickid = meta['users']['nickid'][i]; var nick = meta['users']['nick'][i]; - var um = this.getAllUserMeta(nickid); + var um = this.getAllUserMeta(nickid); if (!um) this.sendRequest('/whois2', nick); } Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-10-29 10:36:26 UTC (rev 848) +++ trunk/src/commands/nick.class.php 2006-10-29 10:42:05 UTC (rev 849) @@ -73,7 +73,8 @@ // new nickname is undefined (not used) and // current nickname (oldnick) is not mine or is undefined // -> this is a first connection - if ($oldnickid != $u->nickid) + if ($newnickid == '' && + $oldnickid != $u->nickid) { // this is a first connection : create the nickname on the server $container->createNick(NULL, $newnick, $u->nickid); Modified: trunk/src/proxies/checknickchange.class.php =================================================================== --- trunk/src/proxies/checknickchange.class.php 2006-10-29 10:36:26 UTC (rev 848) +++ trunk/src/proxies/checknickchange.class.php 2006-10-29 10:42:05 UTC (rev 849) @@ -66,7 +66,7 @@ if ($newnick == $oldnick && $newnickid == $oldnickid) { - $xml_reponse->addScript("pfc.handleResponse('nick', 'notchanged', '".addslashes($newnick)."');"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'notchanged', '".addslashes($newnick)."');"); if ($c->debug) pxlog("/nick ".$newnick." (user just reloded the page so let him keep his nickname without any warnings)", "chat", $c->getId()); return; @@ -74,28 +74,19 @@ // now check the nickname is not yet used (unsensitive case) // 'BoB' and 'bob' must be considered same nicknames - $nick_in_use = false; - $online_users = $container->getOnlineNick(NULL); - if (isset($online_users["nickid"])) - foreach($online_users["nickid"] as $nid) - { - if (preg_match("/^".preg_quote($container->getNickname($nid))."$/i",$newnick)) - { - // the nick match - // just allow the owner to change his capitalised letters - if ($nid != $oldnickid) - $nick_in_use = true; - } - } - if ($nick_in_use || $newnickid != '') + $nick_in_use = $this->_checkNickIsUsed($newnick, $oldnickid); + if ($nick_in_use) { - $xml_reponse->addScript("pfc.handleResponse('nick', 'isused', '".addslashes($newnick)."');"); + if ($c->frozen_nick) + $xml_reponse->addScript("pfc.handleResponse('nick', 'notallowed', '".addslashes($newnick)."');"); + else + $xml_reponse->addScript("pfc.handleResponse('nick', 'isused', '".addslashes($newnick)."');"); if ($c->debug) pxlog("/nick ".$newnick." (wanted nick is allready in use -> wantednickid=".$newnickid.")", "chat", $c->getId()); return; } } - + // allow nick changes only from the parameters array (server side) if ($this->name != 'connect' && // don't check anything on the connect process or it could block the periodic refresh $c->frozen_nick == true && @@ -115,6 +106,24 @@ // forward the command to the next proxy or to the final command $this->next->run($xml_reponse, $p); } + + function _checkNickIsUsed($newnick, $oldnickid) + { + $ct =& $this->c->getContainerInstance(); + $nick_in_use = false; + $online_users = $ct->getOnlineNick(NULL); + if (isset($online_users["nickid"])) + foreach($online_users["nickid"] as $nid) + { + if (preg_match("/^".preg_quote($ct->getNickname($nid))."$/i",$newnick)) + { + // the nick match + // just allow the owner to change his capitalised letters + if ($nid != $oldnickid) + return true; + } + } + } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |