/** * Back compat. with `ZENCACHE_` constants. * * @since 150422 Rewrite. */ public static function zenCacheConstants() { $_global_ns = mb_strtoupper(GLOBAL_NS); if (!($constants = get_defined_constants(true)) || empty($constants['user'])) { return; // Nothing to do; i.e. no user-defined constants. } foreach ($constants['user'] as $_constant => $_value) { if (mb_stripos($_constant, 'ZENCACHE_') !== 0) { continue; // Nothing to do here. } if (!($_constant_sub_name = mb_substr($_constant, 9))) { continue; // Nothing to do here. } if (!defined($_global_ns . '_' . $_constant_sub_name)) { define($_global_ns . '_' . $_constant_sub_name, $_value); } } if (isset($_SERVER['ZENCACHE_ALLOWED']) && !isset($_SERVER[$_global_ns . '_ALLOWED'])) { $_SERVER[$_global_ns . '_ALLOWED'] = $_SERVER['ZENCACHE_ALLOWED']; } unset($_constant, $_value, $_global_ns); // Housekeeping. }
/** * @param $haystack * @param $needle * @param bool $caseSensitive * @return bool */ private function contains($haystack, $needle, $caseSensitive = true) { if ($caseSensitive) { return mb_strpos($haystack, $needle, 0, mb_internal_encoding()) !== false; } return mb_stripos($haystack, $needle, 0, mb_internal_encoding()) !== false; }
protected function parse($st) { if (preg_replace_callback('#GeoPoint\\(.{1,200}АЗС.+?\\)\\);#su', function ($x) { if (!preg_match('#' . '(?<lon>[\\d\\.]+),(?<lat>[\\d\\.]+)' . '.+?(?<operator>(Партнер )?О[ОА]О .+?), АЗС' . '.+?№\\s*(?<ref>[\\dА-Я/-]+)' . '.+?Адрес: (?<_addr>.+?)<' . '(?<text>.+)' . "#su", $x[0], $obj)) { return; } // организация $op = $obj['operator']; $op = preg_replace('/Партнер.+?»/u', '', $op); $op = str_replace('«', '"', $op); $op = str_replace('»', '"', $op); $obj['operator'] = trim($op); // виды топлива $obj["fuel:octane_98"] = mb_stripos($obj['text'], 'Аи-98') ? 'yes' : ''; $obj["fuel:octane_95"] = mb_stripos($obj['text'], 'Аи-95') ? 'yes' : ''; $obj["fuel:octane_92"] = mb_stripos($obj['text'], 'Аи-92') ? 'yes' : ''; $obj["fuel:octane_80"] = mb_stripos($obj['text'], 'Аи-80') ? 'yes' : ''; $obj["fuel:lpg"] = mb_strpos($obj['text'], 'Газ') ? 'yes' : ''; $obj["fuel:diesel"] = mb_strpos($obj['text'], 'Дизель') ? 'yes' : ''; // карты $obj['payment:cards'] = mb_strpos($obj['text'], 'банковским') ? 'yes' : ''; $obj['payment:fuel_cards'] = mb_strpos($obj['text'], 'топливным') ? 'yes' : ''; $this->addObject($this->makeObject($obj)); }, $st)) { } }
/** * Balance HTML markup/tags. * * @since 150424 Initial release. * * @param mixed $value Any input value. * * @throws Exception If missing DOM extension. * * @return string|array|object Balanced value (i.e., HTML markup). * * @internal This works with HTML fragments only. No on a full document. * i.e., If the input contains `</html>` or `</body>` it is left as-is. */ public function tags($value) { if (is_array($value) || is_object($value)) { foreach ($value as $_key => &$_value) { $_value = $this->tags($_value); } // unset($_key, $_value); return $value; } if (!($string = (string) $value)) { return $string; // Nothing to do. } elseif (mb_stripos($string, '</html>') !== false) { return $string; // Not a fragment; leave as-is. } elseif (mb_stripos($string, '</body>') !== false) { return $string; // Not a fragment; leave as-is. } $html = '<html>' . ' <head>' . ' <meta charset="utf-8">' . ' <meta http-equiv="content-type" content="text/html; charset=utf-8">' . ' </head>' . ' <body>' . $string . '</body>' . '</html>'; $Dom = new \DOMDocument(); $Dom->loadHTML($html); $string = $Dom->saveHTML($Dom->getElementsByTagName('body')->item(0)); $string = preg_replace(['/\\<body\\>/ui', '/\\<\\/body\\>/ui'], '', $string); $string = $this->c::htmlTrim($string); return $string; }
public function serviceLoginForm($sParams = '', $sForceRelocate = '') { if (isLogged()) { return false; } // get all auth types $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`'); // define additional auth types if ($aAuthTypes) { $aAddInputEl[''] = _t('_Basic'); // procces all additional menu's items foreach ($aAuthTypes as $iKey => $aItems) { $aAddInputEl[$aItems['Link']] = _t($aItems['Title']); } $aAuthTypes = array('type' => 'select', 'caption' => _t('_Auth type'), 'values' => $aAddInputEl, 'value' => '', 'attrs' => array('onchange' => 'if (this.value) { location.href = "' . BX_DOL_URL_ROOT . '" + this.value }')); } else { $aAuthTypes = array('type' => 'hidden'); } $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); $sCustomHtmlBefore = ''; $sCustomHtmlAfter = ''; bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes)); if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT)) { $oForm->aInputs['relocate']['value'] = $sForceRelocate; } elseif ('homepage' == $sForceRelocate) { $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT; } $sFormCode = $oForm->getCode(); $sJoinText = ''; if (strpos($sParams, 'no_join_text') === false) { $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div>' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>'; } BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js')); return $sCustomHtmlBefore . $sFormCode . $sCustomHtmlAfter . $sJoinText; }
/** * @covers Patchwork\PHP\Override\Mbstring::mb_strpos * @covers Patchwork\PHP\Override\Mbstring::mb_stripos * @covers Patchwork\PHP\Override\Mbstring::mb_strrpos * @covers Patchwork\PHP\Override\Mbstring::mb_strripos */ function testmb_strpos() { $this->assertSame(false, @mb_strpos('abc', '')); $this->assertSame(false, @mb_strpos('abc', 'a', -1)); $this->assertSame(false, mb_strpos('abc', 'd')); $this->assertSame(false, mb_strpos('abc', 'a', 3)); $this->assertSame(1, mb_strpos('한국어', '국')); $this->assertSame(3, mb_stripos('DÉJÀ', 'à')); $this->assertSame(false, mb_strrpos('한국어', '')); $this->assertSame(1, mb_strrpos('한국어', '국')); $this->assertSame(3, mb_strripos('DÉJÀ', 'à')); $this->assertSame(1, mb_stripos('aςσb', 'ΣΣ')); $this->assertSame(1, mb_strripos('aςσb', 'ΣΣ')); $this->assertSame(false, @p::mb_strpos('abc', '')); $this->assertSame(false, @p::mb_strpos('abc', 'a', -1)); $this->assertSame(false, p::mb_strpos('abc', 'd')); $this->assertSame(false, p::mb_strpos('abc', 'a', 3)); $this->assertSame(1, p::mb_strpos('한국어', '국')); $this->assertSame(3, p::mb_stripos('DÉJÀ', 'à')); $this->assertSame(false, p::mb_strrpos('한국어', '')); $this->assertSame(1, p::mb_strrpos('한국어', '국')); $this->assertSame(3, p::mb_strripos('DÉJÀ', 'à')); $this->assertSame(1, p::mb_stripos('aςσb', 'ΣΣ')); $this->assertSame(1, p::mb_strripos('aςσb', 'ΣΣ')); }
function test_encoding($path) { static $ur_exclude = ['lib2/html2text.class.php', 'lib2/imagebmp.inc.php', 'lib2/Net/IDNA2']; $contents = file_get_contents($path, false, null, 0, 2048); $ur = stripos($contents, "Unicode Reminder"); if ($ur) { if (mb_trim(mb_substr($contents, $ur + 17, 2)) != "メモ") { $ur = mb_stripos($contents, "Unicode Reminder"); if (mb_trim(mb_substr($contents, $ur + 17, 2)) != "メモ") { echo "Bad Unicode Reminder found in {$path}: " . mb_trim(mb_substr($contents, $ur + 17, 2)) . "\n"; } else { echo "Unexpected non-ASCII chars (BOMs?) in header of {$path}\n"; } } } else { $ok = false; foreach ($ur_exclude as $exclude) { if (mb_strpos($path, $exclude) === 0) { $ok = true; } } if (!$ok) { echo "No Unicode Reminder found in {$path}\n"; } } }
/** * @return void */ public function sanitizeOutput() { $t = $this; $encrypt_prefix = $this->security_config->get('encrypt_form_name_with_prefix'); $new_content = preg_replace_callback('@(?<=\\<form[^>]*>)(.+?)(?=</form>)@is', function ($match) use($t, $encrypt_prefix) { $form_inner_html = preg_replace_callback('@(?<=\\<[^>]+name\\s*=\\s*["\']?)([^\'"]+)(?=["\' ])@is', function ($sub_match) use($t, $encrypt_prefix) { if (mb_stripos($sub_match[1], $encrypt_prefix) === 0) { return $encrypt_prefix . $t->simple_encrypt->encrypt(str_replace($encrypt_prefix, '', $sub_match[1])); } else { return $sub_match[1]; } }, $match[1]); foreach ((array) $t->html_output->getForm() as $k => $v) { if (!$v) { continue; } if (mb_stripos($k, $encrypt_prefix) === 0) { $k = $encrypt_prefix . $t->simple_encrypt->encrypt(str_replace($encrypt_prefix, '', $k)); } $form_inner_html .= "<input name=\"{$k}\" value=\"{$v}\" type=\"hidden\"/>"; } return $form_inner_html; }, $t->html_output->get(HtmlOutput::CONTENT)); $t->html_output->set(HtmlOutput::CONTENT, $new_content); }
public function __construct(HttpUrl $claimedId, HttpClient $httpClient) { $this->claimedId = $claimedId->makeComparable(); if (!$claimedId->isValid()) { throw new OpenIdException('invalid claimed id'); } $this->httpClient = $httpClient; $response = $httpClient->send(HttpRequest::create()->setHeaderVar('Accept', self::HEADER_ACCEPT)->setMethod(HttpMethod::get())->setUrl($claimedId)); if ($response->getStatus()->getId() != 200) { throw new OpenIdException('can\'t fetch document'); } $contentType = $response->getHeader('content-type'); if (mb_stripos($contentType, self::HEADER_CONT_TYPE) !== false) { $this->parseXRDS($response->getBody()); } elseif ($response->hasHeader(self::HEADER_XRDS_LOCATION)) { $this->loadXRDS($response->getHeader(self::HEADER_XRDS_LOCATION)); } else { $this->parseHTML($response->getBody()); } if (!$this->server || !$this->server->isValid()) { throw new OpenIdException('bad server'); } else { $this->server->makeComparable(); } if (!$this->realId) { $this->realId = $claimedId; } elseif (!$this->realId->isValid()) { throw new OpenIdException('bad delegate'); } else { $this->realId->makeComparable(); } }
public function __construct(BASE_CLASS_WidgetParameter $paramObject) { parent::__construct(); $text = OW::getLanguage()->text('base', 'welcome_widget_content'); $text = str_replace('</li>', "</li>\n", $text); //if the tags are written in a line it is necessary to make a compulsory hyphenation? $photoKey = str_replace('{$key}', self::KEY_PHOTO_UPLOAD, self::PATTERN); $avatarKey = str_replace('{$key}', self::KEY_CHANGE_AVATAR, self::PATTERN); if (OW::getPluginManager()->isPluginActive('photo') && mb_stripos($text, self::KEY_PHOTO_UPLOAD) !== false) { $label = OW::getLanguage()->text('photo', 'upload_photos'); $js = OW::getEventManager()->call('photo.getAddPhotoURL'); $langLabel = $this->getLangLabel($photoKey, $text, self::KEY_PHOTO_UPLOAD); if ($langLabel != NULL) { $label = $langLabel; } $text = preg_replace($photoKey, '<li><a href="javascript://" onclick="' . $js . '();">' . $label . '</a></li>', $text); } else { $text = preg_replace($photoKey, '', $text); } if (mb_stripos($text, self::KEY_CHANGE_AVATAR) !== false) { $label = OW::getLanguage()->text('base', 'avatar_change'); $js = ' $("#welcomeWinget_loadAvatarChangeCmp").click(function(){' . 'document.avatarFloatBox = OW.ajaxFloatBox("BASE_CMP_AvatarChange", [], {width: 749, title: ' . json_encode($label) . '});' . '});'; OW::getDocument()->addOnloadScript($js); $langLabel = $this->getLangLabel($avatarKey, $text, self::KEY_CHANGE_AVATAR); if ($langLabel != NULL) { $label = $langLabel; } $text = preg_replace($avatarKey, '<li><a id="welcomeWinget_loadAvatarChangeCmp" href="javascript://">' . $label . '</a></li>', $text); } else { $text = preg_replace($avatarKey, '', $text); } $this->assign('text', $text); }
function test_encoding($path) { static $ur_exclude = array('lang/de/ocstyle/search1/search.result.caches', 'lib2/b2evo-captcha', 'lib2/HTMLPurifier', 'lib2/html2text.class.php', 'lib2/imagebmp.inc.php', 'lib2/Net/IDNA2', 'lib2/smarty'); $contents = file_get_contents($path, false, null, 0, 2048); $ur = stripos($contents, "Unicode Reminder"); if ($ur) { if (mb_trim(mb_substr($contents, $ur + 17, 2)) != "メモ") { $ur = mb_stripos($contents, "Unicode Reminder"); if (mb_trim(mb_substr($contents, $ur + 17, 2)) != "メモ") { echo "Bad Unicode Reminder found in {$path}: " . mb_trim(mb_substr($contents, $ur + 17, 2)) . "\n"; } else { echo "Unexpected non-ASCII chars (BOMs?) in header of {$path}\n"; } } } else { $ok = false; foreach ($ur_exclude as $exclude) { if (mb_strpos($path, $exclude) === 0) { $ok = true; } } if (!$ok) { echo "No Unicode Reminder found in {$path}\n"; } } }
protected function validateEquals($input) { if (is_array($input)) { return in_array($this->containsValue, $input); } return false !== mb_stripos($input, $this->containsValue, 0, mb_detect_encoding($input)); }
public function supportsExtension($ext) { return (new \Yasca\Core\IteratorBuilder())->from($this->getSupportedFileTypes())->where(static function ($supportedExt) use($ext) { //PHP 5.4 does not have a multibyte-safe case insensitive compare return \mb_strlen($supportedExt) === \mb_strlen($ext) && \mb_stripos($supportedExt, $ext) === 0; })->any(); }
/** * find needle in between html tags and add highlighting * * @param string $needle string to find * @param string $haystack html text to find needle in * @param string $pre insert before needle * @param string $post insert after needle * * @return mixed return from preg_replace_callback() */ protected static function splitOnTag($needle, $haystack, $pre, $post) { $encoding = static::ENCODING; return preg_replace_callback('#((?:(?!<[/a-z]).)*)([^>]*>|$)#si', function ($capture) use($needle, $pre, $post, $encoding) { $haystack = $capture[1]; if (function_exists('mb_substr')) { $p1 = mb_stripos($haystack, $needle, 0, $encoding); $l1 = mb_strlen($needle, $encoding); $ret = ''; while ($p1 !== false) { $ret .= mb_substr($haystack, 0, $p1, $encoding) . $pre . mb_substr($haystack, $p1, $l1, $encoding) . $post; $haystack = mb_substr($haystack, $p1 + $l1, null, $encoding); $p1 = mb_stripos($haystack, $needle, 0, $encoding); } } else { $p1 = stripos($haystack, $needle); $l1 = strlen($needle); $ret = ''; while ($p1 !== false) { $ret .= substr($haystack, 0, $p1) . $pre . substr($haystack, $p1, $l1) . $post; $haystack = substr($haystack, $p1 + $l1); $p1 = stripos($haystack, $needle); } } $ret .= $haystack . $capture[2]; return $ret; }, $haystack); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $referer = $request->server->get('referer'); // Referer is not provided, we continue if (is_null($referer) or env('APP_ENV', 'production') !== 'production') { return $next($request); } // Handle the dictionnary. // @todo Refactor that $dir = realpath(dirname(__FILE__) . '/../../../../../') . '/'; $path = $dir . 'spammers.json'; $file = file_get_contents($path); // Dictionnary is not readable, abort. if (empty($file)) { abort(500, 'Unable to read spammers.json'); } $dictionary = json_decode($file); // Parse the referer $url = new Parser(new PublicSuffixList([])); $host = $url->parseHost($referer)->host; // Compare dictionary against the referer... $search = Arr::where($dictionary, function ($key, $value) use($host) { return mb_stripos($host, $value) !== false; }); // ...and check for results if (count($search) > 0) { abort(500, 'Spammers protection'); } // No spam, we can continue :) return $next($request); }
public function serviceLoginForm($sParams = '', $sForceRelocate = '') { if (isLogged()) { return false; } // get all auth types $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`'); $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); $sCustomHtmlBefore = ''; $sCustomHtmlAfter = ''; bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes)); if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT)) { $oForm->aInputs['relocate']['value'] = $sForceRelocate; } elseif ('homepage' == $sForceRelocate) { $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT; } $sFormCode = $oForm->getCode(); $sJoinText = ''; if (strpos($sParams, 'no_join_text') === false) { $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div class="bx-def-font-align-center">' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>'; } BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js')); $sAuth = $this->serviceMemberAuthCode($aAuthTypes); return $sCustomHtmlBefore . $sAuth . $sFormCode . $sCustomHtmlAfter . $sJoinText; }
/** * @param string $name * @throws Exception * @return OrtGeo|null */ public static function getOrCreate($name) { /** @var null|OrtGeo */ $ort = OrtGeo::model()->findByAttributes(["ort" => $name]); if ($ort) { return $ort; } $data = RISGeo::addressToGeo("Deutschland", "", "München", $name); if (($data === false || $data["lat"] == 0) && mb_strpos($name, "-") !== false) { $data = RISGeo::addressToGeo("Deutschland", "", "München", str_replace("-", "", $name)); } if (($data === false || $data["lat"] == 0) && mb_stripos($name, "Str.") !== false) { $data = RISGeo::addressToGeo("Deutschland", "", "München", str_ireplace("Str.", "Straße", $name)); } if ($data["lat"] <= 0 || $data["lon"] <= 0) { return null; } $ort = new OrtGeo(); $ort->ort = $name; $ort->lat = $data["lat"]; $ort->lon = $data["lon"]; $ort->setzeBA(); $ort->source = "auto"; $ort->to_hide = 0; $ort->to_hide_kommentar = ""; $ort->datum = new CDbExpression('NOW()'); if (!$ort->save()) { RISTools::send_email(Yii::app()->params['adminEmail'], "OrtGeo:getOrCreate Error", print_r($ort->getErrors(), true), null, "system"); throw new Exception("Fehler beim Speichern: Geo"); } return $ort; }
protected function validateEquals($input) { if (is_array($this->haystack)) { return in_array($input, $this->haystack); } return false !== mb_stripos($this->haystack, $input, 0, mb_detect_encoding($input)); }
protected function replaceFirstOccurance($find, $replace, $string, $after_offset = 0) { $length_diff = mb_strlen($replace) - mb_strlen($find); $offset_of_find_match = mb_stripos($string, $find, $after_offset); if ($offset_of_find_match !== false) { // Prevent Infinet loops when working with $find => localhost:8000, $replace => localhost:80001 $offset_of_replace_match = mb_stripos($string, $replace, $after_offset); if ($offset_of_replace_match == $offset_of_find_match) { return $this->replaceFirstOccurance($find, $replace, $string, $offset_of_replace_match + mb_strlen($replace)); } $characters = $this->getCharacters($string); // Substring Find & Replace $replacement = $this->getCharacters($replace); $length = mb_strlen($find); array_splice($characters, $offset_of_find_match, $length, $replacement); // Serialized string definition's length $offset_of_def = $this->getStringDefinitionOffset($characters, $offset_of_find_match); $offset_of_length = $offset_of_def + 2; preg_match('/s:([0-9]+)/', $this->getStringDefinition($characters, $offset_of_def), $matches); $old_length = (int) $matches[1]; $new_length = $old_length + $length_diff; $replacement = $this->getCharacters((string) $new_length); $length = mb_strlen((string) $old_length); array_splice($characters, $offset_of_length, $length, $replacement); $string = implode("", $characters); } return $string; }
protected function _normalizeHeadSpaces($srcNodeContent, $trgNodeContent) { $_srcNodeContent = $srcNodeContent; $_trgNodeContent = $trgNodeContent; //not Used $srcHasHeadNBSP = $this->_hasHeadNBSP($srcNodeContent); $trgHasHeadNBSP = $this->_hasHeadNBSP($trgNodeContent); //normalize spaces and check presence $srcNodeContent = $this->_nbspToSpace($srcNodeContent); $trgNodeContent = $this->_nbspToSpace($trgNodeContent); $headSrcWhiteSpaces = mb_stripos($srcNodeContent, " ", 0, 'utf-8'); $headTrgWhiteSpaces = mb_stripos($trgNodeContent, " ", 0, 'utf-8'); //normalize the target first space according to the source type if ($srcHasHeadNBSP != $trgHasHeadNBSP && $srcHasHeadNBSP) { $_trgNodeContent = preg_replace('/^\\x{20}{1}/u', Utils::unicode2chr(0xa0), $_trgNodeContent); } elseif ($srcHasHeadNBSP != $trgHasHeadNBSP && $trgHasHeadNBSP) { $_trgNodeContent = preg_replace('/^\\x{a0}{1}/u', Utils::unicode2chr(0x20), $_trgNodeContent); } if ($headSrcWhiteSpaces === 0 && $headSrcWhiteSpaces !== $headTrgWhiteSpaces) { $_trgNodeContent = " " . $_trgNodeContent; } elseif ($headSrcWhiteSpaces !== 0 && $headTrgWhiteSpaces === 0 && $headSrcWhiteSpaces !== $headTrgWhiteSpaces) { $_trgNodeContent = mb_substr($_trgNodeContent, 1, mb_strlen($_trgNodeContent)); } return $_trgNodeContent; }
/** * Sets a cookie. * * @param string $name Name of the cookie. * @param string $value Cookie value (empty to delete). * @param int|null $expires_after Time (in seconds) this cookie should last for. * @param string|null $domain Domain name to set the cookie for. * @param string|null $path Path to set the cookie for. * @param string $key Encryption key. */ public function set(string $name, string $value, int $expires_after = null, string $domain = null, string $path = null, string $key = '') { if (!$name) { // Must have a cookie name! throw $this->c::issue('Missing cookie name.'); } if (!$key && !($key = $this->App->Config->©cookies['©encryption_key'])) { throw $this->c::issue('Missing cookie encryption key.'); } if (isset($value[0])) { // If not empty. $value = $this->c::encrypt($value, $key); } $expires_after = max(0, $expires_after ?? 31556926); $expires = $expires_after ? time() + $expires_after : 0; $domain = $domain ?? $this->c::currentHost(true); $domain = $domain === 'root' ? '.' . $this->c::currentRootHost(true) : $domain; $path = $path ?? '/'; // Default path covers the entire site. if (headers_sent()) { throw $this->c::issue('Headers already sent.'); } setcookie($name, $value, $expires, $path, $domain); if (mb_stripos($name, '_test_') === false) { $_COOKIE[$name] = $value; } }
protected function validateEquals($input) { if (is_array($input)) { return reset($input) == $this->startValue; } return 0 === mb_stripos($input, $this->startValue, 0, mb_detect_encoding($input)); }
protected function parse($st) { if (preg_match_all('/options = {.+?group\\.add/s', $st, $m, PREG_SET_ORDER)) { foreach ($m as $item) { if (preg_match('#' . '(?<lon>[\\d\\.]+), (?<lat>[\\d\\.]+)' . '.+?Адрес</b><br>(?<_addr>[^<]+)' . '(.+?работы</b><br>(?<hours>.+?)<)?' . '.+?s(?<type>\\d)_group.add' . '#us', $item[0], $obj)) { $is = mb_stripos($obj['_addr'], 'Москва') || mb_stripos($obj['_addr'], 'Зеленоград'); if ($this->code == 'MOW' && !$is) { continue; } if ($this->code == 'MOS' && $is) { continue; } $is = mb_stripos($obj['_addr'], 'Петербург'); if ($this->code == 'SPE' && !$is) { continue; } if ($this->code == 'LEN' && $is) { continue; } // 1 - банкомат // 2 - банкомат cash in // 6 - банкомат 24/7 // 5 - банк if ($obj['type'] != 5) { continue; } $hours = $obj['hours']; $obj['opening_hours'] = $this->time($hours); $this->addObject($this->makeObject($obj)); } } } }
/** * @param $q * @return \yii\data\DataProviderInterface */ public function getDataProvider($q) { $res = []; $words = array_filter(explode(' ', $q)); if ($this->data) { foreach ($this->data as $item) { if (!$this->searchAttributes) { $this->searchAttributes = []; foreach ($item as $key => $value) { if (is_string($value)) { $this->searchAttributes[] = $key; } } } //All words must be found $found = false; foreach ($this->searchAttributes as $attribute) { $attributeFound = true; foreach ($words as $word) { if (mb_stripos($item[$attribute], $word, null, 'utf8') === false) { $attributeFound = false; //break; } } $found = $found || $attributeFound; } if ($found) { $res[] = $item; } } } $dataProvider = new ArrayDataProvider(['allModels' => $res]); return $dataProvider; }
function str_ihas($str, $has, &$pos = false) { if (is_scalar($has)) { return false !== ($pos = mb_stripos($str, $has, 0, mb_detect_encoding($str))); } return $pos = false; }
/** * Function to get html for data definition and data manipulation statements * * @param string $url_query url query * @param int $last_version last version * * @return string */ function PMA_getHtmlForDataDefinitionAndManipulationStatements($url_query, $last_version) { $html = '<div id="div_create_version">'; $html .= '<form method="post" action="tbl_tracking.php' . $url_query . '">'; $html .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); $html .= '<fieldset>'; $html .= '<legend>'; $html .= sprintf(__('Create version %1$s of %2$s'), $last_version + 1, htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table'])); $html .= '</legend>'; $html .= '<input type="hidden" name="version" value="' . ($last_version + 1) . '" />'; $html .= '<p>' . __('Track these data definition statements:') . '</p>'; $html .= '<input type="checkbox" name="alter_table" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'ALTER TABLE') !== false ? ' checked="checked"' : '') . ' /> ALTER TABLE<br/>'; $html .= '<input type="checkbox" name="rename_table" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'RENAME TABLE') !== false ? ' checked="checked"' : '') . ' /> RENAME TABLE<br/>'; $html .= '<input type="checkbox" name="create_table" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'CREATE TABLE') !== false ? ' checked="checked"' : '') . ' /> CREATE TABLE<br/>'; $html .= '<input type="checkbox" name="drop_table" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'DROP TABLE') !== false ? ' checked="checked"' : '') . ' /> DROP TABLE<br/>'; $html .= '<br/>'; $html .= '<input type="checkbox" name="create_index" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'CREATE INDEX') !== false ? ' checked="checked"' : '') . ' /> CREATE INDEX<br/>'; $html .= '<input type="checkbox" name="drop_index" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'DROP INDEX') !== false ? ' checked="checked"' : '') . ' /> DROP INDEX<br/>'; $html .= '<p>' . __('Track these data manipulation statements:') . '</p>'; $html .= '<input type="checkbox" name="insert" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'INSERT') !== false ? ' checked="checked"' : '') . ' /> INSERT<br/>'; $html .= '<input type="checkbox" name="update" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'UPDATE') !== false ? ' checked="checked"' : '') . ' /> UPDATE<br/>'; $html .= '<input type="checkbox" name="delete" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'DELETE') !== false ? ' checked="checked"' : '') . ' /> DELETE<br/>'; $html .= '<input type="checkbox" name="truncate" value="true"' . (mb_stripos($GLOBALS['cfg']['Server']['tracking_default_statements'], 'TRUNCATE') !== false ? ' checked="checked"' : '') . ' /> TRUNCATE<br/>'; $html .= '</fieldset>'; $html .= '<fieldset class="tblFooters">'; $html .= '<input type="hidden" name="submit_create_version" value="1" />'; $html .= '<input type="submit" value="' . __('Create version') . '" />'; $html .= '</fieldset>'; $html .= '</form>'; $html .= '</div>'; return $html; }
public function testStoreRedirectsForBlankRequest() { $cont = new NewsController(); $res = $cont->store(); $this->assertInstanceOf(RedirectResponse::class, $res); $this->assertTrue(false !== mb_stripos($res->getTargetUrl(), '/news/')); // Check redirects to /news/ }
/** * Find the needle in the haystack, case - sensitive * * @param string $needle * @param string $haystack * @param integer $offset * @return integer|boolean */ public function stripos($needle, $haystack, $offset = null) { if (is_int($offset)) { return mb_stripos($haystack, $needle, $offset); } else { return mb_stripos($haystack, $needle); } }
public function execute() { if ($this->isCaseInsensitive()) { return mb_stripos($this->getValue(), $this->needle, $this->offset); } else { return mb_strpos($this->getValue(), $this->needle, $this->offset); } }
public function indexOf($test) { $returnVal = mb_stripos($this->value, $test); if ($returnVal === false) { return -1; } return $returnVal; }