Thread: [Phpfreechat-svn] SF.net SVN: phpfreechat: [748] trunk/src (Page 3)
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-09-10 20:48:10
|
Revision: 748 http://svn.sourceforge.net/phpfreechat/?rev=748&view=rev Author: kerphi Date: 2006-09-10 13:47:57 -0700 (Sun, 10 Sep 2006) Log Message: ----------- [en] Bug fix: two users with same nick at same time (thanks to wjwlsn, SF bug 1555160). [fr] Bug fix : Deux utilisateurs avec le m?\195?\170me pseudo pouvaient parler ensemble (merci ?\195?\160 wjwlsn, SF bug 1555160). Modified Paths: -------------- trunk/src/client/pfcclient.js trunk/src/proxys/checknickchange.class.php Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-10 19:18:38 UTC (rev 747) +++ trunk/src/client/pfcclient.js 2006-09-10 20:47:57 UTC (rev 748) @@ -303,10 +303,14 @@ { this.el_handle.innerHTML = param; this.nickname = param; + + // clear the possible error box generated by the bellow displayMsg(...) function + this.clearError(Array(this.el_words)); } else if (resp == "isused") { - this.displayMsg( cmd, this.res.getLabel('Choosen nickname is allready used') ); + this.setError(this.res.getLabel('Choosen nickname is allready used'), Array()); + this.askNick(param); } else alert(cmd + "-"+resp+"-"+param); @@ -620,7 +624,7 @@ displayMsg: function( cmd, msg ) { - this.setError(msg); + this.setError(msg, Array()); // @todo find a better crossbrowser way to display messages /* Modified: trunk/src/proxys/checknickchange.class.php =================================================================== --- trunk/src/proxys/checknickchange.class.php 2006-09-10 19:18:38 UTC (rev 747) +++ trunk/src/proxys/checknickchange.class.php 2006-09-10 20:47:57 UTC (rev 748) @@ -46,14 +46,6 @@ $newnick = phpFreeChat::FilterNickname($param); $oldnick = $u->nick; - if ($newnick == $oldnick) - { - $xml_reponse->addScript("pfc.handleResponse('nick', '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; - } - // if the user want to change his nickname but the frozen_nick is enable // then send him a warning if ( $this->name == "nick" && @@ -69,8 +61,17 @@ $container =& $c->getContainerInstance(); $newnickid = $container->getNickId($newnick); - $oldnickid = $container->getNickId($oldnick); + $oldnickid = $u->nickid; + if ($newnick == $oldnick && + $newnickid == $oldnickid) + { + $xml_reponse->addScript("pfc.handleResponse('nick', '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; + } + // now check the nickname is not yet used (unsensitive case) // 'BoB' and 'bob' must be considered same nicknames $nick_in_use = false; @@ -86,20 +87,13 @@ $nick_in_use = true; } } - if ($nick_in_use) + if ($nick_in_use || $newnickid != "undefined") { $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; } - - if ( $newnickid != "undefined" ) - { - // @todo notify the user ? - return; - } - } // allow nick changes only from the parameters array (server side) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-12 14:23:41
|
Revision: 756 http://svn.sourceforge.net/phpfreechat/?rev=756&view=rev Author: kerphi Date: 2006-09-12 07:23:29 -0700 (Tue, 12 Sep 2006) Log Message: ----------- Improve the max_text_len handeling Modified Paths: -------------- trunk/src/client/pfcgui.js trunk/src/phpfreechat.class.php Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-09-12 14:14:00 UTC (rev 755) +++ trunk/src/client/pfcgui.js 2006-09-12 14:23:29 UTC (rev 756) @@ -386,7 +386,7 @@ inputwords.setAttribute('id', 'pfc_words'); inputwords.setAttribute('type', 'text'); inputwords.setAttribute('title', pfc.res.getLabel("Enter your message here")); - inputwords.setAttribute('maxlength', pfc_max_text_len - 25); + inputwords.setAttribute('maxlength', pfc_max_text_len); inputcontainer.appendChild(inputwords); // command container : <div id="pfc_cmd_container"> Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-12 14:14:00 UTC (rev 755) +++ trunk/src/phpfreechat.class.php 2006-09-12 14:23:29 UTC (rev 756) @@ -270,7 +270,11 @@ function PreFilterMsg($msg) { $c =& pfcGlobalConfig::Instance(); - $msg = utf8_substr($msg, 0, $c->max_text_len); + if (preg_match("/^\[/i",$msg)) + // add 25 characteres if the message starts with [ : means there is a bbcode + $msg = utf8_substr($msg, 0, $c->max_text_len+25); + else + $msg = utf8_substr($msg, 0, $c->max_text_len); $msg = phpFreeChat::FilterSpecialChar($msg); // $msg = phpFreeChat::FilterSmiley($msg); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-12 16:53:56
|
Revision: 758 http://svn.sourceforge.net/phpfreechat/?rev=758&view=rev Author: kerphi Date: 2006-09-12 09:53:44 -0700 (Tue, 12 Sep 2006) Log Message: ----------- [en] Bug fix: add a references counter in order to know when the user is really disconnecter (no more '* quit (timeout)'). [fr] Bug fix : ajout d'un compteur de references de facon a detecter precisement lorsqu'un utilisateur est vraiment deconnect (fini les '* quit (timeout)'). Modified Paths: -------------- trunk/src/commands/nick.class.php trunk/src/containers/file.class.php Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-09-12 14:51:27 UTC (rev 757) +++ trunk/src/commands/nick.class.php 2006-09-12 16:53:44 UTC (rev 758) @@ -74,12 +74,15 @@ // -> this is a first connection if ($oldnickid != $u->nickid) { - // this is a first connection (create the nickname) + // this is a first connection : create the nickname on the server $container->createNick(NULL, $newnick, $u->nickid); + /* + // useless code, it's done in updatemynick command foreach($u->channels as $chan) $container->createNick($chan["recipient"], $newnick, $u->nickid); foreach($u->privmsg as $pv) $container->createNick($pv["recipient"], $newnick, $u->nickid); + */ $u->nick = $newnick; $u->active = true; $u->saveInCache(); Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-09-12 14:51:27 UTC (rev 757) +++ trunk/src/containers/file.class.php 2006-09-12 16:53:44 UTC (rev 758) @@ -94,6 +94,13 @@ $this->setMeta($nick, "nickname", "fromnickid", $nickid); $this->setMeta($nickid, "nickid", "fromnickname", $nick); + // increment the nick references (used to know when the nick is really disconnected) + $nick_ref = $this->getMeta("references", $nickid); + if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; + $nick_ref++; + $this->setMeta($nick_ref, "references", $nickid); + + $c =& $this->c; $nick_dir = ($chan != NULL) ? $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : @@ -169,11 +176,21 @@ $ok = @unlink($nickid_filename); // remove the user metadata if he is disconnected from the server - if ($chan == NULL) + + // decrement the nick references and kill the metadata if not more references is found + // (used to know when the nick is really disconnected) + $nick_ref = $this->getMeta("references", $nickid); + if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; + $nick_ref--; + if ($nick_ref <= 0) { $this->rmMeta("nickid", "fromnickname", $nick); $this->rmMeta("nickname", "fromnickid", $nickid); + $this->rmMeta("references", $nickid); // destroy also the reference counter (by default its value is 0) } + else + $this->setMeta($nick_ref, "references", $nickid); + if ($c->debug) { @@ -349,12 +366,27 @@ } // remove the user metadata if he is disconnected from the server - if ($chan == NULL && isset($deleted_user["nickid"])) + if (isset($deleted_user["nickid"]) && count($deleted_user["nickid"])>0) { foreach($deleted_user["nickid"] as $du_nid) { - $this->rmMeta("nickid", "fromnickname", $this->getNickname($du_nid)); - $this->rmMeta("nickname", "fromnickid", $du_nid); + $du_nickid = $du_nid; + $du_nickname = $this->getNickname($du_nid); + + // decrement the nick references and kill the metadata if not more references is found + // (used to know when the nick is really disconnected) + $nick_ref = $this->getMeta("references", $du_nickid); + if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; + $nick_ref--; + if ($nick_ref <= 0) + { + $this->rmMeta("nickid", "fromnickname", $du_nickname); + $this->rmMeta("nickname", "fromnickid", $du_nickid); + $this->rmMeta("references", $du_nickid); // destroy also the reference counter (by default its value is 0) + } + else + $this->setMeta($nick_ref, "references", $du_nickid); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-16 20:40:00
|
Revision: 765 http://svn.sourceforge.net/phpfreechat/?rev=765&view=rev Author: kerphi Date: 2006-09-16 13:39:51 -0700 (Sat, 16 Sep 2006) Log Message: ----------- [en] Now the commands name are case unsensitive. [fr] Maintenant les nom des commandes ne sont plus sensible a la casse. Modified Paths: -------------- trunk/src/client/pfcclient.js trunk/src/phpfreechat.class.php Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-16 20:32:44 UTC (rev 764) +++ trunk/src/client/pfcclient.js 2006-09-16 20:39:51 UTC (rev 765) @@ -450,7 +450,7 @@ this.cmdhistoryissearching = false; // send the string to the server - re = new RegExp("^(\/[a-z0-9]+)( (.*)|)"); + re = new RegExp("^(\/[a-zA-Z0-9]+)( (.*)|)"); if (wval.match(re)) { /* a user command */ Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-16 20:32:44 UTC (rev 764) +++ trunk/src/phpfreechat.class.php 2006-09-16 20:39:51 UTC (rev 765) @@ -318,10 +318,10 @@ $sender = ""; //if (preg_match("/^\/([a-z]*) ([0-9a-f]*) ([0-9a-f]*)( (.*)|)/", $request, $res)) //if (preg_match("/^\/([a-z]+) ([0-9a-f]+) ([0-9a-f]+) (.*)/", $request, $res)) - if (preg_match("/^\/([a-z0-9]+) ([0-9a-f]+) ([0-9a-f]+)( (.*)|)/", $request, $res)) + if (preg_match("/^\/([a-zA-Z0-9]+) ([0-9a-f]+) ([0-9a-f]+)( (.*)|)/", $request, $res)) { - $rawcmd = isset($res[1]) ? $res[1] : ""; + $rawcmd = strtolower(isset($res[1]) ? $res[1] : ""); $clientid = isset($res[2]) ? $res[2] : ""; $recipientid = isset($res[3]) ? $res[3] : ""; $param = isset($res[5]) ? $res[5] : ""; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-17 20:51:45
|
Revision: 767 http://svn.sourceforge.net/phpfreechat/?rev=767&view=rev Author: kerphi Date: 2006-09-17 13:51:29 -0700 (Sun, 17 Sep 2006) Log Message: ----------- Work in progress: the disconnect by timeout process is buggy (don't checkout this revision) Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/getnewmsg.class.php trunk/src/commands/getonlinenick.class.php trunk/src/commands/join.class.php trunk/src/commands/privmsg.class.php trunk/src/commands/send.class.php trunk/src/containers/file.class.php trunk/src/pfcuserconfig.class.php Removed Paths: ------------- trunk/src/containers/memory.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/commands/connect.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -30,11 +30,11 @@ $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_sid = "pfc_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; + $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; $_SESSION[$oldmsg_sid] = true; } Modified: trunk/src/commands/getnewmsg.class.php =================================================================== --- trunk/src/commands/getnewmsg.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/commands/getnewmsg.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -19,21 +19,21 @@ //$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]) ) + if( isset($_SESSION["pfc_lock_readnewmsg_".$c->getId()."_".$clientid]) ) { // kill the lock if it has been created more than 10 seconds ago $last_10sec = time()-10; - $last_lock = $_SESSION[$c->prefix."lock_readnewmsg_".$c->getId()."_".$clientid]; - if ($last_lock < $last_10sec) $_SESSION[$c->prefix."lock_".$c->getId()."_".$clientid] = 0; - if ( $_SESSION[$c->prefix."lock_readnewmsg_".$c->getId()."_".$clientid] != 0 ) exit; + $last_lock = $_SESSION["pfc_lock_readnewmsg_".$c->getId()."_".$clientid]; + if ($last_lock < $last_10sec) $_SESSION["pfc_lock_".$c->getId()."_".$clientid] = 0; + if ( $_SESSION["pfc_lock_readnewmsg_".$c->getId()."_".$clientid] != 0 ) exit; } // create a new lock - $_SESSION[$c->prefix."lock_readnewmsg_".$c->getId()."_".$clientid] = time(); + $_SESSION["pfc_lock_readnewmsg_".$c->getId()."_".$clientid] = time(); // read the last from_id value $container =& $c->getContainerInstance(); - $from_id_sid = $c->prefix."from_id_".$c->getId()."_".$clientid."_".$recipientid; + $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$recipientid; $from_id = 0; if (isset($_SESSION[$from_id_sid])) $from_id = $_SESSION[$from_id_sid]; @@ -43,7 +43,7 @@ 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; + $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$recipientid; $oldmsg = false; if (isset($_SESSION[$oldmsg_sid])) { @@ -91,7 +91,7 @@ } // remove the lock - $_SESSION[$c->prefix."lock_readnewmsg_".$c->getId()."_".$clientid] = 0; + $_SESSION["pfc_lock_readnewmsg_".$c->getId()."_".$clientid] = 0; } } Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/commands/getonlinenick.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -16,7 +16,7 @@ $container =& $c->getContainerInstance(); // get the cached nickname list - $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$recipientid; + $nicklist_sid = "pfc_nicklist_".$c->getId()."_".$clientid."_".$recipientid; $oldnicklist = isset($_SESSION[$nicklist_sid]) ? $_SESSION[$nicklist_sid] : array(); // get the real nickname list Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/commands/join.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -38,7 +38,7 @@ $u->saveInCache(); // clear the cached nicknames list for the given channel - $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$chanid; + $nicklist_sid = "pfc_nicklist_".$c->getId()."_".$clientid."_".$chanid; $_SESSION[$nicklist_sid] = NULL; } Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/commands/privmsg.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -67,12 +67,12 @@ $u->saveInCache(); // clear the cached nicknames list for the given channel - $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$pvrecipientid; + $nicklist_sid = "pfc_nicklist_".$c->getId()."_".$clientid."_".$pvrecipientid; $_SESSION[$nicklist_sid] = NULL; // reset the message id indicator // i.e. be ready to re-get all last posted messages - $from_id_sid = $c->prefix."from_id_".$c->getId()."_".$clientid."_".$pvrecipientid; + $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$pvrecipientid; $from_id = $container->getLastId($pvrecipient)-$c->max_msg; $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; } Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/commands/send.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -57,8 +57,8 @@ // 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 ($text == "") $errors["pfc_words"] = _pfc("Text cannot be empty"); + if ($nick == "") $errors["pfc_handle"] = _pfc("Please enter your nickname"); if (count($errors) > 0) { // an error occured, just ignore the message and display errors @@ -68,8 +68,8 @@ $cmdp["param"] = $errors; $cmd =& pfcCommand::Factory("error"); $cmd->run($xml_reponse, $cmdp); - if (isset($errors[$c->prefix."handle"])) // the nick is empty so give it focus - $xml_reponse->addScript("$('".$c->prefix."handle').focus();"); + if (isset($errors["pfc_handle"])) // the nick is empty so give it focus + $xml_reponse->addScript("$('pfc_handle').focus();"); $can_send = false; } @@ -92,8 +92,8 @@ // a message has been posted so : // - clear errors // - give focus to "words" field - $xml_reponse->addScript("pfc.clearError(Array('".$c->prefix."words"."','".$c->prefix."handle"."'));"); - $xml_reponse->addScript("$('".$c->prefix."words').focus();"); + $xml_reponse->addScript("pfc.clearError(Array('pfc_words"."','pfc_handle"."'));"); + $xml_reponse->addScript("$('pfc_words').focus();"); } } } Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/containers/file.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -90,17 +90,25 @@ */ function createNick($chan, $nick, $nickid) { + $c =& $this->c; + // store nickid -> nickname and nickname -> nickid correspondance $this->setMeta($nick, "nickname", "fromnickid", $nickid); $this->setMeta($nickid, "nickid", "fromnickname", $nick); + $this->_registerUserMeta($nickid, $chan); + + if ($c->debug) pxlog("createNick - nickname metadata created: chan=".($chan==NULL?"SERVER":$chan)." nickid=".$nickid, "chat", $c->getId()); + + /* // increment the nick references (used to know when the nick is really disconnected) $nick_ref = $this->getMeta("references", $nickid); if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; $nick_ref++; $this->setMeta($nick_ref, "references", $nickid); + */ - + $c =& $this->c; $nick_dir = ($chan != NULL) ? $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : @@ -119,19 +127,16 @@ // check the if the file exists only in debug mode! if ($c->debug) { + /* if (file_exists($nickid_filename)) - pxlog("createNick(".$nick.", ".$nickid.") - Error: another nickname data file exists, we are overwriting it (nickname takeover)!", "chat", $c->getId()); + pxlog("createNick(".$nick.", ".$nickid.") - Error: another nickname data file exists, we are overwriting it (nickname takeover)!: ".$nickid_filename, "chat", $c->getId()); + else + pxlog("createNick - nickname file created: chan=".($chan==NULL?"SERVER":$chan)." nickid=".$nickid, "chat", $c->getId()); + */ } // trust the caller : this nick is not used touch($nickid_filename); - /* - $fp = fopen($nickid_filename, "w"); - flock ($fp, LOCK_EX); // lock - fwrite($fp, $nickid); - flock ($fp, LOCK_UN); // unlock - fclose($fp); - */ // append the nickname to the cached nickname list $id = $this->isNickOnline($chan, $nick); @@ -141,7 +146,7 @@ $this->_users[$_chan]["nickid"][] = $nickid; $this->_users[$_chan]["timestamp"][] = filemtime($nickid_filename); } - + return true; } @@ -170,13 +175,18 @@ // check the nickname file really exists if (!file_exists($nickid_filename)) - pxlog("removeNick(".$nick.") - Error: the nickname data file to remove doesn't exists", "chat", $c->getId()); + pxlog("removeNick(".$nick.") - Error: the nickname data file to remove doesn't exists: ".$nickid_filename, "chat", $c->getId()); + else + pxlog("removeNick - nickname file removed: chan=".($chan==NULL?"SERVER":$chan)." nickid=".$nickid, "chat", $c->getId()); } $ok = @unlink($nickid_filename); // remove the user metadata if he is disconnected from the server + $this->_unregisterUserMeta($nickid, $chan); + + /* // decrement the nick references and kill the metadata if not more references is found // (used to know when the nick is really disconnected) $nick_ref = $this->getMeta("references", $nickid); @@ -190,7 +200,7 @@ } else $this->setMeta($nick_ref, "references", $nickid); - + */ if ($c->debug) { @@ -222,6 +232,9 @@ // retrive the nickid to update $nickid = $this->getNickId($nick); if ($nickid == "undefined") return false; + + // update the user metadata + $this->_registerUserMeta($nickid, $chan); $c =& $this->c; $there = false; @@ -237,6 +250,8 @@ @touch($nickid_filename); @chmod($nickid_filename, 0700); + if ($c->debug) pxlog("updateNick - nickname file updated: chan=".($chan==NULL?"SERVER":$chan)." nickid=".$nickid, "chat", $c->getId()); + // append the nickname to the cache list $_chan = ($chan == NULL) ? "SERVER" : $chan; $id = $this->isNickOnline($chan, $nick); @@ -373,6 +388,9 @@ $du_nickid = $du_nid; $du_nickname = $this->getNickname($du_nid); + $this->_unregisterUserMeta($du_nickid, $chan); + + /* // decrement the nick references and kill the metadata if not more references is found // (used to know when the nick is really disconnected) $nick_ref = $this->getMeta("references", $du_nickid); @@ -386,7 +404,7 @@ } else $this->setMeta($nick_ref, "references", $du_nickid); - + */ } } @@ -725,6 +743,52 @@ $this->_users = array("nickid" => array(), "timestamp" => array()); } + + function _registerUserMeta($nickid, $chan) + { + $c =& $this->c; + // create or update the nickname references (used to know when the nick is really disconnected) + if ($chan == NULL) $chan = "SERVER"; + $ref = $this->getMeta("references", $nickid); + if ($ref == NULL) + $ref = array(); + else + $ref = explode(';',$ref); + if ($c->debug) pxlog("registerUserMeta -> ref=".implode(';',$ref), "chat", $c->getId()); + if (in_array($chan,$ref)) + return; + else + $ref[] = $chan; + $ref = implode(';',$ref); + $this->setMeta($ref, "references", $nickid); + } + + function _unregisterUserMeta($nickid, $chan) + { + $c =& $this->c; + // decrement the nick references and kill the metadata if not more references is found + // (used to know when the nick is really disconnected) + if ($chan == NULL) $chan = "SERVER"; + $nickname = $this->getNickname($nickid); + $ref = $this->getMeta("references", $nickid); + if ($ref == NULL) $ref = ''; + $ref = explode(';',$ref); + $ref = array_diff($ref, array($chan)); + if (count($ref) == 0) + { + $this->rmMeta("nickid", "fromnickname", $nickname); + $this->rmMeta("nickname", "fromnickid", $nickid); + $this->rmMeta("references", $nickid); // destroy also the reference counter + if ($c->debug) pxlog("_unregisterUserMeta -> destroy!", "chat", $c->getId()); + } + else + { + $ref = implode(';',$ref); + $this->setMeta($ref, "references", $nickid); + if ($c->debug) pxlog("_unregisterUserMeta -> ref=".$ref, "chat", $c->getId()); + } + } + /** * Return a unique id. Each time this function is called, the last id is incremented. Deleted: trunk/src/containers/memory.class.php =================================================================== --- trunk/src/containers/memory.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/containers/memory.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -1,344 +0,0 @@ -<?php -/** - * pfccontainer_memory.class.php - * - * Copyright \xA9 2006 Bernhard J. M. Gr\xFCn <Ber...@go...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -require_once dirname(__FILE__)."/../pfccontainer.class.php"; -require_once dirname(__FILE__)."/../../lib/pear/System/SharedMemory.php"; - -/** - * pfcContainer_Memory is a concrete container which stores data into - * shared memory using a PEAR class. - * Version: 2006-02-28#01 - * - * @author Bernhard J. M. Gr\xFCn <Ber...@go...> - */ -class pfcContainer_Memory extends pfcContainer -{ - var $_users = NULL; - var $_cache_nickid = array(); - var $_memory = NULL; - - function _connect() - { - $c =& $this->c; - if ($c->container_cfg_sm_type=="auto") - $this->_memory =& System_SharedMemory::factory(); - else - $this->_memory =& System_SharedMemory::factory($c->container_cfg_sm_type, $c->container_cfg_sm_options); - } - - function getDefaultConfig() - { - $c =& $this->c; - - $cfg = array(); - $cfg['sm_type'] = ""; - $cfg['sm_options'] = array(); - $cfg['sm_messages'] = ""; - $cfg['sm_message_index'] = ""; - $cfg['sm_nicknames'] = ""; - $cfg['sm_nicknames_time'] = ""; - return $cfg; - } - - function init() - { - $c =& $this->c; - if ($c->container_cfg_sm_type=="") - $c->container_cfg_sm_type = "auto"; - if ($c->container_cfg_sm_options=="" || !is_array($c->container_cfg_sm_options)) - $c->container_cfg_sm_options = array(); - if ($c->container_cfg_sm_messages=="") - $c->container_cfg_sm_messages = $c->prefix.$c->serverid.'messages'; - if ($c->container_cfg_sm_message_index=="") - $c->container_cfg_sm_message_index = $c->prefix.$c->serverid.'message_index'; - if ($c->container_cfg_sm_nicknames=="") - $c->container_cfg_sm_nicknames = $c->prefix.$c->serverid.'nicknames'; - if ($c->container_cfg_sm_nicknames_time=="") - $c->container_cfg_sm_nicknames_time = $c->prefix.$c->serverid.'nicknames_time'; - - $this->_connect(); - $messages=$this->_memory->get - ($c->container_cfg_sm_messages); - $message_index=$this->_memory->get - ($c->container_cfg_sm_message_index); - $nick_array=$this->_memory->get - ($c->container_cfg_sm_nicknames); - $nicktime_array=$this->_memory->get - ($c->container_cfg_sm_nicknames_time); - if (!isset($messages) || $messages==NULL || !is_array($messages)) - { - $this->_memory->rm($c->container_cfg_sm_messages); - $this->_memory->set - ($c->container_cfg_sm_messages, array()); - } - if (!isset($message_index) || $message_index==NULL || !is_numeric($message_index)) - $this->_memory->set - ($c->container_cfg_sm_message_index, 0); - if (!isset($nick_array) || $nick_array==NULL || !is_array($nick_array)) - { - $this->_memory->rm($c->container_cfg_sm_nicknames); - $this->_memory->set - ($c->container_cfg_sm_nicknames, array()); - } - if (!isset($nicktime_array) || $nicktime_array==NULL || !is_array($nicktime_array)) - { - $this->_memory->rm($c->container_cfg_sm_nicknames_time); - $this->_memory->set - ($c->container_cfg_sm_nicknames_time, array()); - } - return array(); - } - - function updateNick($nickname) - { - $c =& $this->c; - $this->_connect(); - $nick_array=$this->_memory->get - ($c->container_cfg_sm_nicknames_time); - $nick_array[$c->nick]=time(); - $this->_memory->set - ($c->container_cfg_sm_nicknames_time, $nick_array); - return true; - } - - /** - * returns the id identifying the nickname's owner session - */ - function getNickId($nickname) - { - if (!isset($this->_cache_nickid[$nickname])) - { - $c =& $this->c; - $nickid = "undefined"; - $this->_connect(); - $nick_array=$this->_memory->get - ($c->container_cfg_sm_nicknames); - if (isset($nick_array[$nickname])) - { - // write the nickid into the new nickname place - $nickid=$nick_array[$nickname]; - if ($nickid == "") - $nickid = "undefined"; - } - $this->_cache_nickid[$nickname] = $nickid; - } - return $this->_cache_nickid[$nickname]; - } - - /** - * create an array element containing the new nickname id - * and delete oldnickname array element if the nickname id match - */ - function changeNick($newnick) - { - $c =& $this->c; - $nickid = $c->sessionid; - $oldnickid = $this->getNickId($c->nick); - $this->_connect(); - $nick_array=$this->_memory->get - ($c->container_cfg_sm_nicknames); - $nicktime_array=$this->_memory->get - ($c->container_cfg_sm_nicknames_time); - // delete the old nickname element only if the nickid match - if ($nickid == $oldnickid) - { - unset($nick_array[$c->nick]); - unset($nicktime_array[$c->nick]); - } - // write the nickid into the new nicknames element - $nick_array[$newnick]=$nickid; - $nicktime_array[$newnick]=time(); - $this->_memory->set - ($c->container_cfg_sm_nicknames, $nick_array); - $this->_memory->set - ($c->container_cfg_sm_nicknames_time, $nicktime_array); - return $newnick; - } - - function removeNick($nick) - { - $c =& $this->c; - $this->_connect(); - $nick_array=$this->_memory->get - ($c->container_cfg_sm_nicknames); - $nicktime_array=$this->_memory->get - ($c->container_cfg_sm_nicknames_time); - $nickid = $this->getNickId($nick); - // don't allow to remove foreign nicknames - if ($c->sessionid == $nickid && isset($nick_array[$nick])) - { - unset($nick_array[$nick]); - unset($nicktime_array[$nick]); - $this->_memory->set - ($c->container_cfg_sm_nicknames, $nick_array); - $this->_memory->set - ($c->container_cfg_sm_nicknames_time, $nicktime_array); - return true; - } - else - return false; - } - - function removeObsoleteNick() - { - $c =& $this->c; - - $deleted_user = array(); - $users = array(); - $this->_connect(); - $nicktime_array=$this->_memory->get - ($c->container_cfg_sm_nicknames_time); - $nick_array=$this->_memory->get - ($c->container_cfg_sm_nicknames); - if (!isset($nicktime_array)) - return $deleted_user; - $deleted=false; - foreach ($nicktime_array as $key => $nick_time) - { - if (time() > ($nick_time+2+($c->refresh_delay/1000)*4) ) - { - $deleted_user[]=$key; - unset($nicktime_array[$key]); - unset($nick_array[$key]); - $deleted=true; - } - else - { - $users[]=$key; - } - } - $this->_users =& $users; // _users will be used by getOnlineUserList - if ($deleted) - { - $this->_memory->set - ($c->container_cfg_sm_nicknames_time, $nicktime_array); - $this->_memory->set - ($c->container_cfg_sm_nicknames, $nick_array); - } - return $deleted_user; - } - - function getOnlineNick() - { - if (is_array($this->_users) && count($this->_users)>0) - return $this->_users; - - $c =& $this->c; - $users = array(); - $this->_connect(); - $nicktime_array=$this->_memory->get - ($c->container_cfg_sm_nicknames_time); - if (!isset($nicktime_array)) - return $users; - foreach ($nicktime_array as $key => $nick_time) - { - $users[]=$key; - } - return $users; - } - - /** - * Returns the last posted message id - */ - function getLastMsgId() - { - // read last message id - $c =& $this->c; - $this->_connect(); - $msg_id=$this->_memory->get - ($c->container_cfg_sm_message_index); - return isset($msg_id) ? $msg_id : 0; - } - - function readNewMsg($from_id) - { - - $c =& $this->c; - $this->_connect(); - $content=$this->_memory->get - ($c->container_cfg_sm_messages); - - // remove old messages - $content = array_slice($content, -$c->max_msg); - $this->_memory->set - ($c->container_cfg_sm_messages, $content); - - // format content in order to extract only necessary information - $formated_content = array(); - $new_from_id = $from_id; - foreach ( $content as $line ) - { - if ($line != "" && $line != "\n") - { - $formated_line = explode( "\t", $line ); - if ($from_id < $formated_line[0]) - $formated_content[] = $formated_line; - if ($new_from_id < $formated_line[0]) - $new_from_id = $formated_line[0]; - } - } - return array("messages" => $formated_content, "new_from_id" => $new_from_id); - } - - function writeMsg($nickname, $message) - { - // format message - $msg_id = $this->_requestMsgId(); - $line = $msg_id."\t"; - $line .= date("d/m/Y")."\t"; - $line .= date("H:i:s")."\t"; - $line .= $nickname."\t"; - $line .= $message; - - // write it to message array - $c =& $this->c; - $this->_connect(); - $content=$this->_memory->get - ($c->container_cfg_sm_messages); - $count=count($content)+1; - $content[$count]=$line; - $this->_memory->set - ($c->container_cfg_sm_messages, $content); - return true; - } - - /** - * used internaly - */ - function _requestMsgId() - { - // read last message id - $c =& $this->c; - $this->_connect(); - $msg_id=$this->_memory->get - ($c->container_cfg_sm_message_index); - if (!is_numeric($msg_id)) - $msg_id = 0; - // increment message id and save it - $msg_id++; - $this->_memory->set - ($c->container_cfg_sm_message_index, $msg_id); - return $msg_id; - } -} - -?> Modified: trunk/src/pfcuserconfig.class.php =================================================================== --- trunk/src/pfcuserconfig.class.php 2006-09-17 09:51:46 UTC (rev 766) +++ trunk/src/pfcuserconfig.class.php 2006-09-17 20:51:29 UTC (rev 767) @@ -41,6 +41,17 @@ if (!isset($this->privmsg)) $this->_setParam("serverid",$c->serverid); } + function &Instance() + { + static $i; + + if (!isset($i)) + { + $i = new pfcUserConfig(); + } + return $i; + } + function &_getParam($p) { if (!isset($this->$p)) @@ -70,95 +81,7 @@ unset($this->$p); } - function &Instance() - { - static $i; - - if (!isset($i)) - { - $i = new pfcUserConfig(); - } - return $i; - } - /* - function init() - { - // echo "init()<br>"; - $ok = true; - - $c =& pfcGlobalConfig::Instance(); - if ($c) - { - $this->nick = $c->nick; - $this->timeout = $c->timeout; - } - else - { - $this->errors[] = "pfcGlobalConfig must be instanciated first"; - $ok = false; - } - - $this->is_init = $ok; - } - function isInit() - { - return $this->is_init; - } - - function &getErrors() - { - return $this->errors; - } - */ - - /* - function getCacheFile() - { - $c =& pfcGlobalConfig::Instance(); - $cachefile = ""; - if ($this->nick != "") - $cachefile = $c->data_private_path."/cache/".$c->prefix."userconfig_".$c->getId()."_".md5($this->nick); - // echo "getCacheFile() = '$cachefile'<br>"; - return $cachefile; - } - */ - /** - * save the pfcUserConfig object into cache if it doesn't exists yet - * else restore the old pfcConfig object - */ - /* - function synchronizeWithCache() - { - // echo "synchronizeWithCache()<br>"; - $c =& pfcGlobalConfig::Instance(); - $cachefile = $this->getCacheFile(); - if ($c->debug) pxlog("pfcUserConfig::synchronizeWithCache: cachefile=".$cachefile, "chatconfig", $c->getId()); - if (file_exists($cachefile)) - { - echo "synchronizeWithCache():exists<br>"; - $pfc_configvar = unserialize(file_get_contents($cachefile)); - foreach($pfc_configvar as $key => $val) - $this->$key = $val; - if ($c->debug) pxlog("pfcUserConfig::synchronizeWithCache: restore pfcUserConfig from cache", "chatconfig", $c->getId()); - } - else - { - // echo "synchronizeWithCache():!exists<br>"; - if (!$this->isInit()) - $this->init(); - $errors =& $this->getErrors(); - if (count($errors) > 0) - { - echo "<ul>"; foreach( $errors as $e ) echo "<li>".$e."</li>"; echo "</ul>"; - exit; - } - // save the validated config in cache - $this->saveInCache(); - } - } - */ - function destroy() { $this->_rmParam("nick"); @@ -181,27 +104,6 @@ $this->_setParam("channels",$this->channels); $this->_setParam("privmsg",$this->privmsg); $this->_setParam("serverid",$this->serverid); - - /* - - // save nickname and active status into sessions - $nickid = $c->prefix."pfcuserconfig_".$c->getId(); - $nickid_nick = $nickid."_nick"; - $nickid_active = $nickid."_active"; - $_SESSION[$nickid_nick] = $this->nick; - $_SESSION[$nickid_active] = $this->active; - */ - - - // @todo - // save the whole object into cache - /* - $cachefile = $this->getCacheFile(); - if ($cachefile == "") - die("Error: cachefile should not be null!"); - file_put_contents($cachefile, serialize(get_object_vars($this))); - if ($c->debug) pxlog("pfcUserConfig::saveInCache: nick=".$this->nick, "chatconfig", $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 20:34:25
|
Revision: 786 http://svn.sourceforge.net/phpfreechat/?rev=786&view=rev Author: kerphi Date: 2006-09-22 13:33:57 -0700 (Fri, 22 Sep 2006) Log Message: ----------- [en] Disk space optimization: when the last user quit a channel or a private room, the messages history is purged in the container. [1h15] [fr] Optimisation de l'espace disque : lorsque le dernier utilisateur quitte un salon ou un chat priv?\195?\169, l'historique des messages est automatiquement effac?\195?\169. [1h15] Modified Paths: -------------- trunk/src/pfccontainer.class.php trunk/src/proxies/checktimeout.class.php Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2006-09-22 12:47:39 UTC (rev 785) +++ trunk/src/pfccontainer.class.php 2006-09-22 20:33:57 UTC (rev 786) @@ -83,6 +83,15 @@ $this->rmMeta('channelid-to-nickid', $this->encode($chan), $nickid); $this->rmMeta('nickid-to-channelid', $nickid, $this->encode($chan)); + // if the user is the last one to quit this room, + // then clean the room history + $ret = $this->getOnlineNick($chan); + if (count($ret['nickid']) == 0) + { + $this->rmMeta('channelid-to-msg', $this->encode($chan)); + $this->rmMeta('channelid-to-msgid', $this->encode($chan)); + } + // get the current user's channels list $channels = $this->getMeta("nickid-to-channelid",$nickid); $channels = $channels["value"]; @@ -219,7 +228,7 @@ if ($chan == NULL) $chan = 'SERVER'; - $online_user = array(); + $online_user = array('nick'=>array(),'nickid'=>array(),'timestamp'=>array()); $ret = $this->getMeta("channelid-to-nickid", $this->encode($chan)); for($i = 0; $i<count($ret['timestamp']); $i++) { Modified: trunk/src/proxies/checktimeout.class.php =================================================================== --- trunk/src/proxies/checktimeout.class.php 2006-09-22 12:47:39 UTC (rev 785) +++ trunk/src/proxies/checktimeout.class.php 2006-09-22 20:33:57 UTC (rev 786) @@ -43,15 +43,17 @@ $u =& $this->u; // disconnect users from specific channels - $container =& $c->getContainerInstance(); - $disconnected_users = $container->removeObsoleteNick($c->timeout); + $ct =& $c->getContainerInstance(); + $disconnected_users = $ct->removeObsoleteNick($c->timeout); for($i=0; $i<count($disconnected_users["nick"]); $i++) { $nick = $disconnected_users["nick"][$i]; for($j=0; $j<count($disconnected_users["channels"][$i]); $j++) { $chan = $disconnected_users["channels"][$i][$j]; - if ($chan != 'SERVER') + $online_users = $ct->getOnlineNick($chan); + if ($chan != 'SERVER' && + count($online_users['nickid'])) { $cmdp = $p; $cmdp["param"] = _pfc("%s quit (timeout)", $nick); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-24 20:08:57
|
Revision: 793 http://svn.sourceforge.net/phpfreechat/?rev=793&view=rev Author: kerphi Date: 2006-09-24 13:08:47 -0700 (Sun, 24 Sep 2006) Log Message: ----------- [en] New 'privmsg' parameter: this is an array of nicknames that you want to speak to (in a private chat) at first chat loading (thanks to Johnny Philavanh for his sponsoring : $130 USD) [3h00] [fr] Nouveau param?\195?\168tre 'privmsg' : c'est un tableau destin?\195?\169 ?\195?\160 contenir une liste de pseudonyme avec lesquels on souhaite ouvrir une fen?\195?\170tre de discussion au premier demarrage du chat (merci ?\195?\160 Johnny Philavanh pour sa donation de $130 USD). [3h00] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/commands/privmsg.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-09-23 15:49:00 UTC (rev 792) +++ trunk/src/client/chat.js.tpl.php 2006-09-24 20:08:47 UTC (rev 793) @@ -1,4 +1,6 @@ +<?php function quoteandescape($v) { return "'".addslashes($v)."'"; } ?> <?php $nick = $u->nick != "" ? addslashes($u->nick) : addslashes($c->nick); ?> + var pfc_nickname = '<?php echo ($GLOBALS["output_encoding"]=="UTF-8" ? $nick : iconv("UTF-8", $GLOBALS["output_encoding"],$nick)); ?>'; var pfc_version = '<?php echo $version; ?>'; var pfc_clientid = '<?php echo md5(uniqid(rand(), true)); ?>'; @@ -18,18 +20,22 @@ var pfc_connect_at_startup = <?php echo $connect_at_startup ? "true" : "false"; ?>; var pfc_notify_window = <?php echo $notify_window ? "true" : "false"; ?>; var pfc_defaultchan = Array(<?php - function quoteandescape($v) { return "'".addslashes($v)."'"; } - $list = array(); foreach($c->channels as $ch) {$list[] = $ch; } + $list = array(); foreach($c->channels as $item) {$list[] = $item; } $list = array_map("quoteandescape",$list); echo implode(",", $list); ?>); var pfc_userchan = Array(<?php - $list = array(); foreach($u->channels as $ch) {$list[] = $ch["name"];} + $list = array(); foreach($u->channels as $item) {$list[] = $item["name"];} $list = array_map("quoteandescape",$list); echo implode(",", $list); ?>); -var pfc_privmsg = Array(<?php - $list = array(); foreach($u->privmsg as $pv) {$list[] = $pv["name"];} +var pfc_defaultprivmsg = Array(<?php + $list = array(); foreach($c->privmsg as $item) {$list[] = $item; } + $list = array_map("quoteandescape",$list); + echo implode(",", $list); + ?>); +var pfc_userprivmsg = Array(<?php + $list = array(); foreach($u->privmsg as $item) {$list[] = $item["name"];} $list = array_map("quoteandescape",$list); echo implode(",", $list); ?>); @@ -86,6 +92,7 @@ "Maximum number of private chat has been reached", // _pfc "Click here to send your message", // _pfc "Send", // _pfc + "You are not allowed to speak to yourself", // _pfc ); foreach($labels_to_load as $l) { Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-23 15:49:00 UTC (rev 792) +++ trunk/src/client/pfcclient.js 2006-09-24 20:08:47 UTC (rev 793) @@ -234,6 +234,10 @@ { // speak to unknown user } + else if (resp == "speak_to_myself") + { + this.displayMsg( cmd, this.res.getLabel('You are not allowed to speak to yourself') ); + } else alert(cmd + "-"+resp+"-"+param); } @@ -241,20 +245,18 @@ { if (resp == "connected" || resp == "notchanged") { - // now join channels comming from sessions - // or the default one cmd = ''; - if (pfc_userchan.length == 0) + + // join the default channels comming from the parameter list + for (var i=0; i<pfc_defaultchan.length; i++) { - for (var i=0; i<pfc_defaultchan.length; i++) - { - if (i<pfc_defaultchan.length-1) - cmd = "/join2"; - else - cmd = "/join"; - this.sendRequest(cmd, pfc_defaultchan[i]); - } + if (i<pfc_defaultchan.length-1) + cmd = "/join2"; + else + cmd = "/join"; + this.sendRequest(cmd, pfc_defaultchan[i]); } + // now join channels comming from sessions for (var i=0; i<pfc_userchan.length; i++) { if (i<pfc_userchan.length-1) @@ -263,10 +265,21 @@ cmd = "/join"; this.sendRequest(cmd, pfc_userchan[i]); } - for (var i=0; i<pfc_privmsg.length; i++) + + // join the default privmsg comming from the parameter list + for (var i=0; i<pfc_defaultprivmsg.length; i++) { - this.sendRequest("/privmsg", pfc_privmsg[i]); + if (i<pfc_defaultprivmsg.length-1) + cmd = "/privmsg2"; + else + cmd = "/privmsg"; + this.sendRequest(cmd, pfc_defaultprivmsg[i]); } + // now join privmsg comming from the sessions + for (var i=0; i<pfc_userprivmsg.length; i++) + { + this.sendRequest("/privmsg", pfc_userprivmsg[i]); + } } if (resp == "ok" || resp == "notchanged" || resp == "changed" || resp == "connected") Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-09-23 15:49:00 UTC (rev 792) +++ trunk/src/commands/privmsg.class.php 2006-09-24 20:08:47 UTC (rev 793) @@ -25,7 +25,7 @@ // error: can't speak to myself if ($pvnickid == $nickid) { - $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', Array('".addslashes($pvname)."','speak to myself'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."','speak_to_myself');"); return; } Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-23 15:49:00 UTC (rev 792) +++ trunk/src/pfcglobalconfig.class.php 2006-09-24 20:08:47 UTC (rev 793) @@ -54,8 +54,9 @@ var $channels = array(); // the default joined channels when opening the chat var $frozen_channels = array(); // if empty, allows users to create there own channels var $max_channels = 10; // this the max number of allowed channels by users + var $privmsg = array(); // the joined private chat when opening the chat (the nicknames must be online) var $max_privmsg = 5; // this the max number of allowed privmsg by users - var $frozen_nick = false; + var $frozen_nick = false; // set it to true if you don't want the user to be able to change his nickname var $max_nick_len = 15; var $max_text_len = 400; var $refresh_delay = 5000; // in mili-seconds (5 seconds) @@ -111,7 +112,7 @@ // private parameters var $_sys_proxies = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log"); var $_proxies = array(); // will contains proxies to execute on each command (filled in the init step) - var $_dyn_params = array("nick","isadmin","islocked","admins","frozen_channels"); + var $_dyn_params = array("nick","isadmin","islocked","admins","frozen_channels", "channels", "privmsg"); var $_params_type = array(); function pfcGlobalConfig( $params = array() ) @@ -184,6 +185,12 @@ if (isset($params[$dp])) $this->$dp = $params[$dp]; + // 'channels' is now a dynamic parameter, just check if I need to initialize it or not + if (is_array($this->channels) && + count($this->channels) == 0 && + !isset($params['channels'])) + $this->channels = array(_pfc("My room")); + // now load or save the configuration in the cache $this->synchronizeWithCache(); } @@ -274,7 +281,6 @@ if ($this->title == "") $this->title = _pfc("My Chat"); if ($this->xajaxpath == "") $this->xajaxpath = dirname(__FILE__)."/../lib/xajax_0.2.3"; if ($this->jspath == "") $this->jspath = dirname(__FILE__)."/../lib/javascript"; - if (is_array($this->channels) && count($this->channels) == 0) $this->channels = array(_pfc("My room")); // first of all, check the used functions $f_list["file_get_contents"] = _pfc("You need %s", "PHP 4 >= 4.3.0 or PHP 5"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-26 16:35:40
|
Revision: 795 http://svn.sourceforge.net/phpfreechat/?rev=795&view=rev Author: kerphi Date: 2006-09-26 09:35:31 -0700 (Tue, 26 Sep 2006) Log Message: ----------- [en] New 'firstisadmin' parameter : this parameter is used to give admin rights to the first connected users on the server. [fr] Nouveau param?\195?\168tre 'firstisadmin' qui permet de donner les droits administrateurs a la premiere personne connect?\195?\169e sur le serveur. 45min Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-24 20:56:41 UTC (rev 794) +++ trunk/src/commands/connect.class.php 2006-09-26 16:35:31 UTC (rev 795) @@ -44,7 +44,7 @@ // check if the user is alone on the server, and give it the admin status if yes $isadmin = $c->isadmin; - if (!$isadmin) + if ($c->firstisadmin && !$isadmin) { $users = $ct->getOnlineNick(NULL); if (isset($users["nickid"]) && Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-24 20:56:41 UTC (rev 794) +++ trunk/src/pfcglobalconfig.class.php 2006-09-26 16:35:31 UTC (rev 795) @@ -34,8 +34,10 @@ // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) + var $isadmin = false; var $admins = array("admin" => ""); // the key is the nickname, the value is the password + var $firstisadmin = true; // give admin rights to the first connected user on the server var $islocked = false; // set this parameter to true to lock the chat for all users var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-10-07 18:20:22
|
Revision: 825 http://svn.sourceforge.net/phpfreechat/?rev=825&view=rev Author: kerphi Date: 2006-10-07 11:20:15 -0700 (Sat, 07 Oct 2006) Log Message: ----------- [en] Improve the debug routines. [15min] [fr] Ameliore les routines de debogage. [15min] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/phpfreechat.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-10-06 07:55:10 UTC (rev 824) +++ trunk/src/client/chat.js.tpl.php 2006-10-07 18:20:15 UTC (rev 825) @@ -1,7 +1,6 @@ <?php require_once(dirname(__FILE__)."/../../lib/json/JSON.php"); $json = new Services_JSON(); - ?> <?php $nick = $u->nick != "" ? $json->encode($u->nick) : $json->encode($c->nick); ?> @@ -137,6 +136,28 @@ text = s.escapeHTML(); rx = new RegExp('<','g'); text = text.replace(rx, '\n<'); - $('debugxajax').innerHTML += '\n---------------\n' + text; + $('pfc_debugxajax').innerHTML += '\n---------------\n' + text; } - <?php } ?> +<?php } ?> + +<?php if ($debug) { ?> +var pfc_debug_color = true; +function trace(text) { + var s = new String(text); + text = s.escapeHTML(); + rx = new RegExp('<','g'); + text = text.replace(rx, '\n<'); + var color = ''; + if (pfc_debug_color) + { + color = '#BBB'; + pfc_debug_color = false; + } + else + { + color = '#DDD'; + pfc_debug_color = true; + } + $('pfc_debug').innerHTML += '<p style="margin:0;border-bottom:1px solid #555;background-color:'+color+'">' + text + '</p>'; +} +<?php } ?> Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-10-06 07:55:10 UTC (rev 824) +++ trunk/src/client/pfcclient.js 2006-10-07 18:20:15 UTC (rev 825) @@ -138,6 +138,8 @@ */ handleResponse: function(cmd, resp, param) { + if (pfc_debug) + if (cmd != "update") trace('handleResponse: '+cmd + "-"+resp+"-"+param); if (cmd == "connect") { //alert(cmd + "-"+resp+"-"+param); @@ -830,7 +832,7 @@ var recipientid = this.gui.getTabId(); var req = cmd+" "+this.clientid+" "+(recipientid==''?'0':recipientid)+(param?" "+param : ""); if (pfc_debug) - if (cmd != "/update") alert(req); + if (cmd != "/update") trace('sendRequest: '+req); return eval('pfc_handleRequest(req);'); }, Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-10-06 07:55:10 UTC (rev 824) +++ trunk/src/phpfreechat.class.php 2006-10-07 18:20:15 UTC (rev 825) @@ -192,6 +192,18 @@ $output .= "<a href=\"http://www.phpfreechat.net\"><img src=\"http://www.phpfreechat.net/pub/logo_80x15.gif\" alt=\"PHP FREE CHAT [powered by phpFreeChat-".$c->version."]\" title=\"PHP FREE CHAT [powered by phpFreeChat-".$c->version."]\" /></a>"; $output .= "</div>"; + if ($c->debug) + { + $output .= '<div id="pfc_debug">'; + $output .= '</div>'; + } + + if ($c->debugxajax) + { + $output .= '<div id="pfc_debugxajax">'; + $output .= '</div>'; + } + $output .= "<script type=\"text/javascript\">\n"; $output .= " // <![CDATA[\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-10-07 18:30:29
|
Revision: 826 http://svn.sourceforge.net/phpfreechat/?rev=826&view=rev Author: kerphi Date: 2006-10-07 11:30:07 -0700 (Sat, 07 Oct 2006) Log Message: ----------- [en] Bug fix: correct problems with timeout disconnections and with channels user lists. [1h] [fr] Bug fix : corrections d'incoherances au moment de deconnecter les utilisateurs par timeout et au moment de mettre a jour la liste des utilisateurs. [1h] Modified Paths: -------------- trunk/src/commands/update.class.php trunk/src/pfccontainer.class.php Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-10-07 18:20:15 UTC (rev 825) +++ trunk/src/commands/update.class.php 2006-10-07 18:30:07 UTC (rev 826) @@ -30,7 +30,7 @@ } $cmdp = $p; - + // update the user nickname timestamp on the server $cmd =& pfcCommand::Factory("updatemynick"); $cmdp["recipient"] = NULL; @@ -43,12 +43,14 @@ { $cmdp["recipient"] = $chan["recipient"]; $cmdp["recipientid"] = $id; + $cmdp["param"] = ''; // don't forward the parameter because it will be interpreted as a channel name $cmd->run($xml_reponse, $cmdp); } foreach( $u->privmsg as $id => $pv ) { $cmdp["recipient"] = $pv["recipient"]; $cmdp["recipientid"] = $id; + $cmdp["param"] = ''; // don't forward the parameter because it will be interpreted as a channel name $cmd->run($xml_reponse, $cmdp); } Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2006-10-07 18:20:15 UTC (rev 825) +++ trunk/src/pfccontainer.class.php 2006-10-07 18:30:07 UTC (rev 826) @@ -73,10 +73,15 @@ if ($chan == NULL) $chan = 'SERVER'; + $deleted_user = array(); + $deleted_user["nick"] = array(); + $deleted_user["nickid"] = array(); + $deleted_user["timestamp"] = array(); + $timestamp = $this->getMeta("channelid-to-nickid", $this->encode('SERVER'), $nickid); + if (count($timestamp["timestamp"]) == 0) return $deleted_user; $timestamp = $timestamp["timestamp"][0]; - $deleted_user = array(); $deleted_user["nick"][] = $this->getNickname($nickid); $deleted_user["nickid"][] = $nickid; $deleted_user["timestamp"][] = $timestamp; @@ -184,9 +189,8 @@ } /** - * Remove (disconnect/quit) the timeouted nickname from the server or from a channel - * Notice: this function must remove all nicknames which are not uptodate from the given channel or from the server - * @param $chan if NULL then check obsolete nick on the server, otherwise just check obsolete nick on the given channel + * Remove (disconnect/quit) the timeouted nicknames + * Notice: this function will remove all nicknames which are not uptodate from all his joined channels * @param $timeout * @return array("nickid"=>array("nickid1", ...),"timestamp"=>array(timestamp1, ...)) contains all disconnected nickids and there timestamp */ @@ -194,13 +198,11 @@ { $c =& $this->c; - $chan = 'SERVER'; - $deleted_user = array('nick'=>array(), 'nickid'=>array(), 'timestamp'=>array(), 'channels'=>array()); - $ret = $this->getMeta("channelid-to-nickid", $this->encode($chan)); + $ret = $this->getMeta("channelid-to-nickid", $this->encode('SERVER')); for($i = 0; $i<count($ret['timestamp']); $i++) { $timestamp = $ret['timestamp'][$i]; @@ -212,10 +214,19 @@ $ret2 = $this->getMeta("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); + $userchan = $this->decode($userchan); + if ($userchan != 'SERVER') + { + // disconnect the user from each joined channels + $this->removeNick($userchan, $nickid); + $channels[] = $userchan; + } } + // now disconnect the user from the server + // (order is important because the SERVER channel has timestamp informations) + $du = $this->removeNick('SERVER', $nickid); + $channels[] = 'SERVER'; + $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"]); @@ -245,6 +256,7 @@ // get timestamp from the SERVER channel $timestamp = $this->getMeta("channelid-to-nickid", $this->encode('SERVER'), $nickid); + if (count($timestamp['timestamp']) == 0) continue; $timestamp = $timestamp['timestamp'][0]; $online_user["nick"][] = $this->getNickname($nickid); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-10-20 20:15:35
|
Revision: 837 http://svn.sourceforge.net/phpfreechat/?rev=837&view=rev Author: kerphi Date: 2006-10-20 13:15:12 -0700 (Fri, 20 Oct 2006) Log Message: ----------- [en] Now the client keep in memory the last update timestamp in order to automaticaly reconnect one request is lost. ex: when server is down. (thanks to bcc) [30min] [fr] Maintenant le client garde en m?\195?\169moire la date de la derniere mise ?\195?\160 jour du chat ainsi il se reconnect automatiquement si la connexion vennait ?\195?\160 ?\195?\170tre coup?\195?\169e. (merci ?\195?\160 bcc) [30min] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/pfcglobalconfig.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-10-19 07:21:18 UTC (rev 836) +++ trunk/src/client/chat.js.tpl.php 2006-10-20 20:15:12 UTC (rev 837) @@ -10,6 +10,7 @@ var pfc_clientid = <?php echo $json->encode(md5(uniqid(rand(), true))); ?>; var pfc_title = <?php echo $json->encode($title); ?>; var pfc_refresh_delay = <?php echo $json->encode($refresh_delay); ?>; +var pfc_max_refresh_delay = <?php echo $json->encode($max_refresh_delay); ?>; var pfc_start_minimized = <?php echo $json->encode($start_minimized); ?>; var pfc_nickmarker = <?php echo $json->encode($nickmarker); ?>; var pfc_clock = <?php echo $json->encode($clock); ?>; Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-10-19 07:21:18 UTC (rev 836) +++ trunk/src/client/pfcclient.js 2006-10-20 20:15:12 UTC (rev 837) @@ -41,6 +41,8 @@ this.timeout = null; this.refresh_delay = pfc_refresh_delay; + this.max_refresh_delay = pfc_max_refresh_delay; + this.last_refresh_time = 0; /* unique client id for each windows used to identify a open window * this id is passed every time the JS communicate with server * (2 clients can use the same session: then only the nickname is shared) */ @@ -310,6 +312,11 @@ else if (cmd == "update") { this.canupdatenexttime = true; + // if the first ever refresh request never makes it back then the chat will keep + // trying to refresh as usual + // this only helps if we temporarily lose connection in the middle of an established + // chat session + this.last_refresh_time = new Date().getTime(); } else if (cmd == "version") { @@ -844,13 +851,19 @@ if (start) { var res = true; - if (this.canupdatenexttime) + if (this.canupdatenexttime || (new Date().getTime() - this.last_refresh_time) > this.max_refresh_delay) { res = this.sendRequest('/update'); this.canupdatenexttime = false; // don't update since the 'ok' response is received } // adjust the refresh_delay if the connection was lost - if (res == false) { this.refresh_delay = this.refresh_delay * 2; } + if (res == false) { + this.refresh_delay = this.refresh_delay * 2; + if(this.refresh_delay > this.max_refresh_delay) + { + this.refresh_delay = this.max_refresh_delay; + } + } // setup the next update this.timeout = setTimeout('pfc.updateChat(true)', this.refresh_delay); } Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-10-19 07:21:18 UTC (rev 836) +++ trunk/src/pfcglobalconfig.class.php 2006-10-20 20:15:12 UTC (rev 837) @@ -64,6 +64,7 @@ var $max_nick_len = 15; var $max_text_len = 400; var $refresh_delay = 5000; // in mili-seconds (5 seconds) + var $max_refresh_delay = 60000; // in mili-seconds (60 seconds) var $timeout = 20000; // in mili-seconds (20 seconds) var $max_msg = 20; var $quit_on_closedwindow = true; // could be annoying because the reload event is the same as a close event This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-10-28 17:03:41
|
Revision: 846 http://svn.sourceforge.net/phpfreechat/?rev=846&view=rev Author: kerphi Date: 2006-10-28 10:03:31 -0700 (Sat, 28 Oct 2006) Log Message: ----------- [en] Add traces and error messages for debug [50min] [fr] Ajout de traces et de messages d'erreur pour le debug [50min] Modified Paths: -------------- trunk/src/pfccontainer.class.php trunk/src/pfctools.php Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2006-10-28 17:01:17 UTC (rev 845) +++ trunk/src/pfccontainer.class.php 2006-10-28 17:03:31 UTC (rev 846) @@ -45,6 +45,11 @@ { $c =& $this->c; + if ($nick == '') + user_error('pfcContainer::createNick nick is empty', E_USER_ERROR); + if ($nickid == '') + user_error('pfcContainer::createNick nickid is empty', E_USER_ERROR); + if ($chan == NULL) $chan = 'SERVER'; $this->setMeta("nickid-to-metadata", $nickid, 'nick', $nick); Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-10-28 17:01:17 UTC (rev 845) +++ trunk/src/pfctools.php 2006-10-28 17:03:31 UTC (rev 846) @@ -316,7 +316,7 @@ // If we don't have a string, throw an error if (!is_scalar($content)) { - user_error('file_put_contents() The 2nd parameter should be either a string or an array', + user_error('file_put_contents() The 2nd parameter should be either a string or an array ['.$filename.']', E_USER_WARNING); return false; } @@ -336,7 +336,7 @@ // Open the file for writing if (($fh = @fopen($filename, $mode, $use_inc_path)) === false) { - user_error('file_put_contents() failed to open stream: Permission denied', + user_error('file_put_contents() failed to open stream: Permission denied ['.$filename.']', E_USER_WARNING); return false; } @@ -352,7 +352,7 @@ // Write to the file $bytes = 0; if (($bytes = @fwrite($fh, $content)) === false) { - $errormsg = sprintf('file_put_contents() Failed to write %d bytes to %s', + $errormsg = sprintf('file_put_contents() Failed to write %d bytes to %s ['.$filename.']', $length, $filename); user_error($errormsg, E_USER_WARNING); @@ -364,7 +364,7 @@ // Check all the data was written if ($bytes != $length) { - $errormsg = sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space.', + $errormsg = sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space. ['.$filename.']', $bytes, $length); user_error($errormsg, E_USER_WARNING); 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: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. |
From: <ke...@us...> - 2006-10-29 15:37:49
|
Revision: 852 http://svn.sourceforge.net/phpfreechat/?rev=852&view=rev Author: kerphi Date: 2006-10-29 07:37:32 -0800 (Sun, 29 Oct 2006) Log Message: ----------- [en] Add 'cmd_path' parameter : this parameter is used to give an extra path where pfc will search to find the customized commands [20min] [fr] Ajout du param?\195?\168tre 'cmd_path' : ce parametre est utilis?\195?\169 pour donner un chemin ?\195?\160 pfc pour qu'il y recherche des commandes personnalis?\195?\169es [20min] Modified Paths: -------------- trunk/src/pfccommand.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-10-29 14:34:37 UTC (rev 851) +++ trunk/src/pfccommand.class.php 2006-10-29 15:37:32 UTC (rev 852) @@ -71,8 +71,12 @@ $cmd_classname = "pfcCommand_".$name; if (!class_exists($cmd_classname)) { - $cmd_filename = dirname(__FILE__)."/commands/".$cmd_name.".class.php"; - if (file_exists($cmd_filename)) require_once($cmd_filename); + $cmd_paths = array($c->cmd_path_default,$c->cmd_path); + foreach($cmd_paths as $cp) + { + $cmd_filename = $cp."/".$cmd_name.".class.php"; + if (file_exists($cmd_filename)) require_once($cmd_filename); + } } if (class_exists($cmd_classname)) { Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-10-29 14:34:37 UTC (rev 851) +++ trunk/src/pfcglobalconfig.class.php 2006-10-29 15:37:32 UTC (rev 852) @@ -54,6 +54,8 @@ "log" => array("path"=>"")); var $proxies_path = ""; // a custom proxies path var $proxies_path_default = ""; // dirname(__FILE__).'/proxies' + var $cmd_path = ""; // a custom commands path + var $cmd_path_default = ""; // dirname(__FILE__).'/commands' var $title = ""; // default is _pfc("My Chat") var $channels = array(); // the default joined channels when opening the chat var $frozen_channels = array(); // if empty, allows users to create there own channels @@ -64,7 +66,7 @@ var $max_nick_len = 15; var $max_text_len = 400; var $refresh_delay = 5000; // in mili-seconds (5 seconds) - var $max_refresh_delay = 60000; // in mili-seconds (60 seconds) + var $max_refresh_delay = 60000; // in mili-seconds (60 seconds) var $timeout = 20000; // in mili-seconds (20 seconds) var $max_msg = 20; var $quit_on_closedwindow = true; // could be annoying because the reload event is the same as a close event @@ -441,6 +443,9 @@ if ($this->proxies_path != '' && !is_dir($this->proxies_path)) $this->errors[] = _pfc("'%s' directory doesn't exist", $this->proxies_path); + // save the commands path + $this->cmd_path_default = dirname(__FILE__).'/commands'; + // load smileys from file $this->loadSmileyTheme(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-11-05 11:09:27
|
Revision: 865 http://svn.sourceforge.net/phpfreechat/?rev=865&view=rev Author: kerphi Date: 2006-11-05 03:09:12 -0800 (Sun, 05 Nov 2006) Log Message: ----------- [en] Makes possible to use regular expressions for the words in the censor proxy. [45min] [fr] Rend possible l'utilisation d'expressions r?\195?\169guli?\195?\168res pour les mots ?\195?\160 censurer. [45min] Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/proxies/censor.class.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-11-02 20:12:51 UTC (rev 864) +++ trunk/src/pfcglobalconfig.class.php 2006-11-05 11:09:12 UTC (rev 865) @@ -49,9 +49,13 @@ var $post_proxies = array(); // these proxies will be handled just before to process commands and just after system proxies var $pre_proxies = array(); // these proxies will be handled before system proxies (at begining) var $proxies_cfg = array("auth" => array(), - "noflood" => array("charlimit"=>450,"msglimit"=>10,"delay"=>5), - "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), - "log" => array("path"=>"")); + "noflood" => array("charlimit" => 450, + "msglimit" => 10, + "delay" => 5), + "censor" => array("words" => array("fuck","sex","bitch"), + "replaceby" => "*", + "regex" => false), + "log" => array("path" => "")); var $proxies_path = ""; // a custom proxies path var $proxies_path_default = ""; // dirname(__FILE__).'/proxies' var $cmd_path = ""; // a custom commands path Modified: trunk/src/proxies/censor.class.php =================================================================== --- trunk/src/proxies/censor.class.php 2006-11-02 20:12:51 UTC (rev 864) +++ trunk/src/proxies/censor.class.php 2006-11-05 11:09:12 UTC (rev 865) @@ -46,13 +46,24 @@ { $words = $c->proxies_cfg[$this->proxyname]["words"]; $replaceby = $c->proxies_cfg[$this->proxyname]["replaceby"]; - + $regex = $c->proxies_cfg[$this->proxyname]["regex"]; + $patterns = array(); $replacements = array(); foreach($words as $w) { - $patterns[] = "/".preg_quote($w)."/i"; - $replacements[] = str_repeat($replaceby,strlen($w)); + if ($regex) + { + // the words are regular expressions + $patterns[] = "/".$w."/ie"; + $replacements[] = "'\\1'.str_repeat('$replaceby',strlen('\\2')).'\\3'"; + } + else + { + // the words are simple words + $patterns[] = "/".preg_quote($w)."/i"; + $replacements[] = str_repeat($replaceby,strlen($w)); + } } $param = preg_replace($patterns, $replacements, $param); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-11-23 15:40:41
|
Revision: 877 http://svn.sourceforge.net/phpfreechat/?rev=877&view=rev Author: kerphi Date: 2006-11-23 07:40:40 -0800 (Thu, 23 Nov 2006) Log Message: ----------- [en] Bug fix: some servers don't like 777 permissions and the chat was broken. I changed the proxy.php creation rights to 755. It should fix lot of "Error: the chat cannot be loaded!..." (thanks to Mirco D'Inc?\195?\160 - http://www.bellunodolomiti.it)[50min] [fr] Bug fix : certains serveurs n'acceptent pas les repertoires avec les droits 777 ce qui empechait de fonctionner le chat. J'ai donc change les droit de creation du fichier proxy.php et de ses repertoire a 755. Ceci devrait r?\195?\169soudre de nombreux probl?\195?\168mes "Error: the chat cannot be loaded!..." (merci ?\195?\160 Mirco D'Inc?\195?\160 - http://www.bellunodolomiti.it)[50min] Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/pfctools.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-11-21 18:12:57 UTC (rev 876) +++ trunk/src/pfcglobalconfig.class.php 2006-11-23 15:40:40 UTC (rev 877) @@ -412,12 +412,15 @@ $proxycontent = file_get_contents(dirname(__FILE__)."/client/proxy.php.tpl"); $proxycontent = str_replace("//%allowedpath%", $allowedpath_string, $proxycontent); if (!file_exists(dirname($proxyfile))) - @mkdir(dirname($proxyfile)); + mkdir_r(dirname($proxyfile)); if (file_exists($proxyfile) && !is_writable($proxyfile)) $this->errors[] = _pfc("'%s' must be writable", $proxyfile); else - @file_put_contents($proxyfile, $proxycontent); + { + file_put_contents($proxyfile, $proxycontent); + chmod( $proxyfile, 0755 ); // should fix problems on OVH mutualized servers + } } Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-11-21 18:12:57 UTC (rev 876) +++ trunk/src/pfctools.php 2006-11-23 15:40:40 UTC (rev 877) @@ -112,7 +112,7 @@ } -function mkdir_r($path, $modedir = 0775) +function mkdir_r($path, $modedir = 0755) { // This function creates the specified directory using mkdir(). Note // that the recursive feature on mkdir() is broken with PHP 5.0.4 for @@ -146,7 +146,7 @@ * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ -function copy_r($source, $dest, $modedir = 0775, $modefile = 0664) +function copy_r($source, $dest, $modedir = 0755, $modefile = 0664) { // Simple copy for a file if (is_file($source)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-11-29 14:44:45
|
Revision: 881 http://svn.sourceforge.net/phpfreechat/?rev=881&view=rev Author: kerphi Date: 2006-11-29 06:44:44 -0800 (Wed, 29 Nov 2006) Log Message: ----------- [en] Bug fix: on windows server the public path was incorrectly computed [0h25] [fr] Bug fix : sur les serveurs windows le chemin public ?\195?\169tait mal calcul?\195?\169 [0h25] Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/pfctools.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-11-28 17:50:20 UTC (rev 880) +++ trunk/src/pfcglobalconfig.class.php 2006-11-29 14:44:44 UTC (rev 881) @@ -358,6 +358,7 @@ // calculate datapublic url if ($this->data_public_url == "") $this->data_public_url = relativePath($this->client_script_path, $this->data_public_path); + // --- // test server script if ($this->server_script_path == "") Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-11-28 17:50:20 UTC (rev 880) +++ trunk/src/pfctools.php 2006-11-29 14:44:44 UTC (rev 881) @@ -62,11 +62,11 @@ $p1 = realpath(cleanPath($p1)); $p2 = realpath(cleanPath($p2)); $res = ""; - //echo $p1."<br>"; - //echo $p2."<br>"; + // echo $p1."<br>"; + // echo $p2."<br>"; while( $p1 != "" && $p1 != "/" && // for unix root dir - !preg_match("/[a-z]\:\\\/i",$p1) && // for windows rootdir + !preg_match("/^[a-z]\:\\\$/i",$p1) && // for windows rootdir strpos($p2, $p1) !== 0) { $res .= "../"; @@ -86,6 +86,7 @@ if (preg_match("/.*\/$/", $res)) $res = preg_replace("/(.*)\//","$1",$res); // if rootpath is empty replace it by "." to avoide url starting with "/" if ($res == "") $res = "."; + // echo $res."<br>"; return $res; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-11-29 16:33:16
|
Revision: 882 http://svn.sourceforge.net/phpfreechat/?rev=882&view=rev Author: kerphi Date: 2006-11-29 08:33:12 -0800 (Wed, 29 Nov 2006) Log Message: ----------- [en] Optimizations: when directories were open for listing, they were not closed using closedir() php function. [1h00] [fr] Optimisation : lorsque les repertoire ?\195?\169taient list?\195?\169s, ils n'?\195?\169tait jamais ferm?\195?\169s avec la fonction closedir() de php. [1h00] Modified Paths: -------------- trunk/src/commands/help.class.php trunk/src/containers/file.class.php trunk/src/pfci18n.class.php trunk/src/pfctools.php Modified: trunk/src/commands/help.class.php =================================================================== --- trunk/src/commands/help.class.php 2006-11-29 14:44:44 UTC (rev 881) +++ trunk/src/commands/help.class.php 2006-11-29 16:33:12 UTC (rev 882) @@ -26,6 +26,7 @@ if (!preg_match("/^([a-z]+).class.php$/i",$file,$res)) continue; if (!in_array($res[1],$ignore)) $cmdlist[] = $res[1]; } + closedir($dh); sort($cmdlist); $str = _pfc("Here is the command list:")."<br/>"; Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-11-29 14:44:44 UTC (rev 881) +++ trunk/src/containers/file.class.php 2006-11-29 16:33:12 UTC (rev 882) @@ -134,6 +134,7 @@ $ret["timestamp"][] = filemtime($dir.'/'.$file); $ret["value"][] = $file; } + closedir($dh); } return $ret; } @@ -151,6 +152,7 @@ $ret["timestamp"][] = filemtime($dir.'/'.$file); $ret["value"][] = $file; } + closedir($dh); } return $ret; } @@ -197,10 +199,18 @@ return true; } - $leaffilename = $dir.'/'.$leaf; - + $leaffilename = $dir.'/'.$leaf; if (!file_exists($leaffilename)) return false; unlink($leaffilename); + + // check that the directory is empty or not + // remove it if it doesn't contains anything + $dh = opendir($dir); + readdir($dh); readdir($dh); // skip . and .. directories + $isnotempty = readdir($dh); + closedir($dh); + if ($isnotempty === false) rmdir($dir); + return true; } Modified: trunk/src/pfci18n.class.php =================================================================== --- trunk/src/pfci18n.class.php 2006-11-29 14:44:44 UTC (rev 881) +++ trunk/src/pfci18n.class.php 2006-11-29 16:33:12 UTC (rev 882) @@ -110,6 +110,7 @@ if (file_exists(dirname(__FILE__)."/../i18n/".$file."/admin.php")) $GLOBALS["accepted_admin_languages"][] = $file; } + closedir($dir_handle); return $GLOBALS["accepted_admin_languages"]; } else{ @@ -124,6 +125,7 @@ if ($file == "." || $file == ".." || strpos($file,".")===0) continue; $GLOBALS["accepted_languages"][] = $file; } + closedir($dir_handle); return $GLOBALS["accepted_languages"]; } } Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-11-29 14:44:44 UTC (rev 881) +++ trunk/src/pfctools.php 2006-11-29 16:33:12 UTC (rev 882) @@ -135,6 +135,7 @@ if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) rm_r($dir.'/'.$obj); } + closedir($dh); @rmdir($dir); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-12-04 17:12:19
|
Revision: 887 http://svn.sourceforge.net/phpfreechat/?rev=887&view=rev Author: kerphi Date: 2006-12-04 09:12:10 -0800 (Mon, 04 Dec 2006) Log Message: ----------- [en] New parameter 'max_displayed_lines' (by default 150) used to free browser's memory when lot of lines are written in the chat. [1h20] [fr] Nouveau param?\195?\168tre 'max_displayed_lines' (par d?\195?\169faut 150) permettant de lib?\195?\169rer la m?\195?\169moire du navigateur lorsque bcp de messages sont affich?\195?\169s. [1h20] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/pfcglobalconfig.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-12-02 17:22:18 UTC (rev 886) +++ trunk/src/client/chat.js.tpl.php 2006-12-04 17:12:10 UTC (rev 887) @@ -19,6 +19,7 @@ var pfc_showwhosonline = <?php echo $json->encode($showwhosonline); ?>; var pfc_focus_on_connect = <?php echo $json->encode($focus_on_connect); ?>; var pfc_max_text_len = <?php echo $json->encode($max_text_len); ?>; +var pfc_max_displayed_lines = <?php echo $json->encode($max_displayed_lines); ?>; var pfc_quit_on_closedwindow = <?php echo $json->encode($quit_on_closedwindow); ?>; var pfc_debug = <?php echo $json->encode($debug); ?>; var pfc_btn_sh_smileys = <?php echo $json->encode($btn_sh_smileys); ?>; Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-12-02 17:22:18 UTC (rev 886) +++ trunk/src/client/pfcclient.js 2006-12-04 17:12:10 UTC (rev 887) @@ -776,6 +776,7 @@ handleComingRequest: function( cmds ) { var msg_html = $H(); + var max_msgid = 0; //alert(cmds.inspect()); @@ -804,20 +805,20 @@ line += '<span class="pfc_heure">'+ time +'</span> '; if (cmd == 'send') { - line += ' <span class="pfc_nick">'; - line += '‹'; - line += '<span '; + line += ' <span class="pfc_nick">'; + line += '‹'; + line += '<span '; line += 'onclick="pfc.insert_text(\'' + sender.replace("'", '\\\'') + ', \',\'\',false)" '; - line += 'class="pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(sender)) +'">'; - line += sender; - line += '</span>'; - line += '›'; - line += '</span> '; + line += 'class="pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(sender)) +'">'; + line += sender; + line += '</span>'; + line += '›'; + line += '</span> '; } if (cmd == 'notice' || cmd == 'me') - line += '<span class="pfc_words">* '+ this.parseMessage(param) +'</span> '; + line += '<span class="pfc_words">* '+ this.parseMessage(param) +'</span> '; else - line += '<span class="pfc_words">'+ this.parseMessage(param) +'</span> '; + line += '<span class="pfc_words">'+ this.parseMessage(param) +'</span> '; line += '</div>'; if (oldmsg == 0) @@ -828,7 +829,7 @@ var tabid = recipientid; if (this.gui.getTabId() != tabid) this.gui.notifyTab(tabid); - // notify the window (change the title) + // notify the window (change the title) if (!this.detectactivity.isActive() && pfc_notify_window) this.gui.notifyWindow(); } @@ -837,6 +838,9 @@ msg_html[recipientid] = line; else msg_html[recipientid] += line; + + // remember the max message id in order to clean old lines + if (max_msgid < id) max_msgid = id; } // loop on all recipients and post messages @@ -858,6 +862,21 @@ recipientdiv.appendChild(m); this.gui.scrollDown(tabid, m); } + + // delete the old messages from the client (save some memory) + var limit_msgid = max_msgid - pfc_max_displayed_lines; + var elt = $('pfc_msg'+limit_msgid); + while (elt) + { + // delete this element to save browser memory + if (is_ff) + elt.innerHTML = ''; + else + // this code don't work in FF, why ? don't know .. + elt.parentElement.removeChild(elt); + limit_msgid--; + elt = $('pfc_msg'+limit_msgid); + } }, /** Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-12-02 17:22:18 UTC (rev 886) +++ trunk/src/pfcglobalconfig.class.php 2006-12-04 17:12:10 UTC (rev 887) @@ -72,7 +72,8 @@ var $refresh_delay = 5000; // in mili-seconds (5 seconds) var $max_refresh_delay = 60000; // in mili-seconds (60 seconds) var $timeout = 20000; // in mili-seconds (20 seconds) - var $max_msg = 20; + var $max_msg = 20; // number of messages keept in the history (this is what you see when you reload the chat) + var $max_displayed_lines = 150; // maximum number of displayed lines (old lines will be deleted to save browser's memory) var $quit_on_closedwindow = true; // could be annoying because the reload event is the same as a close event var $focus_on_connect = true; var $connect_at_startup = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-12-08 17:58:33
|
Revision: 895 http://svn.sourceforge.net/phpfreechat/?rev=895&view=rev Author: kerphi Date: 2006-12-08 09:58:25 -0800 (Fri, 08 Dec 2006) Log Message: ----------- work in progress : multi parameters in commands Modified Paths: -------------- trunk/src/client/pfcclient.js trunk/src/client/pfcgui.js trunk/src/commands/ban.class.php trunk/src/commands/invite.class.php trunk/src/commands/kick.class.php trunk/src/commands/leave.class.php trunk/src/pfccommand.class.php trunk/src/phpfreechat.class.php Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-12-08 13:55:33 UTC (rev 894) +++ trunk/src/client/pfcclient.js 2006-12-08 17:58:25 UTC (rev 895) @@ -888,12 +888,27 @@ sendRequest: function(cmd, param) { var recipientid = this.gui.getTabId(); + + var req = cmd+" "+this.clientid+" "+(recipientid==''?'0':recipientid)+(param?" "+param : ""); if (pfc_debug) if (cmd != "/update") trace('sendRequest: '+req); return eval('pfc_handleRequest(req);'); }, + // @todo remplacer sendRequest par cette fonction (cf /leave dans pfcgui.js) + sendRequest2: function(cmd) + { + var rx = new RegExp('(^\/[^ ]+) *(.*)','ig'); + var ttt = cmd.split(rx); + + var recipientid = this.gui.getTabId(); + var req = ttt[1]+" "+this.clientid+" "+(recipientid==''?'0':recipientid)+' '+ttt[2]; + if (pfc_debug) + if (cmd != "/update") trace('sendRequest: '+req); + return eval('pfc_handleRequest(req);'); + }, + /** * update function to poll the server each 'refresh_delay' time */ Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-12-08 13:55:33 UTC (rev 894) +++ trunk/src/client/pfcgui.js 2006-12-08 17:58:25 UTC (rev 895) @@ -256,9 +256,10 @@ { var a2 = document.createElement('a'); a2.pfc_tabid = tabid; + a2.pfc_tabname = name; a2.onclick = function(){ var res = confirm(pfc.res.getLabel('Do you really want to leave this room ?')); - if (res == true) pfc.sendRequest('/leave', this.pfc_tabid); return false; + if (res == true) pfc.sendRequest2('/leave "'+this.pfc_tabname+'"'); return false; } a2.alt = pfc.res.getLabel('Close this tab'); a2.title = a2.alt; Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2006-12-08 13:55:33 UTC (rev 894) +++ trunk/src/commands/ban.class.php 2006-12-08 17:58:25 UTC (rev 895) @@ -4,12 +4,13 @@ class pfcCommand_ban extends pfcCommand { - var $usage = "/ban {nickname}"; + var $usage = "/ban {nickname} [ {reason} ]"; function run(&$xml_reponse, $p) { $clientid = $p["clientid"]; $param = $p["param"]; + $params = $p["params"]; $sender = $p["sender"]; $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; @@ -17,7 +18,7 @@ $c =& $this->c; $u =& $this->u; - if (trim($param) == "") + if (trim($params[0]) == '') { // error $cmdp = $p; @@ -28,33 +29,33 @@ return; } + $ct =& $c->getContainerInstance(); + $nickidtoban = $ct->getNickId($params[0]); + + // notify all the channel + $cmdp = $p; + $cmdp["param"] = _pfc("banished from %s by %s", $recipient, $sender); + $cmdp["flag"] = 1; + $cmd =& pfcCommand::Factory("notice"); + $cmd->run($xml_reponse, $cmdp); + + // kick the user (maybe in the future, it will be dissociate in a /kickban command) + $cmdp = $p; + $cmdp["params"] = array(); + $cmdp["params"][] = $params[0]; // nickname to kick + $cmdp["params"][] = $params[1]; // reason + $cmd =& pfcCommand::Factory("kick"); + $cmd->run($xml_reponse, $cmdp); - $container =& $c->getContainerInstance(); - $nickid = $container->getNickId($param); - if ($nickid != "") - { - $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); - $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - $cmdtmp = array("leave", /* cmdname */ - $recipientid,/* param */ - $sender, /* sender */ - $recipient, /* recipient */ - $recipientid,/* recipientid */ - ); - //_pfc("banished from %s by %s", $recipient, $sender); - $cmdtoplay[] = $cmdtmp; // ban the user from the current channel - $container->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); - } - // update the recipient banlist - $banlist = $container->getChanMeta($recipient, 'banlist_nickid'); + $banlist = $ct->getChanMeta($recipient, 'banlist_nickid'); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); - $banlist[] = $nickid; // append the nickid to the banlist - $container->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); + $banlist[] = $nickidtoban; // append the nickid to the banlist + $ct->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); } } Modified: trunk/src/commands/invite.class.php =================================================================== --- trunk/src/commands/invite.class.php 2006-12-08 13:55:33 UTC (rev 894) +++ trunk/src/commands/invite.class.php 2006-12-08 17:58:25 UTC (rev 895) @@ -1,5 +1,4 @@ <?php - /** * invite.class.php * @@ -20,7 +19,10 @@ * Free Software Foundation, 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA */ - + +require_once(dirname(__FILE__)."/../pfccommand.class.php"); +require_once(dirname(__FILE__)."/../commands/join.class.php"); + /** * /invite command * @@ -29,54 +31,56 @@ * The parameter "target channel" is optional, if not set it defaults to the current channel * * @author Benedikt Hallinger <be...@ph...> + * @author Stephane Gully <ste...@gm...> */ class pfcCommand_invite extends pfcCommand { - var $usage = "/invite {nickname to invite} [{target channel}]"; + var $usage = "/invite {nickname to invite} [ {target channel} ]"; - function run(&$xml_reponse, $p) - { - $clientid = $p["clientid"]; - $param = $p["param"]; - $sender = $p["sender"]; - $recipient = $p["recipient"]; - $recipientid = $p["recipientid"]; + function run(&$xml_reponse, $p) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $params = $p["params"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + + $c =& $this->c; // pfcGlobalConfig + $u =& $this->u; // pfcUserConfig + $ct =& $c->getContainerInstance(); // Connection to the chatbackend + + $nicktoinvite = isset($params[0]) ? $params[0] : ''; + $channeltarget = isset($params[1]) ? $params[1] : $u->channels[$recipientid]["name"]; // Default: current channel + + if ($nicktoinvite == '' || $channeltarget == '') + { + // Parameters are not ok + $cmdp = $p; + $cmdp["params"] = array(); + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $cmdp); + return; + } - $c =& $this->c; // pfcGlobalConfig - $u =& $this->u; // pfcUserConfig - $container =& $c->getContainerInstance(); // Connection to the chatbackend - - $p_array = split(' ', $param); // Split the parameters: [0]= targetnick, [1]=targetchannel - if (!isset($p_array[1])) $p_array[1] = $u->channels[$recipientid]["name"]; // Default: current channel - if (!isset($p_array[0]) || !isset($p_array[1])) - { - // Parameters not ok! - $cmdp = $p; - $cmdp["param"] = _pfc("Missing parameter"); - $cmdp["param"] .= " (".$this->usage.")"; - $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $cmdp); - return; - } - - // inviting a user: just add a join command to play to the aimed user metadata. - $nickid = $container->getNickId($p_array[0]); // get the internal ID of that chatter - if ($nickid != "") - { - $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); // get the users command queue - $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - $cmdtmp = array("join", /* cmdname */ - $p_array[1], /* param */ - $sender, /* sender */ - $recipient, /* recipient */ - $recipientid,/* recipientid */ - ); - $cmdtoplay[] = $cmdtmp; // store the command in the queue - $container->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); // close and store the queue + // inviting a user: just add a join command to play to the aimed user metadata. + $nickidtoinvite = $ct->getNickId($nicktoinvite); + $cmdstr = 'join2'; + $cmdp = array(); + $cmdp['param'] = $channeltarget; // channel target name + $cmdp['params'][] = $channeltarget; // channel target name + pfcCommand::AppendCmdToPlay($nickidtoinvite, $cmdstr, $cmdp); - // Ok, the user is invited, now write something into the chat, so his tab opens - $container->write($recipient, 'SYSTEM', "notice", $p_array[0].' was invited by '.$sender); - } - } + // notify the aimed channel that a user has been invited + $cmdp = array(); + $cmdp["param"] = $nicktoinvite.' was invited by '.$sender; + $cmdp["flag"] = 1; + $cmdp["recipient"] = pfcCommand_join::GetRecipient($channeltarget); + $cmdp["recipientid"] = pfcCommand_join::GetRecipientId($channeltarget); + $cmd =& pfcCommand::Factory("notice"); + $cmd->run($xml_reponse, $cmdp); + } } ?> \ No newline at end of file Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-12-08 13:55:33 UTC (rev 894) +++ trunk/src/commands/kick.class.php 2006-12-08 17:58:25 UTC (rev 895) @@ -4,12 +4,13 @@ class pfcCommand_kick extends pfcCommand { - var $usage = "/kick {nickname}"; + var $usage = "/kick {nickname} [ {reason} ]"; function run(&$xml_reponse, $p) { $clientid = $p["clientid"]; $param = $p["param"]; + $params = $p["params"]; $sender = $p["sender"]; $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; @@ -17,7 +18,7 @@ $c =& $this->c; $u =& $this->u; - if (trim($param) == "") + if (trim($params[0]) == '') { // error $cmdp = $p; @@ -27,24 +28,16 @@ $cmd->run($xml_reponse, $cmdp); return; } - + // kicking a user just add a command to play to the aimed user metadata. - $container =& $c->getContainerInstance(); - $nickid = $container->getNickId($param); - if ($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 */ - $recipientid." ".$reason, /* param */ - $sender, /* sender */ - $recipient, /* recipient */ - $recipientid,/* recipientid */ - ); - $cmdtoplay[] = $cmdtmp; // kick the user from the current channel - $container->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); - } + $ct =& $c->getContainerInstance(); + $otherid = $ct->getNickId($params[0]); + $channame = $u->channels[$recipientid]["name"]; + $cmdstr = 'leave'; + $cmdp = array(); + $cmdp['params'][] = $channame; // channel name + $cmdp['params'][] = _pfc("kicked from %s by %s - reason: %s", $channame, $sender, $params[1]); // reason + pfcCommand::AppendCmdToPlay($otherid, $cmdstr, $cmdp); } } Modified: trunk/src/commands/leave.class.php =================================================================== --- trunk/src/commands/leave.class.php 2006-12-08 13:55:33 UTC (rev 894) +++ trunk/src/commands/leave.class.php 2006-12-08 17:58:25 UTC (rev 895) @@ -1,15 +1,16 @@ <?php require_once(dirname(__FILE__)."/../pfccommand.class.php"); +require_once(dirname(__FILE__)."/../commands/join.class.php"); class pfcCommand_leave extends pfcCommand { - var $usage = "/leave [{recipientid} {reason}]"; + var $usage = "/leave [{channel} {reason}]"; function run(&$xml_reponse, $p) { $clientid = $p["clientid"]; - $param = $p["param"]; + $params = $p["params"]; $sender = $p["sender"]; $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; @@ -19,13 +20,13 @@ // tab to leave can be passed in the parameters // a reason can also be present (used for kick and ban commands) - $id = ""; $reason = ""; - if (preg_match("/([a-z0-9]*)( (.*)|)/i", $param, $res)) + $id = ''; $reason = ''; + if (count($params)>0) { - $id = $res[1]; - $reason = trim($res[2]); + $id = pfcCommand_join::GetRecipientId($params[0]); + $reason = implode(" ",array_slice($params,1)); } - if ($id == "") $id = $recipientid; // be default this is the current tab to leave + if ($id == '') $id = $recipientid; // be default this is the current tab to leave // $xml_reponse->addScript("alert('sender=".addslashes($sender)."');"); // $xml_reponse->addScript("alert('recipientid=".addslashes($id)."');"); @@ -84,6 +85,15 @@ // reset the oldmsg flag $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; $_SESSION[$oldmsg_sid] = true; + + // if the /leave command comes from a cmdtoplay then show the reason to the user (ex: kick or ban reason) + if ($p['cmdtoplay']) + { + $cmdp = $p; + $cmdp["param"] = $reason; + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $cmdp); + } // return ok to the client // then the client will remove the channel' tab Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-12-08 13:55:33 UTC (rev 894) +++ trunk/src/pfccommand.class.php 2006-12-08 17:58:25 UTC (rev 895) @@ -161,22 +161,88 @@ // alert them that $nicktorewhois user info just changed foreach($otherids as $otherid) { + $cmdstr = 'whois2'; + $cmdp = array(); + $cmdp['param'] = $nicktorewhois; + pfcCommand::AppendCmdToPlay($otherid, $cmdstr, $cmdp); + + /* $cmdtoplay = $ct->getUserMeta($otherid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - $cmdtmp = array("whois2", /* cmdname */ - $nicktorewhois, /* param */ - NULL, /* sender */ - NULL, /* recipient */ - NULL, /* recipientid */ + $cmdtmp = array("whois2", // cmdname + $nicktorewhois, // param + NULL, // sender + NULL, // recipient + NULL, // recipientid ); if (!in_array($cmdtmp, $cmdtoplay)) { $cmdtoplay[] = $cmdtmp; $ct->setUserMeta($otherid, 'cmdtoplay', serialize($cmdtoplay)); } + */ } } + function AppendCmdToPlay($nickid, $cmdstr, $cmdp) + { + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); + + $ct =& $c->getContainerInstance(); + if ($nickid != "") + { + $cmdtoplay = $ct->getUserMeta($nickid, 'cmdtoplay'); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + $cmdtmp = array(); + $cmdtmp['cmdstr'] = $cmdstr; + $cmdtmp['params'] = $cmdp; + $cmdtoplay[] = $cmdtmp; + $ct->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); + return true; + } + else + return false; + } + + function RunPendingCmdToPlay($nickid,$clientid,$xml_reponse) + { + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); + $ct =& $c->getContainerInstance(); + + $morecmd = true; + while($morecmd) + { + // take a command from the list + $cmdtoplay = $ct->getUserMeta($nickid, 'cmdtoplay'); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + if (count($cmdtoplay) == 0) { $morecmd = false; continue; } + // take the last posted command + $cmdtmp = array_pop($cmdtoplay); + // store the new cmdtoplay list (-1 item) + $ct->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); + + // play the command + // print_r($cmdtmp); + $cmd =& pfcCommand::Factory($cmdtmp['cmdstr']); + $cmdp = $cmdtmp['params']; + $cmdp['clientid'] = $clientid; // the clientid must be the current user one + $cmdp['cmdtoplay'] = true; // used to run some specials actions in the command (ex: if the cmdtoplay is a 'leave' command, then show an alert to the kicked or banished user) + if ($c->debug) + $cmd->run($xml_reponse, $cmdp); + else + @$cmd->run($xml_reponse, $cmdp); + + // check if there is other command to play + $cmdtoplay = $ct->getUserMeta($nickid, 'cmdtoplay'); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + + $morecmd = (count($cmdtoplay) > 0); + } + } + + function trace(&$xml_reponse, $msg, $data = NULL) { if ($data != NULL) Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-12-08 13:55:33 UTC (rev 894) +++ trunk/src/phpfreechat.class.php 2006-12-08 17:58:25 UTC (rev 895) @@ -361,70 +361,21 @@ { // alert the other from the new pv // (warn other user that someone talk to him) - $container =& $c->getContainerInstance(); - $cmdtoplay = $container->getUserMeta($u->privmsg[$recipientid]["pvnickid"], 'cmdtoplay'); - $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - $cmdtmp = array("privmsg2", /* cmdname */ - $u->nick, /* param */ - $sender, /* sender */ - $recipient, /* recipient */ - $recipientid,/* recipientid */ - ); - if (!in_array($cmdtmp, $cmdtoplay)) - { - $cmdtoplay[] = $cmdtmp; - $container->setUserMeta($u->privmsg[$recipientid]["pvnickid"], 'cmdtoplay', serialize($cmdtoplay)); - //$xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); - } + + $ct =& $c->getContainerInstance(); + $nickidtopv = $u->privmsg[$recipientid]["pvnickid"]; + $cmdstr = 'privmsg2'; + $cmdp = array(); + $cmdp['param'] = $u->nick; + $cmdp['params'][] = $u->nick; + pfcCommand::AppendCmdToPlay($nickidtopv, $cmdstr, $cmdp); } } - // before playing the wanted command // play the found commands into the meta 'cmdtoplay' - $container =& $c->getContainerInstance(); - $nickid = $u->nickid; - $morecmd = true; - while($morecmd) - { - // take a command from the list - $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->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); - - // play the command - $cmd =& pfcCommand::Factory($cmdtmp[0]); - $cmdp = array(); - $cmdp["clientid"] = $clientid; - $cmdp["param"] = $cmdtmp[1]; - $cmdp["sender"] = $cmdtmp[2]; - $cmdp["recipient"] = $cmdtmp[3]; - $cmdp["recipientid"] = $cmdtmp[4]; - if ($c->debug) - $cmd->run($xml_reponse, $cmdp); - else - @$cmd->run($xml_reponse, $cmdp); - - // if the cmdtoplay is a 'leave' command, then show an alert to the kicked or banished user - if ($cmdtmp[0] == "leave") - { - if (preg_match("/([a-z0-9]*) (.*)/i", $cmdtmp[1], $res)) - $xml_reponse->addScript("alert('".$res[2]."');"); - } - - // check if there is other command to play - $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); - $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - } - - $morecmd = (count($cmdtoplay) > 0); - } - + pfcCommand::RunPendingCmdToPlay($u->nickid, $clientid, $xml_reponse); $cmd =& pfcCommand::Factory($cmdname); $cmdp = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-12-19 17:56:06
|
Revision: 902 http://svn.sourceforge.net/phpfreechat/?rev=902&view=rev Author: kerphi Date: 2006-12-19 09:56:01 -0800 (Tue, 19 Dec 2006) Log Message: ----------- Container optimization : add a memory cache (work in progress: do not update this revision !!!) Modified Paths: -------------- trunk/src/containers/file.class.php trunk/src/pfccontainer.class.php trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/pfccontainerinterface.class.php Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-12-18 09:16:01 UTC (rev 901) +++ trunk/src/containers/file.class.php 2006-12-19 17:56:01 UTC (rev 902) @@ -20,24 +20,19 @@ * Boston, MA 02110-1301 USA */ -require_once dirname(__FILE__)."/../pfccontainer.class.php"; +require_once dirname(__FILE__)."/../pfccontainerinterface.class.php"; /** * pfcContainer_File is a concret container which stock data into files * * @author Stephane Gully <ste...@gm...> */ -class pfcContainer_File extends pfcContainer +class pfcContainer_File extends pfcContainerInterface { var $_users = array("nickid" => array(), "timestamp" => array()); var $_meta = array(); - function pfcContainer_File(&$config) - { - pfcContainer::pfcContainer($config); - } - function loadPaths() { $c =& $this->c; @@ -91,7 +86,7 @@ { if (file_exists($leaffilename) && filesize($leaffilename)>0) unlink($leaffilename); - touch($leaffilename); + touch($leaffilename); } else { @@ -122,7 +117,6 @@ $dir_base = $c->container_cfg_server_dir; $dir = $dir_base.'/'.$group; - if ($subgroup == NULL) { if (is_dir($dir)) @@ -154,6 +148,7 @@ } closedir($dh); } + return $ret; } Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2006-12-18 09:16:01 UTC (rev 901) +++ trunk/src/pfccontainer.class.php 2006-12-19 17:56:01 UTC (rev 902) @@ -20,6 +20,8 @@ * Boston, MA 02110-1301 USA */ + require_once dirname(__FILE__)."/pfccontainerinterface.class.php"; + /** * pfcContainer is an abstract class which define interface * to be implemented by concrete container (example: File) @@ -27,13 +29,20 @@ * @author Stephane Gully <ste...@gm...> * @abstract */ -class pfcContainer +class pfcContainer extends pfcContainerInterface { - var $c; - function pfcContainer(&$config) { $this->c =& $config; } - function getDefaultConfig() { return array(); } - function init() { return array(); } + var $_container = null; // contains the concrete container instance + + function pfcContainer(&$c, $type = 'File') + { + pfcContainerInterface::pfcContainerInterface($c); + // create the concrete container instance + require_once dirname(__FILE__)."/containers/".strtolower($type).".class.php"; + $container_classname = "pfcContainer_".$type; + $this->_container =& new $container_classname($this->c); + } + /** * Create (connect/join) the nickname into the server or the channel locations * Notice: the caller must take care to update all channels the users joined (use stored channel list into metadata) @@ -280,7 +289,7 @@ { if ($chan == NULL) $chan = 'SERVER'; - $ret = $this->getMeta("channelid-to-nickid", $this->encode($chan)); + $ret = $this->getMeta("channelid-to-nickid", $this->encode($chan)); for($i = 0; $i<count($ret['timestamp']); $i++) { if ($ret['value'][$i] == $nickid) return $i; @@ -411,7 +420,6 @@ return $lastmsgid; } - /** * Remove all created data for this server (identified by serverid) * Notice: for the default File container, it's just a recursive directory remove @@ -421,25 +429,6 @@ $this->rmMeta(NULL); } - /** - * In the default File container: used to encode UTF8 strings to ASCII filenames - * This method can be overridden by the concrete container - */ - function encode($str) - { - return $str; - } - - /** - * In the default File container: used to decode ASCII filenames to UTF8 strings - * This method can be overridden by the concrete container - */ - function decode($str) - { - return $str; - } - - function getAllUserMeta($nickid) { $result = array(); @@ -483,7 +472,9 @@ $ret = $this->setMeta("channelid-to-metadata", $this->encode($chan), $key, $value); return $ret; } - + + var $_cache = array(); + /** * Write a meta data value identified by a group / subgroup / leaf [with a value] * As an example in the default file container this arborescent structure is modelised by simple directories @@ -499,8 +490,24 @@ * @return 1 if the old leaf has been overwritten, 0 if a new leaf has been created */ function setMeta($group, $subgroup, $leaf, $leafvalue = NULL) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + { + $ret = $this->_container->setMeta($group, $subgroup, $leaf, $leafvalue); + echo "setMeta($group, $subgroup, $leaf, $leafvalue)\n"; + //print_r($ret); + + + // @todo creer la bonne hierarchie du cache + + //$this->_cache['group'][$group] = array_merge($this->_cache['group'][$group],array($subgroup)); + //$this->_cache[$group][$subgroup][$leaf] = $leafvalue; + + //$this->_cache['subgroup'][$group][$subgroup] = $ret; + //$this->_cache['leaf'][$group][$subgroup][$leaf] = ($withleafvalue ? ; + + return $ret; + } + /** * Read meta data identified by a group [/ subgroup [/ leaf]] @@ -511,7 +518,73 @@ * @return array which contains two subarray 'timestamp' and 'value' */ function getMeta($group, $subgroup = null, $leaf = null, $withleafvalue = false) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + { + echo "getMeta($group, $subgroup, $leaf, $withleafvalue)\n"; + + // check in the cache + $ret = array('timestamp' => array(), + 'value' => array()); + if ($subgroup == null && + isset($this->_cache[$group]['value'])) + { + $ret['timestamp'] = $this->_cache[$group]['timestamp']; + $ret['value'] = $this->_cache[$group]['value']; + echo "getMeta->incache\n"; + return $ret; + } + else if ($leaf == null && + isset($this->_cache[$group][$subgroup]['value'])) + { + $ret['timestamp'] = $this->_cache[$group][$subgroup]['timestamp']; + $ret['value'] = $this->_cache[$group][$subgroup]['value']; + echo "getMeta->incache\n"; + return $ret; + } + else + { + if ($withleafvalue) + { + if (isset($this->_cache[$group][$subgroup][$leaf]['value'])) + { + echo "getMeta->incache\n"; + return $this->_cache[$group][$subgroup][$leaf]; + } + } + else + { + if (isset($this->_cache[$group][$subgroup][$leaf]['timestamp'])) + { + echo "getMeta->incache\n"; + return $this->_cache[$group][$subgroup][$leaf]; + } + } + } + + echo "getMeta->notincache\n"; + + // get the fresh data + $ret = $this->_container->getMeta($group, $subgroup, $leaf, $withleafvalue); + + // store in the cache + if ($subgroup == null) + { + $this->_cache[$group]['value'] = $ret['value']; + $this->_cache[$group]['timestamp'] = $ret['timestamp']; + } + else if ($leaf == null) + { + $this->_cache[$group][$subgroup]['value'] = $ret['value']; + $this->_cache[$group][$subgroup]['timestamp'] = $ret['timestamp']; + } + else + { + if ($withleafvalue) + $this->_cache[$group][$subgroup][$leaf]['value'] = $ret['value']; + $this->_cache[$group][$subgroup][$leaf]['timestamp'] = $ret['timestamp']; + } + + return $ret; + } /** @@ -522,8 +595,43 @@ * @return true on success, false on error */ function rmMeta($group, $subgroup = null, $leaf = null) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + { + echo "rmMeta($group, $subgroup, $leaf)\n"; + + print_r($this->_cache); + // remove from the cache + if ($group == null) + $this->_cache = array(); + else if ($subgroup == null) + unset($this->_cache[$group]); + else if ($leaf == null) + unset($this->_cache[$group][$subgroup]); + else + unset($this->_cache[$group][$subgroup][$leaf]); + + print_r($this->_cache); + + return $this->_container->rmMeta($group, $subgroup, $leaf); + } + + /** + * In the default File container: used to encode UTF8 strings to ASCII filenames + * This method can be overridden by the concrete container + */ + function encode($str) + { + return $this->_container->encode($str); + } + + /** + * In the default File container: used to decode ASCII filenames to UTF8 strings + * This method can be overridden by the concrete container + */ + function decode($str) + { + return $this->_container->decode($str); + } } ?> \ No newline at end of file Added: trunk/src/pfccontainerinterface.class.php =================================================================== --- trunk/src/pfccontainerinterface.class.php (rev 0) +++ trunk/src/pfccontainerinterface.class.php 2006-12-19 17:56:01 UTC (rev 902) @@ -0,0 +1,96 @@ +<?php +/** + * pfccontainerinterface.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +/** + * pfcContainerInterface is an interface implemented by pfcContainer and each pfcContainer concrete isntances (File,Mysql...) + * + * @author Stephane Gully <ste...@gm...> + * @abstract + */ +class pfcContainerInterface +{ + var $c; + function pfcContainerInterface(&$config) { $this->c =& $config; } + function getDefaultConfig() { return array(); } + function init() { return array(); } + + /** + * Write a meta data value identified by a group / subgroup / leaf [with a value] + * As an example in the default file container this arborescent structure is modelised by simple directories + * group1/subgroup1/leaf1 + * /leaf2 + * /subgroup2/... + * Each leaf can contain or not a value. + * However each leaf and each group/subgroup must store the lastmodified time (timestamp). + * @param $group root arborescent element + * @param $subgroup is the root first child which contains leafs + * @param $leaf is the only element which can contain values + * @param $leafvalue NULL means the leaf will not contain any values + * @return 1 if the old leaf has been overwritten, 0 if a new leaf has been created + */ + function setMeta($group, $subgroup, $leaf, $leafvalue = NULL) + { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + + + /** + * Read meta data identified by a group [/ subgroup [/ leaf]] + * @param $group is mandatory, it's the arborescence's root + * @param $subgroup if null then the subgroup list names are returned + * @param $leaf if null then the leaf names are returned + * @param $withleafvalue if set to true the leaf value will be returned + * @return array which contains two subarray 'timestamp' and 'value' + */ + function getMeta($group, $subgroup = null, $leaf = null, $withleafvalue = false) + { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + + + /** + * Remove a meta data or a group of metadata + * @param $group if null then it will remove all the possible groups (all the created metadata) + * @param $subgroup if null then it will remove the $group's childs (all the subgroup contained by $group) + * @param $leaf if null then it will remove all the $subgroup's childs (all the leafs contained by $subgroup) + * @return true on success, false on error + */ + function rmMeta($group, $subgroup = null, $leaf = null) + { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + + + /** + * In the default File container: used to encode UTF8 strings to ASCII filenames + * This method can be overridden by the concrete container + */ + function encode($str) + { + return $str; + } + + /** + * In the default File container: used to decode ASCII filenames to UTF8 strings + * This method can be overridden by the concrete container + */ + function decode($str) + { + return $str; + } +} + +?> \ No newline at end of file Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-12-18 09:16:01 UTC (rev 901) +++ trunk/src/pfcglobalconfig.class.php 2006-12-19 17:56:01 UTC (rev 902) @@ -235,6 +235,7 @@ */ function &getContainerInstance() { + // bug in php4: cant make a static pfcContainer instance because // it make problems with pfcGlobalConfig references (not updated) // it works well in php5, maybe there is a workeround but I don't have time to debug this @@ -243,11 +244,10 @@ // static $container; // if (!isset($container)) // { - $container_classname = "pfcContainer_".$this->container_type; - require_once dirname(__FILE__)."/containers/".strtolower($this->container_type).".class.php"; - $container =& new $container_classname($this); + require_once dirname(__FILE__).'/pfccontainer.class.php'; + $container =& new pfcContainer($this,$this->container_type); + return $container; // } - return $container; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-12-20 10:31:46
|
Revision: 905 http://svn.sourceforge.net/phpfreechat/?rev=905&view=rev Author: kerphi Date: 2006-12-20 02:31:43 -0800 (Wed, 20 Dec 2006) Log Message: ----------- Add an option to enable or disable the container memory cache + change the getContainerInstance() function to return the same container instance each time this function is called. Modified Paths: -------------- trunk/src/pfccontainer.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2006-12-19 22:35:09 UTC (rev 904) +++ trunk/src/pfccontainer.class.php 2006-12-20 10:31:43 UTC (rev 905) @@ -32,11 +32,14 @@ class pfcContainer extends pfcContainerInterface { var $_container = null; // contains the concrete container instance + var $_usememorycache = true; - function pfcContainer(&$c, $type = 'File') + function pfcContainer(&$c, $type = 'File', $usememorycache = true) { pfcContainerInterface::pfcContainerInterface($c); + $this->_usememorycache = $usememorycache; + // create the concrete container instance require_once dirname(__FILE__)."/containers/".strtolower($type).".class.php"; $container_classname = "pfcContainer_".$type; @@ -493,23 +496,25 @@ { $ret = $this->_container->setMeta($group, $subgroup, $leaf, $leafvalue); - // echo "setMeta($group, $subgroup, $leaf, $leafvalue)\n"; - - if (isset($this->_cache[$group]['value']) && - !in_array($subgroup, $this->_cache[$group]['value'])) + if ($this->_usememorycache) { - $this->_cache[$group]['value'][] = $subgroup; - $this->_cache[$group]['timestamp'][] = time(); + // store the modifications in the cache + if (isset($this->_cache[$group]['value']) && + !in_array($subgroup, $this->_cache[$group]['value'])) + { + $this->_cache[$group]['value'][] = $subgroup; + $this->_cache[$group]['timestamp'][] = time(); + } + if (isset($this->_cache[$group]['childs'][$subgroup]['value']) && + !in_array($leaf, $this->_cache[$group]['childs'][$subgroup]['value'])) + { + $this->_cache[$group]['childs'][$subgroup]['value'][] = $leaf; + $this->_cache[$group]['childs'][$subgroup]['timestamp'][] = time(); + } + $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['value'] = array($leafvalue); + $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['timestamp'] = array(time()); } - if (isset($this->_cache[$group]['childs'][$subgroup]['value']) && - !in_array($leaf, $this->_cache[$group]['childs'][$subgroup]['value'])) - { - $this->_cache[$group]['childs'][$subgroup]['value'][] = $leaf; - $this->_cache[$group]['childs'][$subgroup]['timestamp'][] = time(); - } - $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['value'] = array($leafvalue); - $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['timestamp'] = array(time()); - + return $ret; } @@ -527,73 +532,73 @@ $ret = array('timestamp' => array(), 'value' => array()); - - // check in the cache - $incache = false; - if ($subgroup == null && - isset($this->_cache[$group]['value'])) + if ($this->_usememorycache) { - $incache = true; - $ret = $this->_cache[$group]; - } - else if ($leaf == null && - isset($this->_cache[$group]['childs'][$subgroup]['value'])) - { - $incache = true; - $ret = $this->_cache[$group]['childs'][$subgroup]; - } - else - { - if ($withleafvalue) + // check if the data exists in the cache + $incache = false; + if ($subgroup == null && + isset($this->_cache[$group]['value'])) { - if (isset($this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['value'])) - { - $incache = true; - $ret = $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]; - } + $incache = true; + $ret = $this->_cache[$group]; } + else if ($leaf == null && + isset($this->_cache[$group]['childs'][$subgroup]['value'])) + { + $incache = true; + $ret = $this->_cache[$group]['childs'][$subgroup]; + } else { - if (isset($this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['timestamp'])) + if ($withleafvalue) { - $incache = true; - $ret = $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]; + if (isset($this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['value'])) + { + $incache = true; + $ret = $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]; + } } + else + { + if (isset($this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['timestamp'])) + { + $incache = true; + $ret = $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]; + } + } } + if ($incache) + { + $ret = array('timestamp' => $ret['timestamp'], + 'value' => $ret['value']); + return $ret; + } } - - // echo "getMeta($group, $subgroup, $leaf, $withleafvalue)".($incache?"incache":"notincache")."\n"; - - if ($incache) - { - $ret = array('timestamp' => $ret['timestamp'], - 'value' => $ret['value']); - return $ret; - } - // get the fresh data $ret = $this->_container->getMeta($group, $subgroup, $leaf, $withleafvalue); - - // store in the cache - if ($subgroup == null) + if ($this->_usememorycache) { - $this->_cache[$group]['value'] = $ret['value']; - $this->_cache[$group]['timestamp'] = $ret['timestamp']; - } - else if ($leaf == null) - { - $this->_cache[$group]['childs'][$subgroup]['value'] = $ret['value']; - $this->_cache[$group]['childs'][$subgroup]['timestamp'] = $ret['timestamp']; - } - else - { - if ($withleafvalue) - $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['value'] = $ret['value']; + // store in the cache + if ($subgroup == null) + { + $this->_cache[$group]['value'] = $ret['value']; + $this->_cache[$group]['timestamp'] = $ret['timestamp']; + } + else if ($leaf == null) + { + $this->_cache[$group]['childs'][$subgroup]['value'] = $ret['value']; + $this->_cache[$group]['childs'][$subgroup]['timestamp'] = $ret['timestamp']; + } else - unset($this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['value']); - $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['timestamp'] = $ret['timestamp']; + { + if ($withleafvalue) + $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['value'] = $ret['value']; + else + unset($this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['value']); + $this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]['timestamp'] = $ret['timestamp']; + } } return $ret; @@ -609,45 +614,40 @@ */ function rmMeta($group, $subgroup = null, $leaf = null) { - //echo "rmMeta($group, $subgroup, $leaf)\n"; - - // if ($group == "channelid-to-nickid") - // { echo "avant\n"; print_r($this->_cache[$group]); } - - // remove from the cache - if ($group == null) - $this->_cache = array(); - else if ($subgroup == null) - unset($this->_cache[$group]); - else if ($leaf == null) + if ($this->_usememorycache) { - if (isset($this->_cache[$group]['value'])) + // remove from the cache + if ($group == null) + $this->_cache = array(); + else if ($subgroup == null) + unset($this->_cache[$group]); + else if ($leaf == null) { - $i = array_search($subgroup,$this->_cache[$group]['value']); - if ($i !== FALSE) + if (isset($this->_cache[$group]['value'])) { - unset($this->_cache[$group]['value'][$i]); - unset($this->_cache[$group]['timestamp'][$i]); + $i = array_search($subgroup,$this->_cache[$group]['value']); + if ($i !== FALSE) + { + unset($this->_cache[$group]['value'][$i]); + unset($this->_cache[$group]['timestamp'][$i]); + } } + unset($this->_cache[$group]['childs'][$subgroup]); } - unset($this->_cache[$group]['childs'][$subgroup]); - } - else - { - if (isset($this->_cache[$group]['childs'][$subgroup]['value'])) + else { - $i = array_search($leaf,$this->_cache[$group]['childs'][$subgroup]['value']); - if ($i !== FALSE) + if (isset($this->_cache[$group]['childs'][$subgroup]['value'])) { - unset($this->_cache[$group]['childs'][$subgroup]['value'][$i]); - unset($this->_cache[$group]['childs'][$subgroup]['timestamp'][$i]); + $i = array_search($leaf,$this->_cache[$group]['childs'][$subgroup]['value']); + if ($i !== FALSE) + { + unset($this->_cache[$group]['childs'][$subgroup]['value'][$i]); + unset($this->_cache[$group]['childs'][$subgroup]['timestamp'][$i]); + } } + unset($this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]); } - unset($this->_cache[$group]['childs'][$subgroup]['childs'][$leaf]); } - - // if ($group == "channelid-to-nickid") - // { echo "apres\n"; print_r($this->_cache[$group]); } return $this->_container->rmMeta($group, $subgroup, $leaf); } Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-12-19 22:35:09 UTC (rev 904) +++ trunk/src/pfcglobalconfig.class.php 2006-12-20 10:31:43 UTC (rev 905) @@ -235,19 +235,22 @@ */ function &getContainerInstance() { - // bug in php4: cant make a static pfcContainer instance because // it make problems with pfcGlobalConfig references (not updated) // it works well in php5, maybe there is a workeround but I don't have time to debug this // to reproduce the bug: uncomment the next lines and try to change your nickname // the old nickname will not be removed - // static $container; - // if (!isset($container)) - // { - require_once dirname(__FILE__).'/pfccontainer.class.php'; - $container =& new pfcContainer($this,$this->container_type); + // @todo : check if this bug is already present in php4 + static $container; + if (!isset($container)) + { + require_once dirname(__FILE__).'/pfccontainer.class.php'; + $container =& new pfcContainer($this, // the config instance + $this->container_type, // the container type + true // usememorycache + ); + } return $container; - // } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-12-29 12:23:06
|
Revision: 911 http://svn.sourceforge.net/phpfreechat/?rev=911&view=rev Author: kerphi Date: 2006-12-29 04:22:57 -0800 (Fri, 29 Dec 2006) Log Message: ----------- [en] Bandwidth optimization: do not return any bytes when the periodic /update command returns nothing. [0h30] [fr] Optimisation de la bande passante : retourne rien du tout lorsque la commande periodique /update ne retourne rien. [0h30] Modified Paths: -------------- trunk/src/commands/update.class.php trunk/src/phpfreechat.class.php Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-12-29 11:57:52 UTC (rev 910) +++ trunk/src/commands/update.class.php 2006-12-29 12:22:57 UTC (rev 911) @@ -69,7 +69,8 @@ $cmd->run($xml_reponse, $cmdp); } - $xml_reponse->script("pfc.handleResponse('update', 'ok', '');"); + // do not send ok response to save bandwidth + // $xml_reponse->script("pfc.handleResponse('update', 'ok', '');"); } else $xml_reponse->script("pfc.handleResponse('update', 'ko', '');"); Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-12-29 11:57:52 UTC (rev 910) +++ trunk/src/phpfreechat.class.php 2006-12-29 12:22:57 UTC (rev 911) @@ -61,11 +61,11 @@ { require_once $c->xajaxpath."/xajax_core/xajax.inc.php"; $this->xajax = new xajax($c->server_script_url.(isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "" ? "?".$_SERVER["QUERY_STRING"] : ""), 'pfc_'); - if ($c->debugxajax) $this->xajax->debugOn(); + if ($c->debugxajax) $this->xajax->setFlag('debug', true); $this->xajax->setWrapperPrefix('pfc_'); - // $this->xajax->waitCursorOff(); // do not show a wait cursor during chat updates - //$this->xajax->cleanBufferOff(); - //$this->xajax->errorHandlerOn(); // used to have verbose error logs + $this->xajax->setFlag('waitCursor', false); + $this->xajax->setFlag('cleanBuffer', false); + $this->xajax->setFlag('errorHandler', true); $this->xajax->registerFunction(array('handleRequest',&$this,'handleRequest')); $this->xajax->registerFunction(array('loadStyles',&$this,'loadStyles')); $this->xajax->registerFunction(array('loadScripts',&$this,'loadScripts')); @@ -386,8 +386,8 @@ ob_end_clean(); } - // do nothing else if the xml response is empty - //if ($xml_reponse->xml == "") die(); + // do nothing else if the xml response is empty in order to save bandwidth + if ($xml_reponse->getCommandCount() == 0) die(); return $xml_reponse; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-02-07 16:43:09
|
Revision: 944 http://svn.sourceforge.net/phpfreechat/?rev=944&view=rev Author: kerphi Date: 2007-02-07 08:43:01 -0800 (Wed, 07 Feb 2007) Log Message: ----------- fix the mysql container Modified Paths: -------------- trunk/src/containers/file.class.php trunk/src/containers/mysql.class.php trunk/src/pfccontainer.class.php Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2007-02-06 21:59:17 UTC (rev 943) +++ trunk/src/containers/file.class.php 2007-02-07 16:43:01 UTC (rev 944) @@ -33,20 +33,24 @@ "timestamp" => array()); var $_meta = array(); + function pfcContainer_File(&$config) + { + pfcContainerInterface::pfcContainerInterface($config); + } + function loadPaths() { $c =& $this->c; - if (!isset($c->container_cfg_chat_dir)) + if (!isset($c->container_cfg_chat_dir) || $c->container_cfg_chat_dir == '') $c->container_cfg_chat_dir = $c->data_private_path."/chat"; - if (!isset($c->container_cfg_server_dir)) + if (!isset($c->container_cfg_server_dir) || $c->container_cfg_server_dir == '') $c->container_cfg_server_dir = $c->container_cfg_chat_dir."/s_".$c->serverid; } function getDefaultConfig() { $c =& $this->c; - - $cfg = pfcContainer::getDefaultConfig(); + $cfg = pfcContainerInterface::getDefaultConfig(); $cfg["chat_dir"] = ''; // will be generated from the other parameters into the init step $cfg["server_dir"] = ''; // will be generated from the other parameters into the init step return $cfg; @@ -54,15 +58,16 @@ function init() { - $errors = pfcContainer::init(); + $errors = pfcContainerInterface::init(); $c =& $this->c; + // generate the container parameters from other config parameters $this->loadPaths(); $errors = array_merge($errors, @test_writable_dir($c->container_cfg_chat_dir, "container_cfg_chat_dir")); $errors = array_merge($errors, @test_writable_dir($c->container_cfg_server_dir, "container_cfg_chat_dir/serverid")); - + return $errors; } Modified: trunk/src/containers/mysql.class.php =================================================================== --- trunk/src/containers/mysql.class.php 2007-02-06 21:59:17 UTC (rev 943) +++ trunk/src/containers/mysql.class.php 2007-02-07 16:43:01 UTC (rev 944) @@ -42,7 +42,7 @@ * @author Stephane Gully <ste...@gm...> * @author HenkBB */ -class pfcContainer_Mysql extends pfcContainer +class pfcContainer_Mysql extends pfcContainerInterface { var $_db = null; var $_sql_create_table = " @@ -58,13 +58,13 @@ function pfcContainer_Mysql(&$config) { - pfcContainer::pfcContainer($config); + pfcContainerInterface::pfcContainerInterface($config); } function getDefaultConfig() { $c =& $this->c; - $cfg = pfcContainer::getDefaultConfig(); + $cfg = pfcContainerInterface::getDefaultConfig(); $cfg["mysql_host"] = 'localhost'; $cfg["mysql_port"] = 3306; $cfg["mysql_database"] = 'phpfreechat'; @@ -76,7 +76,7 @@ function init() { - $errors = pfcContainer::init(); + $errors = pfcContainerInterface::init(); $c =& $this->c; // connect to the db Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2007-02-06 21:59:17 UTC (rev 943) +++ trunk/src/pfccontainer.class.php 2007-02-07 16:43:01 UTC (rev 944) @@ -45,7 +45,19 @@ $container_classname = "pfcContainer_".$type; $this->_container =& new $container_classname($this->c); } - + function getDefaultConfig() + { + if ($this->_container) + return $this->_container->getDefaultConfig(); + else + return array(); + } + function init() + { + if ($this->_container) + return $this->_container->init(); + } + /** * Create (connect/join) the nickname into the server or the channel locations * Notice: the caller must take care to update all channels the users joined (use stored channel list into metadata) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-02-09 11:17:00
|
Revision: 947 http://svn.sourceforge.net/phpfreechat/?rev=947&view=rev Author: kerphi Date: 2007-02-09 03:16:59 -0800 (Fri, 09 Feb 2007) Log Message: ----------- fix php notices : http://www.phpfreechat.net/forum/viewtopic.php?id=1201 Modified Paths: -------------- trunk/src/pfccommand.class.php trunk/src/pfccontainer.class.php Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2007-02-09 10:21:22 UTC (rev 946) +++ trunk/src/pfccommand.class.php 2007-02-09 11:16:59 UTC (rev 947) @@ -227,6 +227,10 @@ // print_r($cmdtmp); $cmd =& pfcCommand::Factory($cmdtmp['cmdstr']); $cmdp = $cmdtmp['params']; + if (!isset($cmdp['param'])) $cmdp['param'] = ''; + if (!isset($cmdp['sender'])) $cmdp['sender'] = null; + if (!isset($cmdp['recipient'])) $cmdp['recipient'] = null; + if (!isset($cmdp['recipientid'])) $cmdp['recipientid'] = null; $cmdp['clientid'] = $clientid; // the clientid must be the current user one $cmdp['cmdtoplay'] = true; // used to run some specials actions in the command (ex: if the cmdtoplay is a 'leave' command, then show an alert to the kicked or banished user) if ($c->debug) Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2007-02-09 10:21:22 UTC (rev 946) +++ trunk/src/pfccontainer.class.php 2007-02-09 11:16:59 UTC (rev 947) @@ -579,11 +579,13 @@ } } } + if ($incache) { - $ret = array('timestamp' => $ret['timestamp'], - 'value' => $ret['value']); - return $ret; + $ret2 = array(); + if (isset($ret['timestamp'])) $ret2['timestamp'] = $ret['timestamp']; + if (isset($ret['value'])) $ret2['value'] = $ret['value']; + return $ret2; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |