[Phpfreechat-svn] SF.net SVN: phpfreechat: [995] trunk
Status: Beta
Brought to you by:
kerphi
|
From: <ke...@us...> - 2007-03-11 12:37:38
|
Revision: 995
http://svn.sourceforge.net/phpfreechat/?rev=995&view=rev
Author: kerphi
Date: 2007-03-11 05:37:38 -0700 (Sun, 11 Mar 2007)
Log Message:
-----------
Bug fix: it was possible to connect with an existing nickname [1h30]
Modified Paths:
--------------
trunk/data/public/js/pfcclient.js
trunk/src/commands/connect.class.php
trunk/src/commands/nick.class.php
trunk/src/proxies/auth.class.php
trunk/src/proxies/censor.class.php
trunk/src/proxies/checknickchange.class.php
trunk/src/proxies/checktimeout.class.php
trunk/src/proxies/lock.class.php
trunk/src/proxies/log.class.php
trunk/src/proxies/noflood.class.php
Modified: trunk/data/public/js/pfcclient.js
===================================================================
--- trunk/data/public/js/pfcclient.js 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/data/public/js/pfcclient.js 2007-03-11 12:37:38 UTC (rev 995)
@@ -132,7 +132,7 @@
/**
* Show a popup dialog to ask user to choose a nickname
*/
- askNick: function(nickname)
+ askNick: function(nickname,error_text)
{
// ask to choose a nickname
if (nickname == '' || nickname == undefined) nickname = this.nickname;
@@ -140,7 +140,7 @@
// build a dhtml prompt box
var pfcp = this.getPrompt();//new pfcPrompt($('pfc_container'));
pfcp.callback = function(v) { pfc.askNickResponse(v); }
- pfcp.prompt(this.res.getLabel('Please enter your nickname'), nickname);
+ pfcp.prompt((error_text != undefined ? '<span style="color:red">'+error_text+'</span><br/>' : '')+this.res.getLabel('Please enter your nickname'), nickname);
pfcp.focus();
},
askNickResponse: function(newnick)
@@ -389,7 +389,7 @@
else if (resp == "isused")
{
this.setError(this.res.getLabel('Choosen nickname is allready used'), Array());
- this.askNick(param);
+ this.askNick(param,this.res.getLabel('Choosen nickname is allready used'));
}
else if (resp == "notallowed")
{
Modified: trunk/src/commands/connect.class.php
===================================================================
--- trunk/src/commands/connect.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/commands/connect.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -79,10 +79,6 @@
// create the nickid
$ct->joinChan($nickid, NULL); // join the server
- $ct->createNick($nickid, $nick);
-
- $u->nick = $nick;
- $u->saveInCache();
// setup the active flag in user session
// $u->active = true;
@@ -98,8 +94,20 @@
foreach($c->nickmeta as $k => $v)
$ct->setUserMeta($nickid, $k, $v);
- // connect to the server
- $xml_reponse->script("pfc.handleResponse('connect', 'ok', Array('".addslashes($nick)."'));");
+ // run the /nick command to assign the user nick
+ $cmdp = array();
+ $cmdp["param"] = $nick;
+ $cmd =& pfcCommand::Factory('nick');
+ $ret = $cmd->run($xml_reponse, $cmdp);
+
+ if ($ret)
+ {
+ $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ok', Array('".addslashes($nick)."'));");
+ }
+ else
+ {
+ $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ko', Array('".addslashes($nick)."'));");
+ }
}
}
Modified: trunk/src/commands/nick.class.php
===================================================================
--- trunk/src/commands/nick.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/commands/nick.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -18,7 +18,7 @@
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
- if (trim($param) == "")
+ if (trim($param) == '')
{
// error
$cmdp = $p;
@@ -26,7 +26,7 @@
$cmdp["param"] .= " (".$this->usage.")";
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
- return;
+ return false;
}
$newnick = phpFreeChat::FilterNickname($param);
@@ -41,8 +41,7 @@
// current nickname (oldnick) is mine and
// oldnick is different from new nick
// -> this is a nickname change
- if ($oldnickid == $u->nickid &&
- $oldnick != $newnick &&
+ if ($oldnick != $newnick &&
$oldnick != '')
{
// really change the nick (rename it)
@@ -69,35 +68,28 @@
$cmd->run($xml_reponse, $cmdp);
}
$xml_reponse->script("pfc.handleResponse('nick', 'changed', '".addslashes($newnick)."');");
- return;
+ return true;
}
- /*
- // new nickname is undefined (not used) and
- // current nickname (oldnick) is not mine or is undefined
- // -> this is a first connection
- if ($newnickid == '' &&
- $oldnickid != $u->nickid)
+ // new nickname is undefined (not used)
+ // -> this is a first connection (this piece of code is called by /connect command)
+ if ($newnickid == '')
{
// this is a first connection : create the nickname on the server
- // $container->createNick(NULL, $newnick, $u->nickid);
- $container->createNick($u->nickid, $newnick);
-
- //$u->nick = $newnick;
- // $u->active = true;
- //$u->saveInCache();
+ $ct->createNick($u->nickid, $newnick);
+ $u->nick = $nick;
+ $u->saveInCache();
+
$this->forceWhoisReload($u->nickid);
$xml_reponse->script("pfc.handleResponse('nick', 'connected', '".addslashes($newnick)."');");
if ($c->debug)
pxlog("/nick ".$newnick." (first connection, oldnick=".$oldnick.")", "chat", $c->getId());
- return;
+ return true;
}
- */
- // $ct->createNick($u->nickid, $newnick);
-
+ return false;
}
}
Modified: trunk/src/proxies/auth.class.php
===================================================================
--- trunk/src/proxies/auth.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/proxies/auth.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -51,7 +51,7 @@
$cmdp["param"] = _pfc("Your must be connected to send a message");
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
- return;
+ return false;
}
@@ -65,7 +65,7 @@
if (!$isadmin)
{
$xml_reponse->script("alert('".addslashes(_pfc("You are not allowed to run '%s' command", $this->name))."');");
- return;
+ return false;
}
}
@@ -87,7 +87,7 @@
// the user is banished, show a message and don't forward the /join command
$msg = _pfc("Can't join %s because you are banished", $param);
$xml_reponse->script("pfc.handleResponse('".$this->proxyname."', 'ban', '".addslashes($msg)."');");
- return;
+ return false;
}
if (count($c->frozen_channels)>0)
@@ -97,7 +97,7 @@
// the user is banished, show a message and don't forward the /join command
$msg = _pfc("Can't join %s because the channels list is restricted", $param);
$xml_reponse->script("pfc.handleResponse('".$this->proxyname."', 'frozen', '".addslashes($msg)."');");
- return;
+ return false;
}
}
}
@@ -108,7 +108,7 @@
$p["sender"] = $sender;
$p["recipient"] = $recipient;
$p["recipientid"] = $recipientid;
- $this->next->run($xml_reponse, $p);
+ return $this->next->run($xml_reponse, $p);
}
}
Modified: trunk/src/proxies/censor.class.php
===================================================================
--- trunk/src/proxies/censor.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/proxies/censor.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -74,7 +74,7 @@
$p["sender"] = $sender;
$p["recipient"] = $recipient;
$p["recipientid"] = $recipientid;
- $this->next->run($xml_reponse, $p);
+ return $this->next->run($xml_reponse, $p);
}
}
Modified: trunk/src/proxies/checknickchange.class.php
===================================================================
--- trunk/src/proxies/checknickchange.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/proxies/checknickchange.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -58,7 +58,7 @@
{
$msg = _pfc("You are not allowed to change your nickname");
$xml_reponse->script("pfc.handleResponse('".$this->proxyname."', 'nick', '".addslashes($msg)."');");
- return;
+ return false;
}
$newnickid = $ct->getNickId($newnick);
@@ -70,7 +70,7 @@
$xml_reponse->script("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;
+ return true;
}
// now check the nickname is not yet used (unsensitive case)
@@ -84,7 +84,7 @@
$xml_reponse->script("pfc.handleResponse('nick', 'isused', '".addslashes($newnick)."');");
if ($c->debug)
pxlog("/nick ".$newnick." (wanted nick is allready in use -> wantednickid=".$newnickid.")", "chat", $c->getId());
- return;
+ return false;
}
}
@@ -100,12 +100,11 @@
$cmdp["param"] = $c->nick;
$cmdp["owner"] = $this->proxyname;
$cmd =& pfcCommand::Factory("nick");
- $cmd->run($xml_reponse, $cmdp);
- return;
+ return $cmd->run($xml_reponse, $cmdp);
}
// forward the command to the next proxy or to the final command
- $this->next->run($xml_reponse, $p);
+ return $this->next->run($xml_reponse, $p);
}
function _checkNickIsUsed($newnick, $oldnickid)
Modified: trunk/src/proxies/checktimeout.class.php
===================================================================
--- trunk/src/proxies/checktimeout.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/proxies/checktimeout.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -70,7 +70,7 @@
}
// forward the command to the next proxy or to the final command
- $this->next->run($xml_reponse, $p);
+ return $this->next->run($xml_reponse, $p);
}
}
Modified: trunk/src/proxies/lock.class.php
===================================================================
--- trunk/src/proxies/lock.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/proxies/lock.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -45,6 +45,7 @@
if ($c->islocked)
{
$xml_reponse->addRedirect($c->lockurl);
+ return false;
}
else
{
@@ -54,7 +55,7 @@
$p["sender"] = $sender;
$p["recipient"] = $recipient;
$p["recipientid"] = $recipientid;
- $this->next->run($xml_reponse, $p);
+ return $this->next->run($xml_reponse, $p);
}
}
}
Modified: trunk/src/proxies/log.class.php
===================================================================
--- trunk/src/proxies/log.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/proxies/log.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -69,7 +69,7 @@
}
// forward the command to the next proxy or to the final command
- $this->next->run($xml_reponse, $p);
+ return $this->next->run($xml_reponse, $p);
}
}
Modified: trunk/src/proxies/noflood.class.php
===================================================================
--- trunk/src/proxies/noflood.class.php 2007-03-10 11:30:38 UTC (rev 994)
+++ trunk/src/proxies/noflood.class.php 2007-03-11 12:37:38 UTC (rev 995)
@@ -81,7 +81,7 @@
$cmdp["param"] .=_pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], "noflood");
$cmd =& pfcCommand::Factory("leave");
$cmd->run($xml_reponse, $cmdp);
- return;
+ return false;
}
if ($flood_nbmsg == 0)
@@ -96,7 +96,7 @@
$p["sender"] = $sender;
$p["recipient"] = $recipient;
$p["recipientid"] = $recipientid;
- $this->next->run($xml_reponse, $p);
+ return $this->next->run($xml_reponse, $p);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|