[Phpfreechat-svn] SF.net SVN: phpfreechat: [956] trunk
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-02-15 16:13:34
|
Revision: 956 http://svn.sourceforge.net/phpfreechat/?rev=956&view=rev Author: kerphi Date: 2007-02-15 08:13:34 -0800 (Thu, 15 Feb 2007) Log Message: ----------- Code cleaning on pfcglobalconfig and pfccontainer singleton instances Modified Paths: -------------- trunk/demo/demo27_customized_command.php trunk/demo/demo55_mysql_container.php trunk/src/commands/asknick.class.php trunk/src/commands/ban.class.php trunk/src/commands/banlist.class.php trunk/src/commands/clear.class.php trunk/src/commands/connect.class.php trunk/src/commands/debug.class.php trunk/src/commands/deop.class.php trunk/src/commands/error.class.php trunk/src/commands/getnewmsg.class.php trunk/src/commands/help.class.php trunk/src/commands/identify.class.php trunk/src/commands/init.class.php trunk/src/commands/invite.class.php trunk/src/commands/join.class.php trunk/src/commands/kick.class.php trunk/src/commands/leave.class.php trunk/src/commands/me.class.php trunk/src/commands/nick.class.php trunk/src/commands/notice.class.php trunk/src/commands/op.class.php trunk/src/commands/privmsg.class.php trunk/src/commands/quit.class.php trunk/src/commands/redirect.class.php trunk/src/commands/rehash.class.php trunk/src/commands/send.class.php trunk/src/commands/unban.class.php trunk/src/commands/update.class.php trunk/src/commands/updatemynick.class.php trunk/src/commands/version.class.php trunk/src/commands/who.class.php trunk/src/commands/who2.class.php trunk/src/commands/whois.class.php trunk/src/containers/file.class.php trunk/src/containers/mysql.class.php trunk/src/pfccommand.class.php trunk/src/pfccontainer.class.php trunk/src/pfccontainerinterface.class.php trunk/src/pfcglobalconfig.class.php trunk/src/pfcinfo.class.php trunk/src/pfcproxycommand.class.php trunk/src/phpfreechat.class.php trunk/src/proxies/auth.class.php trunk/src/proxies/censor.class.php trunk/src/proxies/checknickchange.class.php trunk/src/proxies/checktimeout.class.php trunk/src/proxies/lock.class.php trunk/src/proxies/log.class.php trunk/src/proxies/noflood.class.php trunk/testcase/container_generic.php Added Paths: ----------- trunk/demo/demo5_customized_style_data/mytheme/style.css.php Removed Paths: ------------- trunk/demo/demo5_customized_style_data/mytheme/style.css Modified: trunk/demo/demo27_customized_command.php =================================================================== --- trunk/demo/demo27_customized_command.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/demo/demo27_customized_command.php 2007-02-15 16:13:34 UTC (rev 956) @@ -13,11 +13,11 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); - $nick = $c->nick; - $container =& $c->getContainerInstance(); - $text = trim($param); + $nick = $c->nick; + $ct =& pfcContainer::Instance(); + $text = trim($param); // Call parse roll require_once dirname(__FILE__).'/demo27_dice.class.php'; @@ -33,7 +33,7 @@ else { $result = $dice->roll(); - $container->write($recipient, $nick, "send", $result); + $ct->write($recipient, $nick, "send", $result); } if ($c->debug) pxlog("Cmd_roll[".$c->sessionid."]: msg=".$result, "chat", $c->getId()); } Modified: trunk/demo/demo55_mysql_container.php =================================================================== --- trunk/demo/demo55_mysql_container.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/demo/demo55_mysql_container.php 2007-02-15 16:13:34 UTC (rev 956) @@ -1,6 +1,7 @@ <?php require_once dirname(__FILE__)."/../src/phpfreechat.class.php"; +$params = array(); $params["serverid"] = md5(__FILE__); // calculate a unique id for this chat $params["nick"] = "guest".rand(1,1000); $params["container_type"] = "mysql"; Deleted: trunk/demo/demo5_customized_style_data/mytheme/style.css =================================================================== --- trunk/demo/demo5_customized_style_data/mytheme/style.css 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/demo/demo5_customized_style_data/mytheme/style.css 2007-02-15 16:13:34 UTC (rev 956) @@ -1,66 +0,0 @@ - -div#pfc_container { - border: black double 5px; - background-image: url("proxy.php?p=mytheme/images/brick.jpg"); - background-repeat: repeat; - padding: 20px; - color: black; - margin: auto; -} -div#pfc_chat { - background-color: #FFF; -} - -div#pfc_content { - border: none; -} - -div.pfc_message { - background-color: transparent; - background-image: url("proxy.php?p=mytheme/images/newmsg.gif"); - background-repeat: no-repeat; - background-position: right center; -} - -div.pfc_oldmsg { - background-image: url("proxy.php?p=mytheme/images/oldmsg.gif"); -} - -span.pfc_heure { - margin-left: 25px; - color: #888; -} - -span.pfc_date { - display: none; -} - -span.pfc_pseudo { - color: black; - font-weight: bold; -} - -input#pfc_handle { - color: black; - font-weight: bold; -} - -div#pfc_online { -} - -div.pfc_btn img { - border: 1px solid #FFF; /* same as container color */ -} -div.pfc_btn img:hover { - border: 1px solid #000; - background-color: #CCC; -} - - -/* commands */ -.pfc_cmd_notice { - color: red; -} -.pfc_cmd_msg { - color: #555; -} \ No newline at end of file Added: trunk/demo/demo5_customized_style_data/mytheme/style.css.php =================================================================== --- trunk/demo/demo5_customized_style_data/mytheme/style.css.php (rev 0) +++ trunk/demo/demo5_customized_style_data/mytheme/style.css.php 2007-02-15 16:13:34 UTC (rev 956) @@ -0,0 +1,66 @@ + +div#pfc_container { + border: black double 5px; + background-image: url("<?php echo $c->getFileUrlFromTheme('images/brick.jpg'); ?>"); + background-repeat: repeat; + padding: 20px; + color: black; + margin: auto; +} +div#pfc_chat { + background-color: #FFF; +} + +div#pfc_content { + border: none; +} + +div.pfc_message { + background-color: transparent; + background-image: url("<?php echo $c->getFileUrlFromTheme('images/newmsg.gif'); ?>"); + background-repeat: no-repeat; + background-position: right center; +} + +div.pfc_oldmsg { + background-image: url("<?php echo $c->getFileUrlFromTheme('images/oldmsg.gif'); ?>"); +} + +span.pfc_heure { + margin-left: 25px; + color: #888; +} + +span.pfc_date { + display: none; +} + +span.pfc_pseudo { + color: black; + font-weight: bold; +} + +input#pfc_handle { + color: black; + font-weight: bold; +} + +div#pfc_online { +} + +div.pfc_btn img { + border: 1px solid #FFF; /* same as container color */ +} +div.pfc_btn img:hover { + border: 1px solid #000; + background-color: #CCC; +} + + +/* commands */ +.pfc_cmd_notice { + color: red; +} +.pfc_cmd_msg { + color: #555; +} \ No newline at end of file Modified: trunk/src/commands/asknick.class.php =================================================================== --- trunk/src/commands/asknick.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/asknick.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -12,8 +12,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $nicktochange = phpFreeChat::FilterNickname($param); Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/ban.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -15,8 +15,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $nick = isset($params[0]) ? $params[0] : ''; $reason = isset($params[1]) ? $params[1] : ''; @@ -34,7 +34,7 @@ return; } - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $nickidtoban = $ct->getNickId($nick); // notify all the channel Modified: trunk/src/commands/banlist.class.php =================================================================== --- trunk/src/commands/banlist.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/banlist.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -13,10 +13,10 @@ function run(&$xml_reponse, $p) { - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $banlist = $ct->getChanMeta($p["recipient"], 'banlist_nickid'); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); Modified: trunk/src/commands/clear.class.php =================================================================== --- trunk/src/commands/clear.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/clear.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -6,8 +6,8 @@ { function run(&$xml_reponse, $p) { - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ok', '');"); } Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/connect.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -13,9 +13,9 @@ $recipientid = $p["recipientid"]; $getoldmsg = isset($p["getoldmsg"]) ? $p["getoldmsg"] : true; - $c =& $this->c; - $u =& $this->u; - $ct =& $c->getContainerInstance(); + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); + $ct =& pfcContainer::Instance(); // reset the message id indicator (see getnewmsg.class.php) // i.e. be ready to re-get all last posted messages Modified: trunk/src/commands/debug.class.php =================================================================== --- trunk/src/commands/debug.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/debug.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -6,8 +6,8 @@ { function run(&$xml_reponse, $p) { - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if ($p["param"] == "userconfig") { Modified: trunk/src/commands/deop.class.php =================================================================== --- trunk/src/commands/deop.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/deop.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -8,8 +8,8 @@ function run(&$xml_reponse, $p) { - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if (trim($p["param"]) == "") { @@ -24,7 +24,7 @@ // just change the "isadmin" meta flag $nicktodeop = trim($p["param"]); - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $nicktodeopid = $container->getNickId($nicktodeop); $container->setUserMeta($nicktodeopid, 'isadmin', false); Modified: trunk/src/commands/error.class.php =================================================================== --- trunk/src/commands/error.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/error.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -6,7 +6,7 @@ { function run(&$xml_reponse, $p) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); $errors = $p["param"]; if (is_array($errors)) { Modified: trunk/src/commands/getnewmsg.class.php =================================================================== --- trunk/src/commands/getnewmsg.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/getnewmsg.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -32,7 +32,7 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); // do nothing if the recipient is not defined if ($recipient == "") return; @@ -50,7 +50,7 @@ // read the last from_id value - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$recipientid; $from_id = 0; if (isset($_SESSION[$from_id_sid])) Modified: trunk/src/commands/help.class.php =================================================================== --- trunk/src/commands/help.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/help.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -14,8 +14,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $ignore = array("updatemynick", "getnewmsg", "notice", "getonlinenick", "error", "update", "asknick"); Modified: trunk/src/commands/identify.class.php =================================================================== --- trunk/src/commands/identify.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/identify.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -39,8 +39,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $password = trim($param); $isadmin = false; @@ -57,7 +57,7 @@ if ($isadmin) { // ok the current user is an admin, just save the isadmin flag in the metadata - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $ct->setUserMeta($u->nickid, 'isadmin', $isadmin); $this->forceWhoisReload($u->nick); Modified: trunk/src/commands/init.class.php =================================================================== --- trunk/src/commands/init.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/init.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -12,8 +12,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $cmd =& pfcCommand::Factory("quit"); $cmd->run($xml_reponse, $p); Modified: trunk/src/commands/invite.class.php =================================================================== --- trunk/src/commands/invite.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/invite.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -46,9 +46,9 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; // pfcGlobalConfig - $u =& $this->u; // pfcUserConfig - $ct =& $c->getContainerInstance(); // Connection to the chatbackend + $c =& pfcGlobalConfig::Instance(); // pfcGlobalConfig + $u =& pfcUserConfig::Instance(); // pfcUserConfig + $ct =& pfcContainer::Instance(); // Connection to the chatbackend $nicktoinvite = isset($params[0]) ? $params[0] : ''; $channeltarget = isset($params[1]) ? $params[1] : $u->channels[$recipientid]["name"]; // Default: current channel Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/join.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -14,8 +14,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $channame = trim($param); $chanrecip = pfcCommand_join::GetRecipient($channame); @@ -55,7 +55,7 @@ } // register the user (and his metadata) in the channel - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $ct->createNick($chanrecip, $u->nick, $u->nickid); $this->forceWhoisReload($u->nick); Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/kick.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -15,8 +15,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $nick = isset($params[0]) ? $params[0] : ''; $reason = isset($params[1]) ? $params[1] : ''; @@ -34,7 +34,7 @@ } // kicking a user just add a command to play to the aimed user metadata. - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $otherid = $ct->getNickId($nick); $channame = $u->channels[$recipientid]["name"]; $cmdstr = 'leave'; Modified: trunk/src/commands/leave.class.php =================================================================== --- trunk/src/commands/leave.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/leave.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -15,9 +15,9 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; - $ct =& $c->getContainerInstance(); + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); + $ct =& pfcContainer::Instance(); $type = isset($params[0]) ? $params[0] : ''; $name = isset($params[1]) ? $params[1] : ''; Modified: trunk/src/commands/me.class.php =================================================================== --- trunk/src/commands/me.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/me.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -14,8 +14,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if (trim($param) == "") { @@ -28,7 +28,7 @@ return; } - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $msg = phpFreeChat::PreFilterMsg($param); $container->write($recipient, "*me*", $this->name, $u->nick." ".$msg); Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/nick.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -14,8 +14,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if (trim($param) == "") { @@ -31,7 +31,7 @@ $newnick = phpFreeChat::FilterNickname($param); $oldnick = $u->nick; - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $newnickid = $container->getNickId($newnick); $oldnickid = $container->getNickId($oldnick); Modified: trunk/src/commands/notice.class.php =================================================================== --- trunk/src/commands/notice.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/notice.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -13,13 +13,13 @@ $recipientid = $p["recipientid"]; $flag = isset($p["flag"]) ? $p["flag"] : 3; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if ($c->shownotice > 0 && ($c->shownotice & $flag) == $flag) { - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $msg = phpFreeChat::FilterSpecialChar($msg); $res = $container->write($recipient, $u->nick, "notice", $msg); if (is_array($res)) Modified: trunk/src/commands/op.class.php =================================================================== --- trunk/src/commands/op.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/op.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -14,8 +14,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if (trim($param) == "") { @@ -30,7 +30,7 @@ // just change the "isadmin" meta flag $nicktoop = trim($param); - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $nicktoopid = $container->getNickId($nicktoop); $container->setUserMeta($nicktoopid, 'isadmin', true); Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/privmsg.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -12,13 +12,13 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $pvname = $param; // check the pvname exists on the server - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $pvnickid = $container->getNickId($pvname); $nickid = $u->nickid; @@ -83,7 +83,7 @@ } // register the user (and his metadata) in this pv - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $ct->createNick($pvrecipient, $u->nick, $u->nickid); $this->forceWhoisReload($u->nick); Modified: trunk/src/commands/quit.class.php =================================================================== --- trunk/src/commands/quit.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/quit.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -12,11 +12,11 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); // then remove the nickname file - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $quitmsg = $param == "" ? _pfc("%s quit", $u->nick) : _pfc("%s quit (%s)", $u->nick, $param); // from the channels Modified: trunk/src/commands/redirect.class.php =================================================================== --- trunk/src/commands/redirect.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/redirect.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -14,8 +14,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if (trim($param) == '') { // error Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/rehash.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -19,7 +19,7 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); // just destroy the cache // do not synchronizeWithCache() because it will reload the same parameters as the current one // the right way is to wait for the next page reload and the new parameters will be taken into account Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/send.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -12,8 +12,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $nick = phpFreeChat::FilterSpecialChar($sender); $text = phpFreeChat::PreFilterMsg($param); @@ -37,7 +37,7 @@ $can_send = true; if (isset($u->privmsg[$recipientid])) { - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $pvnick = $u->privmsg[$recipientid]["name"]; $pvnickid = $container->getNickId($pvnick); @@ -77,7 +77,7 @@ // Now send the message if there is no errors if ($can_send) { - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $msgid = $container->write($recipient, $nick, "send", $text); if (is_array($msgid)) { Modified: trunk/src/commands/unban.class.php =================================================================== --- trunk/src/commands/unban.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/unban.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -15,10 +15,10 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $nick = isset($params[0]) ? $params[0] : ''; $nickid = $ct->getNickId($nick); Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/update.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -12,15 +12,15 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); // do not update if user isn't active (didn't connect) if ($u->active) { // check the user has not been disconnected from the server by timeout // if I found he has been disconnected, then I reconnect him with /connect command - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); if ($ct->isNickOnline(NULL, $u->nickid) < 0) { $cmd =& pfcCommand::Factory("connect"); Modified: trunk/src/commands/updatemynick.class.php =================================================================== --- trunk/src/commands/updatemynick.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/updatemynick.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -12,10 +12,10 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $container->updateNick($u->nickid); } } Modified: trunk/src/commands/version.class.php =================================================================== --- trunk/src/commands/version.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/version.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -14,8 +14,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ok', '".$c->version."');"); } Modified: trunk/src/commands/who.class.php =================================================================== --- trunk/src/commands/who.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/who.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -34,8 +34,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if ($param != "") { @@ -51,8 +51,8 @@ function _getChanMeta($recipient, $recipientid) { - $c =& $this->c; - $ct =& $c->getContainerInstance(); + $c =& pfcGlobalConfig::Instance(); + $ct =& pfcContainer::Instance(); $chanmeta = array(); $chanmeta['chan'] = $recipient; $chanmeta['chanid'] = $recipientid; Modified: trunk/src/commands/who2.class.php =================================================================== --- trunk/src/commands/who2.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/who2.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -33,8 +33,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if ($param != "") { Modified: trunk/src/commands/whois.class.php =================================================================== --- trunk/src/commands/whois.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/commands/whois.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -34,9 +34,9 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; - $ct =& $c->getContainerInstance(); + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); + $ct =& pfcContainer::Instance(); $nickid = $ct->getNickId($param); if ($nickid) Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/containers/file.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -33,14 +33,13 @@ "timestamp" => array()); var $_meta = array(); - function pfcContainer_File(&$config) + function pfcContainer_File() { - pfcContainerInterface::pfcContainerInterface($config); + pfcContainerInterface::pfcContainerInterface(); } - function loadPaths() + function loadPaths(&$c) { - $c =& $this->c; 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) || $c->container_cfg_server_dir == '') @@ -49,21 +48,18 @@ function getDefaultConfig() { - $c =& $this->c; $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; } - function init() + function init(&$c) { - $errors = pfcContainerInterface::init(); - $c =& $this->c; - + $errors = pfcContainerInterface::init($c); // generate the container parameters from other config parameters - $this->loadPaths(); + $this->loadPaths(&$c); $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")); @@ -74,7 +70,7 @@ function setMeta($group, $subgroup, $leaf, $leafvalue = NULL) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($c->debug) file_put_contents("/tmp/debug", "\nsetMeta(".$group.",".$subgroup.",".$leaf.",".$leafvalue.")", FILE_APPEND); @@ -111,7 +107,7 @@ function getMeta($group, $subgroup = null, $leaf = null, $withleafvalue = false) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($c->debug) file_put_contents("/tmp/debug", "\ngetMeta(".$group.",".$subgroup.",".$leaf.",".$withleafvalue.")", FILE_APPEND); @@ -171,7 +167,7 @@ function rmMeta($group, $subgroup = null, $leaf = null) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($c->debug) file_put_contents("/tmp/debug", "\nrmMeta(".$group.",".$subgroup.",".$leaf.")", FILE_APPEND); Modified: trunk/src/containers/mysql.class.php =================================================================== --- trunk/src/containers/mysql.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/containers/mysql.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -67,14 +67,13 @@ INDEX (`server`,`group`,`subgroup`,`timestamp`) ) ENGINE=%engine%;"; - function pfcContainer_Mysql(&$config) + function pfcContainer_Mysql() { - pfcContainerInterface::pfcContainerInterface($config); + pfcContainerInterface::pfcContainerInterface(); } function getDefaultConfig() - { - $c =& $this->c; + { $cfg = pfcContainerInterface::getDefaultConfig(); $cfg["mysql_host"] = 'localhost'; $cfg["mysql_port"] = 3306; @@ -93,13 +92,12 @@ return $cfg; } - function init() + function init(&$c) { - $errors = pfcContainerInterface::init(); - $c =& $this->c; + $errors = pfcContainerInterface::init($c); // connect to the db - $db = $this->_connect(); + $db = $this->_connect($c); if ($db === FALSE) { $errors[] = _pfc("Mysql container: connect error"); @@ -122,7 +120,7 @@ } mysql_select_db($c->container_cfg_mysql_database, $db); } - + // create the table if it doesn't exists $query = $this->_sql_create_table; $query = str_replace('%engine%', $c->container_cfg_mysql_engine,$query); @@ -142,11 +140,11 @@ return $errors; } - function _connect() + function _connect($c = null) { if (!$this->_db) { - $c =& $this->c; + if ($c == null) $c =& pfcGlobalConfig::Instance(); $this->_db = mysql_pconnect($c->container_cfg_mysql_host.':'.$c->container_cfg_mysql_port, $c->container_cfg_mysql_username, $c->container_cfg_mysql_password); @@ -157,8 +155,8 @@ function setMeta($group, $subgroup, $leaf, $leafvalue = NULL) { - $c =& $this->c; - + $c =& pfcGlobalConfig::Instance(); + if ($c->debug) file_put_contents("/tmp/debug.txt", "\nsetMeta(".$group.",".$subgroup.",".$leaf.",".$leafvalue.")", FILE_APPEND); @@ -196,7 +194,8 @@ function getMeta($group, $subgroup = null, $leaf = null, $withleafvalue = false) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); + if ($c->debug) file_put_contents("/tmp/debug.txt", "\ngetMeta(".$group.",".$subgroup.",".$leaf.",".$withleafvalue.")", FILE_APPEND); @@ -265,7 +264,7 @@ function rmMeta($group, $subgroup = null, $leaf = null) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($c->debug) file_put_contents("/tmp/debug.txt", "\nrmMeta(".$group.",".$subgroup.",".$leaf.")", FILE_APPEND); Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/pfccommand.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -34,30 +34,20 @@ /** * Command name (lowercase) */ - var $name; + var $name = ''; /** * Contains the command syntaxe (how to use the command) */ - var $usage; + var $usage = ''; /** * Not used for now */ - var $desc; - var $help; + var $desc = ''; + var $help = ''; /** - * This is the pfcGlobalConfig instance - */ - var $c; - - /** - * This is the pfcUserConfig instance - */ - var $u; - - /** * Used to instanciate a command * $tag is the command name : "nick", "me", "update" ... */ @@ -67,54 +57,58 @@ // instanciate the real command $cmd = NULL; - $cmd_name = strtolower($name); + $cmd_name = $name; $cmd_classname = "pfcCommand_".$name; + + $cmd_filename = $c->cmd_path_default.'/'.$cmd_name.'.class.php'; + if (file_exists($cmd_filename)) require_once($cmd_filename); + $cmd_filename = $c->cmd_path.'/'.$cmd_name.'.class.php'; + if (file_exists($cmd_filename)) require_once($cmd_filename); + if (!class_exists($cmd_classname)) + return NULL; + + $cmd =& new $cmd_classname; + $cmd->name = $cmd_name; + + // instanciate the proxies chaine + $firstproxy =& $cmd; + for($i = count($c->_proxies)-1; $i >= 0; $i--) { - $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); - } + $proxy_name = $c->_proxies[$i]; + $proxy_classname = "pfcProxyCommand_" . $proxy_name; + + // try to include the proxy class file from the default path or from the customized path + $proxy_filename = $c->proxies_path_default.'/'.$proxy_name.".class.php"; + if (file_exists($proxy_filename)) require_once($proxy_filename); + $proxy_filename = $c->proxies_path.'/'.$proxy_name.".class.php"; + if (file_exists($proxy_filename)) require_once($proxy_filename); + + if (!class_exists($proxy_classname)) + return $firstproxy; + + // instanciate the proxy + $proxy =& new $proxy_classname; + $proxy->name = $cmd_name; + $proxy->proxyname = $proxy_name; + $proxy->linkTo($firstproxy); + $firstproxy =& $proxy; } - if (class_exists($cmd_classname)) + + /* + $tmp = ''; + $cur = $firstproxy; + while($cur) { - $cmd =& new $cmd_classname(); - $cmd->name = $cmd_name; - - // instanciate the proxies chaine - $firstproxy =& $cmd; - for($i = count($c->_proxies)-1; $i >= 0; $i--) - { - $proxy_name = $c->_proxies[$i]; - $proxy_classname = "pfcProxyCommand_" . $proxy_name; - if (!class_exists($proxy_classname)) - { - // try to include the proxy class file from the default path or from the customized path - $proxy_filename = $c->proxies_path_default.'/'.$proxy_name.".class.php"; - if (file_exists($proxy_filename)) - require_once($proxy_filename); - else - { - $proxy_filename = $c->proxies_path.'/'.$proxy_name.".class.php"; - if (file_exists($proxy_filename)) require_once($proxy_filename); - } - } - if (class_exists($proxy_classname)) - { - // instanciate the proxy - $proxy =& new $proxy_classname(); - $proxy->name = $cmd_name; - $proxy->proxyname = $proxy_name; - $proxy->linkTo($firstproxy); - $firstproxy =& $proxy; - } - } - // return the proxy, not the command (the proxy will forward the request to the real command) - return $firstproxy; + $tmp .= (isset($cur->proxyname)?$cur->proxyname:$cur->name).'|'; + $cur = $cur->next; } - return $cmd; + $tmp .= var_export($firstproxy,true); + file_put_contents('/tmp/debug1',$tmp); +*/ + + // return the proxy, not the command (the proxy will forward the request to the real command) + return $firstproxy; } /** @@ -123,8 +117,6 @@ */ function pfcCommand() { - $this->c =& pfcGlobalConfig::Instance(); - $this->u =& pfcUserConfig::Instance(); } /** @@ -141,9 +133,9 @@ */ function forceWhoisReload($nicktorewhois) { - $c = $this->c; - $u = $this->u; - $ct =& $c->getContainerInstance(); + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); + $ct =& pfcContainer::Instance(); $nickid = $ct->getNickid($nicktorewhois); @@ -189,7 +181,7 @@ $c =& pfcGlobalConfig::Instance(); $u =& pfcUserConfig::Instance(); - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); if ($nickid != "") { $cmdtoplay = $ct->getUserMeta($nickid, 'cmdtoplay'); @@ -209,7 +201,7 @@ { $c =& pfcGlobalConfig::Instance(); $u =& pfcUserConfig::Instance(); - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $morecmd = true; while($morecmd) Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/pfccontainer.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -33,17 +33,27 @@ { var $_container = null; // contains the concrete container instance var $_usememorycache = true; + + + function &Instance($type = 'File', $usememorycache = true) + { + static $i; + if (!isset($i)) + $i = new pfcContainer($type, $usememorycache); + return $i; + } - function pfcContainer(&$c, $type = 'File', $usememorycache = true) + function pfcContainer($type = 'File', $usememorycache = true) { - pfcContainerInterface::pfcContainerInterface($c); + pfcContainerInterface::pfcContainerInterface(); $this->_usememorycache = $usememorycache; + $type = strtolower($type); // create the concrete container instance - require_once dirname(__FILE__)."/containers/".strtolower($type).".class.php"; + require_once dirname(__FILE__)."/containers/".$type.".class.php"; $container_classname = "pfcContainer_".$type; - $this->_container =& new $container_classname($this->c); + $this->_container =& new $container_classname(); } function getDefaultConfig() { @@ -52,10 +62,10 @@ else return array(); } - function init() + function init(&$c) { if ($this->_container) - return $this->_container->init(); + return $this->_container->init($c); } /** @@ -67,7 +77,7 @@ */ function createNick($chan, $nick, $nickid) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($nick == '') user_error('pfcContainer::createNick nick is empty', E_USER_ERROR); @@ -98,7 +108,7 @@ */ function removeNick($chan, $nickid) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($chan == NULL) $chan = 'SERVER'; @@ -157,7 +167,7 @@ */ function updateNick($nickid) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); $chan = 'SERVER'; @@ -175,7 +185,7 @@ */ function changeNick($newnick, $oldnick) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); $oldnickid = $this->getNickId($oldnick); $newnickid = $this->getNickId($newnick); @@ -225,7 +235,7 @@ */ function removeObsoleteNick($timeout) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); $deleted_user = array('nick'=>array(), 'nickid'=>array(), @@ -273,7 +283,7 @@ */ function getOnlineNick($chan) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($chan == NULL) $chan = 'SERVER'; @@ -323,7 +333,7 @@ */ function write($chan, $nick, $cmd, $param) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($chan == NULL) $chan = 'SERVER'; $msgid = $this->_requestMsgId($chan); @@ -357,7 +367,7 @@ */ function read($chan, $from_id) { - $c =& $this->c; + $c =& pfcGlobalConfig::Instance(); if ($chan == NULL) $chan = 'SERVER'; // read new messages id Modified: trunk/src/pfccontainerinterface.class.php =================================================================== --- trunk/src/pfccontainerinterface.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/pfccontainerinterface.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -28,10 +28,9 @@ */ class pfcContainerInterface { - var $c; - function pfcContainerInterface(&$config) { $this->c =& $config; } - function getDefaultConfig() { return array(); } - function init() { return array(); } + function pfcContainerInterface() { } + function getDefaultConfig() { return array(); } + function init(&$c) { return array(); } /** * Write a meta data value identified by a group / subgroup / leaf [with a value] Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/pfcglobalconfig.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -22,6 +22,7 @@ require_once dirname(__FILE__)."/pfctools.php"; require_once dirname(__FILE__)."/pfci18n.class.php"; +require_once dirname(__FILE__).'/pfccontainer.class.php'; /** * pfcGlobalConfig stock configuration data into sessions and initialize some stuff @@ -146,16 +147,15 @@ $this->errors[] = _pfc("'%s' parameter is mandatory by default use '%s' value", "serverid", "md5(__FILE__)"); $this->serverid = $params["serverid"]; - // setup data_private_path because _getCacheFile needs it + // setup data_private_path because _GetCacheFile needs it if (!isset($params["data_private_path"])) $this->data_private_path = dirname(__FILE__)."/../data/private"; else $this->data_private_path = $params["data_private_path"]; - // check if a cached configuration allready exists // don't load parameters if the cache exists - $cachefile = $this->_getCacheFile(); + $cachefile = $this->_GetCacheFile(); if (!file_exists($cachefile)) { // first of all, save our current state in order to be able to check for variable types later @@ -169,11 +169,13 @@ // load users container or keep default one if (isset($params["container_type"])) $this->container_type = $params["container_type"]; + + // load default container's config - $container =& $this->getContainerInstance(); - $container_cfg = $container->getDefaultConfig(); - foreach( $container_cfg as $k => $v ) + $ct =& pfcContainer::Instance($this->container_type, true); + $ct_cfg = $ct->getDefaultConfig(); + foreach( $ct_cfg as $k => $v ) { $attr = "container_cfg_".$k; if (!isset($this->$attr)) @@ -219,6 +221,9 @@ // now load or save the configuration in the cache $this->synchronizeWithCache(); + // to be sure the container instance is initialized + $ct =& pfcContainer::Instance($this->container_type, true); + // This is a dirty workaround which fix a infinite loop when: // 'frozen_nick' is true // 'nick' length is > 'max_nick_len' @@ -228,7 +233,6 @@ function &Instance( $params = array() ) { static $i; - if (!isset($i)) $i = new pfcGlobalConfig( $params ); return $i; @@ -236,30 +240,6 @@ /** - * Return the selected container instance - * by default it is the File container - */ - 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 - // @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 function saves all the parameters types in order to check later if the types are ok */ function _saveParamsTypes() @@ -284,7 +264,7 @@ $ok = true; if ($this->debug) pxlog("pfcGlobalConfig::init()", "chatconfig", $this->getId()); - + // check the parameters types $array_params = $this->_params_type["array"]; foreach( $array_params as $ap ) @@ -420,11 +400,12 @@ // --- // run specific container initialisation - $container_classname = "pfcContainer_".$this->container_type; + $ct =& pfcContainer::Instance(); + /* $container_classname = "pfcContainer_".$this->container_type; require_once dirname(__FILE__)."/containers/".strtolower($this->container_type).".class.php"; - $container = new $container_classname($this); - $container_errors = $container->init(); - $this->errors = array_merge($this->errors, $container_errors); + $container = new $container_classname($this);*/ + $ct_errors = $ct->init($this); + $this->errors = array_merge($this->errors, $ct_errors); // load debug url $this->debugurl = relativePath($this->client_script_path, dirname(__FILE__)."/../debug"); @@ -434,32 +415,6 @@ if ( $this->language != "" && !in_array($this->language, $lg_list) ) $this->errors[] = _pfc("'%s' parameter is not valid. Available values are : '%s'", "language", implode(", ", $lg_list)); - /* - // install the proxy file - if (count($this->errors) == 0) - { - $proxyfile = $this->_getProxyFile(); - $allowedpath_string = ""; - $allowedpath_string .= "\$allowedpath[] = '".realpath(dirname(__FILE__)."/../lib")."';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath(dirname(__FILE__)."/../src/client")."';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath_default)."';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath)."';\n"; - $proxycontent = file_get_contents(dirname(__FILE__)."/client/proxy.php.tpl"); - $proxycontent = str_replace("//%allowedpath%", $allowedpath_string, $proxycontent); - if (!file_exists(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); - chmod( $proxyfile, 0755 ); // should fix problems on OVH mutualized servers - } - } - */ - - // calculate the proxies chaine $this->_proxies = array(); foreach($this->pre_proxies as $px) @@ -544,7 +499,7 @@ } */ - function _getCacheFile($serverid = "", $data_private_path = "") + function _GetCacheFile($serverid = "", $data_private_path = "") { if ($serverid == "") $serverid = $this->getId(); if ($data_private_path == "") $data_private_path = $this->data_private_path; @@ -553,7 +508,7 @@ function destroyCache() { - $cachefile = $this->_getCacheFile(); + $cachefile = $this->_GetCacheFile(); if (!file_exists($cachefile)) return false; $this->is_init = false; @@ -570,7 +525,7 @@ */ function synchronizeWithCache() { - $cachefile = $this->_getCacheFile(); + $cachefile = $this->_GetCacheFile(); $cachefile_lock = $cachefile."_lock"; if (file_exists($cachefile)) @@ -618,7 +573,7 @@ } function saveInCache() { - $cachefile = $this->_getCacheFile(); + $cachefile = $this->_GetCacheFile(); file_put_contents($cachefile, serialize(get_object_vars($this))); if ($this->debug) pxlog("pfcGlobalConfig::saveInCache()", "chatconfig", $this->getId()); } @@ -675,4 +630,4 @@ } } -?> +?> \ No newline at end of file Modified: trunk/src/pfcinfo.class.php =================================================================== --- trunk/src/pfcinfo.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/pfcinfo.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -4,9 +4,9 @@ require_once dirname(__FILE__)."/pfci18n.class.php"; require_once dirname(__FILE__)."/commands/join.class.php"; -class pfcInfo extends pfcGlobalConfig +class pfcInfo { - var $container; + var $c = null; var $errors = array(); function pfcInfo( $serverid, $data_private_path = "" ) @@ -15,7 +15,7 @@ // if it doesn't exists, just stop the process // because we can't initialize the chat from the external API if ($data_private_path == "") $data_private_path = dirname(__FILE__)."/../data/private"; - $cachefile = $this->_getCacheFile( $serverid, $data_private_path ); + $cachefile = pfcGlobalConfig::_GetCacheFile( $serverid, $data_private_path ); if (!file_exists($cachefile)) { $this->errors[] = _pfc("Error: the cached config file doesn't exists"); @@ -24,7 +24,7 @@ // then intitialize the pfcglobalconfig $params["serverid"] = $serverid; $params["data_private_path"] = $data_private_path; - pfcGlobalConfig::pfcGlobalConfig($params); + $this->c =& pfcGlobalConfig::Instance($params); } /** @@ -32,7 +32,7 @@ */ function getErrors() { - return $this->errors; + return array_merge($this->errors, $this->c->getErrors()); } /** @@ -42,18 +42,18 @@ */ function getOnlineNick($channel = NULL, $timeout = 20) { - $container =& $this->getContainerInstance(); + $ct =& pfcContainer::Instance(); if ($channel != NULL) $channel = pfcCommand_join::GetRecipient($channel); - $res = $container->getOnlineNick($channel); + $res = $ct->getOnlineNick($channel); $users = array(); if (isset($res["nickid"])) { for($i = 0; $i < count($res["nickid"]); $i++) { if (time()-$timeout < $res["timestamp"][$i]) - $users[] = $container->getNickname($res["nickid"][$i]); + $users[] = $ct->getNickname($res["nickid"][$i]); } } return $users; @@ -72,9 +72,9 @@ // @todo must use another function to get a private message last messages $channel = pfcCommand_join::GetRecipient($channel); - $container =& $this->getContainerInstance(); - $lastmsg_id = $container->getLastId($channel); - $lastmsg_raw = $container->read($channel, $lastmsg_id-$nb); + $ct =& pfcContainer::Instance(); + $lastmsg_id = $ct->getLastId($channel); + $lastmsg_raw = $ct->read($channel, $lastmsg_id-$nb); return $lastmsg_raw; } @@ -84,7 +84,7 @@ */ function rehash() { - $destroyed = $this->destroyCache(); + $destroyed = $this->c->destroyCache(); return $destroyed; } } Modified: trunk/src/pfcproxycommand.class.php =================================================================== --- trunk/src/pfcproxycommand.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/pfcproxycommand.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -33,12 +33,12 @@ /** * Next proxy command */ - var $next; + var $next = null; /** * The proxy name (similare to the command name) */ - var $proxyname; + var $proxyname = ''; /** * Constructor @@ -50,7 +50,7 @@ function linkTo(&$cmd) { - $this->next = $cmd; + $this->next =& $cmd; } } Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/phpfreechat.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -243,7 +243,7 @@ { $c =& pfcGlobalConfig::Instance(); $u =& pfcUserConfig::Instance(); - + if ($c->debug) ob_start(); // capture output $xml_reponse = new xajaxResponse(); @@ -286,7 +286,7 @@ // alert the other from the new pv // (warn other user that someone talk to him) - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $nickidtopv = $u->privmsg[$recipientid]["pvnickid"]; $cmdstr = 'privmsg2'; $cmdp = array(); Modified: trunk/src/proxies/auth.class.php =================================================================== --- trunk/src/proxies/auth.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/proxies/auth.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -38,14 +38,14 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); // protect admin commands $admincmd = array("kick", "ban", "unban", "op", "deop", "debug", "rehash"); if ( in_array($this->name, $admincmd) ) { - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $nickid = $u->nickid; $isadmin = $container->getUserMeta($nickid, 'isadmin'); if (!$isadmin) @@ -59,7 +59,7 @@ if ($this->name == "join" || $this->name == "join2") { - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $channame = $param; // check the user is not listed in the banished channel list Modified: trunk/src/proxies/censor.class.php =================================================================== --- trunk/src/proxies/censor.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/proxies/censor.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -38,8 +38,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); $cmdtocheck = array("send", "nick", "me"); if ( in_array($this->name, $cmdtocheck) ) Modified: trunk/src/proxies/checknickchange.class.php =================================================================== --- trunk/src/proxies/checknickchange.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/proxies/checknickchange.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -38,8 +38,8 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; $owner = isset($p["owner"]) ? $p["owner"] : ''; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); if ( $this->name == 'nick' ) { @@ -59,7 +59,7 @@ return; } - $container =& $c->getContainerInstance(); + $container =& pfcContainer::Instance(); $newnickid = $container->getNickId($newnick); $oldnickid = $u->nickid; @@ -109,7 +109,8 @@ function _checkNickIsUsed($newnick, $oldnickid) { - $ct =& $this->c->getContainerInstance(); + $c =& pfcGlobalConfig::Instance(); + $ct =& pfcContainer::Instance(); $nick_in_use = false; $online_users = $ct->getOnlineNick(NULL); if (isset($online_users["nickid"])) Modified: trunk/src/proxies/checktimeout.class.php =================================================================== --- trunk/src/proxies/checktimeout.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/proxies/checktimeout.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -39,11 +39,11 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - $c =& $this->c; - $u =& $this->u; + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); // disconnect users from specific channels - $ct =& $c->getContainerInstance(); + $ct =& pfcContainer::Instance(); $disconnected_users = $ct->removeObsoleteNick($c->timeout); for($i=0; $i<count($disconnected_users["nick"]); $i++) { Modified: trunk/src/proxies/lock.class.php =================================================================== --- trunk/src/proxies/lock.class.php 2007-02-15 11:29:18 UTC (rev 955) +++ trunk/src/proxies/lock.class.php 2007-02-15 16:13:34 UTC (rev 956) @@ -38,8 +38,8 @@ $recipient = $p["rec... [truncated message content] |