本文整理汇总了PHP中mb_strpos函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_strpos函数的具体用法?PHP mb_strpos怎么用?PHP mb_strpos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_strpos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanup
protected function cleanup()
{
parent::cleanup();
$start = mb_strpos($this->data, $this->partToken) + mb_strlen($this->partToken);
$end = mb_strrpos($this->data, $this->partToken);
$this->data = mb_substr($this->data, $start, $end - $start);
}
示例2: save_get_and_exit_reload
/**
* Définir un cookie avec le contenu de paramètres transmis en GET puis rappeler la page
*
* @param string $query_string éventuellement avec 'url_redirection' en dernier paramètre
* @return void
*/
public static function save_get_and_exit_reload( $query_string )
{
Cookie::definir( COOKIE_MEMOGET , $query_string , 300 /* 60*5 = 5 min */ );
$param_redir_pos = mb_strpos($query_string,'&url_redirection');
$param_sans_redir = ($param_redir_pos) ? mb_substr( $query_string , 0 , $param_redir_pos ) : $query_string ; // J'ai déjà eu un msg d'erreur car il n'aime pas les chaines trop longues + Pas la peine d'encombrer avec le paramètre de redirection qui sera retrouvé dans le cookie de toutes façons
exit_redirection(URL_BASE.$_SERVER['SCRIPT_NAME'].'?'.$param_sans_redir);
}
示例3: f_banners
function f_banners(&$text)
{
$phrase = 'БАННЕР';
if (mb_strpos($text, $phrase) === false) {
return true;
}
if (!cmsCore::getInstance()->isComponentEnable('banners')) {
return true;
}
$regex = '/{(' . $phrase . '=)\\s*(.*?)}/i';
$matches = array();
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
if (!$matches) {
return true;
}
cmsCore::loadModel('banners');
foreach ($matches as $elm) {
$elm[0] = str_replace('{', '', $elm[0]);
$elm[0] = str_replace('}', '', $elm[0]);
mb_parse_str($elm[0], $args);
$position = @$args[$phrase];
if ($position) {
$output = cms_model_banners::getBannerHTML($position);
} else {
$output = '';
}
$text = str_replace('{' . $phrase . '=' . $position . '}', $output, $text);
}
return true;
}
示例4: getOptions
/**
* Get plugin options.
*
* @since 151002 Improving multisite compat.
*
* @param bool $intersect Discard options not present in $this->default_options
* @param bool $refresh Force-pull options directly from get_site_option()
*
* @return array Plugin options.
*
* @note $intersect should be `false` when this method is called via a VS upgrade routine or during inital startup on when upgrading. See https://git.io/viGIK
*/
public function getOptions($intersect = true, $refresh = false)
{
if (!($options = $this->options) || $refresh) {
// If not defined yet, or if we're forcing a refresh via get_site_option()
if (!is_array($options = get_site_option(GLOBAL_NS . '_options'))) {
$options = [];
// Force array.
}
if (!$options && is_array($zencache_options = get_site_option('zencache_options'))) {
$options = $zencache_options;
// Old ZenCache options.
$options['crons_setup'] = $this->default_options['crons_setup'];
$options['latest_lite_version'] = $this->default_options['latest_lite_version'];
$options['latest_pro_version'] = $this->default_options['latest_pro_version'];
}
}
$this->options = array_merge($this->default_options, $options);
$this->options = $this->applyWpFilters(GLOBAL_NS . '_options', $this->options);
$this->options = $intersect ? array_intersect_key($this->options, $this->default_options) : $this->options;
foreach ($this->options as $_key => &$_value) {
$_value = trim((string) $_value);
// Force strings.
}
unset($_key, $_value);
// Housekeeping.
$this->options['base_dir'] = trim($this->options['base_dir'], '\\/' . " \t\n\r\v");
if (!$this->options['base_dir'] || mb_strpos(basename($this->options['base_dir']), 'wp-') === 0) {
$this->options['base_dir'] = $this->default_options['base_dir'];
}
return $this->options;
// Plugin options.
}
示例5: f_includes
function f_includes(&$text){
$phrase = 'ФАЙЛ';
if (mb_strpos($text, $phrase) === false){
return true;
}
$regex = '/{('.$phrase.'=)\s*(.*?)}/i';
$matches = array();
preg_match_all( $regex, $text, $matches, PREG_SET_ORDER );
foreach ($matches as $elm) {
$elm[0] = str_replace('{', '', $elm[0]);
$elm[0] = str_replace('}', '', $elm[0]);
mb_parse_str( $elm[0], $args );
$file=@$args[$phrase];
if ($file){
$output = getLink($file);
} else { $output = ''; }
$text = str_replace('{'.$phrase.'='.$file.'}', $output, $text );
}
return true;
}
示例6: utf8_strpos
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strpos
* Find position of first occurrence of a string
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer offset in characters (from left)
* @return mixed integer position or FALSE on failure
* @package utf8
* @subpackage strings
*/
function utf8_strpos($str, $search, $offset = FALSE){
if ( $offset === FALSE ) {
return mb_strpos($str, $search);
} else {
return mb_strpos($str, $search, $offset);
}
}
示例7: validateIdentical
protected function validateIdentical($input)
{
if (is_array($input)) {
return reset($input) === $this->startValue;
}
return 0 === mb_strpos($input, $this->startValue, 0, mb_detect_encoding($input));
}
示例8: load
/** Last inn siden (kalles til slutten av scriptet for å hente themet */
public function load()
{
$this->content .= ob_get_contents();
@ob_clean();
// load through twig template?
$templates = array('guest_simple' => 'templates/guest/simple', 'guest' => 'templates/guest/wide', 'node' => 'templates/guest/node', 'doc' => 'templates/doc');
if (isset($templates[$this->theme_file])) {
$template = $templates[$this->theme_file];
\Kofradia\View::forgeTwig($template);
$response = new \Kofradia\Response();
$response->setContents(\Kofradia\View::forgeTwig($template));
$response->output();
die;
}
global $_base;
$_base->dt("page_load_pre");
// temafilen
$theme_file = PATH_PUBLIC . "/themes/" . $this->theme . "/" . $this->theme_file . ".php";
// finnes ikke temafilen?
if (!file_exists($theme_file)) {
throw new HSException("Fant ikke temafilen <b>{$this->theme_file}.php</b> for temaet <b>{$this->theme}</b>.");
}
if (mb_strpos($this->content, '<boxes />') === false) {
$this->content = '<boxes />' . $this->content;
}
// hent temafilen
require $theme_file;
// hent full html kode som ble generert
$content = ob_get_contents();
@ob_clean();
echo $this->postParse($content);
die;
}
示例9: smarty_function_eF_template_printMessageBlock
/**
* prints a block
*
*/
function smarty_function_eF_template_printMessageBlock($params, &$smarty)
{
!isset($params['type']) || !$params['type'] ? $params['type'] = 'failure' : null;
in_array($params['type'], array('success', 'failure')) or $params['type'] = 'failure';
if ($params['type'] == 'success') {
$messageImage = '<img src = "images/32x32/success.png" alt = "' . _SUCCESS . '" title = "' . _SUCCESS . '">';
} else {
$messageImage = '<img src = "images/32x32/warning.png" alt = "' . _FAILURE . '" title = "' . _FAILURE . '">';
}
$link = mb_substr($params['content'], mb_strpos($params['content'], ' <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'));
$message = mb_substr($params['content'], 0, mb_strpos($params['content'], ' <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'));
$params['content'] = strip_tags($message) . $link;
if (mb_strlen($params['content']) > 1000) {
$prefix = mb_substr($params['content'], 0, 1000);
$suffix = mb_substr($params['content'], mb_strlen($params['content']) - 300, mb_strlen($params['content']));
$infix = mb_substr($params['content'], 1001, mb_strlen($params['content']) - mb_strlen($prefix) - mb_strlen($suffix));
$params['content'] = $prefix . '<a href = "javascript:void(0)" onclick = "this.style.display = \'none\';Element.extend(this).next().show()"><br>[...]<br></a><span style = "display:none">' . $infix . '</span>' . $suffix;
}
$str .= '
<div class = "block" id = "messageBlock">
<div class = "blockContents messageContents">
<table class = "messageBlock">
<tr><td>' . $messageImage . '</td>
<td class = "' . strip_tags($params['type']) . 'Block">' . $params['content'] . '</td>
<td><img src = "images/32x32/close.png" alt = "' . _CLOSE . '" title = "' . _CLOSE . '" onclick = "window.Effect ? new Effect.Fade($(\'messageBlock\')) : document.getElementById(\'messageBlock\').style.display = \'none\';"></td></tr>
</table>
</div>
</div>';
return $str;
}
示例10: _renderFilters
protected function _renderFilters()
{
/* @var $core Mana_Core_Helper_Data */
$core = Mage::helper(strtolower('Mana_Core'));
$items = array();
foreach ($this->_items as $key => $item) {
$conforms = true;
foreach ($this->_mFilters as $filter) {
if ($filter['attribute'] == 'entity_type_id') {
continue;
}
$method = 'get' . $core->pascalCased($filter['attribute']);
$value = $item->{$method}();
if (isset($filter['condition']['like'])) {
$value = mb_convert_case($value, MB_CASE_UPPER, "UTF-8");
$test = mb_convert_case($filter['condition']['like'], MB_CASE_UPPER, "UTF-8");
if (mb_strpos($value, mb_substr($test, 1, mb_strlen($test) - 2)) === false) {
$conforms = false;
break;
}
} elseif (isset($filter['condition']['eq'])) {
$test = $filter['condition']['eq'];
if ($value != $test) {
$conforms = false;
break;
}
}
}
if ($conforms) {
$items[$key] = $item;
}
}
$this->_items = $items;
return $this;
}
示例11: getConfigFile
/**
* Creates config file
*
* @param ConfigFile $cf Config file instance
*
* @return string
*/
public static function getConfigFile(ConfigFile $cf)
{
$crlf = isset($_SESSION['eol']) && $_SESSION['eol'] == 'win' ? "\r\n" : "\n";
$conf = $cf->getConfig();
// header
$ret = '<?php' . $crlf . '/*' . $crlf . ' * Generated configuration file' . $crlf . ' * Generated by: phpMyAdmin ' . $GLOBALS['PMA_Config']->get('PMA_VERSION') . ' setup script' . $crlf . ' * Date: ' . date(DATE_RFC1123) . $crlf . ' */' . $crlf . $crlf;
//servers
if (!empty($conf['Servers'])) {
$ret .= self::getServerPart($cf, $crlf, $conf['Servers']);
unset($conf['Servers']);
}
// other settings
$persistKeys = $cf->getPersistKeysMap();
foreach ($conf as $k => $v) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= self::_getVarExport($k, $v, $crlf);
if (isset($persistKeys[$k])) {
unset($persistKeys[$k]);
}
}
// keep 1d array keys which are present in $persist_keys (config.values.php)
foreach (array_keys($persistKeys) as $k) {
if (mb_strpos($k, '/') === false) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= self::_getVarExport($k, $cf->getDefault($k), $crlf);
}
}
$ret .= '?' . '>';
return $ret;
}
示例12: getSchemeHTML
public function getSchemeHTML()
{
$template = cmsTemplate::getInstance();
$scheme_html = $template->getSchemeHTML();
if (!$scheme_html) {
return false;
}
if (!preg_match_all('/{([a-zA-Z0-9:_\\-]+)}/u', $scheme_html, $matches)) {
return false;
}
$blocks = $matches[1];
foreach ($blocks as $block) {
list($type, $value) = explode(':', $block);
if ($type == 'position') {
$replace_html = '<ul class="position" rel="' . $value . '" id="pos-' . $value . '"></ul>';
}
if ($type == 'block') {
if (mb_strpos($value, 'LANG_') === 0) {
$value = constant($value);
}
$replace_html = '<div class="block"><span>' . $value . '</span></div>';
}
if ($type == 'cell') {
if (mb_strpos($value, 'LANG_') === 0) {
$value = constant($value);
}
$replace_html = '<div class="cell"><span>' . $value . '</span></div>';
}
$scheme_html = str_replace("{{$block}}", $replace_html, $scheme_html);
}
return $scheme_html;
}
示例13: strpos
private function strpos($haystack, $needle, $offset = 0)
{
# echo "n: ->$needle<-, o: $offset len: ".strlen($haystack)." mblen: ".mb_strlen($haystack, mb_detect_encoding($haystack));
# echo " enc: ".mb_detect_encoding($haystack)."\n";
# echo "hs: $haystack, n: $needle, o: $offset\n";
return mb_strpos($haystack, $needle, $offset, mb_detect_encoding($haystack));
}
示例14: set
/**
* Сохраняем сообщение об ошибке
* @return Errors объект
*/
function set($errCodeName, $sErrorKey = null, $bSuccessfull = false, $sParam1 = null, $sParam2 = null, $sParam3 = null)
{
if ($errCodeName == 1) {
$this->sm->assign('errno', 1);
}
if ($bSuccessfull) {
$this->isSuccessfull = true;
}
if (is_string($errCodeName) && mb_strpos($errCodeName, ':') !== FALSE) {
list($type, $param) = explode(':', $errCodeName);
if (isset($this->lang['err_' . $type])) {
$sMessage = $this->lang['err_' . $type];
$sParam1 = '<b>' . mb_strtolower($this->getMessage($param)) . '</b>';
} else {
$sMessage = $this->getMessage($errCodeName);
}
} else {
$sMessage = $this->getMessage($errCodeName);
}
$sMessage = str_replace(array('##$1##', '##$2##', '##$3##'), array($sParam1, $sParam2, $sParam3), $sMessage);
if (isset($sErrorKey)) {
$this->aErrors[$sErrorKey] = array('successfull' => $bSuccessfull, 'errno' => $errCodeName, 'msg' => $sMessage);
} else {
$this->aErrors[] = array('successfull' => $bSuccessfull, 'errno' => $errCodeName, 'msg' => $sMessage);
}
return $this;
}
示例15: _includeFiles
/**
* Returns HTML code to include javascript file.
*
* @param array $files The list of js file to include
*
* @return string HTML code for javascript inclusion.
*/
private function _includeFiles($files)
{
$first_dynamic_scripts = "";
$dynamic_scripts = "";
$scripts = array();
foreach ($files as $value) {
if (mb_strpos($value['filename'], "?") !== false) {
if ($value['before_statics'] === true) {
$first_dynamic_scripts .= "<script type='text/javascript' src='js/" . $value['filename'] . "'></script>";
} else {
$dynamic_scripts .= "<script type='text/javascript' src='js/" . $value['filename'] . "'></script>";
}
continue;
}
$include = true;
if ($value['conditional_ie'] !== false && PMA_USR_BROWSER_AGENT === 'IE') {
if ($value['conditional_ie'] === true) {
$include = true;
} else {
if ($value['conditional_ie'] == PMA_USR_BROWSER_VER) {
$include = true;
} else {
$include = false;
}
}
}
if ($include) {
$scripts[] = "scripts[]=" . $value['filename'];
}
}
$separator = PMA_URL_getArgSeparator();
$url = 'js/get_scripts.js.php' . PMA_URL_getCommon(array(), 'none') . $separator . implode($separator, $scripts);
$static_scripts = sprintf('<script type="text/javascript" src="%s"></script>', htmlspecialchars($url));
return $first_dynamic_scripts . $static_scripts . $dynamic_scripts;
}