示例#1
1
 function __construct($action = '')
 {
     if (empty($action)) {
         $action = Piwik_Url::getCurrentQueryString();
     }
     parent::HTML_QuickForm('form', 'POST', $action);
     $this->registerRule('checkEmail', 'function', 'Piwik_Form_isValidEmailString');
     $this->registerRule('fieldHaveSameValue', 'function', 'Piwik_Form_fieldHaveSameValue');
     $this->init();
 }
示例#2
0
文件: Url.php 项目: Doluci/tomatocart
 static function getArrayFromCurrentQueryString()
 {
     $queryString = Piwik_Url::getCurrentQueryString();
     $queryString = htmlspecialchars($queryString);
     $urlValues = Piwik_Common::getArrayFromQueryString($queryString);
     return $urlValues;
 }
示例#3
0
 function login($messageNoAccess = null)
 {
     $form = new Piwik_Login_Form();
     // get url from POSTed form or GET parameter (getting back from password remind form)
     $currentUrl = 'index.php' . Piwik_Url::getCurrentQueryString();
     $urlToRedirect = Piwik_Common::getRequestVar('form_url', htmlspecialchars($currentUrl), 'string');
     $urlToRedirect = htmlspecialchars_decode($urlToRedirect);
     if ($form->validate()) {
         $login = $form->getSubmitValue('form_login');
         $password = $form->getSubmitValue('form_password');
         $md5Password = md5($password);
         $authenticated = $this->authenticateAndRedirect($login, $md5Password, $urlToRedirect);
         if ($authenticated === false) {
             $messageNoAccess = Piwik_Translate('Login_LoginPasswordNotCorrect');
         }
     }
     $view = new Piwik_View('Login/templates/login.tpl');
     // 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();
 }
示例#4
0
 /**
  * display output of all methods
  */
 public function test_allMethods()
 {
     Piwik::createConfigObject();
     Piwik_Config::getInstance()->setTestEnvironment();
     $this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified(array()), Piwik_Url::getCurrentQueryString());
     $expectedUrl = parse_url(Piwik_Url::getCurrentUrl());
     $port = isset($expectedUrl['port']) ? ":{$expectedUrl['port']}" : '';
     $expectedUrl = $expectedUrl['scheme'] . '://' . $expectedUrl['host'] . $port . $expectedUrl['path'];
     $this->assertEqual($expectedUrl, Piwik_Url::getCurrentUrlWithoutQueryString());
     $this->assertEqual($expectedUrl, Piwik_Url::getCurrentScheme() . '://' . Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName());
     print "<br/>\nPiwik_Url::getCurrentUrl() -> " . Piwik_Url::getCurrentUrl();
     print "<br/>\nPiwik_Url::getCurrentUrlWithoutQueryString() -> " . Piwik_Url::getCurrentUrlWithoutQueryString();
     print "<br/>\nPiwik_Url::getCurrentUrlWithoutFileName() -> " . Piwik_Url::getCurrentUrlWithoutFileName();
     print "<br/>\nPiwik_Url::getCurrentScriptPath() -> " . Piwik_Url::getCurrentScriptPath();
     print "<br/>\nPiwik_Url::getCurrentHost() -> " . Piwik_Url::getCurrentHost();
     print "<br/>\nPiwik_Url::getCurrentScriptName() -> " . Piwik_Url::getCurrentScriptName();
     print "<br/>\nPiwik_Url::getCurrentQueryString() -> " . Piwik_Url::getCurrentQueryString();
     print "<br/>\nPiwik_Url::getArrayFromCurrentQueryString() -> ";
     var_dump(Piwik_Url::getArrayFromCurrentQueryString());
     print "<br/>\nPiwik_Url::getCurrentQueryStringWithParametersModified() -> " . Piwik_Url::getCurrentQueryStringWithParametersModified(array());
     echo "<br/>\n\n";
     // setting parameter to null should remove it from url
     // test on Url.test.php?test=value
     $parameters = array_keys(Piwik_Url::getArrayFromCurrentQueryString());
     $parametersNameToValue = array();
     foreach ($parameters as $name) {
         $parametersNameToValue[$name] = null;
     }
     $this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified($parametersNameToValue), '');
 }
示例#5
0
 function __construct($id, $method = 'post', $attributes = null, $trackSubmit = false)
 {
     if (!isset($attributes['action'])) {
         $attributes['action'] = Piwik_Url::getCurrentQueryString();
     }
     if (!isset($attributes['name'])) {
         $attributes['name'] = $id;
     }
     parent::__construct($id, $method, $attributes, $trackSubmit);
     $this->init();
 }
示例#6
0
 /**
  * @group Core
  * @group Url
  */
 public function testAllMethods()
 {
     $this->assertEquals(Piwik_Url::getCurrentQueryStringWithParametersModified(array()), Piwik_Url::getCurrentQueryString());
     $this->assertEquals(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentUrlWithoutQueryString());
     $this->assertEquals(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentScheme() . '://' . Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName());
     $_SERVER['QUERY_STRING'] = 'q=test';
     $parameters = array_keys(Piwik_Url::getArrayFromCurrentQueryString());
     $parametersNameToValue = array();
     foreach ($parameters as $name) {
         $parametersNameToValue[$name] = null;
     }
     $this->assertEquals('', Piwik_Url::getCurrentQueryStringWithParametersModified($parametersNameToValue));
 }
 function init()
 {
     $urlToGoAfter = 'index.php' . Piwik_Url::getCurrentQueryString();
     $urlExample = 'http://example.org';
     $javascriptOnClickUrlExample = "\"javascript:if(this.value=='{$urlExample}'){this.value='http://';} this.style.color='black';\"";
     $formElements = array(array('text', 'siteName', 'website name'), array('text', 'url', 'website URL', "style='color:rgb(153, 153, 153);' value={$urlExample} onfocus=" . $javascriptOnClickUrlExample . " onclick=" . $javascriptOnClickUrlExample));
     $this->addElements($formElements);
     $formRules = array();
     foreach ($formElements as $row) {
         $formRules[] = array($row[1], sprintf('%s required', $row[2]), 'required');
     }
     $this->addRules($formRules);
     $this->addElement('submit', 'submit', 'Go!');
 }
示例#8
0
 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');
 }
示例#9
0
 /**
  * display output of all methods
  */
 public function test_allMethods()
 {
     $this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified(array()), Piwik_Url::getCurrentQueryString());
     $this->assertEqual(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentUrlWithoutQueryString());
     $this->assertEqual(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName());
     print "<br>\nPiwik_Url::getCurrentQueryStringWithParametersModified() " . Piwik_Url::getCurrentQueryStringWithParametersModified(array());
     print "<br>\nPiwik_Url::getCurrentUrl() " . Piwik_Url::getCurrentUrl();
     print "<br>\nPiwik_Url::getCurrentUrlWithoutQueryString() " . Piwik_Url::getCurrentUrlWithoutQueryString();
     print "<br>\nPiwik_Url::getCurrentUrlWithoutFileName() " . Piwik_Url::getCurrentUrlWithoutFileName();
     print "<br>\nPiwik_Url::getCurrentScriptName() " . Piwik_Url::getCurrentScriptName();
     print "<br>\nPiwik_Url::getCurrentScriptPath() " . Piwik_Url::getCurrentScriptPath();
     print "<br>\nPiwik_Url::getCurrentHost() " . Piwik_Url::getCurrentHost();
     print "<br>\nPiwik_Url::getCurrentQueryString() " . Piwik_Url::getCurrentQueryString();
     print "<br>\nPiwik_Url::getArrayFromCurrentQueryString() ";
     var_dump(Piwik_Url::getArrayFromCurrentQueryString());
     // setting parameter to null should remove it from url
     // test on Url.test.php?test=value
     $parameters = array_keys(Piwik_Url::getArrayFromCurrentQueryString());
     $parametersNameToValue = array();
     foreach ($parameters as $name) {
         $parametersNameToValue[$name] = null;
     }
     $this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified($parametersNameToValue), '');
 }
 function init()
 {
     $urlToGoAfter = Piwik_Url::getCurrentQueryString();
     $formElements = array(array('text', 'login', Piwik_Translate('Installation_SuperUserLogin')), array('password', 'password', Piwik_Translate('Installation_Password')), array('password', 'password_bis', Piwik_Translate('Installation_PasswordRepeat')), array('text', 'email', Piwik_Translate('Installation_Email')), array('checkbox', 'subscribe_newsletter_security', '', '&nbsp;&nbsp;' . Piwik_Translate('Installation_SecurityNewsletter')), array('checkbox', 'subscribe_newsletter_community', '', '&nbsp;&nbsp;' . Piwik_Translate('Installation_CommunityNewsletter')));
     $this->addElements($formElements);
     if (!$this->isSubmitted() || $this->getSubmitValue('subscribe_newsletter_community') == '1') {
         $this->setChecked('subscribe_newsletter_community');
     }
     if (!$this->isSubmitted() || $this->getSubmitValue('subscribe_newsletter_security') == '1') {
         $this->setChecked('subscribe_newsletter_security');
     }
     $formRules = array();
     foreach ($formElements as $row) {
         // checkboxes are not required (form should validate when unchecked)
         if (in_array($row[1], array('subscribe_newsletter_security', 'subscribe_newsletter_community'))) {
             continue;
         }
         $formRules[] = array($row[1], sprintf(Piwik_Translate('General_Required'), $row[2]), 'required');
     }
     $formRules[] = array('email', Piwik_Translate('UsersManager_ExceptionInvalidEmail'), 'checkEmail');
     $formRules[] = array('password', Piwik_Translate('Installation_PasswordDoNotMatch'), 'fieldHaveSameValue', 'password_bis');
     $this->addRules($formRules);
     $this->addElement('submit', 'submit', Piwik_Translate('Installation_SubmitGo'));
 }
示例#11
0
 /**
  * Check force_ssl_login and redirect if connection isn't secure and not using a reverse proxy
  *
  * @param none
  * @return void
  */
 protected function checkForceSslLogin()
 {
     $forceSslLogin = Zend_Registry::get('config')->General->force_ssl_login;
     if ($forceSslLogin) {
         if (!Piwik::isHttps()) {
             $url = 'https://' . Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName() . Piwik_Url::getCurrentQueryString();
             Piwik_Url::redirectToUrl($url);
         }
     }
 }
示例#12
0
 /**
  * Check force_ssl_login and redirect if connection isn't secure and not using a reverse proxy
  *
  * @param none
  * @return void
  */
 protected function checkForceSslLogin()
 {
     $forceSslLogin = Piwik_Config::getInstance()->General['force_ssl_login'];
     if ($forceSslLogin && !Piwik::isHttps()) {
         $url = 'https://' . Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName() . Piwik_Url::getCurrentQueryString();
         Piwik_Url::redirectToUrl($url);
     }
 }