本文整理汇总了PHP中Piwik\Common::mb_strtolower方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::mb_strtolower方法的具体用法?PHP Common::mb_strtolower怎么用?PHP Common::mb_strtolower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Common
的用法示例。
在下文中一共展示了Common::mb_strtolower方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTranslationForComparison
private function getTranslationForComparison($operand, $segmentType)
{
$operator = $operand[SegmentExpression::INDEX_OPERAND_OPERATOR];
$translation = $operator;
if ($operator === SegmentExpression::MATCH_IS_NULL_OR_EMPTY) {
return Piwik::translate('SegmentEditor_SegmentOperatorIsNullOrEmpty');
}
if ($operator === SegmentExpression::MATCH_IS_NOT_NULL_NOR_EMPTY) {
return Piwik::translate('SegmentEditor_SegmentOperatorIsNotNullNorEmpty');
}
if ($segmentType === 'dimension' && !empty($this->matchesDimension[$operator])) {
$translation = Piwik::translate($this->matchesDimension[$operator]);
}
if ($segmentType === 'metric' && !empty($this->matchesMetric[$operator])) {
$translation = Piwik::translate($this->matchesMetric[$operator]);
}
return Common::mb_strtolower($translation);
}
示例2: __construct
/**
* Constructor.
*/
public function __construct($idSite = false)
{
parent::__construct();
$this->jsClass = "SegmentSelectorControl";
$this->cssIdentifier = "segmentEditorPanel";
$this->cssClass = "piwikTopControl borderedControl piwikSelector";
$this->idSite = $idSite ?: Common::getRequestVar('idSite', false, 'int');
$this->selectedSegment = Common::getRequestVar('segment', false, 'string');
$formatter = StaticContainer::get('Piwik\\Plugins\\SegmentEditor\\SegmentFormatter');
$this->segmentDescription = $formatter->getHumanReadable(Request::getRawSegmentFromRequest(), $this->idSite);
$this->isAddingSegmentsForAllWebsitesEnabled = SegmentEditor::isAddingSegmentsForAllWebsitesEnabled();
$segments = APIMetadata::getInstance()->getSegmentsMetadata($this->idSite);
$visitTitle = Piwik::translate('General_Visit');
$segmentsByCategory = array();
foreach ($segments as $segment) {
if ($segment['category'] == $visitTitle && ($segment['type'] == 'metric' && $segment['segment'] != 'visitIp')) {
$metricsLabel = Piwik::translate('General_Metrics');
$metricsLabel[0] = Common::mb_strtolower($metricsLabel[0]);
$segment['category'] .= ' (' . $metricsLabel . ')';
}
$segmentsByCategory[$segment['category']][] = $segment;
}
$this->createRealTimeSegmentsIsEnabled = Config::getInstance()->General['enable_create_realtime_segments'];
$this->segmentsByCategory = $segmentsByCategory;
$this->nameOfCurrentSegment = '';
$this->isSegmentNotAppliedBecauseBrowserArchivingIsDisabled = 0;
$this->availableSegments = API::getInstance()->getAll($this->idSite);
foreach ($this->availableSegments as &$savedSegment) {
$savedSegment['name'] = Common::sanitizeInputValue($savedSegment['name']);
if (!empty($this->selectedSegment) && $this->selectedSegment == $savedSegment['definition']) {
$this->nameOfCurrentSegment = $savedSegment['name'];
$this->isSegmentNotAppliedBecauseBrowserArchivingIsDisabled = $this->wouldApplySegment($savedSegment) ? 0 : 1;
}
}
$this->authorizedToCreateSegments = SegmentEditorAPI::getInstance()->isUserCanAddNewSegment($this->idSite);
$this->isUserAnonymous = Piwik::isUserIsAnonymous();
$this->segmentTranslations = $this->getTranslations();
$this->segmentProcessedOnRequest = Rules::isBrowserArchivingAvailableForSegments();
$this->hideSegmentDefinitionChangeMessage = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), 'hideSegmentDefinitionChangeMessage');
}
示例3: extractSearchEngineInformationFromUrl
//.........这里部分代码省略.........
$searchEngineNames = Common::getSearchEngineNames();
$url = $searchEngineNames[$searchEngineName];
$variableNames = $searchEngines[$url][1];
}
if (!is_array($variableNames)) {
$variableNames = array($variableNames);
}
$key = null;
if ($searchEngineName === 'Google Images' || $searchEngineName === 'Google' && strpos($referrerUrl, '/imgres') !== false) {
if (strpos($query, '&prev') !== false) {
$query = urldecode(trim(self::getParameterFromQueryString($query, 'prev')));
$query = str_replace('&', '&', strstr($query, '?'));
}
$searchEngineName = 'Google Images';
} elseif ($searchEngineName === 'Google' && (strpos($query, '&as_') !== false || strpos($query, 'as_') === 0)) {
$keys = array();
$key = self::getParameterFromQueryString($query, 'as_q');
if (!empty($key)) {
array_push($keys, $key);
}
$key = self::getParameterFromQueryString($query, 'as_oq');
if (!empty($key)) {
array_push($keys, str_replace('+', ' OR ', $key));
}
$key = self::getParameterFromQueryString($query, 'as_epq');
if (!empty($key)) {
array_push($keys, "\"{$key}\"");
}
$key = self::getParameterFromQueryString($query, 'as_eq');
if (!empty($key)) {
array_push($keys, "-{$key}");
}
$key = trim(urldecode(implode(' ', $keys)));
}
if ($searchEngineName === 'Google') {
// top bar menu
$tbm = self::getParameterFromQueryString($query, 'tbm');
switch ($tbm) {
case 'isch':
$searchEngineName = 'Google Images';
break;
case 'vid':
$searchEngineName = 'Google Video';
break;
case 'shop':
$searchEngineName = 'Google Shopping';
break;
}
}
if (empty($key)) {
foreach ($variableNames as $variableName) {
if ($variableName[0] == '/') {
// regular expression match
if (preg_match($variableName, $referrerUrl, $matches)) {
$key = trim(urldecode($matches[1]));
break;
}
} else {
// search for keywords now &vname=keyword
$key = self::getParameterFromQueryString($query, $variableName);
$key = trim(urldecode($key));
// Special cases: empty or no keywords
if (empty($key) && ($searchEngineName == 'Google' && (empty($query) && (empty($referrerPath) || $referrerPath == '/') && empty($referrerParsed['fragment'])) || $searchEngineName == 'Yahoo!' && $referrerParsed['host'] == 'r.search.yahoo.com' || strpos($query, sprintf('&%s=', $variableName)) !== false || strpos($query, sprintf('?%s=', $variableName)) !== false || $searchEngineName == 'Ixquick' || $searchEngineName == 'Google Images' || $searchEngineName == 'DuckDuckGo')) {
$key = false;
}
if (!empty($key) || $key === false) {
break;
}
}
}
}
// $key === false is the special case "No keyword provided" which is a Search engine match
if ($key === null || $key === '') {
return false;
}
if (!empty($key)) {
if (function_exists('iconv') && isset($searchEngines[$referrerHost][3])) {
// accepts string, array, or comma-separated list string in preferred order
$charsets = $searchEngines[$referrerHost][3];
if (!is_array($charsets)) {
$charsets = explode(',', $charsets);
}
if (!empty($charsets)) {
$charset = $charsets[0];
if (count($charsets) > 1 && function_exists('mb_detect_encoding')) {
$charset = mb_detect_encoding($key, $charsets);
if ($charset === false) {
$charset = $charsets[0];
}
}
$newkey = @iconv($charset, 'UTF-8//IGNORE', $key);
if (!empty($newkey)) {
$key = $newkey;
}
}
}
$key = Common::mb_strtolower($key);
}
return array('name' => $searchEngineName, 'keywords' => $key);
}
示例4: hasReferrerColumnChanged
protected function hasReferrerColumnChanged(Visitor $visitor, $information, $infoName)
{
return Common::mb_strtolower($visitor->getVisitorColumn($infoName)) != Common::mb_strtolower($information[$infoName]);
}
示例5: getCanonicalPathFromParsedUrl
private function getCanonicalPathFromParsedUrl($urlParsed)
{
$path = '/';
if (isset($urlParsed['path'])) {
$path = Common::mb_strtolower($urlParsed['path']);
if (!Common::stringEndsWith($path, '/')) {
$path .= '/';
}
}
return $path;
}
示例6: isValidHost
/**
* Validates the **Host** HTTP header (untrusted user input). Used to prevent Host header
* attacks.
*
* @param string|bool $host Contents of Host: header from the HTTP request. If `false`, gets the
* value from the request.
* @return bool `true` if valid; `false` otherwise.
*/
public static function isValidHost($host = false)
{
// only do trusted host check if it's enabled
if (isset(Config::getInstance()->General['enable_trusted_host_check']) && Config::getInstance()->General['enable_trusted_host_check'] == 0) {
return true;
}
if ($host === false) {
$host = @$_SERVER['HTTP_HOST'];
if (empty($host)) {
return true;
}
}
// if host is in hardcoded whitelist, assume it's valid
if (in_array($host, self::$alwaysTrustedHosts)) {
return true;
}
$trustedHosts = self::getTrustedHosts();
// if no trusted hosts, just assume it's valid
if (empty($trustedHosts)) {
self::saveTrustedHostnameInConfig($host);
return true;
}
// Only punctuation we allow is '[', ']', ':', '.' and '-'
$hostLength = strlen($host);
if ($hostLength !== strcspn($host, '`~!@#$%^&*()_+={}\\|;"\'<>,?/ ')) {
return false;
}
foreach ($trustedHosts as &$trustedHost) {
$trustedHost = preg_quote($trustedHost);
}
$untrustedHost = Common::mb_strtolower($host);
$untrustedHost = rtrim($untrustedHost, '.');
$hostRegex = Common::mb_strtolower('/(^|.)' . implode('|', $trustedHosts) . '$/');
$result = preg_match($hostRegex, $untrustedHost);
return 0 !== $result;
}
示例7: toCanonicalHost
private static function toCanonicalHost($host)
{
$hostLower = Common::mb_strtolower($host);
return str_replace('www.', '', $hostLower);
}
示例8: extractInformationFromUrl
//.........这里部分代码省略.........
if (empty($referrerHost)) {
return false;
}
// some search engines (eg. Bing Images) use the same domain
// as an existing search engine (eg. Bing), we must also use the url path
$referrerPath = '';
if (isset($referrerParsed['path'])) {
$referrerPath = $referrerParsed['path'];
}
$query = '';
if (isset($referrerParsed['query'])) {
$query = $referrerParsed['query'];
}
// Google Referrers URLs sometimes have the fragment which contains the keyword
if (!empty($referrerParsed['fragment'])) {
$query .= '&' . $referrerParsed['fragment'];
}
$referrerHost = $this->getEngineHostFromUrl($referrerHost, $referrerPath, $query);
if (empty($referrerHost)) {
return false;
}
$definitions = $this->getDefinitionByHost($referrerHost);
$searchEngineName = $definitions['name'];
$variableNames = $definitions['params'];
$key = null;
if ($searchEngineName === 'Google Images' || $searchEngineName === 'Google' && strpos($referrerUrl, '/imgres') !== false) {
if (strpos($query, '&prev') !== false) {
$query = urldecode(trim(UrlHelper::getParameterFromQueryString($query, 'prev')));
$query = str_replace('&', '&', strstr($query, '?'));
}
$searchEngineName = 'Google Images';
} elseif ($searchEngineName === 'Google' && (strpos($query, '&as_') !== false || strpos($query, 'as_') === 0)) {
$keys = array();
$key = UrlHelper::getParameterFromQueryString($query, 'as_q');
if (!empty($key)) {
array_push($keys, $key);
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_oq');
if (!empty($key)) {
array_push($keys, str_replace('+', ' OR ', $key));
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_epq');
if (!empty($key)) {
array_push($keys, "\"{$key}\"");
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_eq');
if (!empty($key)) {
array_push($keys, "-{$key}");
}
$key = trim(urldecode(implode(' ', $keys)));
}
if ($searchEngineName === 'Google') {
// top bar menu
$tbm = UrlHelper::getParameterFromQueryString($query, 'tbm');
switch ($tbm) {
case 'isch':
$searchEngineName = 'Google Images';
break;
case 'vid':
$searchEngineName = 'Google Video';
break;
case 'shop':
$searchEngineName = 'Google Shopping';
break;
}
}
if (empty($key)) {
foreach ($variableNames as $variableName) {
if ($variableName[0] == '/') {
// regular expression match
if (preg_match($variableName, $referrerUrl, $matches)) {
$key = trim(urldecode($matches[1]));
break;
}
} else {
// search for keywords now &vname=keyword
$key = UrlHelper::getParameterFromQueryString($query, $variableName);
$key = trim(urldecode($key));
// Special cases: empty or no keywords
if (empty($key) && ($searchEngineName == 'Google' && (empty($query) && (empty($referrerPath) || $referrerPath == '/') && empty($referrerParsed['fragment'])) || $searchEngineName == 'Yahoo!' && $referrerParsed['host'] == 'r.search.yahoo.com' || strpos($query, sprintf('&%s=', $variableName)) !== false || strpos($query, sprintf('?%s=', $variableName)) !== false || $searchEngineName == 'Ixquick' || $searchEngineName == 'Google Images' || $searchEngineName == 'DuckDuckGo')) {
$key = false;
}
if (!empty($key) || $key === false) {
break;
}
}
}
}
// $key === false is the special case "No keyword provided" which is a Search engine match
if ($key === null || $key === '') {
return false;
}
if (!empty($key)) {
if (!empty($definitions['charsets'])) {
$key = $this->convertCharset($key, $definitions['charsets']);
}
$key = Common::mb_strtolower($key);
}
return array('name' => $searchEngineName, 'keywords' => $key);
}
示例9: isHostInUrls
/**
* Checks whether any of the given URLs has the given host. If not, we will also check whether any URL uses a
* subdomain of the given host. For instance if host is "example.com" and a URL is "http://www.example.com" we
* consider this as valid and return true. The always trusted hosts such as "127.0.0.1" are considered valid as well.
*
* @param $host
* @param $urls
* @return bool
*/
public static function isHostInUrls($host, $urls)
{
if (empty($host)) {
return false;
}
$host = Common::mb_strtolower($host);
if (!empty($urls)) {
foreach ($urls as $url) {
if (Common::mb_strtolower($url) === $host) {
return true;
}
$siteHost = self::getHostFromUrl($url);
if ($siteHost === $host) {
return true;
}
if (Common::stringEndsWith($siteHost, '.' . $host)) {
// allow subdomains
return true;
}
}
}
return in_array($host, self::$alwaysTrustedHosts);
}
示例10: cleanupHostAndHashTag
/**
* Will cleanup the hostname (some browser do not strolower the hostname),
* and deal ith the hash tag on incoming URLs based on website setting.
*
* @param $parsedUrl
* @param $idSite int|bool The site ID of the current visit. This parameter is
* only used by the tracker to see if we should remove
* the URL fragment for this site.
* @return array
*/
protected static function cleanupHostAndHashTag($parsedUrl, $idSite = false)
{
if (empty($parsedUrl)) {
return $parsedUrl;
}
if (!empty($parsedUrl['host'])) {
$parsedUrl['host'] = Common::mb_strtolower($parsedUrl['host'], 'UTF-8');
}
if (!empty($parsedUrl['fragment'])) {
$parsedUrl['fragment'] = PageUrl::processUrlFragment($parsedUrl['fragment'], $idSite);
}
return $parsedUrl;
}
示例11: detectSiteSearchFromUrl
protected function detectSiteSearchFromUrl($website, $parsedUrl)
{
$doRemoveSearchParametersFromUrl = true;
$separator = '&';
$count = $actionName = $categoryName = false;
$keywordParameters = isset($website['sitesearch_keyword_parameters']) ? $website['sitesearch_keyword_parameters'] : array();
$queryString = (!empty($parsedUrl['query']) ? $parsedUrl['query'] : '') . (!empty($parsedUrl['fragment']) ? $separator . $parsedUrl['fragment'] : '');
$parametersRaw = UrlHelper::getArrayFromQueryString($queryString);
// strtolower the parameter names for smooth site search detection
$parameters = array();
foreach ($parametersRaw as $k => $v) {
$parameters[Common::mb_strtolower($k)] = $v;
}
// decode values if they were sent from a client using another charset
$pageEncoding = $this->request->getParam('cs');
PageUrl::reencodeParameters($parameters, $pageEncoding);
// Detect Site Search keyword
foreach ($keywordParameters as $keywordParameterRaw) {
$keywordParameter = Common::mb_strtolower($keywordParameterRaw);
if (!empty($parameters[$keywordParameter])) {
$actionName = $parameters[$keywordParameter];
break;
}
}
if (empty($actionName)) {
return false;
}
$categoryParameters = isset($website['sitesearch_category_parameters']) ? $website['sitesearch_category_parameters'] : array();
foreach ($categoryParameters as $categoryParameterRaw) {
$categoryParameter = Common::mb_strtolower($categoryParameterRaw);
if (!empty($parameters[$categoryParameter])) {
$categoryName = $parameters[$categoryParameter];
break;
}
}
if (isset($parameters['search_count']) && $this->isValidSearchCount($parameters['search_count'])) {
$count = $parameters['search_count'];
}
// Remove search kwd from URL
if ($doRemoveSearchParametersFromUrl) {
// @see excludeQueryParametersFromUrl()
// Excluded the detected parameters from the URL
$parametersToExclude = array($categoryParameterRaw, $keywordParameterRaw);
if (isset($parsedUrl['query'])) {
$parsedUrl['query'] = UrlHelper::getQueryStringWithExcludedParameters(UrlHelper::getArrayFromQueryString($parsedUrl['query']), $parametersToExclude);
}
if (isset($parsedUrl['fragment'])) {
$parsedUrl['fragment'] = UrlHelper::getQueryStringWithExcludedParameters(UrlHelper::getArrayFromQueryString($parsedUrl['fragment']), $parametersToExclude);
}
}
$url = UrlHelper::getParseUrlReverse($parsedUrl);
if (is_array($actionName)) {
$actionName = reset($actionName);
}
$actionName = trim(urldecode($actionName));
if (empty($actionName)) {
return false;
}
if (is_array($categoryName)) {
$categoryName = reset($categoryName);
}
$categoryName = trim(urldecode($categoryName));
return array($url, $actionName, $categoryName, $count);
}
示例12: setCampaignValuesToLowercase
/**
* @param $type
* @param $name
* @param $keyword
*/
protected function setCampaignValuesToLowercase($type, &$name, &$keyword)
{
if ($type === Common::REFERRER_TYPE_CAMPAIGN) {
if (!empty($name)) {
$name = Common::mb_strtolower($name);
}
if (!empty($keyword)) {
$keyword = Common::mb_strtolower($keyword);
}
}
}
示例13: detectReferrerCampaign
/**
* @return bool
*/
protected function detectReferrerCampaign()
{
$this->detectReferrerCampaignFromLandingUrl();
$this->detectCampaignKeywordFromReferrerUrl();
if ($this->typeReferrerAnalyzed != Common::REFERRER_TYPE_CAMPAIGN) {
return false;
}
// if we detected a campaign but there is still no keyword set, we set the keyword to the Referrer host
if (empty($this->keywordReferrerAnalyzed)) {
$this->keywordReferrerAnalyzed = $this->referrerHost;
}
$this->keywordReferrerAnalyzed = Common::mb_strtolower($this->keywordReferrerAnalyzed);
$this->nameReferrerAnalyzed = Common::mb_strtolower($this->nameReferrerAnalyzed);
return true;
}