private function onAdd(Dog_User $user, $url) { if (false !== ($link = Dog_Link::getByURL($url))) { return true; } if (false === ($description = $this->getDescription($url))) { Dog_Log::error('Mod_Link::onAdd() failed. URL: ' . $url); return false; } $type = $description[0]; $description = $description[1]; switch ($type) { case 'image': if (false === ($link = Dog_Link::insertImage($user->getID(), $url, $description))) { GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return; } break; case 'html': if (false === ($link = Dog_Link::insertLink($user->getID(), $url, $description))) { GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return; } break; default: echo "UNKNOWN TYPE: {$type}\n"; return; } Dog_Log::user($user, sprintf('Inserted Link %s (ID:%d)', $url, $link->getID())); }
public function __toString() { $uid = $this->user ? $this->user->getID() : '?'; $cid = $this->channel ? $this->channel->getID() : '?'; $sid = $this->server ? $this->server->getID() : '?'; return sprintf('SCOPE(U:%s,C:%s,S:%s)', $uid, $cid, $sid); }
private function onAutoLogin(Dog_User $user) { if ($user->isRegistered() && !$user->isLoggedIn()) { unset($this->tried[array_search($user->getID(), $this->tried)]); $user->setLoggedIn(true); $user->sendNOTICE($this->lang('logged_in')); } }
private static function onBan(Dog_Server $server, Dog_Channel $channel, Dog_User $user, $message) { $uid = $user->getID(); $cut = time() - DOGMOD_PG::BAN_TIMEOUT; $count = self::table(__CLASS__)->countRows("lpg_uid={$uid} AND lpg_time>{$cut}"); if ($count < DOGMOD_PG::BAN_COUNT) { return; } echo "!!! BAN HIM NOW !!!\n"; }
/** * 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; }
public static function getPermbits(Dog_Server $server, Dog_User $user, $needlogin = true) { $bits = $user->isRegistered() ? Dog_IRCPriv::REGBIT : 0; if ($needlogin && !$user->isLoggedIn()) { return $bits; } $uid = $user->getID(); $sid = $server->getID(); if (0 === ($bits = $user->getVarDefault("dsp_{$sid}", 0))) { $bits |= Dog_IRCPriv::LOGBIT; $bits |= self::table(__CLASS__)->selectVar('priv_privs', "priv_sid={$sid} AND priv_uid={$uid}"); # Cache if ($user->isHoster()) { $bits |= Dog_IRCPriv::HOSTBIT; } $user->setVar("dsp_{$sid}", $bits); } return $bits; }
public static function slap(Dog_User $user, Dog_User $target, $adverb, $dmg_adv, $verb, $dmg_verb, $adjective, $dmg_adj, $item, $dmg_item, $total_damage) { return self::slapB($user->getID(), $target->getID(), $adverb, $dmg_adv, $verb, $dmg_verb, $adjective, $dmg_adj, $item, $dmg_item, $total_damage); }
public static function onQuit(Dog_Server $server, Dog_User $user, $message) { if (false === ($player = self::getPlayerByUID($user->getID()))) { // printf('Can not get Player for user '.$user->getName().".\n"); return; } $p = $player->getParty(); # %s just quit his irc server. $p->ntice('5000', array($player->displayNameNB()), $player); }
public static function record(Dog_User $user, $channel, $event, $message) { return self::table(__CLASS__)->insertAssoc(array('dogseen_uid' => $user->getID(), 'dogseen_cid' => $channel === false ? '0' : $channel->getID(), 'dogseen_event' => $event, 'dogseen_time' => GWF_Time::getDate(), 'dogseen_message' => $message)); }
public function addUser(Dog_User $user) { $this->users[$user->getID()] = $user; }
public static function getPlayer(Dog_User $user) { if (false === ($player = self::getByUID($user->getID()))) { $player = self::createHuman($user); } return $player; }
public function onSend(Dog_Server $server, Dog_User $user, $message) { // $c = Dog::getTrigger(); if (false === ($nickname = Common::substrUntil($message, ' ', false))) { return $this->lang('help_send'); } $message = Common::substrFrom($message, ' '); if (false === ($user_to = Dog_User::getForServer($server->getID(), $nickname))) { return Dog::lang('err_user'); } if (false === Dog_Note::isWithinLimits($user->getID())) { return $this->lang('err_limit', array(Dog_Note::LIMIT_AMT, GWF_Time::humanDuration(Dog_Note::LIMIT_TIME))); } if (false !== ($channel = Dog::getChannel())) { if (false !== $channel->getUserByName($nickname)) { return $this->lang('err_in_chan', array($nickname)); } } if (false === Dog_Note::insertNote($user, $user_to, $message)) { return GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->lang('msg_sent', array($nickname)); }
public static function getUserRecord(Dog_User $user) { return self::table(__CLASS__)->getRow($user->getID()); }
public static function getUID() { return self::$LAST_USER->getID(); }
/** * Add or remove a privilege for a user in a channel. * @param Dog_User $user * @param char $priv * @param boolean $bool */ public function setUser(Dog_User $user, $priv, $bool = true) { $uid = $user->getID(); $has = strpos($this->privs[$uid], $priv) !== false; if ($bool) { if (!$has) { $this->privs[$uid] .= $priv; } } elseif ($has) { $this->privs[$uid] = str_replace($priv, '', $this->privs[$uid]); } }