public static function addTimer($func, $args, $delay, $repeat = true) { if ($delay < 0.2) { die(Dog_Log::critical("Timer has delay < 0.200!")); } self::$TIMERS[] = new self($func, $args, $delay, $repeat); }
public function after_pull($repo_id, array $data) { // printf("DOGMOD_CVS::afterPull($repo_id): %s\n", print_r($data, true)); $code = $data[0]; $pullResult = $data[1]; $this->pulling = false; if (!($repo = Dog_Repo::getByID($repo_id))) { Dog_Log::critical(GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__))); return; } if (!$repo->isNew($pullResult)) { return; } if (!$repo->storePullResult($pullResult)) { Dog_Log::critical(GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__))); return; } $this->announce_commit($repo); }
<?php # :Dog!Dawg@localhost JOIN :#sr $msg = Dog::getIRCMsg(); $serv = Dog::getServer(); if (false === ($user = Dog::getOrCreateUser())) { return Dog_Log::critical("Cannot create user!"); } $serv->addUser($user); if (false === Dog::setupUser()) { return Dog_Log::critical('Cannot setup user!'); } $chan_name = $msg->getArg(0); if (false === ($channel = $serv->getChannelByName($chan_name))) { if (false === ($channel = Dog_Channel::getOrCreate($serv, $chan_name))) { return; } $serv->addChannel($channel); } $channel->addUser($user); if (false === Dog::setupChannel()) { Dog_Log::critical('Cannot setup channel.'); }
/** * 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; }
<?php # :Dog!gizmore@localhost NICK gizmore $old_user = Dog::setupUser(); $serv = Dog::getServer(); if (false === ($new_user = Dog::getOrCreateUserByName(Dog::argv(0)))) { Dog::suppressModules(); return Dog_Log::critical('Cannot create user!'); } # Copy channels with privs if ($old_user) { $old_uid = $old_user->getID(); $serv->addUser($new_user); foreach ($serv->getChannels() as $channel) { $channel instanceof Dog_Channel; if (false !== $channel->getUserByID($old_uid)) { $channel->addUser($new_user, $channel->getPriv($old_user)); } } $serv->removeUser($old_user); echo "OLD DOG: {$old_user->getName()}\n"; echo "OLD DOG: " . Dog::getNickname() . "\n"; if ($old_user->getName() === Dog::getNickname()) { if (false !== ($nick = Dog_Nick::getExistingNick($serv, Dog::argv(0)))) { $serv->setNick($nick); $serv->setNicknum(0); $nick->identify(); } else { $serv->setNickName(Dog::argv(0)); } }