[Phpfreechat-svn] SF.net SVN: phpfreechat: [528] trunk/src/proxys
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-05-28 17:09:38
|
Revision: 528 Author: kerphi Date: 2006-05-28 10:09:31 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=528&view=rev Log Message: ----------- basic user authentification based on the initial nickname Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/op.class.php trunk/src/proxys/auth.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-05-28 17:08:53 UTC (rev 527) +++ trunk/src/commands/connect.class.php 2006-05-28 17:09:31 UTC (rev 528) @@ -14,6 +14,17 @@ $container =& $c->getContainerInstance(); $disconnected_users = $container->removeObsoleteNick(NULL, $c->timeout); + + // setup some user meta + $nickid = $container->getNickId($u->nick); + // store the user ip + $container->setMeta($_SERVER["REMOTE_ADDR"], "ip", "nickname", $nickid); + // store the admin flag + if (in_array($c->nick, $c->admins)) + $container->setMeta(true, "isadmin", "nickname", $nickid); + else + $container->setMeta(false, "isadmin", "nickname", $nickid); + // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); Modified: trunk/src/commands/op.class.php =================================================================== --- trunk/src/commands/op.class.php 2006-05-28 17:08:53 UTC (rev 527) +++ trunk/src/commands/op.class.php 2006-05-28 17:09:31 UTC (rev 528) @@ -4,12 +4,28 @@ class pfcCommand_op extends pfcCommand { + var $usage = "/op {nickname}"; + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; $u =& $this->u; - $xml_reponse->addScript("alert('op command');"); + if (trim($param) == "") + { + // error + $msg = _pfc("Missing parameter"); + $msg .= " (".$this->usage.")"; + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + return; + } + + // just change the "isadmin" meta flag + $nicktoop = trim($param); + $container =& $c->getContainerInstance(); + $nicktoopid = $container->getNickId($nicktoop); + $container->setMeta(true, "isadmin", "nickname", $nicktoopid); } } Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-05-28 17:08:53 UTC (rev 527) +++ trunk/src/proxys/auth.class.php 2006-05-28 17:09:31 UTC (rev 528) @@ -42,12 +42,20 @@ if ($this->name == "op") { - if (!in_array($u->nick, $c->admins)) + $container =& $c->getContainerInstance(); + $nickid = $container->getNickId($sender); + $isadmin = $container->getMeta("isadmin", "nickname", $nickid); + if (!$isadmin) { $xml_reponse->addScript("alert('not allowed to do /op');"); + return; } + else + { + // $xml_reponse->addScript("alert('allowed to do /op');"); + } } - if ($this->name == "join") + else if ($this->name == "join") { // check the user is not listed in the banished channel list $container =& $c->getContainerInstance(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |