예제 #1
0
	/**
	 * Check for a newer version
	 */
	public static function check()
	{
		$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
		if($lastTimeChecked === false
			|| time() - self::CHECK_INTERVAL > $lastTimeChecked )
		{
			$parameters = array(
				'piwik_version' => Piwik_Version::VERSION,
				'php_version' => phpversion(),
				'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
				'trigger' => Piwik_Common::getRequestVar('module','','string'),
			);

			$url = self::PIWIK_HOST . "?" . http_build_query($parameters, '', '&');
			$timeout = self::SOCKET_TIMEOUT;
			try {
				$latestVersion = Piwik::sendHttpRequest($url, $timeout);
				Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
			} catch(Exception $e) {
				// e.g., disable_functions = fsockopen; allow_url_open = Off
				Piwik_SetOption(self::LATEST_VERSION, '');
			}
			Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
		}
	}
예제 #2
0
파일: php.php 프로젝트: Doluci/tomatocart
 function _retrieveCurrentValue()
 {
     $this->current_value = PHP_VERSION;
     $url = 'http://php.net/releases/?serialize=1&version=5';
     $timeout = Piwik_UpdateCheck::SOCKET_TIMEOUT;
     try {
         $latestVersion = Piwik::sendHttpRequest($url, $timeout);
         $versionInfo = Piwik_Common::unserialize_array($latestVersion);
         $this->recommended_value = $versionInfo['version'];
     } catch (Exception $e) {
         $this->recommended_value = '';
     }
 }
예제 #3
0
 /**
  * Returns array of counts and images based on Feedburner URI
  * 
  * @param string $uri
  * @return array()
  */
 protected function getFeedData($uri)
 {
     // Awareness API only supports yesterday and back
     // we get stats for previous two days
     // http://code.google.com/apis/feedburner/awareness_api.html#dates
     $yesterday = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
     $beforeYesterday = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")));
     //create url to gather XML feed from
     $url = 'http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . $uri . '&dates=' . $beforeYesterday . ',' . $yesterday . '';
     $data = Piwik::sendHttpRequest($url, 5);
     try {
         $xml = new SimpleXMLElement($data);
     } catch (Exception $e) {
         return "Error parsing the data for feed {$uri}. Fetched data was: \n'" . $data . "'";
     }
     if (count($xml->feed->entry) != 2) {
         return "Error fetching the Feedburner stats. Expected XML, Got: \n" . strip_tags($data);
     }
     $data = array();
     $i = 0;
     foreach ($xml->feed->entry as $feedDay) {
         $data[0][$i] = $feedDay['circulation'];
         $data[1][$i] = $feedDay['hits'];
         $data[2][$i] = $feedDay['reach'];
         $i++;
     }
     foreach ($data as $key => $value) {
         if ($value[0] == $value[1]) {
             $img = 'nochange.gif';
         } else {
             if ($value[0] < $value[1]) {
                 $img = 'arrow-up-green.gif';
             } else {
                 $img = 'arrow-down-red.gif';
             }
         }
         $prefixImage = '<img alt="" src="./plugins/ExampleFeedburner/templates/';
         $suffixImage = '" />';
         $data[$key][2] = $prefixImage . $img . $suffixImage;
     }
     return $data;
 }
예제 #4
0
	function generalSetup()
	{
		$this->checkPreviousStepIsValid( __FUNCTION__ );

		$view = new Piwik_Installation_View(
						$this->pathView . 'generalSetup.tpl',
						$this->getInstallationSteps(),
						__FUNCTION__
					);
		$this->skipThisStep( __FUNCTION__ );

		$form = new Piwik_Installation_FormGeneralSetup();

		if($form->validate())
		{
			$superUserInfos = array(
				'login' 		=> $form->getSubmitValue('login'),
				'password' 		=> md5( $form->getSubmitValue('password') ),
				'email' 		=> $form->getSubmitValue('email'),
				'salt'			=> Piwik_Common::generateUniqId(),
			);

			$this->session->superuser_infos = $superUserInfos;

			$host = 'http://api.piwik.org/1.0/';
			$host .= 'subscribeNewsletter/';
			$params = array(
				'email' => $form->getSubmitValue('email'),
				'security' => $form->getSubmitValue('subscribe_newsletter_security'),
				'community' => $form->getSubmitValue('subscribe_newsletter_community'),
				'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
			);
			if($params['security'] == '1'
				|| $params['community'] == '1')
			{
				if( !isset($params['security']))  { $params['security'] = '0'; }
				if( !isset($params['community'])) { $params['community'] = '0'; }
				$url = $host . '?' . http_build_query($params, '', '&');
				try {
					Piwik::sendHttpRequest($url, $timeout = 2);
				} catch(Exception $e) {
					// e.g., disable_functions = fsockopen; allow_url_open = Off
				}
			}
			$this->redirectToNextStep( __FUNCTION__ );
		}
		$view->addForm($form);

		echo $view->render();
	}
예제 #5
0
 function generalSetup()
 {
     $this->checkPreviousStepIsValid(__FUNCTION__);
     $view = new Piwik_Installation_View($this->pathView . 'generalSetup.tpl', $this->getInstallationSteps(), __FUNCTION__);
     $this->skipThisStep(__FUNCTION__);
     $session = new Zend_Session_Namespace("Installation");
     require_once "FormGeneralSetup.php";
     $form = new Piwik_Installation_FormGeneralSetup();
     if ($form->validate()) {
         $superUserInfos = array('login' => $form->getSubmitValue('login'), 'password' => md5($form->getSubmitValue('password')), 'email' => $form->getSubmitValue('email'));
         $session->superuser_infos = $superUserInfos;
         $host = 'http://api.piwik.org/1.0/';
         $host .= 'subscribeNewsletter/';
         $params = array('email' => $form->getSubmitValue('email'), 'security' => $form->getSubmitValue('subscribe_newsletter_security'), 'community' => $form->getSubmitValue('subscribe_newsletter_community'), 'url' => Piwik_Url::getCurrentUrlWithoutQueryString());
         if ($params['security'] == '1' || $params['community'] == '1') {
             if (!isset($params['security'])) {
                 $params['security'] = '0';
             }
             if (!isset($params['community'])) {
                 $params['community'] = '0';
             }
             $url = $host . "?" . http_build_query($params, '', '&');
             Piwik::sendHttpRequest($url, $timeout = 2);
         }
         $this->redirectToNextStep(__FUNCTION__);
     }
     $view->addForm($form);
     echo $view->render();
 }