Make backup of your chat before start editing source code.
Ban IP time usage
/baniptime {nickname} {ip} {time minutes} [ {reason} ]
ex. /baniptime user3 60.100.112.15 60
Unban:
/unbaniptime {ip} or /unbaniptime all
Finde in pfc/src/proxies/auth.class.php
- Code: Select all
- if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist);
 $nickid = $u->nickid;
 if (in_array($nickid,$banlist))
 {
 // the user is banished, show a message and don't forward the /join command
 $msg = _pfc("Can't join %s because you are banished", $param);
 $xml_reponse->script("pfc.handleResponse('".$this->proxyname."', 'ban', '".addslashes($msg)."');");
 return false;
 }
Replace width
- Code: Select all
- if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist);
 $nickid = $u->nickid;
 if (in_array($nickid,$banlist))
 {
 // the user is banished, show a message and don't forward the /join command
 $msg = _pfc("Can't join %s because you are banished", $param);
 $xml_reponse->script("pfc.handleResponse('".$this->proxyname."', 'ban', '".addslashes($msg)."');");
 return false;
 }
 // ban ip time list
 $baniplist = $container->getChanMeta('baniptime', 'baniplist_nickid');
 if ($baniplist == NULL) $baniplist = array(); else $baniplist = unserialize($baniplist);
 $ip=@$_SERVER['REMOTE_ADDR'];
 //$nickid = $u->nickid;
 //echo 'alert("IP ban")';
 foreach ($baniplist as $tempone) {
 if($tempone[1] == $ip && $tempone[2] > date('c')){
 // the user is banished, show a message and don't forward the /join command
 $wr = "Can't join because your ip is blocked ".$ip." to time: ". $tempone[2] ;
 $msg = _pfc($wr, $param);
 $xml_reponse->script("pfc.handleResponse('".$this->proxyname."', 'ban', '".addslashes($wr)."');");
 return false;
 }
 }
Make file pfc/src/commands/baniptime.class.php
- Code: Select all
- <?php
 require_once(dirname(__FILE__)."/../pfccommand.class.php");
 class pfcCommand_baniptime extends pfcCommand
 {
 var $usage = "/baniptime {nickname} {ip} [ {reason} ]";
 
 function run(&$xml_reponse, $p)
 {
 $clientid = $p["clientid"];
 $param = $p["param"];
 $params = $p["params"];
 $sender = $p["sender"];
 $recipient = $p["recipient"];
 $recipientid = $p["recipientid"];
 
 $c =& pfcGlobalConfig::Instance();
 $u =& pfcUserConfig::Instance();
 $nick = isset($params[0]) ? $params[0] : '';
 $ip = isset($params[1]) ? $params[1] : '';
 $timeban = isset($params[2]) ? $params[2] : '';
 $reason = isset($params[3]) ? $params[3] : '';
 
 if ($reason == '') $reason = _pfc("no reason");
 // to allow unquotted reason
 if (count($params) > 2)
 for ($x=2;$x<count($params);$x++)
 $reason.=" ".$params[$x];
 
 $channame = $u->channels[$recipientid]["name"];
 
 if ($nick == '')
 {
 // error
 $cmdp = $p;
 $cmdp["param"] = "Missing parameter: nick";
 $cmdp["param"] .= " (".$this->usage.")";
 $cmd =& pfcCommand::Factory("error");
 $cmd->run($xml_reponse, $cmdp);
 return;
 }
 
 if (ip == '')
 {
 // error
 $cmdp = $p;
 $cmdp["param"] = "Missing parameter: ip";
 $cmdp["param"] .= " (".$this->usage.")";
 $cmd =& pfcCommand::Factory("error");
 $cmd->run($xml_reponse, $cmdp);
 return;
 }
 $ct =& pfcContainer::Instance();
 $nickidtoban = $ct->getNickId($nick);
 
 // notify all the channel
 $cmdp = $p;
 $cmdp["param"] = $nick." ip banished from ".$channame." by ". $sender;
 $cmdp["flag"] = 1;
 $cmd =& pfcCommand::Factory("notice");
 $cmd->run($xml_reponse, $cmdp);
 
 // kick the user (maybe in the future, it will be dissociate in a /kickban command)
 $cmdp = $p;
 $cmdp["params"] = array();
 $cmdp["params"][] = $nick; // nickname to kick
 $cmdp["params"][] = $reason; // reason
 $cmd =& pfcCommand::Factory("kick");
 $cmd->run($xml_reponse, $cmdp);
 // update the recipient banlist
 $baniplist = $ct->getChanMeta('baniptime', 'baniplist_nickid');
 if ($baniplist == NULL)
 $baniplist = array();
 else
 $baniplist = unserialize($baniplist);
 
 // searching a removeing old bans
 $updated = false;
 $newban = array();
 foreach ($baniplist as $tempone) {
 if($tempone[2] > date('c'))
 $newban[]=$tempone;
 }
 $baniplist = $newban;
 
 
 $baniplist[] = array($nickidtoban, $ip, date('c', mktime(date("H"),date("i")+$timeban,date("s"),date("m"),date("d"),date("Y"))));
 // append the nickid to the banlist
 $msg="Nick: ".$nickidtoban ." widt ip: ". $ip."is banishet for time: ". date('c', mktime(date("H"),date("i")+$timeban,date("s"),date("m"),date("d"),date("Y")));
 $xml_reponse->script("pfc.handleResponse('banlist', 'ok', '".addslashes($msg)."');");
 $ct->setChanMeta('baniptime', 'baniplist_nickid', serialize($baniplist));
 }
 }
 ?>
Make file pfc/src/commands/baniptimelist.class.php
- Code: Select all
- <?php
 require_once(dirname(__FILE__)."/../pfccommand.class.php");
 /**
 * This command list the banished users on the given channel
 *
 * @author Stephane Gully <stephane.gully@gmail.com>
 */
 class pfcCommand_baniptimelist extends pfcCommand
 {
 var $desc = "This command list the banished users on the given channel";
 
 function run(&$xml_reponse, $p)
 {
 $c =& pfcGlobalConfig::Instance();
 $u =& pfcUserConfig::Instance();
 
 $ct =& pfcContainer::Instance();
 $baniplist = $ct->getChanMeta('baniptime', 'baniplist_nickid');
 
 if ($baniplist == NULL) $baniplist = array(); else $baniplist = unserialize($baniplist);
 $msg = "";
 $msg .= "<p>"."The time ip banished user list is:"."</p>";
 if (count($baniplist)>0)
 {
 $msg .= "<ul>";
 foreach ($baniplist as $tempone) {
 // foreach ($tempone as $key=>$temptwo) {
 // echo $key.":".$temptwo."n";
 // }
 // echo "</br>";
 $n = $ct->getNickname($tempone[0]);
 $msg .= "<li style="margin-left:50px">".$n." width ip: ".$tempone[1]." to time: ".$tempone[2]. " now is: ".date("c")."</li>";
 }
 $msg .= "</ul>";
 }
 else
 {
 $msg .= "<p>("._pfc("Empty").")</p>";
 }
 $msg .= "<p>"._pfc("'/unbanip {ip}' will unban the user identified by {nickname}")."</p>";
 $msg .= "<p>"._pfc("'/unbanip all' will unban all the users on this channel")."</p>";
 
 $xml_reponse->script("pfc.handleResponse('banlist', 'ok', '".addslashes($msg)."');");
 }
 }
 ?>
Make file pfc/src/commands/unbaniptime.class.php
- Code: Select all
- <?php
 require_once(dirname(__FILE__)."/../pfccommand.class.php");
 class pfcCommand_unbaniptime extends pfcCommand
 {
 var $usage = "/unbaniptime {ip} or /unbaniptime all";
 
 function run(&$xml_reponse, $p)
 {
 $clientid = $p["clientid"];
 $param = $p["param"];
 $params = $p["params"];
 $sender = $p["sender"];
 $recipient = $p["recipient"];
 $recipientid = $p["recipientid"];
 
 $c =& pfcGlobalConfig::Instance();
 $u =& pfcUserConfig::Instance();
 $ct =& pfcContainer::Instance();
 $ip = isset($params[0]) ? $params[0] : '';
 
 if ($ip == "")
 {
 // error
 $cmdp = $p;
 $cmdp["param"] = "Missing parameter: ip";
 $cmdp["param"] .= " (".$this->usage.")";
 $cmd =& pfcCommand::Factory("error");
 $cmd->run($xml_reponse, $cmdp);
 return;
 }
 
 $updated = false;
 $msg = "<p>"."Nobody has been unbanipished"."</p>";
 
 // update the recipient banlist
 $baniplist = $ct->getChanMeta('baniptime', 'baniplist_nickid');
 if ($baniplist == NULL)
 $baniplist = array();
 else
 $baniplist = unserialize($baniplist);
 $nb = count($baniplist);
 $allnickid=array();
 $newban = array();
 foreach ($baniplist as $tempone) {
 
 if($tempone[1] != $ip)
 $newban[]=$tempone;
 else{
 $updated = true;
 $msg = "<p>NOo</p>";
 }
 }
 if ($updated){
 $ct->setChanMeta('baniptime', 'baniplist_nickid', serialize($newban));
 $msg = "<p>".$ip." has been unbanipished"."</p>";
 }
 else if ($ip == "all") // @todo move the "/unbanip all" command in another command /unbanipall
 {
 $baniplist = array();
 $ct->setChanMeta('baniptime', 'baniplist_nickid', serialize($baniplist));
 $updated = true;
 $msg = "<p>".$nb." users have been unbanipished"."</p>";
 }
 $xml_reponse->script("pfc.handleResponse('unban', 'ok', '".$msg."');");
 }
 }
 ?>
EDIT 2010 07 13
Finde in pfc/src/proxies/auth.class.php
- Code: Select all
- // protect admin commands
 $admincmd = array("kick", "ban", "bantime", "banip", "unbantime", "unbanip", "unban", "op", "deop", "debug", "rehash");
 if ( in_array($this->name, $admincmd) )
Replace width
- Code: Select all
- // protect admin commands
 $admincmd = array("kick", "ban", "bantime", "banip", "unbantime", "unbanip", "unban", "op", "deop", "debug", "rehash", "bantimelist", "baniplist", "banlist", "bantimelist", "baniptime", "unbaniptime", "baniptimelist");
 if ( in_array($this->name, $admincmd) )
When you find a fail write comment.


 I sorted out a very annoying user thanks to you. ^^
 I sorted out a very annoying user thanks to you. ^^