1<?php 2 3require_once(dirname(__FILE__)."/../pfccommand.class.php"); 4 5class pfcCommand_ban extends pfcCommand 6{ 7 var $usage = "/ban {nickname} [ {reason} ]"; 8 9 function run(&$xml_reponse, $p) 10 { 11 $clientid = $p["clientid"]; 12 $param = $p["param"]; 13 $params = $p["params"]; 14 $sender = $p["sender"]; 15 $recipient = $p["recipient"]; 16 $recipientid = $p["recipientid"]; 17 18 $c =& pfcGlobalConfig::Instance(); 19 $u =& pfcUserConfig::Instance(); 20 21 $nick = isset($params[0]) ? $params[0] : ''; 22 $reason = isset($params[1]) ? $params[1] : ''; 23 if ($reason == '') $reason = _pfc("no reason"); 24 25 // to allow unquotted reason 26 if (count($params) > 2) 27 for ($x=2;$x<count($params);$x++) 28 $reason.=" ".$params[$x]; 29 30 $channame = $u->channels[$recipientid]["name"]; 31 32 if ($nick == '') 33 { 34 // error 35 $cmdp = $p; 36 $cmdp["param"] = _pfc("Missing parameter"); 37 $cmdp["param"] .= " (".$this->usage.")"; 38 $cmd =& pfcCommand::Factory("error"); 39 $cmd->run($xml_reponse, $cmdp); 40 return; 41 } 42 43 $ct =& pfcContainer::Instance(); 44 $nickidtoban = $ct->getNickId($nick); 45 46 // notify all the channel 47 $cmdp = $p; 48 $cmdp["param"] = _pfc("%s banished from %s by %s", $nick, $channame, $sender); 49 $cmdp["flag"] = 4; 50 $cmd =& pfcCommand::Factory("notice"); 51 $cmd->run($xml_reponse, $cmdp); 52 53 // kick the user (maybe in the future, it will exists a /kickban command) 54 $cmdp = $p; 55 $cmdp["params"] = array(); 56 $cmdp["params"][] = $nick; // nickname to kick 57 $cmdp["params"][] = $reason; // reason 58 $cmd =& pfcCommand::Factory("kick"); 59 $cmd->run($xml_reponse, $cmdp); 60 61 62 // update the recipient banlist 63 $banlist = $ct->getChanMeta($recipient, 'banlist_nickid'); 64 if ($banlist == NULL) 65 $banlist = array(); 66 else 67 $banlist = unserialize($banlist); 68 $banlist[] = $nickidtoban; // append the nickid to the banlist 69 $ct->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); 70 } 71} 72 73?>