Make backup of your chat before start editing source code.
Ban time usage
/bantime {user} {time in minutes} [{reason}]
ex. /bantime user3 60
/bantimelist
/unbantime [user]
ex. /unbantime user3
/unbantime /all
don't forgot /rehash after modification
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 time list
$bantimelist = $container->getChanMeta($chan, 'bantimelist_nickid');
if ($bantimelist == NULL) $bantimelist = array(); else $bantimelist = unserialize($bantimelist);
$nickid = $u->nickid;
foreach ($bantimelist as $tempone) {
if($tempone[0] == $nickid && $tempone[1] > date('c')){
// the user is banished, show a message and don't forward the /join command
$wr = "Can't join %s because you are banished to time ".$tempone[1];
$msg = _pfc($wr, $param);
$xml_reponse->script("pfc.handleResponse('".$this->proxyname."', 'ban', '".addslashes($msg)."');");
return false;
}
}
Make file pfc/src/commands/bantime.class.php
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_bantime extends pfcCommand
{
var $usage = "/bantime {nickname} {time} [ {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] : '';
$timeban = isset($params[1]) ? $params[1] : '';
$reason = isset($params[2]) ? $params[2] : '';
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"] = _pfc("Missing parameter");
$cmdp["param"] .= " (".$this->usage.")";
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
return;
}
if (timeban == '')
{
// error
$cmdp = $p;
$cmdp["param"] = _pfc("Missing parameter");
$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"] = _pfc("%s banished from %s by %s for %s minuts" , $nick, $channame, $sender, $timeban);
$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
$bantimelist = $ct->getChanMeta($recipient, 'bantimelist_nickid');
if ($bantimelist == NULL)
$bantimelist = array();
else
$bantimelist = unserialize($bantimelist);
// searching a removeing old bans
$updated = false;
$newban = array();
foreach ($bantimelist as $tempone) {
if($tempone[1] > date('c'))
$newban[]=$tempone;
}
$bantimelist = $newban;
$bantimelist[] = array($nickidtoban, date('c', mktime(date("H"),date("i")+$timeban,date("s"),date("m"),date("d"),date("Y"))));
// append the nickid to the banlist
$ct->setChanMeta($recipient, 'bantimelist_nickid', serialize($bantimelist));
}
}
?>
Make file pfc/src/commands/bantimelist.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_bantimelist 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();
$bantimelist = $ct->getChanMeta($p["recipient"], 'bantimelist_nickid');
if ($bantimelist == NULL) $bantimelist = array(); else $bantimelist = unserialize($bantimelist);
$msg = "";
$msg .= "<p>"._pfc("The banished user list is:")."</p>";
if (count($bantimelist)>0)
{
$msg .= "<ul>";
foreach ($bantimelist 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." to time: ".$tempone[1]." Time: ".date("c")."</li>";
}
$msg .= "</ul>";
}
else
{
$msg .= "<p>("._pfc("Empty").")</p>";
}
$msg .= "<p>"._pfc("'/unban {nickname}' will unban the user identified by {nickname}")."</p>";
$msg .= "<p>"._pfc("'/unban all' will unban all the users on this channel")."</p>";
$xml_reponse->script("pfc.handleResponse('banlist', 'ok', '".addslashes($msg)."');");
}
}
?>
Make file pfc/src/commands/unbantime.class.php
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_unbantime extends pfcCommand
{
var $usage = "/unbantime {nickname}";
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();
$nick = isset($params[0]) ? $params[0] : '';
$nickid = $ct->getNickId($nick);
if ($nick == "")
{
// error
$cmdp = $p;
$cmdp["param"] = _pfc("Missing parameter");
$cmdp["param"] .= " (".$this->usage.")";
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
return;
}
$updated = false;
$msg = "<p>"._pfc("Nobody has been unbantimeished")."</p>";
// update the recipient banlist
$bantimelist = $ct->getChanMeta($recipient, 'bantimelist_nickid');
if ($bantimelist == NULL)
$bantimelist = array();
else
$bantimelist = unserialize($bantimelist);
$nb = count($bantimelist);
$allnickid=array();
$newban = array();
foreach ($bantimelist as $tempone) {
if($tempone[0] != $nickid)
$newban[]=$tempone;
else
$updated = true;
}
if ($updated){
$ct->setChanMeta($recipient, 'bantimelist_nickid', serialize($newban));
$msg = "<p>"._pfc("%s has been unbantimeished", $nick)."</p>";
}
else if ($nick == "all") // @todo move the "/unbantime all" command in another command /unbantimeall
{
$bantimelist = array();
$ct->setChanMeta($recipient, 'bantimelist_nickid', serialize($bantimelist));
$updated = true;
$msg = "<p>"._pfc("%s users have been unbantimeished", $nb)."</p>";
}
if ($updated)
$xml_reponse->script("pfc.handleResponse('unban', 'ok', '".$msg."');");
else
$xml_reponse->script("pfc.handleResponse('unban', 'ko', '".$msg."');");
}
}
?>
When you find a fail write comment.