本文整理汇总了PHP中Piwik_Common::isLookLikeUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::isLookLikeUrl方法的具体用法?PHP Piwik_Common::isLookLikeUrl怎么用?PHP Piwik_Common::isLookLikeUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::isLookLikeUrl方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_isUrl_notvalid
function test_isUrl_notvalid()
{
$notValid = array('it doesnt look like url', '/index?page=test', 'test.html', '/\\/\\/\\/\\/\\/\\\\http://test.com////', 'jmleslangues.php', 'http://', ' http://', 'testhttp://test.com');
foreach ($notValid as $url) {
$this->assertTrue(!Piwik_Common::isLookLikeUrl($url), "{$url} validated");
}
}
示例2: getRank
function getRank()
{
$idSite = Piwik_Common::getRequestVar('idSite');
$site = new Piwik_Site($idSite);
$url = urldecode(Piwik_Common::getRequestVar('url', '', 'string'));
if (!empty($url) && strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
$url = 'http://' . $url;
}
if (empty($url) || !Piwik_Common::isLookLikeUrl($url)) {
$url = $site->getMainUrl();
}
$dataTable = Piwik_SEO_API::getInstance()->getRank($url);
$view = Piwik_View::factory('index');
$view->urlToRank = Piwik_SEO_RankChecker::extractDomainFromUrl($url);
$renderer = Piwik_DataTable_Renderer::factory('php');
$renderer->setSerialize(false);
$view->ranks = $renderer->render($dataTable);
echo $view->render();
}
示例3: redirectToUrl
/**
* Redirects the user to the specified URL
*
* @param string $url
*/
public static function redirectToUrl($url)
{
if (Piwik_Common::isLookLikeUrl($url) || strpos($url, 'index.php') === 0) {
@header("Location: {$url}");
} else {
echo "Invalid URL to redirect to.";
}
exit;
}
示例4: displayAlternativeTagsHelp
/**
* Used to generate the doc at http://piwik.org/docs/tracking-api/
*/
function displayAlternativeTagsHelp()
{
$view = Piwik_View::factory('DisplayAlternativeTags');
$view->idSite = Piwik_Common::getRequestVar('idSite');
$url = Piwik_Common::getRequestVar('piwikUrl', '', 'string');
if (empty($url) || !Piwik_Common::isLookLikeUrl($url)) {
$url = $view->piwikUrl;
}
$view->piwikUrlRequest = $url;
$view->calledExternally = true;
echo $view->render();
}
示例5: getRefererUrl
function getRefererUrl()
{
if ($this->getRefererType() == 'search') {
if (Piwik_PluginsManager::getInstance()->isPluginActivated('Referers') && $this->details['referer_keyword'] == Piwik_Referers::LABEL_KEYWORD_NOT_DEFINED) {
return 'http://piwik.org/faq/general/#faq_144';
} elseif ($this->getRefererName() == 'Google' && strpos($this->details['referer_url'], '/url')) {
$refUrl = @parse_url($this->details['referer_url']);
if (isset($refUrl['host'])) {
$url = Piwik_getSearchEngineUrlFromUrlAndKeyword('http://google.com', $this->getKeyword());
$url = str_replace('google.com', $refUrl['host'], $url);
return $url;
}
}
}
if (Piwik_Common::isLookLikeUrl($this->details['referer_url'])) {
return $this->details['referer_url'];
}
return null;
}
示例6: isValidUrl
/**
* Tests if the URL is a valid URL
*
* @return bool
*/
private static function isValidUrl($url)
{
return Piwik_Common::isLookLikeUrl($url);
}
示例7: initPiwikHost
private function initPiwikHost()
{
// If archive.php run as a web cron, we use the current hostname
if (!Piwik_Common::isPhpCliMode()) {
// example.org/piwik/misc/cron/
$piwikUrl = Piwik_Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName());
// example.org/piwik/
$piwikUrl = $piwikUrl . "../../";
} else {
$piwikUrl = $this->isParameterSet("url", true);
if (!$piwikUrl || !Piwik_Common::isLookLikeUrl($piwikUrl)) {
$this->logFatalError("archive.php expects the argument --url to be set to your Piwik URL, for example: --url=http://example.org/piwik/ ", $backtrace = false);
}
// ensure there is a trailing slash
if ($piwikUrl[strlen($piwikUrl) - 1] != '/') {
$piwikUrl .= '/';
}
}
if (Piwik_Config::getInstance()->General['force_ssl'] == 1) {
$piwikUrl = str_replace('http://', 'https://', $piwikUrl);
}
$this->piwikUrl = $piwikUrl . "index.php";
}
示例8: extractUrlAndActionNameFromRequest
/**
* Generates the name of the action from the URL or the specified name.
* Sets the name as $this->actionName
*
* @return array
*/
protected function extractUrlAndActionNameFromRequest()
{
$actionName = null;
// download?
$downloadUrl = Piwik_Common::getRequestVar('download', '', 'string', $this->request);
if (!empty($downloadUrl)) {
$actionType = self::TYPE_DOWNLOAD;
$url = $downloadUrl;
}
// outlink?
if (empty($actionType)) {
$outlinkUrl = Piwik_Common::getRequestVar('link', '', 'string', $this->request);
if (!empty($outlinkUrl)) {
$actionType = self::TYPE_OUTLINK;
$url = $outlinkUrl;
}
}
// handle encoding
$actionName = Piwik_Common::getRequestVar('action_name', '', 'string', $this->request);
// defaults to page view
if (empty($actionType)) {
$actionType = self::TYPE_ACTION_URL;
$url = Piwik_Common::getRequestVar('url', '', 'string', $this->request);
// get the delimiter, by default '/'; BC, we read the old action_category_delimiter first (see #1067)
$actionCategoryDelimiter = isset(Piwik_Config::getInstance()->General['action_category_delimiter']) ? Piwik_Config::getInstance()->General['action_category_delimiter'] : Piwik_Config::getInstance()->General['action_url_category_delimiter'];
// create an array of the categories delimited by the delimiter
$split = explode($actionCategoryDelimiter, $actionName);
// trim every category
$split = array_map('trim', $split);
// remove empty categories
$split = array_filter($split, 'strlen');
// rebuild the name from the array of cleaned categories
$actionName = implode($actionCategoryDelimiter, $split);
}
$url = self::cleanupString($url);
if (!Piwik_Common::isLookLikeUrl($url)) {
$url = '';
}
$actionName = self::cleanupString($actionName);
return array('name' => empty($actionName) ? '' : $actionName, 'type' => $actionType, 'url' => $url);
}
示例9: getRefererInformation
/**
* Returns an array containing the following information:
* - referer_type
* - direct -- absence of referer URL OR referer URL has the same host
* - site -- based on the referer URL
* - search_engine -- based on the referer URL
* - campaign -- based on campaign URL parameter
*
* - referer_name
* - ()
* - piwik.net -- site host name
* - google.fr -- search engine host name
* - adwords-search -- campaign name
*
* - referer_keyword
* - ()
* - ()
* - my keyword
* - my paid keyword
* - ()
* - ()
*
* - referer_url : the same for all the referer types
*
* @param $refererUrl must be URL Encoded
* @param $currentUrl
* @param $idSite
* @return array
*/
public function getRefererInformation($refererUrl, $currentUrl, $idSite)
{
$this->idsite = $idSite;
// default values for the referer_* fields
$refererUrl = Piwik_Common::unsanitizeInputValue($refererUrl);
if (!empty($refererUrl) && !Piwik_Common::isLookLikeUrl($refererUrl)) {
$refererUrl = '';
}
$currentUrl = Piwik_Tracker_Action::cleanupUrl($currentUrl);
$this->refererUrl = $refererUrl;
$this->refererUrlParse = @parse_url($this->refererUrl);
$this->currentUrlParse = @parse_url($currentUrl);
$this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY;
$this->nameRefererAnalyzed = '';
$this->keywordRefererAnalyzed = '';
$this->refererHost = '';
if (isset($this->refererUrlParse['host'])) {
$this->refererHost = $this->refererUrlParse['host'];
}
$refererDetected = false;
if (!empty($this->currentUrlParse['host']) && $this->detectRefererCampaign()) {
$refererDetected = true;
}
if (!$refererDetected) {
if ($this->detectRefererDirectEntry() || $this->detectRefererSearchEngine()) {
$refererDetected = true;
}
}
if (!empty($this->refererHost) && !$refererDetected) {
$this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_WEBSITE;
$this->nameRefererAnalyzed = mb_strtolower($this->refererHost, 'UTF-8');
}
$refererInformation = array('referer_type' => $this->typeRefererAnalyzed, 'referer_name' => $this->nameRefererAnalyzed, 'referer_keyword' => $this->keywordRefererAnalyzed, 'referer_url' => $this->refererUrl);
return $refererInformation;
}
示例10: generateInfo
/**
* Generates the name of the action from the URL or the specified name.
* Sets the name as $this->finalActionName
*
* @return void
*/
private function generateInfo()
{
$actionName = '';
if (!empty($this->downloadUrl)) {
$this->actionType = self::TYPE_DOWNLOAD;
$url = $this->downloadUrl;
//$actionName = $this->nameDownloadOutlink;
$actionName = $url;
} elseif (!empty($this->outlinkUrl)) {
$this->actionType = self::TYPE_OUTLINK;
$url = $this->outlinkUrl;
//remove the last '/' character if it's present
if (substr($url, -1) == '/') {
$url = substr($url, 0, -1);
}
$actionName = $this->nameDownloadOutlink;
if (empty($actionName)) {
$actionName = $url;
}
} else {
$this->actionType = self::TYPE_ACTION;
$url = $this->url;
$actionName = $this->actionName;
}
// the ActionName wasn't specified
if (empty($actionName)) {
$actionName = trim(Piwik_Common::getPathAndQueryFromUrl($url));
// in case the $actionName is ending with a slash,
// which means that it is the index page of a category
// we append the defaultActionName
// toto/tata/ becomes toto/tata/index
if (strlen($actionName) > 0 && $actionName[strlen($actionName) - 1] == '/') {
$actionName .= $this->defaultActionName;
}
}
/*
* Clean the action name
*/
// get the delimiter, by default '/'
$actionCategoryDelimiter = Piwik_LogStats_Config::getInstance()->General['action_category_delimiter'];
// case the name is an URL we dont clean the name the same way
if (Piwik_Common::isLookLikeUrl($actionName)) {
$actionName = trim($actionName);
} else {
// create an array of the categories delimited by the delimiter
$split = explode($actionCategoryDelimiter, $actionName);
// trim every category
$split = array_map('trim', $split);
// remove empty categories
$split = array_filter($split);
// rebuild the name from the array of cleaned categories
$actionName = implode($actionCategoryDelimiter, $split);
}
// remove the extra bad characters if any (shouldn't be any at this point...)
$actionName = str_replace(array("\n", "\r"), '', $actionName);
if (empty($actionName)) {
$actionName = $this->defaultActionName;
}
$this->finalActionName = $actionName;
}
示例11: testIsUrl
/**
* @dataProvider getUrls
* @group Core
* @group Common
* @group isLookLikeUrl
*/
public function testIsUrl($url, $isValid)
{
$this->assertEquals($isValid, Piwik_Common::isLookLikeUrl($url));
}