Exemplo n.º 1
0
 /**
  * Grant a user all privileges on a server.
  * @param int $sid
  * @param int $uid
  */
 public static function grantAllToAll(Dog_Server $server, Dog_User $user, $bits = NULL)
 {
     $uid = $user->getID();
     $all = $bits === NULL ? Dog_IRCPriv::allBits() : intval($bits);
     foreach (GDO::table('Dog_Channel')->selectColumn('chan_id', "chan_sid={$server->getID()}") as $cid) {
         if (false === self::table(__CLASS__)->insertAssoc(array('priv_cid' => $cid, 'priv_uid' => $uid, 'priv_privs' => $all))) {
             return false;
         }
         $user->setVar("dcp_{$cid}", $all);
     }
     return true;
 }
Exemplo n.º 2
0
 public function getPower()
 {
     return Dog_IRCPriv::charToBit($this->priv);
 }
Exemplo n.º 3
0
 public static function grantIrcop(Dog_Server $server, Dog_User $user)
 {
     return self::setPermbits($server, $user, Dog_IRCPriv::allBitsButOwner());
 }
Exemplo n.º 4
0
<?php

# :irc.giz.org 353 Dog = #sr :@gizmore Dog
$msg = Dog::getIRCMsg();
$serv = Dog::getServer();
$chan_name = $msg->getArg(2);
if (false === ($channel = $serv->getChannelByName($chan_name))) {
    return Dog::suppressModules();
}
Dog::setChannel($channel);
$sid = $serv->getID();
foreach (explode(' ', $msg->getArg(3)) as $username) {
    if (false !== ($user = Dog::getOrCreateUserByName(ltrim($username, Dog_IRCPriv::allSymbols())))) {
        $serv->addUser($user);
        $channel->addUser($user, Dog_IRCPriv::matchSymbols($username));
    }
}
Exemplo n.º 5
0
 /**
  * Parse config vars from a ####conf string.
  * Returns array of Dog_Var
  * @param string $string
  * @return array
  */
 public static function parseConfigVars($string, $module = NULL, $plugin = NULL)
 {
     $back = array();
     $csv = str_getcsv($string . ',,');
     $len = count($csv);
     for ($i = 0; $i < $len;) {
         if ('' === ($name = trim($csv[$i++]))) {
             Dog_Log::critical(sprintf('Empty config name in %s:%s.', $i - 1, $string));
             return $back;
         }
         $scope = @substr(strtolower(trim($csv[$i++])), 0, 1);
         if (strpos(self::SCOPES, $scope) === false) {
             Dog_Log::critical(sprintf('Invalid config scope "%s" in %s:%s.', $scope, $i - 1, $string));
             return $back;
         }
         $priv = @substr(strtolower(trim($csv[$i++])), 0, 1);
         if (strpos(Dog_IRCPriv::allChars(), $priv) === false) {
             Dog_Log::critical(sprintf('Invalid config privilege "%s" in %s:%s.', $priv, $i - 1, $string));
             return $back;
         }
         $type = @substr(strtolower(trim($csv[$i++])), 0, 1);
         if (strpos(self::TYPES, $type) === false) {
             Dog_Log::critical(sprintf('Invalid config type "%s" in %s:%s.', $type, $i - 1, $string));
             return $back;
         }
         if ('' === ($default = trim($csv[$i++]))) {
             Dog_Log::critical(sprintf('Empty default value in %s:%s.', $i - 1, $string));
             return $back;
         }
         if (!self::isValid($type, $default)) {
             Dog_Log::critical(sprintf('Invalid default value in %s:%s.', $i - 1, $string));
             return $back;
         }
         if ('' !== ($e1 = $csv[$i++]) || '' !== ($e1 = $csv[$i++])) {
             Dog_Log::critical('Invalid ####conf format. There have to be three consecutive comma to seperate vars.');
             return $back;
         }
         # Yay \o/
         $back[] = new self($name, $scope, $priv, $type, $default, $module, $plugin);
     }
     return $back;
 }
Exemplo n.º 6
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();
}
Exemplo n.º 7
0
        $u = Dog::getUser();
        $have = Dog_PrivServer::getPermbits($serv, $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_PrivServer::getPermbits($serv, $user) | $want;
            Dog_PrivServer::setPermbits($serv, $user, $now);
            $plugin->rply('set', array($user->displayName(), $serv->displayName(), Dog_IRCPriv::displayBits($now)));
        }
    } elseif ($sign === '-' && strlen($argv[1]) >= 1) {
        $u = Dog::getUser();
        $have = Dog_PrivServer::getPermbits($serv, $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_PrivServer::getPermbits($serv, $user) & ~$want;
            Dog_PrivServer::setPermbits($serv, $user, $now);
            $plugin->rply('set', array($user->displayName(), $serv->displayName(), Dog_IRCPriv::displayBits($now)));
        }
    } else {
        $plugin->rply('err_bits');
    }
} else {
    $plugin->showHelp();
}
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
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('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();
}
Exemplo n.º 10
0
<?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()));
}
Exemplo n.º 11
0
 public function addUser(Dog_User $user, $priv_symbols = '')
 {
     $this->users[$user->getID()] = $user;
     $this->privs[$user->getID()] = Dog_IRCPriv::symbolsToChar($priv_symbols);
 }