本文整理汇总了PHP中Common::substrUntil方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::substrUntil方法的具体用法?PHP Common::substrUntil怎么用?PHP Common::substrUntil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common
的用法示例。
在下文中一共展示了Common::substrUntil方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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();
}
示例2: on_slap_Pc
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);
}
示例3: __call
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);
}
示例4: warscore_function
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);
}
示例5: populateFromQueue
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());
}
}
}
示例6: getLocationByAbbrev
/**
* @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);
}
示例7: on_scum_Pc
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);
}
示例8: execute
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);
}
示例9: parseStats
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);
}
示例10: parseSudoshRow
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);
}
}
示例11: populateFile
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;
}
示例12: onSend
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));
}
示例13: onTrigger
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);
}
示例14: cfgWarboxProtocol
public function cfgWarboxProtocol()
{
return Common::substrUntil($this->cfgWarboxURL(), '://', 'http');
}
示例15: getNPC
/**
* 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;
}