Thread: [Phpfreechat-svn] SF.net SVN: phpfreechat: [488] trunk/src/commands
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-05-11 15:51:11
|
Revision: 488 Author: kerphi Date: 2006-05-11 08:51:03 -0700 (Thu, 11 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=488&view=rev Log Message: ----------- Bug fix: When I chat in 1:1. If one of the two members quit the discussion, closing this tab, if I speak again it will open a new tab for him, ok !! But if my correspondent quit the chat because he close his browser, it must appear off line, for the moment we could continue to chat with nobody... It could be fine to detect the off line status of the correspondent and display a "your correspondent is off line" message... Modified Paths: -------------- trunk/src/commands/getonlinenick.class.php trunk/src/commands/send.class.php Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-05-11 15:11:34 UTC (rev 487) +++ trunk/src/commands/getonlinenick.class.php 2006-05-11 15:51:03 UTC (rev 488) @@ -13,6 +13,7 @@ $oldnicklist = isset($_SESSION[$nicklist_sid]) ? $_SESSION[$nicklist_sid] : array(); $container =& $c->getContainerInstance(); + $disconnected_users = $container->removeObsoleteNick(NULL,$c->timeout); $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); foreach ($disconnected_users as $u) { Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2006-05-11 15:11:34 UTC (rev 487) +++ trunk/src/commands/send.class.php 2006-05-11 15:51:03 UTC (rev 488) @@ -6,25 +6,54 @@ { function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { - $c =& $this->c; - $u =& $this->u; + $c =& $this->c; + $u =& $this->u; + $nick = phpFreeChat::FilterSpecialChar($sender); + $text = phpFreeChat::PreFilterMsg($param); - //$xml_reponse->addScript("alert('send: sender=".addslashes($sender)." param=".addslashes($param)." recipient=".addslashes($recipient)." recipientid=".addslashes($recipientid)."');"); - // check the nick is not allready known - $nick = phpFreeChat::FilterSpecialChar($sender); - $text = phpFreeChat::PreFilterMsg($param); - + // if this channel is a pv (one to one channel), + // first of all, check if the other user is connected + // if he is not connected anymore, display an error + $can_send = true; + if (isset($u->privmsg[$recipientid])) + { + $pvnick = $u->privmsg[$recipientid]["name"]; + // now check if this user is currently online + $container =& $c->getContainerInstance(); + $onlineusers = $container->getOnlineNick(NULL); + if (!in_array($pvnick,$onlineusers)) + { + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $clientid, _pfc("Can't send the message, %s is offline", $pvnick)); + $can_send = false; + } + } + + + // check the sent text is not empty and the user has a none empty nickname $errors = array(); if ($text == "") $errors[$c->prefix."words"] = _pfc("Text cannot be empty"); if ($nick == "") $errors[$c->prefix."handle"] = _pfc("Please enter your nickname"); - if (count($errors) == 0) + if (count($errors) > 0) { + // 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()); + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $clientid, $errors); + if (isset($errors[$c->prefix."handle"])) // the nick is empty so give it focus + $xml_reponse->addScript("$('".$c->prefix."handle').focus();"); + $can_send = false; + } + + + // Now send the message if there is no errors + if ($can_send) + { $container =& $c->getContainerInstance(); $msgid = $container->write($recipient, $nick, "send", $text); if ($c->debug) pxlog("/send ".$text." (a user just sent a message -> nick=".$u->nick.")", "chat", $c->getId()); - - //$xml_reponse->addScript("alert('send: msgid=".$msgid."');"); // a message has been posted so : // - clear errors @@ -32,16 +61,6 @@ $xml_reponse->addScript("pfc.clearError(Array('".$c->prefix."words"."','".$c->prefix."handle"."'));"); $xml_reponse->addScript("$('".$c->prefix."words').focus();"); } - else - { - // 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()); - $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $errors); - if (isset($errors[$c->prefix."handle"])) // the nick is empty so give it focus - $xml_reponse->addScript("$('".$c->prefix."handle').focus();"); - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-11 16:30:40
|
Revision: 489 Author: kerphi Date: 2006-05-11 09:11:14 -0700 (Thu, 11 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=489&view=rev Log Message: ----------- Code cleaning: when a user close his window, take care to disconnect users from the server and from the joined channels. Modified Paths: -------------- trunk/src/commands/getonlinenick.class.php trunk/src/commands/update.class.php Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-05-11 15:51:03 UTC (rev 488) +++ trunk/src/commands/getonlinenick.class.php 2006-05-11 16:11:14 UTC (rev 489) @@ -7,19 +7,21 @@ function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; + $container =& $c->getContainerInstance(); - // get the actual nicklist - $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$recipientid; - $oldnicklist = isset($_SESSION[$nicklist_sid]) ? $_SESSION[$nicklist_sid] : array(); - - $container =& $c->getContainerInstance(); - $disconnected_users = $container->removeObsoleteNick(NULL,$c->timeout); + // take care to disconnect timeouted users on this channel $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); foreach ($disconnected_users as $u) { $cmd =& pfcCommand::Factory("notice"); $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$u), $sender, $recipient, $recipientid, 2); } + + // get the cached nickname list + $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$recipientid; + $oldnicklist = isset($_SESSION[$nicklist_sid]) ? $_SESSION[$nicklist_sid] : array(); + + // get the real nickname list $users = $container->getOnlineNick($recipient); sort($users); // check if the nickname list must be updated Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-05-11 15:51:03 UTC (rev 488) +++ trunk/src/commands/update.class.php 2006-05-11 16:11:14 UTC (rev 489) @@ -12,9 +12,20 @@ // do not update if user isn't active (didn't connect) if ($u->active) { + $container =& $c->getContainerInstance(); + + // take care to disconnect timeouted users on the server + $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); + // } + // ----- // check if other user talk to me or not - $container =& $c->getContainerInstance(); $nickid = $container->getNickId($u->nick); $pvnicks = $container->getMeta("privmsg", "nickname", $nickid); if (is_string($pvnicks)) $pvnicks = unserialize($pvnicks); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-11 16:48:03
|
Revision: 490 Author: kerphi Date: 2006-05-11 09:47:54 -0700 (Thu, 11 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=490&view=rev Log Message: ----------- improve the getOnlineNick function: now it returns the nicknames timestamps Modified Paths: -------------- trunk/src/commands/getonlinenick.class.php trunk/src/commands/nick.class.php trunk/src/commands/send.class.php trunk/src/containers/file.class.php Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-05-11 16:11:14 UTC (rev 489) +++ trunk/src/commands/getonlinenick.class.php 2006-05-11 16:47:54 UTC (rev 490) @@ -34,7 +34,7 @@ $js = ""; foreach ($users as $u) { - $nickname = addslashes($u); // must escape ' charactere for javascript string + $nickname = addslashes($u["nick"]); // must escape ' charactere for javascript string $js .= "'".$nickname."',"; } $js = substr($js, 0, strlen($js)-1); // remove last ',' Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-05-11 16:11:14 UTC (rev 489) +++ trunk/src/commands/nick.class.php 2006-05-11 16:47:54 UTC (rev 490) @@ -34,11 +34,11 @@ $online_users = $container->getOnlineNick(NULL); foreach($online_users as $ou) { - if (preg_match("/^".preg_quote($ou)."$/i",$newnick)) + if (preg_match("/^".preg_quote($ou["nick"])."$/i",$newnick)) { // the nick match // just allow the owner to change his capitalised letters - if ($container->getNickId($ou) != $oldnickid) + if ($container->getNickId($ou["nick"]) != $oldnickid) $nick_in_use = true; } } Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2006-05-11 16:11:14 UTC (rev 489) +++ trunk/src/commands/send.class.php 2006-05-11 16:47:54 UTC (rev 490) @@ -22,8 +22,14 @@ // now check if this user is currently online $container =& $c->getContainerInstance(); $onlineusers = $container->getOnlineNick(NULL); - if (!in_array($pvnick,$onlineusers)) + $uid = 0; $isonline = false; + while($uid < count($onlineusers) && !$isonline) { + if ($onlineusers[$uid]["nick"] == $pvnick) $isonline = true; + $uid++; + } + if (!$isonline) + { $cmd =& pfcCommand::Factory("error"); $cmd->run($xml_reponse, $clientid, _pfc("Can't send the message, %s is offline", $pvnick)); $can_send = false; Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-05-11 16:11:14 UTC (rev 489) +++ trunk/src/containers/file.class.php 2006-05-11 16:47:54 UTC (rev 490) @@ -147,11 +147,21 @@ @unlink($nick_filename); // remove the nickname from the cache list - if (isset($this->_users[$chan]) && - in_array($nick, $this->_users[$chan])) + if (isset($this->_users[$chan])) { - $key = array_search($nick, $this->_users[$chan]); - unset($this->_users[$chan][$key]); + $uid = 0; $isonline = false; + while($uid < count($this->_users[$chan]) && !$isonline) + { + if ($this->_users[$chan][$uid]["nick"] == $nick) + $isonline = true; + else + $uid++; + } + if ($isonline) + { + $key = $uid; + unset($this->_users[$chan][$key]); + } } return true; @@ -179,10 +189,21 @@ @chmod($nick_filename, 0777); // append the nickname to the cache list - if (isset($this->_users[$chan]) && - !in_array($nick, $this->_users[$chan])) + if (isset($this->_users[$chan])) { - $this->_users[$chan][] = $nick; + $uid = 0; $isonline = false; + while($uid < count($this->_users[$chan]) && !$isonline) + { + if ($this->_users[$chan][$uid]["nick"] == $nick) + $isonline = true; + else + $uid++; + } + if (!$isonline) + { + $this->_users[$chan][] = array("nick" => $nick, + "timestamp" => filemtime($nick_filename)); + } } return $there; @@ -210,14 +231,22 @@ // update the nick cache list if($ok) { - if (isset($this->_users[$chan]) && - in_array($oldnick, $this->_users[$chan])) + if (isset($this->_users[$chan])) { - // remove the oldnick from the cache - $key = array_search($oldnick, $this->_users[$chan]); - unset($this->_users[$chan][$key]); - // append the new nick to the cache - $this->_users[$chan][] = $newnick; + $uid = 0; $isonline = false; + while($uid < count($this->_users[$chan]) && !$isonline) + { + if ($this->_users[$chan][$uid]["nick"] == $oldnick) + $isonline = true; + else + $uid++; + } + if ($isonline) + { + $key = $uid; + $this->_users[$chan][$key]["nick"] = $newnick; + $this->_users[$chan][$key]["timestamp"] = filemtime($newnick_filename); + } } } @@ -287,8 +316,9 @@ } else { - // optimisation: cache user list for next getOnlineUserList call - $users[] = $this->_decode($file); + // optimisation: cache user list for next getOnlineNick call + $users[] = array("nick" => $this->_decode($file), + "timestamp" => filemtime($nick_dir."/".$file)); } } @@ -321,7 +351,8 @@ while (false !== ($file = readdir($dir_handle))) { if ($file == "." || $file == "..") continue; // skip . and .. generic files - $users[] = $this->_decode($file); + $users[] = array("nick" => $this->_decode($file), + "timestamp" => filemtime($nick_dir."/".$file)); } // cache the user list This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-23 20:33:37
|
Revision: 499 Author: kerphi Date: 2006-05-23 13:33:23 -0700 (Tue, 23 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=499&view=rev Log Message: ----------- code cleaning Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/send.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-05-19 13:39:57 UTC (rev 498) +++ trunk/src/commands/connect.class.php 2006-05-23 20:33:23 UTC (rev 499) @@ -14,45 +14,6 @@ $container =& $c->getContainerInstance(); $disconnected_users = $container->removeObsoleteNick(NULL, $c->timeout); - /* - // reset the nickname cache - $_SESSION[$c->prefix."nicklist_".$c->getId()."_".$clientid] = NULL; - - // disable or not the nickname button if the frozen_nick is on/off - if ($c->frozen_nick) - $xml_reponse->addAssign($c->prefix."handle", "disabled", true); - else - $xml_reponse->addAssign($c->prefix."handle", "disabled", false); - - // disconnect last connected users if necessary - $cmd =& pfcCommand::Factory("getonlinenick"); - $cmd->run($xml_reponse, $clientid); - - // check if the wanted nickname was allready known - if ($c->debug) - { - $container =& $c->getContainerInstance(); - $nickid = $container->getNickId($u->nick); - pxlog("/connect (nick=".$u->nick." nickid=".$nickid.")", "chat", $c->getId()); - } - - if ($u->nick == "") - { - // ask user to choose a nickname - $cmd =& pfcCommand::Factory("asknick"); - $cmd->run($xml_reponse, $clientid, ""); - } - else - { - $cmd =& pfcCommand::Factory("nick"); - $cmd->run($xml_reponse, $clientid, $u->nick); - } - */ - - // start updates - // $xml_reponse->addScript("pfc.updateChat(true);"); - // $xml_reponse->addScript("pfc.isconnected = true; pfc.refresh_loginlogout();"); - // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2006-05-19 13:39:57 UTC (rev 498) +++ trunk/src/commands/send.class.php 2006-05-23 20:33:23 UTC (rev 499) @@ -11,6 +11,10 @@ $nick = phpFreeChat::FilterSpecialChar($sender); $text = phpFreeChat::PreFilterMsg($param); + + + // $offline = $container->getMeta("offline", "nickname", $u->privmsg[$recipientid]["name"]); + // if this channel is a pv (one to one channel), // first of all, check if the other user is connected This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-27 10:33:23
|
Revision: 512 Author: kerphi Date: 2006-05-27 03:33:13 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=512&view=rev Log Message: ----------- Bug fix: the quit command didn't works Modified Paths: -------------- trunk/src/commands/kick.class.php trunk/src/commands/quit.class.php Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-05-27 10:29:54 UTC (rev 511) +++ trunk/src/commands/kick.class.php 2006-05-27 10:33:13 UTC (rev 512) @@ -9,7 +9,39 @@ $c =& $this->c; $u =& $this->u; - $xml_reponse->addScript("alert('/kick $param command');"); + + + + $container =& $c->getContainerInstance(); + $nickid = $container->getNickId($param); + + if ($nickid != "undefined") + { + $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); + if (!is_array($cmdtoplay)) $cmdtoplay = array(); + if (!isset($cmdtoplay["quit"])) $cmdtoplay["quit"] = array(); + $cmdtoplay["quit"][] = "dummy param"; + $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); + } + $xml_reponse->addScript("alert('/kick $param command -> $nickid');"); + + + /* + $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); + if (!is_array($cmdtoplay)) $cmdtoplay = array(); + if (!isset($cmdtoplay["privmsg2"])) $cmdtoplay["privmsg2"] = array(); + if (!in_array($u->nick, $cmdtoplay["privmsg2"])) + { + $cmdtoplay["privmsg2"][] = $u->nick; + $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + // $xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); + } + */ + + + } } Modified: trunk/src/commands/quit.class.php =================================================================== --- trunk/src/commands/quit.class.php 2006-05-27 10:29:54 UTC (rev 511) +++ trunk/src/commands/quit.class.php 2006-05-27 10:33:13 UTC (rev 512) @@ -15,18 +15,23 @@ // then remove the nickname file $container =& $c->getContainerInstance(); - foreach( $u->channels as $id => $chan ) - if ($container->removeNick($chan, $u->nick)) + + // from the channels + foreach( $u->channels as $id => $chandetail ) + if ($container->removeNick($chandetail["recipient"], $u->nick)) { $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit", $u->nick), $sender, $chan["recipient"], $id, 2); + $cmd->run($xml_reponse, $clientid, _pfc("%s quit", $u->nick), $sender, $chandetail["recipient"], $id, 2); } - foreach( $u->privmsg as $id => $pv ) - if ($container->removeNick($pv, $u->nick)) + // from the private messages + foreach( $u->privmsg as $id => $pvdetail ) + if ($container->removeNick($pvdetail["recipient"], $u->nick)) { $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit", $u->nick), $sender, $pv["recipient"], $id, 2); + $cmd->run($xml_reponse, $clientid, _pfc("%s quit", $u->nick), $sender, $pvdetail["recipient"], $id, 2); } + // from the server + $container->removeNick(NULL, $u->nick); $xml_reponse->addScript("pfc.handleResponse('quit', 'ok', '');"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-27 19:11:13
|
Revision: 513 Author: kerphi Date: 2006-05-27 12:11:04 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=513&view=rev Log Message: ----------- Implement a basic 'kick' command Modified Paths: -------------- trunk/src/commands/kick.class.php trunk/src/commands/quit.class.php Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-05-27 10:33:13 UTC (rev 512) +++ trunk/src/commands/kick.class.php 2006-05-27 19:11:04 UTC (rev 513) @@ -10,38 +10,19 @@ $u =& $this->u; - - + // kicking a user just add a command to play to the aimed user metadata. $container =& $c->getContainerInstance(); $nickid = $container->getNickId($param); - if ($nickid != "undefined") { $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); if (!is_array($cmdtoplay)) $cmdtoplay = array(); if (!isset($cmdtoplay["quit"])) $cmdtoplay["quit"] = array(); - $cmdtoplay["quit"][] = "dummy param"; + $cmdtoplay["quit"][] = _pfc("kicked by %s", $sender); $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); } - $xml_reponse->addScript("alert('/kick $param command -> $nickid');"); - - /* - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); - if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); - if (!is_array($cmdtoplay)) $cmdtoplay = array(); - if (!isset($cmdtoplay["privmsg2"])) $cmdtoplay["privmsg2"] = array(); - if (!in_array($u->nick, $cmdtoplay["privmsg2"])) - { - $cmdtoplay["privmsg2"][] = $u->nick; - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); - // $xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); - } - */ - - - } } Modified: trunk/src/commands/quit.class.php =================================================================== --- trunk/src/commands/quit.class.php 2006-05-27 10:33:13 UTC (rev 512) +++ trunk/src/commands/quit.class.php 2006-05-27 19:11:04 UTC (rev 513) @@ -15,20 +15,21 @@ // then remove the nickname file $container =& $c->getContainerInstance(); + $quitmsg = $param == "" ? _pfc("%s quit", $u->nick) : _pfc("%s quit (%s)", $u->nick, $param); // from the channels foreach( $u->channels as $id => $chandetail ) if ($container->removeNick($chandetail["recipient"], $u->nick)) { $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit", $u->nick), $sender, $chandetail["recipient"], $id, 2); + $cmd->run($xml_reponse, $clientid, $quitmsg, $sender, $chandetail["recipient"], $id, 2); } // from the private messages foreach( $u->privmsg as $id => $pvdetail ) if ($container->removeNick($pvdetail["recipient"], $u->nick)) { $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit", $u->nick), $sender, $pvdetail["recipient"], $id, 2); + $cmd->run($xml_reponse, $clientid, $quitmsg, $sender, $pvdetail["recipient"], $id, 2); } // from the server $container->removeNick(NULL, $u->nick); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-15 20:31:51
|
Revision: 593 Author: kerphi Date: 2006-06-15 13:31:43 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=593&view=rev Log Message: ----------- The "xxxx quit (timeout)" notification was broken Modified Paths: -------------- trunk/src/commands/getonlinenick.class.php trunk/src/commands/update.class.php trunk/src/containers/file.class.php Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-06-15 20:21:26 UTC (rev 592) +++ trunk/src/commands/getonlinenick.class.php 2006-06-15 20:31:43 UTC (rev 593) @@ -11,10 +11,10 @@ // take care to disconnect timeouted users on this channel $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); - foreach ($disconnected_users["nickid"] as $nid) + foreach ($disconnected_users["nick"] as $n) { $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$container->getNickname($nid)), $sender, $recipient, $recipientid, 2); + $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)", $n), $sender, $recipient, $recipientid, 2); } // get the cached nickname list Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-06-15 20:21:26 UTC (rev 592) +++ trunk/src/commands/update.class.php 2006-06-15 20:31:43 UTC (rev 593) @@ -11,19 +11,7 @@ // do not update if user isn't active (didn't connect) if ($u->active) - { - $container =& $c->getContainerInstance(); - - // take care to disconnect timeouted users on the server - $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); - // } - + { // update the user nickname timestamp $cmd =& pfcCommand::Factory("updatemynick"); foreach( $u->channels as $id => $chan ) @@ -46,6 +34,17 @@ foreach( $u->privmsg as $id => $pv ) $cmd->run($xml_reponse, $clientid, $param, $sender, $pv["recipient"], $id); + // 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); + // } + $xml_reponse->addScript("pfc.handleResponse('update', 'ok', '');"); } else Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-06-15 20:21:26 UTC (rev 592) +++ trunk/src/containers/file.class.php 2006-06-15 20:31:43 UTC (rev 593) @@ -334,6 +334,7 @@ $f_time = filemtime($nick_dir."/".$file); if (time() > ($f_time+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity { + $deleted_user["nick"][] = $this->getNickname($file); $deleted_user["nickid"][] = $file; $deleted_user["timestamp"][] = $f_time; @unlink($nick_dir."/".$file); // disconnect expired user This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-16 18:47:49
|
Revision: 604 Author: kerphi Date: 2006-06-16 11:47:36 -0700 (Fri, 16 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=604&view=rev Log Message: ----------- Bug fix: the "max_msg" parameter was broken, setting this parameter to zero displayed blank screen on next reload Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/getnewmsg.class.php trunk/src/commands/join.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-06-16 16:12:08 UTC (rev 603) +++ trunk/src/commands/connect.class.php 2006-06-16 18:47:36 UTC (rev 604) @@ -9,15 +9,28 @@ $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 + require_once(dirname(__FILE__)."/join.class.php"); + foreach($u->channels as $chan) + { + $channame = $chan["name"]; + $chanrecip = pfcCommand_join::GetRecipient($channame); + $chanid = pfcCommand_join::GetRecipientId($channame); + $from_id_sid = $c->prefix."from_id_".$c->getId()."_".$clientid."_".$chanid; + $from_id = $container->getLastId($chanrecip)-$c->max_msg; + $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; + } + + + // check if the user is alone on the server, and give it the admin status if yes $isadmin = $c->isadmin; if (!$isadmin) { - // check if the user is alone on the server, and give it the admin status if yes $users = $container->getOnlineNick(NULL); if (count($users["nickid"]) == 0) $isadmin = true; } Modified: trunk/src/commands/getnewmsg.class.php =================================================================== --- trunk/src/commands/getnewmsg.class.php 2006-06-16 16:12:08 UTC (rev 603) +++ trunk/src/commands/getnewmsg.class.php 2006-06-16 18:47:36 UTC (rev 604) @@ -11,7 +11,7 @@ // do nothing if the recipient is not defined if ($recipient == "") return; - // $xml_reponse->addScript("alert('getnewmsg: sender=".addslashes($sender)." param=".addslashes($param)." recipient=".addslashes($recipient)." recipientid=".addslashes($recipientid)."');"); + //$xml_reponse->addScript("alert('getnewmsg: sender=".addslashes($sender)." param=".addslashes($param)." recipient=".addslashes($recipient)." recipientid=".addslashes($recipientid)."');"); // check this methode is not being called if( isset($_SESSION[$c->prefix."lock_readnewmsg_".$c->getId()."_".$clientid]) ) Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-06-16 16:12:08 UTC (rev 603) +++ trunk/src/commands/join.class.php 2006-06-16 18:47:36 UTC (rev 604) @@ -34,18 +34,13 @@ $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$chanid; $_SESSION[$nicklist_sid] = NULL; - // reset the message id indicator - // i.e. be ready to re-get all last posted messages - $container =& $c->getContainerInstance(); - $from_id_sid = $c->prefix."from_id_".$c->getId()."_".$clientid."_".$chanid; - $from_id = $container->getLastId($chanrecip)-$c->max_msg; - $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; - // show a join message $cmd =& pfcCommand::Factory("notice"); $cmd->run($xml_reponse, $clientid, _pfc("%s joins %s",$u->nick, $channame), $sender, $chanrecip, $chanid, 1); } - //$xml_reponse->addScript("alert('join: chan=".$channame."');"); + + + //$xml_reponse->addScript("alert('join: chan=".$channame.", from_id=".$from_id."');"); // $xml_reponse->addScript("alert('join: u->nick=".$u->nick." chanid=".$chanid." channame=".addslashes($channame)."');"); // $xml_reponse->addScript("alert('join: fromidsid=".$from_id_sid."');"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-16 20:40:38
|
Revision: 607 Author: kerphi Date: 2006-06-16 13:40:30 -0700 (Fri, 16 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=607&view=rev Log Message: ----------- Bug fix: the oldmsg flag was broken Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/getnewmsg.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-06-16 20:30:27 UTC (rev 606) +++ trunk/src/commands/connect.class.php 2006-06-16 20:40:30 UTC (rev 607) @@ -21,11 +21,14 @@ $channame = $chan["name"]; $chanrecip = pfcCommand_join::GetRecipient($channame); $chanid = pfcCommand_join::GetRecipientId($channame); + // reset the fromid flag $from_id_sid = $c->prefix."from_id_".$c->getId()."_".$clientid."_".$chanid; $from_id = $container->getLastId($chanrecip)-$c->max_msg; $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; + // reset the oldmsg flag + $oldmsg_sid = $c->prefix."oldmsg_".$c->getId()."_".$clientid."_".$chanid; + $_SESSION[$oldmsg_sid] = true; } - // check if the user is alone on the server, and give it the admin status if yes $isadmin = $c->isadmin; Modified: trunk/src/commands/getnewmsg.class.php =================================================================== --- trunk/src/commands/getnewmsg.class.php 2006-06-16 20:30:27 UTC (rev 606) +++ trunk/src/commands/getnewmsg.class.php 2006-06-16 20:40:30 UTC (rev 607) @@ -37,6 +37,13 @@ $from_id = $container->getLastId($recipient)-$c->max_msg; if ($from_id < 0) $from_id = 0; } + // check if this is the first time you get messages + $oldmsg_sid = $c->prefix."oldmsg_".$c->getId()."_".$clientid."_".$recipientid; + if (isset($_SESSION[$oldmsg_sid])) + { + unset($_SESSION[$oldmsg_sid]); + $oldmsg = true; + } //$xml_reponse->addScript("alert('getnewmsg: fromidsid=".$from_id_sid."');"); //$xml_reponse->addScript("alert('getnewmsg: recipient=".$recipient." fromid=".$from_id."');"); @@ -61,7 +68,7 @@ $m_recipientid = $recipientid; $m_cmd = $d["cmd"]; $m_param = phpFreeChat::PostFilterMsg($d["param"]); - $js .= "Array(".$m_id.",'".addslashes($m_date)."','".addslashes($m_time)."','".addslashes($m_sender)."','".addslashes($m_recipientid)."','".addslashes($m_cmd)."','".addslashes($m_param)."',".(date("d/m/Y") == $m_date ? 1 : 0).",".($from_id == 0? 1 : 0)."),"; + $js .= "Array(".$m_id.",'".addslashes($m_date)."','".addslashes($m_time)."','".addslashes($m_sender)."','".addslashes($m_recipientid)."','".addslashes($m_cmd)."','".addslashes($m_param)."',".(date("d/m/Y") == $m_date ? 1 : 0).",".($oldmsg ? 1 : 0)."),"; $data_sent = true; } if ($js != "") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-17 18:20:30
|
Revision: 617 Author: kerphi Date: 2006-06-17 11:20:22 -0700 (Sat, 17 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=617&view=rev Log Message: ----------- fix warnings Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/getonlinenick.class.php trunk/src/commands/nick.class.php trunk/src/containers/file.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-06-17 12:33:51 UTC (rev 616) +++ trunk/src/commands/connect.class.php 2006-06-17 18:20:22 UTC (rev 617) @@ -40,7 +40,8 @@ if (!$isadmin) { $users = $container->getOnlineNick(NULL); - if (count($users["nickid"]) == 0) $isadmin = true; + if (isset($users["nickid"]) && + count($users["nickid"]) == 0) $isadmin = true; } // setup some user meta Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-06-17 12:33:51 UTC (rev 616) +++ trunk/src/commands/getonlinenick.class.php 2006-06-17 18:20:22 UTC (rev 617) @@ -11,11 +11,12 @@ // take care to disconnect timeouted users on this channel $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); - foreach ($disconnected_users["nick"] as $n) - { - $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)", $n), $sender, $recipient, $recipientid, 2); - } + if (isset($disconnected_users["nick"])) + foreach ($disconnected_users["nick"] as $n) + { + $cmd =& pfcCommand::Factory("notice"); + $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)", $n), $sender, $recipient, $recipientid, 2); + } // get the cached nickname list $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$recipientid; @@ -35,8 +36,8 @@ if ($c->debug) { - $nicklist = implode(",",$nicklist); - pxlog("/getonlinenick (nicklist updated - nicklist=".$nicklist.")", "chat", $c->getId()); + $nicklist2 = implode(",",$nicklist); + pxlog("/getonlinenick (nicklist updated - nicklist=".$nicklist2.")", "chat", $c->getId()); } // build and send the nickname list Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-06-17 12:33:51 UTC (rev 616) +++ trunk/src/commands/nick.class.php 2006-06-17 18:20:22 UTC (rev 617) @@ -34,16 +34,17 @@ // 'BoB' and 'bob' must be considered same nicknames $nick_in_use = false; $online_users = $container->getOnlineNick(NULL); - foreach($online_users["nickid"] as $nid) - { - if (preg_match("/^".preg_quote($container->getNickname($nid))."$/i",$newnick)) + if (isset($online_users["nickid"])) + foreach($online_users["nickid"] as $nid) { - // the nick match - // just allow the owner to change his capitalised letters - if ($nid != $oldnickid) - $nick_in_use = true; + 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 ( $newnickid == "undefined" && !$nick_in_use ) { Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-06-17 12:33:51 UTC (rev 616) +++ trunk/src/containers/file.class.php 2006-06-17 18:20:22 UTC (rev 617) @@ -112,7 +112,7 @@ // check the if the file exists only in debug mode! if ($c->debug) { - if (file_exists($nick_filename)) + if (file_exists($nickid_filename)) pxlog("createNick(".$nick.", ".$nickid.") - Error: another nickname data file exists, we are overwriting it (nickname takeover)!", "chat", $c->getId()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-22 08:12:35
|
Revision: 781 http://svn.sourceforge.net/phpfreechat/?rev=781&view=rev Author: kerphi Date: 2006-09-22 01:12:22 -0700 (Fri, 22 Sep 2006) Log Message: ----------- -- 1 -- [en] CPU Optimization: since the new data model some operation were useless and CPU consuming. [fr] Optimisation du CPU : depuis la mise en place du nouveau datamodel certaines op?\195?\169rations n'?\195?\169taient plus necessaire et consommaient du CPU inutile. -- 2 -- [en] Bug fix: the /leave command was broken [fr] Bug fix : la commande /leave ne fonctionnait plus Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/getonlinenick.class.php trunk/src/commands/join.class.php trunk/src/commands/leave.class.php trunk/src/commands/update.class.php trunk/src/commands/updatemynick.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/connect.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -14,7 +14,7 @@ $c =& $this->c; $u =& $this->u; - $container =& $c->getContainerInstance(); + $ct =& $c->getContainerInstance(); // reset the message id indicator (see getnewmsg.class.php) // i.e. be ready to re-get all last posted messages @@ -31,7 +31,7 @@ $chanid = pfcCommand_join::GetRecipientId($channame); // reset the fromid flag $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$chanid; - $from_id = $container->getLastId($chanrecip)-$c->max_msg; + $from_id = $ct->getLastId($chanrecip)-$c->max_msg; $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; // reset the oldmsg flag $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; @@ -42,7 +42,7 @@ $isadmin = $c->isadmin; if (!$isadmin) { - $users = $container->getOnlineNick(NULL); + $users = $ct->getOnlineNick(NULL); if (isset($users["nickid"]) && count($users["nickid"]) == 0) $isadmin = true; } @@ -50,9 +50,16 @@ // setup some user meta $nickid = $u->nickid; // store the user ip - $container->setUserMeta($nickid, 'ip', $_SERVER["REMOTE_ADDR"]); + $ct->setUserMeta($nickid, 'ip', $_SERVER["REMOTE_ADDR"]); // store the admin flag - $container->setUserMeta($nickid, 'isadmin', $isadmin); + $ct->setUserMeta($nickid, 'isadmin', $isadmin); + + // register the user (and his metadata) in the allready joined channel + foreach( $u->channels as $id => $chan ) + $ct->createNick($chan["recipient"], $u->nick, $u->nickid); + foreach( $u->privmsg as $id => $pv ) + $ct->createNick($pv["recipient"], $u->nick, $u->nickid); + // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); } Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/getonlinenick.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -22,9 +22,9 @@ // get the real nickname list $users = $container->getOnlineNick($recipient); $nicklist = array(); - if (isset($users["nickid"])) - foreach($users["nickid"] as $nid) - $nicklist[] = $container->getNickname($nid); + if (isset($users["nick"])) + foreach($users["nick"] as $n) + $nicklist[] = $n; sort($nicklist); if ($oldnicklist != $nicklist) // check if the nickname list must be updated on the client side Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/join.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -56,8 +56,12 @@ $cmdp["flag"] = 2; $cmd =& pfcCommand::Factory("notice"); $cmd->run($xml_reponse, $cmdp); + + // register the user (and his metadata) in the channel + $ct =& $c->getContainerInstance(); + $ct->createNick($chanrecip, $u->nick, $u->nickid); } - + // return ok to the client // then the client will create a new tab $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$chanid."','".addslashes($channame)."'));"); Modified: trunk/src/commands/leave.class.php =================================================================== --- trunk/src/commands/leave.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/leave.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -72,7 +72,7 @@ // remove the nickname from the channel/pv $container =& $c->getContainerInstance(); - $container->removeNick($chan, $u->nickid); + $container->removeNick($leave_recip, $u->nickid); // return ok to the client // then the client will remove the channel' tab Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/update.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -19,20 +19,8 @@ if ($u->active) { $cmdp = $p; - // update the user nickname timestamp + // update the user nickname timestamp on the server $cmd =& pfcCommand::Factory("updatemynick"); - foreach( $u->channels as $id => $chan ) - { - $cmdp["recipient"] = $chan["recipient"]; - $cmdp["recipientid"] = $id; - $cmd->run($xml_reponse, $cmdp); - } - foreach( $u->privmsg as $id => $pv ) - { - $cmdp["recipient"] = $pv["recipient"]; - $cmdp["recipientid"] = $id; - $cmd->run($xml_reponse, $cmdp); - } $cmdp["recipient"] = NULL; $cmdp["recipientid"] = NULL; $cmd->run($xml_reponse, $cmdp); Modified: trunk/src/commands/updatemynick.class.php =================================================================== --- trunk/src/commands/updatemynick.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/updatemynick.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -17,22 +17,6 @@ $container =& $c->getContainerInstance(); $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 - // because when the user is timeouted, his metadata are destroyed. - $container->createNick($recipient, $u->nick, $u->nickid); - - /* - @todo: write the timeout adjustment when the user object will be available - if ($c->debug) pxlog("Cmd_updateMyNick[".$c->sessionid."]: nick ".$u->nick." updated but was not there, adjust timeout to ".$c->timeout, "chat", $c->getId()); - // adjust the timeout value dynamicaly for this user - $c->timeout += $c->refresh_delay; - $c->saveInCache(); - */ - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-23 09:36:18
|
Revision: 788 http://svn.sourceforge.net/phpfreechat/?rev=788&view=rev Author: kerphi Date: 2006-09-23 02:36:13 -0700 (Sat, 23 Sep 2006) Log Message: ----------- [en] Bug fix: when a user was disconnected by timeout because of his bad connection, when hi comes back he was not correctly reconnected. So, private messages were broken. [1h15] [fr] Bug fix : lorsque un utilisateur est deconnect?\195?\169 par timeout a cause de sa mauvaise connexion, ses metadonnees ne sont pas recrees car il ne repasse pas par la commande /connect. La solution est d'appeler la m?\195?\169thode /connect dans le cas ou l'on d?\195?\169tecte que l'utilisateur n'est plus online juste apr?\195?\168s sa deconnexion au moment du /update suivant. [1h15] Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/update.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-23 09:31:52 UTC (rev 787) +++ trunk/src/commands/connect.class.php 2006-09-23 09:36:13 UTC (rev 788) @@ -11,6 +11,7 @@ $sender = $p["sender"]; $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; + $getoldmsg = isset($p["getoldmsg"]) ? $p["getoldmsg"] : true; $c =& $this->c; $u =& $this->u; @@ -18,26 +19,29 @@ // reset the message id indicator (see getnewmsg.class.php) // i.e. be ready to re-get all last posted messages - require_once(dirname(__FILE__)."/join.class.php"); - $channels = array(); - if (count($u->channels) == 0) - $channels = $c->channels; - else - foreach($u->channels as $chan) - $channels[] = $chan["name"]; - foreach($channels as $channame) + if ($getoldmsg) { - $chanrecip = pfcCommand_join::GetRecipient($channame); - $chanid = pfcCommand_join::GetRecipientId($channame); - // reset the fromid flag - $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$chanid; - $from_id = $ct->getLastId($chanrecip)-$c->max_msg; - $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; - // reset the oldmsg flag - $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; - $_SESSION[$oldmsg_sid] = true; + require_once(dirname(__FILE__)."/join.class.php"); + $channels = array(); + if (count($u->channels) == 0) + $channels = $c->channels; + else + foreach($u->channels as $chan) + $channels[] = $chan["name"]; + foreach($channels as $channame) + { + $chanrecip = pfcCommand_join::GetRecipient($channame); + $chanid = pfcCommand_join::GetRecipientId($channame); + // reset the fromid flag + $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$chanid; + $from_id = $ct->getLastId($chanrecip)-$c->max_msg; + $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; + // reset the oldmsg flag + $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; + $_SESSION[$oldmsg_sid] = true; + } } - + // check if the user is alone on the server, and give it the admin status if yes $isadmin = $c->isadmin; if (!$isadmin) Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-09-23 09:31:52 UTC (rev 787) +++ trunk/src/commands/update.class.php 2006-09-23 09:36:13 UTC (rev 788) @@ -18,7 +18,19 @@ // do not update if user isn't active (didn't connect) if ($u->active) { + // check the user has not been disconnected from the server by timeout + // if I found he has been disconnected, then I reconnect him with /connect command + $ct =& $c->getContainerInstance(); + if ($ct->isNickOnline(NULL, $u->nickid) < 0) + { + $cmd =& pfcCommand::Factory("connect"); + $cmdp = $p; + $cmdp["getoldmsg"] = false; + $cmd->run($xml_reponse, $cmdp); + } + $cmdp = $p; + // update the user nickname timestamp on the server $cmd =& pfcCommand::Factory("updatemynick"); $cmdp["recipient"] = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-10-04 11:26:22
|
Revision: 820 http://svn.sourceforge.net/phpfreechat/?rev=820&view=rev Author: kerphi Date: 2006-10-04 04:26:16 -0700 (Wed, 04 Oct 2006) Log Message: ----------- [en] Bandwidth optimization: store user's list in cache and send it to the browser only when it changes. [30min] [fr] Optimisation de la bande passante : la liste des utilisateurs est mise en cache et n'est envoy?\195?\169e au navigateur que lorsqu'elle a chang?\195?\169. [30min] Modified Paths: -------------- trunk/src/commands/who.class.php trunk/src/commands/who2.class.php Modified: trunk/src/commands/who.class.php =================================================================== --- trunk/src/commands/who.class.php 2006-10-04 09:40:34 UTC (rev 819) +++ trunk/src/commands/who.class.php 2006-10-04 11:26:16 UTC (rev 820) @@ -20,7 +20,6 @@ * Boston, MA 02110-1301 USA */ -require_once(dirname(__FILE__)."/../../lib/json/JSON.php"); require_once(dirname(__FILE__)."/../pfccommand.class.php"); class pfcCommand_who extends pfcCommand @@ -44,7 +43,15 @@ $recipient = pfcCommand_join::GetRecipient($param); $recipientid = pfcCommand_join::GetRecipientId($param); } + + $chanmeta = $this->_getChanMeta($recipient, $recipientid); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', ".$chanmeta.");"); + } + + function _getChanMeta($recipient, $recipientid) + { + $c =& $this->c; $ct =& $c->getContainerInstance(); $chanmeta = array(); $chanmeta['chan'] = $recipient; @@ -55,9 +62,10 @@ $chanmeta['meta']['users']['nick'] = $users['nick']; $chanmeta['meta']['users']['nickid'] = $users['nickid']; + require_once(dirname(__FILE__)."/../../lib/json/JSON.php"); $json = new Services_JSON(); $js = $json->encode($chanmeta); - $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', ".$js.");"); + return $js; } } Modified: trunk/src/commands/who2.class.php =================================================================== --- trunk/src/commands/who2.class.php 2006-10-04 09:40:34 UTC (rev 819) +++ trunk/src/commands/who2.class.php 2006-10-04 11:26:16 UTC (rev 820) @@ -24,6 +24,40 @@ class pfcCommand_who2 extends pfcCommand_who { + + 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 ($param != "") + { + require_once dirname(__FILE__)."/join.class.php"; + $recipient = pfcCommand_join::GetRecipient($param); + $recipientid = pfcCommand_join::GetRecipientId($param); + } + + $chanmeta = $this->_getChanMeta($recipient, $recipientid); + + // check if info didn't change since last call + $sid = "pfc_who2_".$c->getId()."_".$clientid."_".$recipientid; + if (isset($_SESSION[$sid]) && $chanmeta == $_SESSION[$sid]) + { + // do not send the response to save bandwidth + //$xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'unchanged', '');"); + } + else + { + $_SESSION[$sid] = $chanmeta; + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', ".$chanmeta.");"); + } + } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-10-16 15:18:23
|
Revision: 830 http://svn.sourceforge.net/phpfreechat/?rev=830&view=rev Author: kerphi Date: 2006-10-16 08:17:57 -0700 (Mon, 16 Oct 2006) Log Message: ----------- add commented traces Modified Paths: -------------- trunk/src/commands/privmsg.class.php trunk/src/commands/send.class.php trunk/src/commands/who2.class.php Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-10-16 15:17:20 UTC (rev 829) +++ trunk/src/commands/privmsg.class.php 2006-10-16 15:17:57 UTC (rev 830) @@ -29,6 +29,8 @@ return; } + //$this->trace($xml_reponse, $this->name, $sender); + // error: can't speak to unknown if ($pvnickid == '') { Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2006-10-16 15:17:20 UTC (rev 829) +++ trunk/src/commands/send.class.php 2006-10-16 15:17:57 UTC (rev 830) @@ -27,9 +27,9 @@ $cmd->run($xml_reponse, $cmdp); return; } - - // $offline = $container->getMeta("offline", "nickname", $u->privmsg[$recipientid]["name"]); + + // $offline = $container->getMeta("offline", "nickname", $u->privmsg[$recipientid]["name"]); // if this channel is a pv (one to one channel), // first of all, check if the other user is connected Modified: trunk/src/commands/who2.class.php =================================================================== --- trunk/src/commands/who2.class.php 2006-10-16 15:17:20 UTC (rev 829) +++ trunk/src/commands/who2.class.php 2006-10-16 15:17:57 UTC (rev 830) @@ -45,6 +45,9 @@ $chanmeta = $this->_getChanMeta($recipient, $recipientid); + //if (preg_match("/^pv_/", $recipient)) + //$this->trace($xml_reponse, 'who2', $recipient); + // check if info didn't change since last call $sid = "pfc_who2_".$c->getId()."_".$clientid."_".$recipientid; if (isset($_SESSION[$sid]) && $chanmeta == $_SESSION[$sid]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-10-22 13:23:38
|
Revision: 839 http://svn.sourceforge.net/phpfreechat/?rev=839&view=rev Author: kerphi Date: 2006-10-22 06:23:30 -0700 (Sun, 22 Oct 2006) Log Message: ----------- [en] Bug fix: when max_msg was set to 0 the first posted message in a PV was lost. [1h30] [fr] Bug fix : lorsque max_msg valait 0 le premier message post?\195?\169 dans un message priv?\195?\169 ?\195?\169tait perdu. [1h30] Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/privmsg.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-10-20 20:39:06 UTC (rev 838) +++ trunk/src/commands/connect.class.php 2006-10-22 13:23:30 UTC (rev 839) @@ -21,6 +21,7 @@ // i.e. be ready to re-get all last posted messages if ($getoldmsg) { + // reset the channel identifiers require_once(dirname(__FILE__)."/join.class.php"); $channels = array(); if (count($u->channels) == 0) @@ -40,6 +41,21 @@ $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; $_SESSION[$oldmsg_sid] = true; } + // reset the private messages identifiers + if (count($u->privmsg) > 0) + { + foreach($u->privmsg as $recipientid2 => $pv) + { + $recipient2 = $pv['recipient']; + // reset the fromid flag + $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$recipientid2; + $from_id = $ct->getLastId($recipient2)-$c->max_msg; + $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; + // reset the oldmsg flag + $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$recipientid2; + $_SESSION[$oldmsg_sid] = true; + } + } } // check if the user is alone on the server, and give it the admin status if yes Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-10-20 20:39:06 UTC (rev 838) +++ trunk/src/commands/privmsg.class.php 2006-10-22 13:23:30 UTC (rev 839) @@ -78,7 +78,7 @@ // reset the message id indicator // i.e. be ready to re-get all last posted messages $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$pvrecipientid; - $from_id = $container->getLastId($pvrecipient)-$c->max_msg; + $from_id = $container->getLastId($pvrecipient)-$c->max_msg-1; $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; // register the user (and his metadata) in this pv This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-10-29 10:36:32
|
Revision: 848 http://svn.sourceforge.net/phpfreechat/?rev=848&view=rev Author: kerphi Date: 2006-10-29 02:36:26 -0800 (Sun, 29 Oct 2006) Log Message: ----------- code cleaning Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/join.class.php trunk/src/commands/privmsg.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-10-29 10:33:50 UTC (rev 847) +++ trunk/src/commands/connect.class.php 2006-10-29 10:36:26 UTC (rev 848) @@ -81,15 +81,7 @@ // store the customized nick metadata foreach($c->nickmeta as $k => $v) $ct->setUserMeta($nickid, $k, $v); - - // register the user (and his metadata) in the allready joined channel - foreach( $u->channels as $id => $chan ) - $ct->createNick($chan["recipient"], $u->nick, $u->nickid); - foreach( $u->privmsg as $id => $pv ) - $ct->createNick($pv["recipient"], $u->nick, $u->nickid); - $this->forceWhoisReload($u->nick); - // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); } Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-10-29 10:33:50 UTC (rev 847) +++ trunk/src/commands/join.class.php 2006-10-29 10:36:26 UTC (rev 848) @@ -52,11 +52,12 @@ $cmdp["flag"] = 2; $cmd =& pfcCommand::Factory("notice"); $cmd->run($xml_reponse, $cmdp); + } - // register the user (and his metadata) in the channel - $ct =& $c->getContainerInstance(); - $ct->createNick($chanrecip, $u->nick, $u->nickid); - } + // register the user (and his metadata) in the channel + $ct =& $c->getContainerInstance(); + $ct->createNick($chanrecip, $u->nick, $u->nickid); + $this->forceWhoisReload($u->nick); // return ok to the client // then the client will create a new tab Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-10-29 10:33:50 UTC (rev 847) +++ trunk/src/commands/privmsg.class.php 2006-10-29 10:36:26 UTC (rev 848) @@ -80,12 +80,13 @@ $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$pvrecipientid; $from_id = $container->getLastId($pvrecipient)-$c->max_msg-1; $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; - - // register the user (and his metadata) in this pv - $ct =& $c->getContainerInstance(); - $ct->createNick($pvrecipient, $u->nick, $u->nickid); } + // register the user (and his metadata) in this pv + $ct =& $c->getContainerInstance(); + $ct->createNick($pvrecipient, $u->nick, $u->nickid); + $this->forceWhoisReload($u->nick); + // return ok to the client // then the client will create a new tab $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$pvrecipientid."','".addslashes($pvname)."'));"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-07-27 07:30:58
|
Revision: 1057 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1057&view=rev Author: kerphi Date: 2007-07-27 00:30:58 -0700 (Fri, 27 Jul 2007) Log Message: ----------- Allow unquotted reason for /kick and /ban commands (thanks to ljbuesch) http://www.phpfreechat.net/forum/viewtopic.php?id=1699 Modified Paths: -------------- trunk/src/commands/ban.class.php trunk/src/commands/kick.class.php Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2007-07-23 10:21:38 UTC (rev 1056) +++ trunk/src/commands/ban.class.php 2007-07-27 07:30:58 UTC (rev 1057) @@ -21,6 +21,12 @@ $nick = isset($params[0]) ? $params[0] : ''; $reason = isset($params[1]) ? $params[1] : ''; if ($reason == '') $reason = _pfc("no reason"); + + // to allow unquotted reason + if (count($params) > 2) + for ($x=2;$x<count($params);$x++) + $reason.=" ".$params[$x]; + $channame = $u->channels[$recipientid]["name"]; if ($nick == '') Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2007-07-23 10:21:38 UTC (rev 1056) +++ trunk/src/commands/kick.class.php 2007-07-27 07:30:58 UTC (rev 1057) @@ -22,6 +22,11 @@ $reason = isset($params[1]) ? $params[1] : ''; if ($reason == '') $reason = _pfc("no reason"); + // to allow unquotted reason + if (count($params) > 2) + for ($x=2;$x<count($params);$x++) + $reason.=" ".$params[$x]; + if ($nick == '') { // error This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |