[Phpfreechat-svn] SF.net SVN: phpfreechat: [501] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-05-23 21:16:09
|
Revision: 501 Author: kerphi Date: 2006-05-23 14:16:00 -0700 (Tue, 23 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=501&view=rev Log Message: ----------- firt proxy command implementation (will be used for moderation, logging, ...) Modified Paths: -------------- trunk/src/pfccommand.class.php trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/pfcproxycommand.class.php trunk/src/proxys/ trunk/src/proxys/auth.class.php Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-05-23 20:34:13 UTC (rev 500) +++ trunk/src/pfccommand.class.php 2006-05-23 21:16:00 UTC (rev 501) @@ -58,18 +58,36 @@ */ function &Factory($name) { - $cmd = NULL; - $name = strtolower($name); - $classname = "pfcCommand_".$name; - $filename = dirname(__FILE__)."/commands/".$name.".class.php"; - - if (file_exists($filename)) require_once($filename); - if(class_exists($classname)) + $c =& pfcGlobalConfig::Instance(); + + // instanciate the real command + $cmd = NULL; + $cmd_name = strtolower($name); + $cmd_classname = "pfcCommand_".$name; + $cmd_filename = dirname(__FILE__)."/commands/".$cmd_name.".class.php"; + if (file_exists($cmd_filename)) require_once($cmd_filename); + if (class_exists($cmd_classname)) { - $cmd =& new $classname(); - $cmd->name = $name; + $cmd =& new $cmd_classname(); + $cmd->name = $cmd_name; } - return $cmd; + + // instanciate the proxy chains + $proxy = NULL; + $proxy_name = strtolower($c->proxy[0]); + $proxy_classname = "pfcProxyCommand_" . $proxy_name; + $proxy_filename = dirname(__FILE__)."/proxys/".$proxy_name.".class.php"; + if (file_exists($proxy_filename)) require_once($proxy_filename); + if (class_exists($proxy_classname)) + { + $proxy =& new $proxy_classname(); + $proxy->name = $cmd_name; + $proxy->proxyname = $proxy_name; + $proxy->linkTo($cmd); + } + + // return the proxy, not the command (the proxy will forward the request to the real command) + return $proxy; } /** Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-05-23 20:34:13 UTC (rev 500) +++ trunk/src/pfcglobalconfig.class.php 2006-05-23 21:16:00 UTC (rev 501) @@ -32,12 +32,15 @@ { var $serverid = ""; // this is the chat server id (comparable to the server host in IRC) + var $admins = array(); + var $proxy = array("auth"); + // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) var $channels = array(); // the default joined channels when opening the chat var $privmsg = array(); // the default privmsg chat to lauch when opening the chat var $active = false; // by default the user is not connected - + // these parameters are static (cached) var $title = ""; // default is _pfc("My Chat") var $channel = ""; // default is _pfc("My room") Added: trunk/src/pfcproxycommand.class.php =================================================================== --- trunk/src/pfcproxycommand.class.php (rev 0) +++ trunk/src/pfcproxycommand.class.php 2006-05-23 21:16:00 UTC (rev 501) @@ -0,0 +1,64 @@ +<?php +/** + * pfcproxycommand.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 + */ +require_once dirname(__FILE__)."/pfci18n.class.php"; +require_once dirname(__FILE__)."/pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/pfccommand.class.php"; + +/** + * pfcProxyCommand is an abstract class (interface) which must be inherited by each concrete proxy commands + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand extends pfcCommand +{ + /** + * Next proxy command + */ + var $next; + + /** + * The proxy name (similare to the command name) + */ + var $proxyname; + + /** + * Constructor + */ + function pfcProxyCommand() + { + pfcCommand::pfcCommand(); + } + + function linkTo(&$cmd) + { + $this->next = $cmd; + } + + /* + function run(&$xml_reponse, $clientid, &$param, &$sender, &$recipient, &$recipientid) + { + die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); + } + */ +} + +?> \ No newline at end of file Added: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php (rev 0) +++ trunk/src/proxys/auth.class.php 2006-05-23 21:16:00 UTC (rev 501) @@ -0,0 +1,45 @@ +<?php +/** + * auth.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 + */ +require_once dirname(__FILE__)."/../pfci18n.class.php"; +require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_auth + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_auth extends pfcProxyCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + // $xml_reponse->addScript("alert('proxy auth');"); + + // if ($this->name == "send") + // $xml_reponse->addScript("alert('proxy auth');"); + + // on passe la main a au prochain proxy (ou a la command finale) + $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + } +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |