本文整理汇总了PHP中strrpos函数的典型用法代码示例。如果您正苦于以下问题:PHP strrpos函数的具体用法?PHP strrpos怎么用?PHP strrpos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strrpos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: openfire_authenticate
function openfire_authenticate($user, $username, $password)
{
global $openfire;
$openfire->of_logInfo("openfire_authenticate 1 " . $username . " " . $password);
if (!openfire_wants_to_login()) {
return new WP_Error('user_logged_out', sprintf(__('You are now logged out of Azure AD.', AADSSO), $username));
}
// Don't re-authenticate if already authenticated
if (strrpos($username, "@") == false || is_a($user, 'WP_User')) {
return $user;
}
$openfire->of_logInfo("openfire_authenticate 2 ");
// Try to find an existing user in WP where the UPN of the current AAD user is
// (depending on config) the 'login' or 'email' field
if ($username && $password && $openfire->of_authenticate_365($username, $password)) {
$user = get_user_by("email", $username);
if (!is_a($user, 'WP_User')) {
$openfire->of_logInfo("openfire_authenticate 3");
// Since the user was authenticated with AAD, but not found in WordPress,
// need to decide whether to create a new user in WP on-the-fly, or to stop here.
$openfire->of_logInfo("openfire_authenticate 4");
$paras = explode("@", $username);
$userid = $paras[0] . "." . $paras[1];
$new_user_id = wp_create_user($userid, $password, $username);
$user = new WP_User($new_user_id);
$user->set_role('subscriber');
$first_name = $openfire->of_get_given_name();
$last_name = $openfire->get_family_name();
$display_name = $first_name . " " . $last_name;
wp_update_user(array('ID' => $new_user_id, 'display_name' => $display_name, 'first_name' => $first_name, 'last_name' => $last_name));
}
}
return $user;
}
示例2: sanitize_uri
function sanitize_uri()
{
global $PATH_INFO, $SCRIPT_NAME, $REQUEST_URI;
if (isset($PATH_INFO) && $PATH_INFO != "") {
$SCRIPT_NAME = $PATH_INFO;
$REQUEST_URI = "";
}
if ($REQUEST_URI == "") {
//necessary for some IIS installations (CGI in particular)
$get = httpallget();
if (count($get) > 0) {
$REQUEST_URI = $SCRIPT_NAME . "?";
reset($get);
$i = 0;
while (list($key, $val) = each($get)) {
if ($i > 0) {
$REQUEST_URI .= "&";
}
$REQUEST_URI .= "{$key}=" . URLEncode($val);
$i++;
}
} else {
$REQUEST_URI = $SCRIPT_NAME;
}
$_SERVER['REQUEST_URI'] = $REQUEST_URI;
}
$SCRIPT_NAME = substr($SCRIPT_NAME, strrpos($SCRIPT_NAME, "/") + 1);
if (strpos($REQUEST_URI, "?")) {
$REQUEST_URI = $SCRIPT_NAME . substr($REQUEST_URI, strpos($REQUEST_URI, "?"));
} else {
$REQUEST_URI = $SCRIPT_NAME;
}
}
示例3: process
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
// Make sure this is the first PHP open tag so we don't process
// the same file twice.
$prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1);
if ($prevOpenTag !== false) {
return;
}
$fileName = $phpcsFile->getFileName();
$extension = substr($fileName, strrpos($fileName, '.'));
$nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), $stackPtr);
if ($extension === '.php') {
if ($nextClass !== false) {
$error = '%s found in ".php" file; use ".inc" extension instead';
$data = array(ucfirst($tokens[$nextClass]['content']));
$phpcsFile->addError($error, $stackPtr, 'ClassFound', $data);
}
} else {
if ($extension === '.inc') {
if ($nextClass === false) {
$error = 'No interface or class found in ".inc" file; use ".php" extension instead';
$phpcsFile->addError($error, $stackPtr, 'NoClass');
}
}
}
}
示例4: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case "HtmlIncludeFilePath":
// Passed-in value is null -- use the "default" path name of file".tpl.php"
if (!$mixValue) {
$strPath = realpath(substr(QApplication::$ScriptFilename, 0, strrpos(QApplication::$ScriptFilename, '.php')) . '.tpl.php');
} else {
$strPath = realpath($mixValue);
}
// Verify File Exists, and if not, throw exception
if (is_file($strPath)) {
$this->strHtmlIncludeFilePath = $strPath;
return $strPath;
} else {
throw new QCallerException('Accompanying HTML Include File does not exist: "' . $mixValue . '"');
}
break;
case "CssClass":
try {
return $this->strCssClass = QType::Cast($mixValue, QType::String);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
default:
try {
return parent::__set($strName, $mixValue);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例5: packageDoc
/** Constructor
*
* @param str name
* @param RootDoc root
*/
function packageDoc($name, &$root)
{
$this->_name = $name;
$this->_root =& $root;
$phpdoctor =& $root->phpdoctor();
// parse overview file
$packageCommentDir = $phpdoctor->getOption('packageCommentDir');
$packageCommentFilename = strtolower(str_replace('/', '.', $this->_name)) . '.html';
if (isset($packageCommentDir) && is_file($packageCommentDir . $packageCommentFilename)) {
$overviewFile = $packageCommentDir . $packageCommentFilename;
} else {
$pos = strrpos(str_replace('\\', '/', $phpdoctor->_currentFilename), '/');
if ($pos !== FALSE) {
$overviewFile = substr($phpdoctor->_currentFilename, 0, $pos) . '/package.html';
} else {
$overviewFile = $phpdoctor->sourcePath() . $this->_name . '.html';
}
}
if (is_file($overviewFile)) {
$phpdoctor->message("\n" . 'Reading package overview file "' . $overviewFile . '".');
if ($html = $this->getHTMLContents($overviewFile)) {
$this->_data = $phpdoctor->processDocComment('/** ' . $html . ' */', $this->_root);
$this->mergeData();
}
}
}
示例6: generateClass
/**
* Generate Class
*
* @param string $className
* @return string
* @throws \Magento\Framework\Exception
* @throws \InvalidArgumentException
*/
public function generateClass($className)
{
// check if source class a generated entity
$entity = null;
$entityName = null;
foreach ($this->_generatedEntities as $entityType => $generatorClass) {
$entitySuffix = ucfirst($entityType);
// if $className string ends on $entitySuffix substring
if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) {
$entity = $entityType;
$entityName = rtrim(substr($className, 0, -1 * strlen($entitySuffix)), \Magento\Framework\Autoload\IncludePath::NS_SEPARATOR);
break;
}
}
if (!$entity || !$entityName) {
return self::GENERATION_ERROR;
}
// check if file already exists
$autoloader = $this->_autoloader;
if ($autoloader::getFile($className)) {
return self::GENERATION_SKIP;
}
if (!isset($this->_generatedEntities[$entity])) {
throw new \InvalidArgumentException('Unknown generation entity.');
}
$generatorClass = $this->_generatedEntities[$entity];
$generator = new $generatorClass($entityName, $className, $this->_ioObject);
if (!$generator->generate()) {
$errors = $generator->getErrors();
throw new \Magento\Framework\Exception(implode(' ', $errors));
}
return self::GENERATION_SUCCESS;
}
示例7: render
/**
* Render method
*
* @throws Exception
* @return string
*/
public function render()
{
$sources = $this->getSourcesFromArgument();
if (0 === count($sources)) {
throw new Exception('No audio sources provided.', 1359382189);
}
foreach ($sources as $source) {
if (TRUE === is_string($source)) {
if (FALSE !== strpos($source, '//')) {
$src = $source;
$type = substr($source, strrpos($source, '.') + 1);
} else {
$src = substr(GeneralUtility::getFileAbsFileName($source), strlen(PATH_site));
$type = pathinfo($src, PATHINFO_EXTENSION);
}
} elseif (TRUE === is_array($source)) {
if (FALSE === isset($source['src'])) {
throw new Exception('Missing value for "src" in sources array.', 1359381250);
}
$src = $source['src'];
if (FALSE === isset($source['type'])) {
throw new Exception('Missing value for "type" in sources array.', 1359381255);
}
$type = $source['type'];
} else {
// skip invalid source
continue;
}
if (FALSE === in_array(strtolower($type), $this->validTypes)) {
throw new Exception('Invalid audio type "' . $type . '".', 1359381260);
}
$type = $this->mimeTypesMap[$type];
$src = $this->preprocessSourceUri($src);
$this->renderChildTag('source', array('src' => $src, 'type' => $type), FALSE, 'append');
}
$tagAttributes = array('width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'preload' => 'auto');
if (TRUE === (bool) $this->arguments['autoplay']) {
$tagAttributes['autoplay'] = 'autoplay';
}
if (TRUE === (bool) $this->arguments['controls']) {
$tagAttributes['controls'] = 'controls';
}
if (TRUE === (bool) $this->arguments['loop']) {
$tagAttributes['loop'] = 'loop';
}
if (TRUE === (bool) $this->arguments['muted']) {
$tagAttributes['muted'] = 'muted';
}
if (TRUE === in_array($this->validPreloadModes, $this->arguments['preload'])) {
$tagAttributes['preload'] = 'preload';
}
if (NULL !== $this->arguments['poster']) {
$tagAttributes['poster'] = $this->arguments['poster'];
}
$this->tag->addAttributes($tagAttributes);
if (NULL !== $this->arguments['unsupported']) {
$this->tag->setContent($this->tag->getContent() . LF . $this->arguments['unsupported']);
}
return $this->tag->render();
}
示例8: readUrl
function readUrl($url)
{
var_dump($url);
die;
$urldata = parse_url($url);
if (isset($urldata['host'])) {
if ($this->host and $this->host != $urldata['host']) {
return false;
}
$this->protocol = $urldata['scheme'];
$this->host = $urldata['host'];
$this->path = $urldata['path'];
return $url;
}
if (preg_match('#^/#', $url)) {
$this->path = $urldata['path'];
return $this->protocol . '://' . $this->host . $url;
} else {
if (preg_match('#/$#', $this->path)) {
return $this->protocol . '://' . $this->host . $this->path . $url;
} else {
if (strrpos($this->path, '/') !== false) {
return $this->protocol . '://' . $this->host . substr($this->path, 0, strrpos($this->path, '/') + 1) . $url;
} else {
return $this->protocol . '://' . $this->host . '/' . $url;
}
}
}
}
示例9: deserializationAction
function deserializationAction(&$body)
{
$data = $body->getValue();
//Get the method that is being called
$description = xmlrpc_parse_method_descriptions($data);
$target = $description['methodName'];
$baseClassPath = $GLOBALS['amfphp']['classPath'];
$lpos = strrpos($target, '.');
$methodname = substr($target, $lpos + 1);
$trunced = substr($target, 0, $lpos);
$lpos = strrpos($trunced, ".");
if ($lpos === false) {
$classname = $trunced;
$uriclasspath = $trunced . ".php";
$classpath = $baseClassPath . $trunced . ".php";
} else {
$classname = substr($trunced, $lpos + 1);
$classpath = $baseClassPath . str_replace(".", "/", $trunced) . ".php";
// removed to strip the basecp out of the equation here
$uriclasspath = str_replace(".", "/", $trunced) . ".php";
// removed to strip the basecp out of the equation here
}
$body->methodName = $methodname;
$body->className = $classname;
$body->classPath = $classpath;
$body->uriClassPath = $uriclasspath;
$body->packageClassMethodName = $description['methodName'];
}
示例10: generateattach
function generateattach($name, $size, $price, $auth, $id, $free, $count)
{
$extension = substr($name, strrpos($name, ".") + 1);
$supportedExt = explode(" ", "bmp csv gif html jpg jpeg key mov mp3 mp4 numbers pages pdf png rtf tiff txt zip ipa ipsw doc docx ppt pptx xls avi wmv mkv mts");
$imgsrc = "file";
if (in_array($extension, $supportedExt)) {
$imgsrc = $extension;
}
$imgsrc = "../assets/fileicons/" . $imgsrc . ".png";
$s = '<div class="attachdark" onclick="attachdl(\'' . $name . '\',' . $price . ',' . $auth . ',' . $id . ',' . ($free ? "true" : "false") . ')">';
$s = $s . '<img src="' . $imgsrc . '" class="fileicon">';
$s = $s . '<div class="fileinfo"><span class="filename">' . $name . '<br></span>';
$s = $s . '<span class="sub">' . packSize($size) . '<br>';
if ($free) {
$s = $s . '您可以免费下载';
} else {
if ($price == 0) {
$s = $s . '免费';
} else {
$s = $s . '售价:' . $price . "积分";
}
}
if ($count == 0) {
$s = $s . "(暂时无人下载)";
} else {
$s = $s . "(下载次数:" . $count . ")";
}
$s = $s . "</span>";
$s = $s . '</div></div>';
return $s;
}
示例11: getClassShortName
/**
* {@inheritDoc}
*/
public function getClassShortName($className)
{
if (strpos($className, '\\') !== false) {
$className = substr($className, strrpos($className, "\\") + 1);
}
return $className;
}
示例12: classToTableName
/**
* {@inheritdoc}
*/
public function classToTableName($className)
{
if (strpos($className, '\\') !== false) {
$className = substr($className, strrpos($className, '\\') + 1);
}
return $this->underscore($className);
}
示例13: get_profile_url
function get_profile_url($html)
{
$profiles = array();
$keys = array();
$doc = new \DOMDocument();
$html = "<html><head> <title> test </title> </head> <body> " . $html . "</body> </html>";
@$doc->loadHTML($html);
$links = $doc->getElementsByTagName("a");
$length = $links->length;
if ($length <= 0) {
return $profiles;
}
for ($i = 0; $i < $length; $i++) {
//individual link node
$link = $links->item($i);
$href = $link->getAttribute("href");
//does the link href end in profile?
$pos = strrpos($href, "/");
if ($pos !== false) {
$token = substr($href, $pos + 1);
if (strcasecmp($token, "profile") == 0) {
$key = md5($href);
//avoid duplicates!
if (!in_array($key, $keys)) {
array_push($profiles, $href);
array_push($keys, $key);
}
}
}
}
return $profiles;
}
示例14: getExtension
public static function getExtension($host, $addr)
{
$BBC_IP2EXT_PATH = dirname(__FILE__) . '/../ip2ext/';
// generic extensions which need to be looked up first
$gen_ext = array("ac", "aero", "ag", "arpa", "as", "biz", "cc", "cd", "com", "coop", "cx", "edu", "eu", "gb", "gov", "gs", "info", "int", "la", "mil", "ms", "museum", "name", "net", "nu", "org", "pro", "sc", "st", "su", "tc", "tf", "tk", "tm", "to", "tv", "vu", "ws");
// hosts with reliable country extension don't need to be looked up
$cnt_ext = array("ad", "ae", "af", "ai", "al", "am", "an", "ao", "aq", "ar", "at", "au", "aw", "az", "ba", "bb", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bm", "bn", "bo", "br", "bs", "bt", "bv", "bw", "by", "bz", "ca", "cf", "cg", "ch", "ci", "ck", "cl", "cm", "cn", "co", "cr", "cs", "cu", "cv", "cy", "cz", "de", "dj", "dk", "dm", "do", "dz", "ec", "ee", "eg", "eh", "er", "es", "et", "fi", "fj", "fk", "fm", "fo", "fr", "ga", "gd", "ge", "gf", "gg", "gh", "gi", "gl", "gm", "gn", "gp", "gq", "gr", "gt", "gu", "gw", "gy", "hk", "hm", "hn", "hr", "ht", "hu", "id", "ie", "il", "im", "in", "io", "iq", "ir", "is", "it", "je", "jm", "jo", "jp", "ke", "kg", "kh", "ki", "km", "kn", "kp", "kr", "kw", "ky", "kz", "lb", "lc", "li", "lk", "lr", "ls", "lt", "lu", "lv", "ly", "ma", "mc", "md", "me", "mg", "mh", "mk", "ml", "mm", "mn", "mo", "mp", "mq", "mr", "mt", "mu", "mv", "mw", "mx", "my", "mz", "na", "nc", "ne", "nf", "ng", "ni", "nl", "no", "np", "nr", "nz", "om", "pa", "pe", "pf", "pg", "ph", "pk", "pl", "pm", "pn", "pr", "ps", "pt", "pw", "py", "qa", "re", "ro", "ru", "rs", "rw", "sa", "sb", "sd", "se", "sg", "sh", "si", "sj", "sk", "sl", "sm", "sn", "so", "sr", "sv", "sy", "sz", "td", "tg", "th", "tj", "tl", "tn", "tp", "tr", "tt", "tw", "tz", "ua", "ug", "uk", "um", "us", "uy", "uz", "va", "vc", "ve", "vg", "vi", "vn", "wf", "ye", "yt", "yu", "za", "zm", "zr", "zw");
$file = $BBC_IP2EXT_PATH . (substr($addr, 0, strpos($addr, ".")) . ".inc");
$ext = strtolower(substr($host, strrpos($host, ".") + 1));
// Don't look up if there's already a country extension
if (in_array($ext, $cnt_ext)) {
return $ext;
}
if (!is_readable($file)) {
return self::legacy_ext($ext, $gen_ext);
}
$long = ip2long($addr);
$long = sprintf("%u", $long);
$fp = fopen($file, "rb");
while (($range = fgetcsv($fp, 32, "|")) !== false) {
if ($long >= $range[1] && $long <= $range[1] + $range[2] - 1) {
// don't hose our stats if the database returns an unexpected extension
$db_ext = in_array($range[0], $cnt_ext) || in_array($range[0], $gen_ext) ? $range[0] : self::legacy_ext($ext, $gen_ext);
break;
}
}
fclose($fp);
return !empty($db_ext) ? $db_ext : self::legacy_ext($ext, $gen_ext);
}
示例15: getParentPath
function getParentPath()
{
if (($pos = strrpos($this->path, '/')) === FALSE) {
return "";
}
return substr($this->path, 0, $pos);
}