* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
if (!($chan = $this->getChannel($chan_name))) {
    $bot->noticef($user, "Nobody is on channel %s.", $chan_name);
    return false;
}
if (!$chan->isOn($bot->getNumeric())) {
    $bot->noticef($user, 'I am not on %s.', $chan->getName());
    return false;
}
$reason = assemble($pargs, 2);
$users = $this->getChannelUsersByMask($chan_name);
foreach ($users as $numeric => $chan_user) {
    if (!$chan_user->isBot() && $chan_user != $user) {
        $mask = $chan_user->getHostMask();
        $ban = new DB_Ban($chan_reg->getId(), $user->getAccountId(), $mask);
        $ban->setReason($reason);
        $chan_reg->addBan($ban);
        $bot->mode($chan->getName(), "-o+b {$numeric} {$mask}");
        $bot->kick($chan->getName(), $numeric, $reason);
        $chan->addBan($mask);
    }
}
$chan_reg->save();
    return false;
}
if (!preg_match('/[!@\\.]/', $mask)) {
    if ($tmp_user = $this->getUserByNick($mask)) {
        $mask = $tmp_user->getHostMask();
    } else {
        $mask = $mask . '!*@*';
    }
}
$mask = fixHostMask($mask);
if ($ban = $chan_reg->getBan($mask)) {
    $bot->noticef($user, 'A ban for %s already exists.', $ban->getMask());
    return false;
}
if ($ban = $chan_reg->countMatchingBans($mask)) {
    $bot->noticef($user, 'An existing ban for %s supercedes the one you are trying to set.', $ban->getMask());
    return false;
}
$ban = new DB_Ban();
$ban->setChanId($chan_reg->getId());
$ban->setUserId($user->getAccountId());
$ban->setMask($mask);
$ban->setDuration($duration_secs);
$ban->setLevel($level);
$ban->setReason($reason);
$ban->setTs(time());
$ban->save();
$chan_reg->addBan($ban);
$chan_reg->save();
$bot->ban($chan->getName(), $mask);
$chan->addBan($mask);
Beispiel #3
0
 function loadBans()
 {
     $n = 0;
     $res = db_query('select * from channel_bans');
     while ($row = mysql_fetch_assoc($res)) {
         $chan_id = $row['chan_id'];
         $user_id = $row['user_id'];
         $mask = $row['mask'];
         $chan = $this->getChannelRegById($chan_id);
         if (!$chan) {
             debug("*** Loaded ban for channel ID {$chan_id}, but no such channel exists!");
             continue;
         }
         $ban = new DB_Ban($chan_id, $user_id, $mask);
         $ban->loadFromRow($row);
         $chan->addBan($ban);
         $n++;
     }
     debug("Loaded {$n} channel ban records.");
 }