[Phpfreechat-svn] SF.net SVN: phpfreechat: [625] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-06-24 20:09:52
|
Revision: 625 Author: kerphi Date: 2006-06-24 13:09:32 -0700 (Sat, 24 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=625&view=rev Log Message: ----------- new command: "/identify {password}" used to take admin rights Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Added Paths: ----------- trunk/src/commands/identify.class.php Added: trunk/src/commands/identify.class.php =================================================================== --- trunk/src/commands/identify.class.php (rev 0) +++ trunk/src/commands/identify.class.php 2006-06-24 20:09:32 UTC (rev 625) @@ -0,0 +1,67 @@ +<?php +/** + * identify.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__)."/../pfccommand.class.php"); + +/** + * pfcCommand_identify + * this command will identify the user admin rights + * @author Stephane Gully <ste...@gm...> + */ +class pfcCommand_identify extends pfcCommand +{ + var $usage = "/identify {password}"; + + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + $password = trim($param); + $isadmin = false; + + // @todo simplify the search in the admins config array using a native php function (array_search?) + foreach($c->admins as $a_nick => $a_pass) + { + if ($a_nick == $sender && $a_pass == $password) + $isadmin = true; + } + + $msg = ""; + if ($isadmin) + { + // ok the current user is an admin, just save the isadmin flag in the metadata + $container =& $c->getContainerInstance(); + $container->setMeta($isadmin, "isadmin", "nickname", $u->nickid); + + $msg .= _pfc("Succesfully identified"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$msg."');"); + } + else + { + $msg .= _pfc("Identification failure"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '".$msg."');"); + } + } +} + +?> \ No newline at end of file Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-24 20:08:36 UTC (rev 624) +++ trunk/src/pfcglobalconfig.class.php 2006-06-24 20:09:32 UTC (rev 625) @@ -35,6 +35,7 @@ // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) var $isadmin = false; + var $admins = array("admin" => ""); // nicknames is the key, password is the value // these parameters are static (cached) var $proxys = array("auth", "noflood"); Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-24 20:08:36 UTC (rev 624) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-24 20:09:32 UTC (rev 625) @@ -390,6 +390,10 @@ var container = this.gui.getChatContentFromTabId(tabid); container.innerHTML = ""; } + else if (cmd == "identify") + { + this.displayMsg( cmd, param ); + } else alert(cmd + "-"+resp+"-"+param); }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |