Example #1
0
 public function setMask($s)
 {
     $this->mask = fixHostMask($s);
 }
$mask = $pargs[2];
$reason = '';
// default reason
$kick_reason = 'Banned';
if ($cmd_num_args >= 3) {
    $reason = assemble($pargs, 3);
    $kick_reason = $reason;
}
if (!preg_match('/[!@\\.]/', $mask)) {
    if ($tmp_user = $this->getUserByNick($mask)) {
        $mask = $tmp_user->getHostMask();
    } else {
        $mask = $mask . '!*@*';
    }
}
$mask = fixHostMask($mask);
if ($ban = $chan->hasBan($mask)) {
    $bot->noticef($user, 'A ban for %s already exists.', $mask);
    return false;
}
if ($bans = $chan->getMatchingBans($mask)) {
    $bot->noticef($user, 'An existing ban for %s supersedes the one you are trying to set.', $bans[0]);
    return false;
}
$this->ban($chan->getName(), $mask);
$kick_users = $this->getChannelUsersByMask($chan->getName(), $mask);
foreach ($kick_users as $numeric => $chan_user) {
    if (!$chan_user->isBot() && $chan_user != $user) {
        $this->kick($chan->getName(), $numeric, $kick_reason);
    }
}
Example #3
0
 function getHostMask()
 {
     $mask = '*!*' . right($this->ident, IDENT_LEN) . '@';
     $host = $this->host;
     if ($this->hasFakehost()) {
         $host = $this->fakehost;
     } elseif ($this->isHostHidden()) {
         $host = $this->getAccountName() . '.' . HIDDEN_HOST;
     }
     $levels = explode('.', $host);
     $num_levels = count($levels);
     if (isIp($host)) {
         $host = assemble($levels, 0, 3, '.');
         $host .= '.*';
     } elseif ($num_levels > 2) {
         for ($n = $num_levels - 1; $n > 0; $n--) {
             if (preg_match('/[0-9]/', $levels[$n])) {
                 break;
             }
         }
         $host = '*.';
         $host .= assemble($levels, $n + 1, -1, '.');
     }
     $mask = fixHostMask($mask);
     return $mask . $host;
 }