示例#1
0
文件: Dog_Var.php 项目: sinfocol/gwf3
 public function hasPermission(Dog_Server $server, $channel, Dog_User $user)
 {
     $c = $this->priv;
     switch ($this->scope) {
         case 'u':
         case 'g':
         case 's':
             return Dog_PrivServer::hasPermChar($server, $user, $c);
         case 'c':
             return $channel === false ? false : Dog_PrivChannel::hasPermChar($channel, $user, $c);
         default:
             return Dog_Log::critical('Invalid scope in hasPermission()!');
     }
 }
示例#2
0
$argc = $plugin->argc();
$argv = $plugin->argv();
unset($user);
if ($argc === 2) {
    if (false === ($user = Dog_User::getByLongName($argv[1]))) {
        return $plugin->rply('user');
    }
    $server = $user->getServer();
    $argc = 1;
}
if ($argc === 1) {
    if (!isset($user)) {
        $user = Dog::getUser();
    }
    if (!$user->isRegistered()) {
        return $plugin->rply('not_regged', array($user->displayName(), $server->displayName()));
    }
    if ($argv[0] === Dog_Conf_Bot::getConf('superword', 'gizmore')) {
        Dog_PrivServer::grantAll($server, $user);
        Dog_PrivChannel::grantAllToAll($server, $user);
        $plugin->rply('super', array($user->displayName(), $server->displayName()));
    } elseif ($argv[0] === $server->getConf('ircoppass')) {
        Dog_PrivServer::grantIrcop($server, $user);
        Dog_PrivChannel::grantAllToAll($server, $user, Dog_IRCPriv::allBitsButOwner());
        $plugin->rply('super', array($user->displayName(), $server->displayName()));
    } else {
        $plugin->rply('wrong');
    }
} else {
    $plugin->showHelp();
}
示例#3
0
文件: modc_Pc.php 项目: sinfocol/gwf3
        $u = Dog::getUser();
        $have = Dog_PrivChannel::getPermbits($channel, $u);
        $want = Dog_IRCPriv::charsToBits(substr($argv[1], 1));
        $high = Dog_IRCPriv::getHighestBit($have);
        $wigh = Dog_IRCPriv::getHighestBit($want);
        if ($wigh > $high) {
            $plugin->rply('no', array(Dog_IRCPriv::displayBits($wigh, ''), $user->displayName()));
        } else {
            $now = Dog_PrivChannel::getPermbits($channel, $user) | $want;
            Dog_PrivChannel::setPermbits($channel, $user, $now);
            $plugin->rply('set', array($user->displayName(), $channel->displayLongName(), Dog_IRCPriv::displayBits($now)));
        }
    } elseif ($argv[1][0] === '-') {
        $u = Dog::getUser();
        $have = Dog_PrivChannel::getPermbits($channel, $u);
        $want = Dog_IRCPriv::charsToBits(substr($argv[1], 1));
        $high = Dog_IRCPriv::getHighestBit($have);
        $wigh = Dog_IRCPriv::getHighestBit($want);
        if ($wigh >= $high) {
            $plugin->rply('no2', array(Dog_IRCPriv::displayBits($wigh, ''), $user->displayName()));
        } else {
            $now = Dog_PrivChannel::getPermbits($channel, $user) & ~$want;
            Dog_PrivChannel::setPermbits($channel, $user, $now);
            $plugin->rply('set', array($user->displayName(), $channel->displayLongName(), Dog_IRCPriv::displayBits($now)));
        }
    } else {
        $plugin->rply('err_bits');
    }
} else {
    $plugin->showHelp();
}
示例#4
0
文件: Dog.php 项目: sinfocol/gwf3
 public static function hasPermission(Dog_Server $serv, $chan = false, Dog_User $user, $priv, $abc = NULL, $needlogin = true)
 {
     switch ($abc) {
         case 'a':
             if ($chan !== false) {
                 return false;
             }
             # works not in channel vvv fallthrough
         # works not in channel vvv fallthrough
         case 'b':
             $chan = false;
             break;
             # need server perms
         # need server perms
         case 'c':
             if ($chan === false) {
                 return false;
             }
             # only channel
     }
     $priv = Dog_IRCPriv::charToBit($priv);
     return $chan === false ? Dog_PrivServer::hasPermBits($serv, $user, $priv, $needlogin) : Dog_PrivChannel::hasPermBits($chan, $user, $priv, $needlogin);
 }
示例#5
0
文件: opme_Vc.php 项目: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Works only inside a channel and will try to lift your status.', 'no_privs' => 'I have not enough privileges in that channel.', 'yours_better' => 'Your privileges are even higher than mine :O'), 'de' => array('help' => 'Nutze: %CMD%. Funktioniert nur in Kanälen und erhöht deinen IRC Status.', 'no_privs' => 'Meine Rechte reichen hier nicht aus.', 'yours_better' => 'Deine Rechte sind ja höher als meine ^^'));
$user = Dog::getUser();
$plugin = Dog::getPlugin();
$server = Dog::getServer();
if (false === ($channel = Dog::getChannel())) {
    return Dog::rply('err_only_channel');
}
$dogprv = $channel->getPriv($channel->getDog());
#echo "DOGPRV: $dogprv\n";
$dogbit = Dog_IRCPriv::charsToBits($dogprv);
$bit = Dog_IRCPriv::charsToBits($channel->getPriv($user));
$wantbit = Dog_PrivChannel::getPermbits($channel, $user);
if ($wantbit > $dogbit) {
    $wantbit = $dogbit;
}
if ($dogbit < Dog_IRCPriv::charsToBits('h')) {
    $plugin->rply('no_privs');
} elseif ($bit > $dogbit) {
    $plugin->rply('yours_better');
} elseif ($dogbit > $bit) {
    $server->getConnection()->sendRAW(sprintf('MODE %s +%s %s', $channel->getName(), Dog_IRCPriv::bitToBestNamedSymbol($wantbit), $user->getName()));
}