本文整理汇总了PHP中Common::substrFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::substrFrom方法的具体用法?PHP Common::substrFrom怎么用?PHP Common::substrFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common
的用法示例。
在下文中一共展示了Common::substrFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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())));
}
if (false === ($result2 = Common::substrFrom($result, '<br /><br />', false))) {
return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
}
$stats = explode(':', $result2);
if (count($stats) !== 7) {
// if ($result2 === '0') {
// return array(0, 0);
// }
return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
}
# username:rank:score:maxscore:challssolved:challcount:usercount
$uname = $stats[0];
$rank = intval($stats[1]);
$onsitescore = intval($stats[2]);
$maxscore = intval($stats[3]);
$challssolved = intval($stats[4]);
$challcount = intval($stats[5]);
$usercount = intval($stats[6]);
if ($maxscore === 0 || $challcount === 0 || $usercount === 0) {
return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
}
return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount);
}
示例2: addToBlacklist
public static function addToBlacklist($email)
{
if (false === ($domain = Common::substrFrom($email, '@', false))) {
$domain = $email;
}
if (self::isBlacklisted($domain)) {
return true;
}
return self::table(__CLASS__)->insertAssoc(array('eb_domain' => $domain), false);
}
示例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: getRandomRadio
function getRandomRadio($term)
{
$term = str_replace(" ", "+", $term);
$url = 'http://hagbard.host-ed.me/intranet/radio.php?out=inline&shuffle=true&limit=1&search=' . urlencode($term);
$content = GWF_HTTP::getFromUrl($url . str_replace("%23", "#", urlencode($term)) . '*');
if ($content === false || strlen($content) == 0) {
return false;
}
echo $content . PHP_EOL;
$temp = explode('|', $content, 2);
return array(Common::substrFrom($temp[1], ') ', $temp[1]), $temp[0]);
}
示例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: 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());
}
}
}
示例8: 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);
}
示例9: 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);
}
示例10: dog_trac_helper4
function dog_trac_helper4($entry, $fullpath, $search, $casei = false)
{
if ($casei === true) {
if (stripos($fullpath, $search) !== false) {
if (strpos($fullpath, '/disabled_modules/') === false) {
global $__DOG_TRAC_RESULTS;
$__DOG_TRAC_RESULTS[] = Common::substrFrom($fullpath, GWF_PATH);
}
}
} else {
if (strpos($fullpath, $search) !== false) {
if (strpos($fullpath, '/disabled_modules/') === false) {
global $__DOG_TRAC_RESULTS;
$__DOG_TRAC_RESULTS[] = Common::substrFrom($fullpath, GWF_PATH);
}
}
}
}
示例11: 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);
}
}
示例12: 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())));
}
$file = explode('<br>', $result);
if (count($file) !== 5) {
return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
}
// $ranking = $file[1];
list($ranking, $usercount) = explode('/', trim(Common::substrFrom($file[1], ':')));
// $usercount = Common::substrFrom($ranking, "/");
$challstats = $file[3];
$challcount = Common::substrFrom($challstats, "/");
$points = $file[2];
$back = array();
preg_match('#(\\d*)\\/(\\d*)#', $points, $back);
if (count($back) !== 3 || $back[1] < 0 || $back[1] > $back[2] || $usercount == 0 || $challcount == 0) {
return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
}
return array($back[1], $ranking, -1, $back[2], $usercount, $challcount);
}
示例13: onGuess
/**
*
* @param string $user the username
* @param string|char $message the guess
* @return the answer
*/
public function onGuess($user, $message)
{
$message = trim($message);
if ($this->finish) {
if ($message === 'false') {
$this->CONFIG['solution_allowed_everytime'] = false;
}
$iso = Common::substrFrom($message, ' ', Dog::getChannel()->getLangISO());
$this->onStartGame($iso);
} elseif ($message === '') {
$this->sendOutput('The game has already started');
} else {
if (GWF_String::strlen($message) !== 1) {
$this->trySolution($user, $message);
} else {
$this->tryChar($user, $message);
}
if (GWF_String::toLower($this->grid) === GWF_String::tolower($this->solution)) {
$this->winGame($nick);
}
}
return $this->clearOutput();
}
示例14: call
/**
* Call a hook. User is a default argument. calls hook($user, array $args)
* @param string $name unique ID
* @param GWF_User $user the current user
* @param array $args
*/
public static function call($name, GWF_User $user, array $args = array())
{
self::initHooks();
if (!isset(self::$HOOKS[$name])) {
// GWF_Log::logCritical('Unknown hook: '.$name);
return true;
}
$output = '';
foreach (self::$HOOKS[$name] as $hook) {
$modulename = Common::substrFrom($hook[0], '_');
if (false !== ($module = GWF_Module::loadModuleDB($modulename, true, true))) {
$output .= self::cleanResult($hook, call_user_func(array($module, $hook[1]), $user, $args));
}
}
if ($output === '') {
return true;
}
GWF_Website::addDefaultOutput($output);
return false;
}
示例15: strtolower
<?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));