当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik_Url::getReferer方法代码示例

本文整理汇总了PHP中Piwik_Url::getReferer方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Url::getReferer方法的具体用法?PHP Piwik_Url::getReferer怎么用?PHP Piwik_Url::getReferer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik_Url的用法示例。


在下文中一共展示了Piwik_Url::getReferer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendFeedback

 /**
  * send email to Piwik team and display nice thanks
  */
 function sendFeedback()
 {
     $email = Piwik_Common::getRequestVar('email', '', 'string');
     $body = Piwik_Common::getRequestVar('body', '', 'string');
     $category = Piwik_Common::getRequestVar('category', '', 'string');
     $nonce = Piwik_Common::getRequestVar('nonce', '', 'string');
     $view = Piwik_View::factory('sent');
     $view->feedbackEmailAddress = Zend_Registry::get('config')->General->feedback_email_address;
     try {
         $minimumBodyLength = 35;
         if (strlen($body) < $minimumBodyLength) {
             throw new Exception(Piwik_TranslateException('Feedback_ExceptionBodyLength', array($minimumBodyLength)));
         }
         if (!Piwik::isValidEmailString($email)) {
             throw new Exception(Piwik_TranslateException('UsersManager_ExceptionInvalidEmail'));
         }
         if (preg_match('/https?:/i', $body)) {
             throw new Exception(Piwik_TranslateException('Feedback_ExceptionNoUrls'));
         }
         if (!Piwik_Nonce::verifyNonce('Piwik_Feedback.sendFeedback', $nonce)) {
             throw new Exception(Piwik_TranslateException('General_ExceptionNonceMismatch'));
         }
         Piwik_Nonce::discardNonce('Piwik_Feedback.sendFeedback');
         $mail = new Piwik_Mail();
         $mail->setFrom(Piwik_Common::unsanitizeInputValue($email));
         $mail->addTo($view->feedbackEmailAddress, 'Piwik Team');
         $mail->setSubject('[ Feedback form - Piwik ] ' . $category);
         $mail->setBodyText(Piwik_Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Piwik_Version::VERSION . "\n" . 'IP: ' . Piwik_Common::getIpString() . "\n" . 'URL: ' . Piwik_Url::getReferer() . "\n");
         @$mail->send();
     } catch (Exception $e) {
         $view->ErrorString = $e->getMessage();
         $view->message = $body;
     }
     echo $view->render();
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:38,代码来源:Controller.php

示例2: verifyNonce

	/**
	 * Verify nonce and check referrer (if present, i.e., it may be suppressed by the browser or a proxy/network).
	 *
	 * @param string $id Unique id
	 * @param string $cnonce Nonce sent to client
	 * @return bool true if valid; false otherwise
	 */
	static public function verifyNonce($id, $cnonce)
	{
		$ns = new Piwik_Session_Namespace($id);
		$nonce = $ns->nonce;

		// validate token
		if(empty($cnonce) || $cnonce !== $nonce)
		{
			return false;
		}

		// validate referer
		$referer = Piwik_Url::getReferer();
		if(!empty($referer) && !Piwik_Url::isLocalUrl($referer))
		{
			return false;
		}

		// validate origin
		$origin = self::getOrigin();
		if(!empty($origin) &&
			($origin == 'null'
			|| !in_array($origin, self::getAcceptableOrigins())))
		{
			return false;
		}

		return true;
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:36,代码来源:Nonce.php

示例3: login

 /**
  * Login form
  */
 function login()
 {
     $messageNoAccess = null;
     $form = new Piwik_Login_Form();
     $currentUrl = Piwik_Url::getReferer();
     $urlToRedirect = Piwik_Common::getRequestVar('form_url', $currentUrl, 'string');
     $urlToRedirect = htmlspecialchars_decode($urlToRedirect);
     if ($form->validate()) {
         // if the current url to redirect contains module=Login or Installation we instead redirect to the doc root
         if (preg_match('/module=(Login|Installation)/', $urlToRedirect)) {
             $urlToRedirect = 'index.php';
         }
         $login = $form->getSubmitValue('form_login');
         $password = $form->getSubmitValue('form_password');
         $md5Password = md5($password);
         $messageNoAccess = $this->authenticateAndRedirect($login, $md5Password, $urlToRedirect);
     }
     $view = Piwik_View::factory('login');
     // make navigation login form -> reset password -> login form remember your first url
     $view->urlToRedirect = $urlToRedirect;
     $view->AccessErrorString = $messageNoAccess;
     $view->linkTitle = Piwik::getRandomTitle();
     $view->addForm($form);
     $view->subTemplate = 'genericForm.tpl';
     echo $view->render();
 }
开发者ID:ntulip,项目名称:piwik,代码行数:29,代码来源:Controller.php

示例4: init

 function init()
 {
     // if form_url is not defined go to current url
     $currentUrl = 'index.php' . Piwik_Url::getCurrentQueryString();
     $urlToGoAfter = Piwik_Common::getRequestVar('form_url', $currentUrl, 'string');
     // if the current url to redirect contains module=login we insteaed redirect to the referer url
     if (stripos($urlToGoAfter, 'module=Login') !== false) {
         $urlToGoAfter = Piwik_Url::getReferer();
     }
     $formElements = array(array('text', 'form_login'), array('password', 'form_password'), array('hidden', 'form_url', $urlToGoAfter));
     $this->addElements($formElements);
     $formRules = array(array('form_login', sprintf(Piwik_Translate('General_Required'), Piwik_Translate('Login_Login')), 'required'), array('form_password', sprintf(Piwik_Translate('General_Required'), Piwik_Translate('Login_Password')), 'required'));
     $this->addRules($formRules);
     $this->addElement('submit', 'submit');
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:15,代码来源:Form.php

示例5: init

	function init()
	{
		// if form_url is not defined, go to referrer
		$currentUrl = Piwik_Url::getReferer();
		$urlToGoAfter = Piwik_Common::getRequestVar('form_url', $currentUrl, 'string');
		$urlToGoAfter = htmlspecialchars_decode($urlToGoAfter);

		$formElements = array(
			array('text', 'form_login'),
			array('password', 'form_password'),
			array('hidden', 'form_url', $urlToGoAfter),
		);
		$this->addElements( $formElements );

		$formRules = array(
			array('form_login', sprintf(Piwik_Translate('General_Required'), Piwik_Translate('Login_Login')), 'required'),
			array('form_password', sprintf(Piwik_Translate('General_Required'), Piwik_Translate('Login_Password')), 'required'),
		);
		$this->addRules( $formRules );

		$this->addElement('submit', 'submit');
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:22,代码来源:Form.php

示例6: redirect

    /**
     * Output redirection page instead of linking directly to avoid
     * exposing the referrer on the Piwik demo.
     *
     * @param string $url (via $_GET)
     */
    public function redirect()
    {
        $url = Piwik_Common::getRequestVar('url', '', 'string', $_GET);
        // validate referrer
        $referrer = Piwik_Url::getReferer();
        if (!empty($referrer) && !Piwik_Url::isLocalUrl($referrer)) {
            die('Invalid Referer detected - check that your browser sends the Referer header. <br/>The link you would have been redirected to is: ' . $url);
            exit;
        }
        // mask visits to *.piwik.org
        if (self::isPiwikUrl($url)) {
            echo '<html><head>
<meta http-equiv="refresh" content="0;url=' . $url . '" />
</head></html>';
        }
        exit;
    }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:23,代码来源:Controller.php

示例7: testGetReferer

 /**
  * @group Core
  * @group Url
  */
 public function testGetReferer()
 {
     $_SERVER['HTTP_REFERER'] = 'http://www.piwik.org';
     $this->assertEquals('http://www.piwik.org', Piwik_Url::getReferer());
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:9,代码来源:UrlTest.php

示例8: verifyNonce

 /**
  * Verify nonce and check referrer (if present, i.e., it may be suppressed by the browser or a proxy/network).
  *
  * @param string $id Unique id
  * @param string $nonce Nonce sent to client
  * @return bool true if valid; false otherwise
  */
 public static function verifyNonce($id, $nonce)
 {
     $ns = new Zend_Session_Namespace($id);
     $snonce = $ns->nonce;
     // validate token
     if (empty($nonce) || $snonce !== $nonce) {
         return false;
     }
     // validate referer
     $referer = Piwik_Url::getReferer();
     if (!empty($referer) && Piwik_Url::getLocalReferer() === false) {
         return false;
     }
     return true;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:22,代码来源:Piwik.php


注:本文中的Piwik_Url::getReferer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。