public function execute() { $back = ''; $write = false; if (true === isset($_GET['delete'])) { $write = true; if (false === GWF_PageLinks::deleteLink($_GET['delete'])) { $back .= $this->module->error('err_deleting_failed'); } } if (true === isset($_POST['add'])) { $url = Common::getPostString('url'); $href = Common::getPostString('href'); if ('' !== $url && '' !== $href) { if ($url[0] === '/') { $url = substr($url, 1); } if (true === GWF_PB_Rewrites::matchURL(Common::substrUntil(GWF_PB_Rewrites::replaceRewriteURL($url), '/'))) { $back .= $this->module->error('err_url_exists'); } else { $write = true; GWF_PageLinks::insertLink($url, $href); } } else { $back .= $this->module->error('err_parame'); } } if (true === $write && false === $this->module->writeHTA()) { $back .= $this->module->error('err_htaccess_writing'); } return $back . $this->templateLinks(); }
public function on_slap_Pc() { $message = $this->msgarg(); if ($message === '') { return $this->showHelp('slap'); } $channel = Dog::getChannel(); $origin = $channel->getName(); require $this->getPath() . 'slaps.php'; $server = Dog::getServer(); $user = Dog::getUser(); $damage = 10000; list($adverb, $dmg_adv) = $this->getRandomItem($slaps['adverbs']); $damage = $this->applyDamage($damage, $dmg_adv); list($verb, $dmg_verb) = $this->getRandomItem($slaps['verbs']); $damage = $this->applyDamage($damage, $dmg_verb); list($adjective, $dmg_adj) = $this->getRandomItem($slaps['adjectives']); $damage = $this->applyDamage($damage, $dmg_adj); list($item, $dmg_item) = $this->getRandomItem($slaps['items']); $damage = $this->applyDamage($damage, $dmg_item); $damage = round($damage); $target_name = Common::substrUntil($message, ' '); # Check if a non record slap $fake = false; if (false === ($target = $this->getTarget($server, $target_name, $origin))) { $fake = true; } elseif (true !== ($remain = Dog_SlapHistory::maySlap($user->getID(), $target->getID(), $this->getTimeout()))) { $fake = true; } elseif (true !== ($toomuch = Dog_SlapHistory::maySlapMore($user->getID(), $this->getTimeout(), $this->getSlapsPerPlayer()))) { $fake = true; } if ($target instanceof Dog_User) { $target_name = Dog::softhyphe($target->getName()); } $message = sprintf('%s %s %s %s with %s %s.', $user->getVar('user_name'), $adverb, $verb, $target_name, $adjective, $item); # Insert slap if ($fake === true) { if (false === Dog_SlapHistory::slapTimeout($adverb, $dmg_adv, $verb, $dmg_verb, $adjective, $dmg_adj, $item, $dmg_item)) { return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__); } if (isset($remain) && $remain !== true) { $malus = $this->getRemainMalus(); Dog_SlapUser::removePoints($user->getID(), $malus); $message .= sprintf(' (%s remaining, Lost %d points).', GWF_Time::humanDuration($remain), $malus); } elseif (isset($toomuch) && $toomuch !== true) { $malus = $this->getPerPlayerMalus(); Dog_SlapUser::removePoints($user->getID(), $malus); $message .= sprintf(' (more than %d slaps within %s. Lost %d points).', $this->getSlapsPerPlayer(), GWF_Time::humanDuration($this->getTimeout()), $malus); } } else { if (false === Dog_SlapHistory::slap($user, $target, $adverb, $dmg_adv, $verb, $dmg_verb, $adjective, $dmg_adj, $item, $dmg_item, $damage)) { return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__); } $message .= ' (' . $damage . ' damage).'; } $server->reply($message); }
public function __call($name, $args) { if (false === ($mo = Common::substrUntil($name, '_'))) { return GWF_HTML::error('ERR_GENERAL', array(__FILE__, __LINE__)); } $me = Common::substrFrom($name, '_'); if (false === ($module = GWF_Module::loadModuleDB($mo))) { return GWF_HTML::error('ERR_MODULE_MISSING', array(__FILE__, __LINE__)); } return $module->execute($me); }
function warscore_function($socket, $pid) { # Init GWF $gwf = new GWF3(getcwd(), array('website_init' => false, 'autoload_modules' => false, 'load_module' => false, 'start_debug' => true, 'get_user' => false, 'log_request' => false, 'no_session' => true, 'store_last_url' => false, 'ignore_user_abort' => false)); gdo_db(); GWF_Debug::setDieOnError(false); GWF_HTML::init(); if (false === ($wechall = GWF_Module::loadModuleDB('WeChall', true, true, true))) { warscore_error($socket, 'Cannot load WeChall!'); } $wechall->includeClass('WC_Warbox'); $wechall->includeClass('WC_WarToken'); $wechall->includeClass('WC_Warflag'); $wechall->includeClass('WC_Warflags'); $wechall->includeClass('sites/warbox/WCSite_WARBOX'); if (false === ($input = socket_read($socket, 2048))) { warscore_error($socket, 'Read Error 1!'); } warscore_debug("GOT INPUT: {$input}"); if (false === ($username = Common::substrUntil($input, "\n", false))) { warscore_error($socket, 'No username sent!'); } if (false === ($user = GWF_User::getByName($username))) { warscore_error($socket, 'Unknown user!'); } warscore_debug("GOT USER: {$username}"); if ('' === ($token = Common::substrFrom($input, "\n", ''))) { warscore_error($socket, 'No token sent!'); } $token = trim(Common::substrUntil($token, "\n", $token)); if (!WC_WarToken::isValidWarToken($user, $token)) { warscore_error($socket, 'Invalid Token!'); } if (!socket_getpeername($socket, $client_ip, $client_port)) { warscore_error($socket, 'Socket Error 2!'); } echo "{$client_ip}\n"; $boxes = WC_Warbox::getByIP($client_ip); if (count($boxes) === 0) { warscore_error($socket, 'Unknown Warbox!'); } warscore_debug("GOT N BOXES: " . count($boxes)); $curr_port = 0; foreach ($boxes as $box) { $box instanceof WC_Warbox; if ($curr_port !== $box->getVar('wb_port')) { $curr_port = $box->getVar('wb_port'); warscore_identd($socket, $box, $user, $client_ip, $client_port); } } socket_write($socket, 'Bailing out! You should not see me.'); socket_close($socket); die(0); }
private function populateFromQueue() { $type = 1; $data = NULL; while (false !== msg_receive($this->queue, 1, $type, 16384, $data, false, MSG_IPC_NOWAIT)) { $uid = Common::substrUntil($data, ':'); $message = Common::substrFrom($data, ':'); echo "GOT {$uid}:{$message}\n"; if (false !== ($socket = $this->getSocketByResourceB($uid))) { $frame = WebSocketFrame::create(WebSocketOpcode::TextFrame, $message); $socket->write($frame->encode()); } } }
/** * @param string $cityname * @param string $arg * @return SR_Location */ public static function getLocationByAbbrev($cityname, $arg) { $player = Shadowrun4::getCurrentPlayer(); if (false !== ($c = Common::substrUntil($arg, '_', false))) { $cityname = $c; $arg = Common::substrFrom($arg, '_', $arg); } if (false === ($city = Shadowrun4::getCityByAbbrev($cityname))) { self::reply($player, 'Unknown city: ' . $cityname); return false; } $city instanceof SR_City; return $city->getLocationByAbbrev($arg); }
public function on_scum_Pc() { if (false === ($chanel = Dog::getChannel())) { return Dog::rply('err_only_channel'); } $user = Dog::getUser(); $msg = $this->msgarg(); $command = Common::substrUntil($msg, ' ', $msg); $message = Common::substrFrom($msg, ' ', ''); switch ($command) { case '': case 'help': $out = $this->scumHelp($message); break; case 'init': $out = $this->scumInit($user); break; case 'join': $out = $this->scumJoin($user); break; case 'start': $out = $this->scumStart($user); break; case 'cards': $out = $this->scumCards($user); break; case 'turn': case 'deck': $out = $this->scumDeck($user); break; case 'top5': $out = $this->scumTop5($user, $message); break; case 'stats': $out = $this->scumStats($user, $message); break; case 'abort': $out = $this->scumAbort($user); break; case 'pass': $out = $this->scumPass($user); break; default: $out = $this->scumPlay($user, $msg, false); break; } return Dog::reply($out); }
public static function execute(SR_Player $player, array $args) { if (count($args) === 0) { Shadowcmd_known_spells::execute($player, array()); return false; } $sn = array_shift($args); $wanted_level = Common::substrFrom($sn, ':', true); $sn = Common::substrUntil($sn, ':', $sn); if (false === ($spell = $player->getSpell($sn))) { $player->msg('1048'); // self::rply($player, '1048'); // $player->message(sprintf('You don\'t know the %s spell.', $sn)); return false; } $spell->setMode(SR_Spell::MODE_SPELL); return $spell->onCast($player, $args, $wanted_level); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $result = Common::substrUntil($result, "<br/>"); $data = explode(":", $result); if (count($data) !== 5) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $rank = (int) $data[0]; $score = (int) $data[1]; $maxscore = (int) $data[2]; $users = (int) $data[3]; $challs = (int) $data[4]; if ($score > $maxscore || $score < 0 || $maxscore == 0 || $users == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($score, $rank, -1, $maxscore, $users, $challs); }
private static function parseSudoshRow(Module_Audit $module, $row, $fh2) { // echo $row; if (false === ($row2 = Common::substrFrom($row, '-sudosh: ', false))) { return self::error('Invalid line: ' . $row); } elseif (Common::startsWith($row2, 'created')) { return self::parseSudoCreated($module, $row2); } elseif (Common::startsWith($row2, 'destroyed')) { return self::parseSudoDestroyed($module, $row2); } elseif (Common::startsWith($row2, 'st')) { return true; # skip } elseif (false === ($id = Common::substrUntil($row2, ':', false))) { return self::error('Invalid line: ' . $row); } elseif (false === ($row2 = Common::substrFrom($row2, ':', false))) { return self::error('Invalid line: ' . $row); } else { return self::appendToLog($module, $id, $row2); } }
public static function populateFile($basedir, $fullpath, $modulename = true, $designname = true) { if (self::isBlacklisted($fullpath)) { return true; } if (false === ($mtimeOld = GWF_Time::getDate(GWF_Date::LEN_SECOND, @filemtime($fullpath)))) { echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array($fullpath)); return false; } # Get modulename if (is_string($modulename)) { // keep } elseif ($basedir === 'modules') { $modulename = substr($fullpath, 8); $modulename = Common::substrUntil($modulename, '/'); } else { $modulename = ''; } # Get designname if (is_string($designname)) { // keep } if (preg_match('#.*(^|/)tpl/([^/]+)/.+$#D', $fullpath, $matches)) { $designname = $matches[2]; } else { $designname = ''; } self::$size_unpacked += filesize($fullpath); if (false === ($row = self::getByPath($fullpath))) { // echo GWF_HTML::message('New File Detected', 'New File: '.$fullpath); $row = new self(array('vsf_id' => 0, 'vsf_dir' => $basedir, 'vsf_path' => $fullpath, 'vsf_module' => $modulename, 'vsf_design' => $designname, 'vsf_hash' => self::hash(file_get_contents($fullpath)), 'vsf_date' => $mtimeOld, 'vsf_size' => filesize($fullpath))); return $row->insert(); } $mtimeDB = $row->getVar('vsf_date'); if ($mtimeOld != $mtimeDB) { // echo GWF_HTML::message('New File Detected', 'Updated: '.$fullpath. 'OLD='.$mtimeOld.' | DB='.$mtimeDB); return $row->saveVars(array('vsf_hash' => self::hash(file_get_contents($fullpath)), 'vsf_date' => $mtimeOld, 'vsf_size' => filesize($fullpath))); } return true; }
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 onTrigger(SR_Player $player, $message) { self::$CURRENT_PLAYER = $player; if ($player->isFighting()) { $cmd = Common::substrUntil($message, ' ', $message); $cmd = self::unshortcut($cmd); $cmd = self::untranslate($cmd); if (true === in_array($cmd, self::$CMDS['fight'], true)) { $player->combatPush($message); return true; } } return self::onExecute($player, $message); }
public function cfgWarboxProtocol() { return Common::substrUntil($this->cfgWarboxURL(), '://', 'http'); }
/** * Get an NPC by name. * @param string $name * @return SR_NPC */ public static function getNPC($name) { if (false === ($cityname = Common::substrUntil($name, '_', false))) { return Dog_Log::error(sprintf('Shadowrun4::getNPC(%s) failed no cityname.', $name)); } if (false === ($city = self::getCity($cityname))) { return Dog_Log::error(sprintf('Shadowrun4::getNPC(%s) failed no city.', $name)); } if (false === ($npc = $city->getNPC($name))) { return Dog_Log::error(sprintf('Shadowrun4::getNPC(%s) failed no such NPC.', $name)); } return $npc; }
public static function getHostname($url) { return Common::substrUntil(Common::substrFrom($url, '://', $url), '/'); }
public function loadTriggers() { // $this->triggers = array(); $s = array('UP', 'DOWN', 'ADD', 'REMOVE'); $r = array('++', '--', '+', '-'); foreach (get_class_methods(get_class($this)) as $method) { if (Common::startsWith($method, 'on_')) { $trigger = substr($method, 3); // Cut off 'on_' $trigger = Common::substrUntil($trigger, '_', $trigger, true); // Cut off privabcdef $trigger = str_replace($s, $r, $trigger); // replace special chars $this->triggers[$trigger] = $method; } } }
function train_regex_level_4(WC_Challenge $chall, $answer) { $solution = '/^(wechall4?)\\.(?:jpg|gif|tiff|bmp|png)$/'; $samples_good = array('wechall.jpg', 'wechall.gif', 'wechall.tiff', 'wechall.bmp', 'wechall.png', 'wechall4.jpg', 'wechall4.gif', 'wechall4.tiff', 'wechall4.bmp', 'wechall4.png'); $samples_bad = array('wechall', 'wechall4', 'wechall3.png', 'wechall4.jpf', 'wechallpng', 'wechallxjpg', 'wechall.jpg ', ' wechall.jpg', 'mechall.jpg', 'meechll.jpg', 'wechall44.jpg', 'wecdfss.jpg'); foreach ($samples_good as $t) { if (!preg_match($answer, $t, $matches)) { echo GWF_HTML::error('WeChall', $chall->lang('err_no_match', array($t)), false); return false; } $filename = Common::substrUntil($t, '.'); if (count($matches) !== 2 || $filename !== $matches[1]) { echo GWF_HTML::error('WeChall', $chall->lang('err_not_capturing'), false); return false; } } foreach ($samples_bad as $t) { if (preg_match($answer, $t, $matches)) { echo GWF_HTML::error('WeChall', $chall->lang('err_matching', $t), false); return false; } } if (strlen($answer) > strlen($solution)) { echo GWF_HTML::error('WeChall', $chall->lang('err_too_long', array(strlen($solution))), false); return false; } return true; }
private function parseUsername($message) { return substr(Common::substrUntil($message, '!'), 1); }
function zreloadCheckInput($shellid, $input, array $answers) { global $allowcmd, $noresponse; $level = GWF_Session::get('zreload'); # replace multi spaces. $input = preg_replace('/[ ]{2,}/', ' ', $input); $input_cmd = Common::substrUntil($input, ' '); $function = 'zreload_func_' . $input_cmd; foreach ($answers as $answer) { $answer_cmd = Common::substrUntil($answer, ' '); # DBG // echo sprintf('Checking<br/>'); // echo $input.'<br/>'; // echo $answer.'<br/>'; // echo '<hr/>'; // EVIL! // if ($level === 7 || $level ===8) // { // $input =strtolower($input); // } // if ($input === $answer) { return true; } } foreach ($answers as $answer) { if ($input === 'ssh -L 222:164.109.44.69:22 10.2.2.2' && $level === 9) { $output = 'Almost, but think again :-) Or read the manual.'; break; } elseif ($input_cmd === $answer_cmd && $allowcmd) { $output = 'Yes, you have to use ' . $answer_cmd . '.'; break; } elseif (function_exists($function) && $allowcmd) { $output = call_user_func($function, $shellid, Common::substrFrom($input, ' ')); break; } elseif ($input_cmd === '') { $output = ''; } elseif ($allowcmd) { $output = 'Unknown command: ' . htmlspecialchars($input_cmd); } elseif ($noresponse) { $output = 'Authentication failure.'; } else { if ($input_cmd === 'reset') { $output = zreload_func_reset($shellid, ''); } else { $output = 'Wrong.'; } } } zreloadAppendToShell($shellid, $output); return false; }
/** * * @param string $url * @return Ambigous <string, false, boolean, unknown> */ public static function getDomain($url) { $url = Common::substrFrom($url, '://', $url); $url = Common::substrUntil($url, '/', $url); return Common::regex('#([^\\.]+\\.[^\\.]+)$#D', $url); }
$port = substr($host, strrpos($host, ':') + 1); $host = substr($host, 0, strrpos($host, ':')); $prot = Common::substrUntil($host, '://'); $ssl = $prot === 'ircs' ? true : false; $host = Common::substrFrom($host, '://', $host); $server->saveVars(array('serv_host' => $host, 'serv_port' => $port)); $server->saveOption(Dog_Server::SSL, $ssl); } # Copy Nicknames + passwords from config global $LAMB_CFG; $nicks = GDO::table('Dog_Nick'); $nicks->createTable(true); GDO::table('Dog_Channel')->update('chan_options=0x02'); foreach ($LAMB_CFG['servers'] as $srv) { $nickname = $srv['nickname']; $nickname = Common::substrUntil($nickname, ',', $nickname); $password = $srv['password']; if (false === ($server = Dog_Server::getByTLD(Common::getDomain($srv['host'])))) { die('OUCH!'); } $nicks->insertAssoc(array('nick_sid' => $server->getID(), 'nick_name' => $nickname, 'nick_pass' => $password)); if (isset($srv['options'])) { $server->saveOption(Dog_Server::BNC); } $co = Dog_Channel::DEFAULT_OPTIONS; foreach (explode(',', $srv['channels']) as $chan_name) { GDO::table('Dog_Channel')->update("chan_options={$co}", "chan_sid={$server->getID()} AND chan_name='{$chan_name}'"); } } foreach ($servers->selectAll('*', '', '', NULL, -1, -1, GDO::ARRAY_O) as $server) { $server instanceof Dog_Server;
private static function validateVars($context, GWF_Form $form, $validator) { $errors = array(); $method = $form->getMethod(); foreach ($form->getFormData() as $key => $data) { # Skippers if (in_array($data[0], self::$SKIPPERS, true) || $data[0] === GWF_Form::SUBMITS || $data[0] === GWF_Form::SUBMIT_IMGS) { continue; } # Captcha if ($data[0] === GWF_Form::CAPTCHA) { if (false !== ($error = self::validateCaptcha($context, $form, $validator, $key))) { $errors[] = $error; } continue; } # Get forms do not validate mo/me if ($method === GWF_Form::METHOD_GET) { if ($key === 'mo' || $key === 'me') { continue; } } # Validators $func_name = 'validate_' . Common::substrUntil($key, '[', $key); $function = array($validator, $func_name); if (!method_exists($validator, $func_name)) { $errors[] = GWF_HTML::lang('ERR_METHOD_MISSING', array($func_name, get_class($validator))); } elseif (false !== ($error = call_user_func($function, $context, $form->getVar($key)))) { $errors[] = $error; } } return count($errors) === 0 ? false : $errors; }
/** * LeatherVest_of_strength:1,quickness:4,marm:4,foo:4 * @param string $itemname * @param int $amount * @param boolean $insert * @return SR_Item */ public static function createByName($itemname, $amount = true, $insert = true) { // printf("%s(%s, %s, %s)\n", __METHOD__, $itemname, $amount, $insert); if ($amount === true) { // printf("%s(%s, %s, %s)\n", __METHOD__, $itemname, $amount, $insert); if (preg_match('/^(\\d+)x(.*)$/iD', $itemname, $matches)) { $amount = (int) $matches[1]; $itemname = $matches[2]; } } $name = Common::substrUntil($itemname, '_of_', $itemname); if (!array_key_exists($name, self::$items)) { Dog_Log::error(sprintf('SR_Item::createByName(%s) failed: Unknown itemname: %s.', $itemname, $name)); return false; } $classname = "Item_{$name}"; if ('' === ($modstring = Common::substrFrom($itemname, '_of_', ''))) { $modifiers = NULL; } else { $modifiers = $modstring; if (false === self::checkModifiers($modstring)) { return false; } } $item = self::instance($name); if ($amount === true) { $amount = self::$items[$name]->getItemDefaultAmount(); } $item->setVar('sr4it_amount', $amount); $item->setVar('sr4it_modifiers', $modifiers); if ($insert === true) { if (false === $item->insert()) { return false; } } $item->initModifiersB(); return $item; }
$serv = Dog::getServer(); $serv->addUser($user); $user = Dog::setupUser(); $chan = Dog::setupChannel(); if ($user === false) { return Dog::suppressModules(); } # Log PRIVMSGs $msg = Dog::getIRCMsg()->getArg(1); if (Dog::getIRCMsg()->shouldLog()) { Dog_Log::user($user, $msg); Dog_Log::channel($chan, $msg); } # Exec Stuff if (!$user->isBot()) { if ('' !== ($trigger = Common::substrUntil($msg, ' '))) { if (Dog_Init::isTrigger($serv, $chan, $trigger[0])) { if ($user->isFlooding()) { return; } Dog::setTriggered(); $trigger = substr($trigger, 1); if (false !== ($plug = Dog_Plugin::getPlug($trigger))) { if (!$plug->isInScope($serv, $chan)) { Dog::scopeError($plug->getScope()); } elseif (!$plug->hasPermission($serv, $chan, $user)) { Dog::permissionError($plug->getPriv()); } elseif (!$plug->isEnabled($serv, $chan)) { Dog::rply('err_disabled'); } else { $plug->execute();
/** * Use fileinfo extension to detect mime type of a file. * @param string $filename * @return string */ private static function getMimeTypeB($filename) { $finfo = finfo_open(FILEINFO_MIME); $mime = finfo_file($finfo, $filename); finfo_close($finfo); return Common::substrUntil($mime, ';'); }
public function onCast(SR_Player $player, array $args, $wanted_level = true) { if ($this->isBrewMode()) { return $this->onBrew($player, 70, 4, 10); } $p = $player->getParty(); if (!$p->isIdle()) { $player->msg('1033'); // $player->message('This spell only works when your party is idle.'); return false; } if (count($args) === 0) { $player->msg('1072'); // $player->message('Please specify a target to teleport to.'); return false; } $bot = Shadowrap::instance($player); if (false === ($tlc = Shadowcmd_goto::getTLCByArgMulticity($player, $args[0]))) { $player->msg('1069'); // $player->message('The location does not exist or is ambigous.'); return false; } $city = Common::substrUntil($tlc, '_'); if (false === ($cityclass = Shadowrun4::getCity($city))) { $player->msg('1073'); // $bot->reply('This city is unknown.'); return false; } if ($cityclass->isDungeon()) { $player->msg('1079'); // $bot->reply('You can not teleport into dungeons.'); return false; } if (false === ($target = $cityclass->getLocation($tlc))) { $player->msg('1070', array($p->getCity())); // $bot->reply(sprintf('The location %s does not exist in %s.', $tlc, $city)); return false; } $tlc = $target->getName(); if (!$player->hasKnowledge('places', $tlc)) { $player->msg('1023'); // $bot->reply(sprintf('You don`t know where the %s is.', $tlc)); return false; } if ($p->getLocation() === $tlc) { $player->msg('1071', array($tlc)); // $bot->reply(sprintf('You are already at the %s.', $tlc)); return false; } # Imprisoned if (false !== ($loc = $p->getLocationClass('inside'))) { if (!$loc->isExitAllowed($player)) { $player->msg('1074'); // $bot->reply('You cannot cast teleport inside this lcoation.'); return false; } } # Minlevels (thx sabretooth) if (false === $this->checkCityTargetLimits($player, $target)) { return false; } $level = $this->getLevel($this->getCaster()); $mc = $p->getMemberCount(); $need_level = $mc / 2; if ($level < $need_level) { $player->msg('1076', array($this->getName(), $need_level, $mc)); return false; // $bot->reply(sprintf('You need at least %s level %s to teleport %s party members.', $this->getName(), $need_level, $mc)); // return false; } $need = $this->getManaCost($player, $need_level); $have = $player->getMP(); if ($need > $have) { $player->msg('1055', array($need, $this->getName(), $need_level, $have)); // $player->message(sprintf('You need %s MP to cast %s, but you only have %s.', $need, $this->getName(), $have)); return false; } if (true === $this->isCastMode()) { $player->healMP(-$need); } $p->ntice('5133', array($player->getName(), $need, $this->getName(), $tlc)); // $p->notice(sprintf('%s used %s MP to cast %s and your party is now outside of %s.', $player->getName(), $need, $this->getName(), $tlc)); $p->pushAction('outside', $tlc); return true; }
public function iExecAnyway() { $anyway = array('eq', 'equip', 'g', 'give', 'uq', 'unequip', 'ca', 'cast', 'u', 'use'); $cmd = $this->combat_stack; $cmd = Common::substrUntil($cmd, ' ', $cmd); if (in_array($cmd, $anyway, true)) { return Shadowcmd::onExecute($this, $this->combat_stack); } $this->combat_stack = ''; $this->old_combat_stack = ''; return true; }
/** * Filewalker for getPlugins * @see GWF_File::filewalker */ public static function getPlugRec($entry, $fullpath, $name) { if ($entry[0] !== '_' && Common::substrUntil($entry, '_', NULL, true) === $name) { self::$PLUGIN[] = new Dog_Plugin($name, substr(Common::substrFrom($entry, '_', NULL, true), 0, -4), $fullpath); } }
<?php $user = Dog::getUser(); $server = Dog::getServer(); $message = Dog::getIRCMsg()->getArg(1); $cmd = strtolower(Common::substrUntil($message, ' ', $message)); $msg = Common::substrFrom($message, ' ', $message); switch ($cmd) { case "ping": case "time": case "action": case "finger": break; case 'version': $user->sendCTCP(sprintf('VERSION Dog v%s. Http://dog.gizmore.org', DOG_VERSION)); break; } Dog_Module::map('trigger_ctcp', array($cmd, $msg));