示例#1
0
 /**
  * Checks that the directories Piwik needs write access are actually writable
  * Displays a nice error page if permissions are missing on some directories
  * 
  * @return void
  */
 public static function checkDirectoriesWritableOrDie($directoriesToCheck = null)
 {
     $resultCheck = Piwik::checkDirectoriesWritable($directoriesToCheck);
     if (array_search(false, $resultCheck) !== false) {
         $directoryList = '';
         foreach ($resultCheck as $dir => $bool) {
             $realpath = Piwik_Common::realpath($dir);
             if (!empty($realpath) && $bool === false) {
                 $directoryList .= "<code>chmod 777 {$realpath}</code><br>";
             }
         }
         $directoryList .= '';
         $directoryMessage = "<p><b>Piwik couldn't write to some directories</b>.</p> <p>Try to Execute the following commands on your Linux server:</P>";
         $directoryMessage .= $directoryList;
         $directoryMessage .= "<p>If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 777 (with your FTP software, right click on the directories, permissions).";
         $directoryMessage .= "<p>After applying the modifications, you can <a href='index.php'>refresh the page</a>.";
         $directoryMessage .= "<p>If you need more help, try <a href='misc/redirectToUrl.php?url=http://piwik.org'>Piwik.org</a>.";
         Piwik_ExitWithMessage($directoryMessage, false, true);
     }
 }
示例#2
0
	/**
	 * Get system information
	 */
	public static function getSystemInformation()
	{
		global $piwik_minimumPHPVersion;
		$minimumMemoryLimit = Zend_Registry::get('config')->General->minimum_memory_limit;

		$infos = array();

		$infos['general_infos'] = array();
		$infos['directories'] = Piwik::checkDirectoriesWritable();
		$infos['can_auto_update'] = Piwik::canAutoUpdate();
		
		if(Piwik_Common::isIIS())
		{
			Piwik::createWebConfigFiles();
		}
		else
		{
			Piwik::createHtAccessFiles();
		}
		Piwik::createWebRootFiles();

		$infos['phpVersion_minimum'] = $piwik_minimumPHPVersion;
		$infos['phpVersion'] = PHP_VERSION;
		$infos['phpVersion_ok'] = version_compare( $piwik_minimumPHPVersion, $infos['phpVersion']) === -1;

		// critical errors
		$extensions = @get_loaded_extensions();
		$needed_extensions = array(
			'zlib',
			'SPL',
			'iconv',
			'Reflection',
		);
		$infos['needed_extensions'] = $needed_extensions;
		$infos['missing_extensions'] = array();
		foreach($needed_extensions as $needed_extension)
		{
			if(!in_array($needed_extension, $extensions))
			{
				$infos['missing_extensions'][] = $needed_extension;
			}
		}

		$infos['pdo_ok'] = false;
		if(in_array('PDO', $extensions))
		{
			$infos['pdo_ok'] = true;
		}

		$infos['adapters'] = Piwik_Db_Adapter::getAdapters();

		$needed_functions = array(
			'debug_backtrace',
			'create_function',
			'eval',
			'gzcompress',
			'gzuncompress',
			'pack',
		);
		$infos['needed_functions'] = $needed_functions;
		$infos['missing_functions'] = array();
		foreach($needed_functions as $needed_function)
		{
			if(!self::functionExists($needed_function))
			{
				$infos['missing_functions'][] = $needed_function;
			}
		}

		// warnings
		$desired_extensions = array(
			'json',
			'libxml',
			'dom',
			'SimpleXML',
		);
		$infos['desired_extensions'] = $desired_extensions;
		$infos['missing_desired_extensions'] = array();
		foreach($desired_extensions as $desired_extension)
		{
			if(!in_array($desired_extension, $extensions))
			{
				$infos['missing_desired_extensions'][] = $desired_extension;
			}
		}

		$desired_functions = array(
			'set_time_limit',
			'mail',
			'parse_ini_file',
			'glob',
		);
		$infos['desired_functions'] = $desired_functions;
		$infos['missing_desired_functions'] = array();
		foreach($desired_functions as $desired_function)
		{
			if(!self::functionExists($desired_function))
			{
				$infos['missing_desired_functions'][] = $desired_function;
			}
		}

		$infos['openurl'] = Piwik_Http::getTransportMethod();

		$infos['gd_ok'] = false;
		if (in_array('gd', $extensions))
		{
			$gdInfo = gd_info();
			$infos['gd_version'] = $gdInfo['GD Version'];
			preg_match('/([0-9]{1})/', $gdInfo['GD Version'], $gdVersion);
			if($gdVersion[0] >= 2)
			{
				$infos['gd_ok'] = true;
			}
		}

		$infos['hasMbstring'] = false;
		$infos['multibyte_ok'] = true;
		if(function_exists('mb_internal_encoding'))
		{
			$infos['hasMbstring'] = true;
			if (((int) ini_get('mbstring.func_overload')) != 0)
			{
				$infos['multibyte_ok'] = false;
			}
		}

		$serverSoftware = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '';
		$infos['serverVersion'] = addslashes($serverSoftware);
		$infos['serverOs'] = @php_uname();
		$infos['serverTime'] = date('H:i:s');

		$infos['registerGlobals_ok'] = ini_get('register_globals') == 0;
		$infos['memoryMinimum'] = $minimumMemoryLimit;

		$infos['memory_ok'] = true;
		$infos['memoryCurrent'] = '';

		$raised = Piwik::raiseMemoryLimitIfNecessary();
		if(($memoryValue = Piwik::getMemoryLimitValue()) > 0)
		{
			$infos['memoryCurrent'] = $memoryValue.'M';
			$infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit;
		}

		$infos['isWindows'] = Piwik_Common::isWindows();

		$integrityInfo = Piwik::getFileIntegrityInformation();
		$infos['integrity'] = $integrityInfo[0];
		
		$infos['integrityErrorMessages'] = array();
		if(isset($integrityInfo[1]))
		{
			if($infos['integrity'] == false)
			{
				$infos['integrityErrorMessages'][] = '<b>'.Piwik_Translate('General_FileIntegrityWarningExplanation').'</b>';
			}
			$infos['integrityErrorMessages'] = array_merge($infos['integrityErrorMessages'], array_slice($integrityInfo, 1));
		}

		$infos['timezone'] = Piwik::isTimezoneSupportEnabled();

		$infos['tracker_status'] = Piwik_Common::getRequestVar('trackerStatus', 0, 'int');

		$infos['protocol'] = Piwik_ProxyHeaders::getProtocolInformation();
		if(Piwik_Url::getCurrentScheme() == 'http' && $infos['protocol'] !== null)
		{
			$infos['general_infos']['secure_protocol'] = '1';
		}
		if(count($headers = Piwik_ProxyHeaders::getProxyClientHeaders()) > 0)
		{
			$infos['general_infos']['proxy_client_headers'] = $headers;
		}
		if(count($headers = Piwik_ProxyHeaders::getProxyHostHeaders()) > 0)
		{
			$infos['general_infos']['proxy_host_headers'] = $headers;
		}

		return $infos;
	}
示例#3
0
	public static function getSystemInformation()
	{
		$minimumPhpVersion = Zend_Registry::get('config')->General->minimum_php_version;
		$minimumMemoryLimit = Zend_Registry::get('config')->General->minimum_memory_limit;

		$infos = array();

		$infos['directories'] = Piwik::checkDirectoriesWritable();
		$infos['phpVersion_minimum'] = $minimumPhpVersion;
		$infos['phpVersion'] = phpversion();
		$infos['phpVersion_ok'] = version_compare( $minimumPhpVersion, $infos['phpVersion']) === -1;

		// critical errors
		$extensions = @get_loaded_extensions();
		$needed_extensions = array(
			'zlib',
			'SPL',
			'iconv',
		);
		$infos['needed_extensions'] = $needed_extensions;
		$infos['missing_extensions'] = array();
		foreach($needed_extensions as $needed_extension)
		{
			if(!in_array($needed_extension, $extensions))
			{
				$infos['missing_extensions'][] = $needed_extension;
			}
		}

		$infos['pdo_ok'] = false;
		if(in_array('PDO', $extensions))
		{
			$infos['pdo_ok'] = true;
		}

		$infos['adapters'] = Piwik_Db::getAdapters();

		$infos['json'] = false;
		if(in_array('json', $extensions))
		{
			$infos['json'] = true;
		}

		$infos['xml'] = false;
		if(in_array('xml', $extensions))
		{
			$infos['xml'] = true;
		}

		// warnings
		$needed_functions = array(
			'set_time_limit',
			'mail',
		);
		$infos['needed_functions'] = $needed_functions;
		$infos['missing_functions'] = array();
		foreach($needed_functions as $needed_function)
		{
			if(!function_exists($needed_function))
			{
				$infos['missing_functions'][] = $needed_function;
			}
		}

		$infos['openurl'] = Piwik::getTransportMethod();

		$infos['gd_ok'] = false;
		if (in_array('gd', $extensions))
		{
			$gdInfo = gd_info();
			$infos['gd_version'] = $gdInfo['GD Version'];
			preg_match('/([0-9]{1})/', $gdInfo['GD Version'], $gdVersion);
			if($gdVersion[0] >= 2)
			{
				$infos['gd_ok'] = true;
			}
		}

		$infos['serverVersion'] = addslashes($_SERVER['SERVER_SOFTWARE']);
		$infos['serverOs'] = @php_uname();
		$infos['serverTime'] = date('H:i:s');

		$infos['registerGlobals_ok'] = ini_get('register_globals') == 0;
		$infos['memoryMinimum'] = $minimumMemoryLimit;

		$infos['memory_ok'] = true;
		// on windows the ini_get is not working?
		$infos['memoryCurrent'] = '?M';

		$raised = Piwik::raiseMemoryLimitIfNecessary();
		if(	$memoryValue = Piwik::getMemoryLimitValue() )
		{
			$infos['memoryCurrent'] = $memoryValue.'M';
			$infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit;
		}

		$infos['isWindows'] = substr(PHP_OS, 0, 3) == 'WIN';

		$infos['protocol_ok'] = true;
		$infos['protocol'] = self::getProtocolInformation();
		if(Piwik_Url::getCurrentScheme() == 'http' &&
			$infos['protocol'] !== null)
		{
			$infos['protocol_ok'] = false;
		}

		return $infos;
	}
示例#4
0
 /**
  * Checks that the directories Piwik needs write access are actually writable
  * Displays a nice error page if permissions are missing on some directories
  *
  * @param array $directoriesToCheck Array of directory names to check
  */
 public static function checkDirectoriesWritableOrDie($directoriesToCheck = null)
 {
     $resultCheck = Piwik::checkDirectoriesWritable($directoriesToCheck);
     if (array_search(false, $resultCheck) === false) {
         return;
     }
     $directoryList = '';
     foreach ($resultCheck as $dir => $bool) {
         $realpath = Piwik_Common::realpath($dir);
         if (!empty($realpath) && $bool === false) {
             $directoryList .= self::getMakeWritableCommand($realpath);
         }
     }
     // Also give the chown since the chmod is only 755
     if (!Piwik_Common::isWindows()) {
         $realpath = Piwik_Common::realpath(PIWIK_INCLUDE_PATH . '/');
         $directoryList = "<code>chown -R www-data:www-data " . $realpath . "</code><br/>" . $directoryList;
     }
     // The error message mentions chmod 777 in case users can't chown
     $directoryMessage = "<p><b>Piwik couldn't write to some directories</b>.</p> \n\t\t\t\t\t\t\t<p>Try to Execute the following commands on your server:</p>" . "<blockquote>{$directoryList}</blockquote>" . "<p>If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 0777 (with your FTP software, right click on the directories, permissions).</p>" . "<p>After applying the modifications, you can <a href='index.php'>refresh the page</a>.</p>" . "<p>If you need more help, try <a href='?module=Proxy&action=redirect&url=http://piwik.org'>Piwik.org</a>.</p>";
     Piwik_ExitWithMessage($directoryMessage, false, true);
 }
示例#5
0
 /**
  * Checks that the directories Piwik needs write access are actually writable
  * Displays a nice error page if permissions are missing on some directories
  *
  * @param array $directoriesToCheck Array of directory names to check
  */
 public static function checkDirectoriesWritableOrDie($directoriesToCheck = null)
 {
     $resultCheck = Piwik::checkDirectoriesWritable($directoriesToCheck);
     if (array_search(false, $resultCheck) === false) {
         return;
     }
     $directoryList = '';
     foreach ($resultCheck as $dir => $bool) {
         $realpath = Piwik_Common::realpath($dir);
         if (!empty($realpath) && $bool === false) {
             if (Piwik_Common::isWindows()) {
                 $directoryList .= "<code>cacls {$realpath} /t /g " . get_current_user() . ":f</code><br />";
             } else {
                 $directoryList .= "<code>chmod 0777 {$realpath}</code><br />";
             }
         }
     }
     $directoryMessage = "<p><b>Piwik couldn't write to some directories</b>.</p> <p>Try to Execute the following commands on your server:</p>" . "<blockquote>{$directoryList}</blockquote>" . "<p>If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 0777 (with your FTP software, right click on the directories, permissions).</p>" . "<p>After applying the modifications, you can <a href='index.php'>refresh the page</a>.</p>" . "<p>If you need more help, try <a href='?module=Proxy&action=redirect&url=http://piwik.org'>Piwik.org</a>.</p>";
     Piwik_ExitWithMessage($directoryMessage, false, true);
 }
示例#6
0
 /**
  * Get system information
  */
 public static function getSystemInformation()
 {
     $minimumPhpVersion = Zend_Registry::get('config')->General->minimum_php_version;
     $minimumMemoryLimit = Zend_Registry::get('config')->General->minimum_memory_limit;
     $infos = array();
     $infos['directories'] = Piwik::checkDirectoriesWritable();
     $infos['phpVersion_minimum'] = $minimumPhpVersion;
     $infos['phpVersion'] = phpversion();
     $infos['phpVersion_ok'] = version_compare($minimumPhpVersion, $infos['phpVersion']) === -1;
     // critical errors
     $extensions = @get_loaded_extensions();
     $needed_extensions = array('zlib', 'SPL', 'iconv', 'Reflection');
     $infos['needed_extensions'] = $needed_extensions;
     $infos['missing_extensions'] = array();
     foreach ($needed_extensions as $needed_extension) {
         if (!in_array($needed_extension, $extensions)) {
             $infos['missing_extensions'][] = $needed_extension;
         }
     }
     $infos['pdo_ok'] = false;
     if (in_array('PDO', $extensions)) {
         $infos['pdo_ok'] = true;
     }
     $infos['adapters'] = Piwik_Db::getAdapters();
     $infos['json'] = false;
     if (in_array('json', $extensions)) {
         $infos['json'] = true;
     }
     $infos['xml'] = false;
     if (in_array('xml', $extensions)) {
         $infos['xml'] = true;
     }
     $needed_functions = array('debug_backtrace', 'create_function');
     $infos['needed_functions'] = $needed_functions;
     $infos['missing_functions'] = array();
     foreach ($needed_functions as $needed_function) {
         if (!self::functionExists($needed_function)) {
             $infos['missing_functions'][] = $needed_function;
         }
     }
     // warnings
     $desired_functions = array('set_time_limit', 'mail', 'parse_ini_file');
     $infos['desired_functions'] = $desired_functions;
     $infos['missing_desired_functions'] = array();
     foreach ($desired_functions as $desired_function) {
         if (!self::functionExists($desired_function)) {
             $infos['missing_desired_functions'][] = $desired_function;
         }
     }
     $infos['openurl'] = Piwik::getTransportMethod();
     $infos['gd_ok'] = false;
     if (in_array('gd', $extensions)) {
         $gdInfo = gd_info();
         $infos['gd_version'] = $gdInfo['GD Version'];
         preg_match('/([0-9]{1})/', $gdInfo['GD Version'], $gdVersion);
         if ($gdVersion[0] >= 2) {
             $infos['gd_ok'] = true;
         }
     }
     $infos['hasMbstring'] = false;
     $infos['multibyte_ok'] = true;
     if (function_exists('mb_internal_encoding')) {
         $infos['hasMbstring'] = true;
         if ((int) ini_get('mbstring.func_overload') != 0) {
             $infos['multibyte_ok'] = false;
         }
     }
     /**
      * @see http://php.net/ip2long
      */
     $infos['isIpv4'] = true;
     if (strpos($_SERVER['REMOTE_ADDR'], ':') !== false) {
         $infos['isIpv4'] = false;
     }
     $infos['serverVersion'] = addslashes($_SERVER['SERVER_SOFTWARE']);
     $infos['serverOs'] = @php_uname();
     $infos['serverTime'] = date('H:i:s');
     $infos['registerGlobals_ok'] = ini_get('register_globals') == 0;
     $infos['memoryMinimum'] = $minimumMemoryLimit;
     $infos['memory_ok'] = true;
     // on windows the ini_get is not working?
     $infos['memoryCurrent'] = '?M';
     $raised = Piwik::raiseMemoryLimitIfNecessary();
     if ($memoryValue = Piwik::getMemoryLimitValue()) {
         $infos['memoryCurrent'] = $memoryValue . 'M';
         $infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit;
     }
     $infos['isWindows'] = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
     $infos['protocol_ok'] = true;
     $infos['protocol'] = self::getProtocolInformation();
     if (Piwik_Url::getCurrentScheme() == 'http' && $infos['protocol'] !== null) {
         $infos['protocol_ok'] = false;
     }
     $integrityInfo = Piwik::getFileIntegrityInformation();
     $infos['integrity'] = $integrityInfo[0];
     $infos['integrityErrorMessages'] = array();
     if (isset($integrityInfo[1])) {
         $infos['integrityErrorMessages'][] = '<b>' . Piwik_Translate('General_FileIntegrityWarningExplanation') . '</b>';
         $infos['integrityErrorMessages'] += array_splice($integrityInfo, 1);
     }
     return $infos;
 }
示例#7
0
    /**
     * Checks that the directories Piwik needs write access are actually writable
     * Displays a nice error page if permissions are missing on some directories
     * 
     * @return void
     */
    protected function checkDirectoriesWritableOrDie()
    {
        $resultCheck = Piwik::checkDirectoriesWritable();
        if (array_search(false, $resultCheck) !== false) {
            $directoryList = '';
            foreach ($resultCheck as $dir => $bool) {
                $dir = realpath($dir);
                if (!empty($dir) && $bool === false) {
                    $directoryList .= "<code>chmod 777 {$dir}</code><br>";
                }
            }
            $directoryList .= '';
            $directoryMessage = "<p><b>Piwik couldn't write to some directories</b>.</p> <p>Try to Execute the following commands on your Linux server:</P>";
            $directoryMessage .= $directoryList;
            $directoryMessage .= "<p>If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 777 (with your FTP software, right click on the directories, permissions).";
            $directoryMessage .= "<p>After applying the modifications, you can <a href='index.php'>refresh the page</a>.";
            $directoryMessage .= "<p>If you need more help, try <a href='http://piwik.org'>Piwik.org</a>.";
            $html = '
				<html>
				<head>
					<title>Piwik &rsaquo; Error</title>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<style>
				
				html { background: #eee; }
				
				body {
					background: #fff;
					color: #000;
					font-family: Georgia, "Times New Roman", Times, serif;
					margin-left: 20%;
					margin-top: 25px;
					margin-right: 20%;
					padding: .2em 2em;
				}
				
				#h1 {
					color: #006;
					font-size: 45px;
					font-weight: lighter;
				}
				
				#subh1 {
					color: #879DBD;
					font-size: 25px;
					font-weight: lighter;
				}
				
				
				p, li, dt {
					line-height: 140%;
					padding-bottom: 2px;
				}
				
				ul, ol { padding: 5px 5px 5px 20px; }
				
				#logo { margin-bottom: 2em; }
				
				code { margin-left: 40px; }
				</style>
				</head>
				<body>
					<span id="h1">Piwik </span><span id="subh1"> # open source web analytics</span>
					<p>' . $directoryMessage . '</p>
				
				</body>
				</html>
				';
            print $html;
            exit;
        }
    }
示例#8
0
 protected function getSystemInformation()
 {
     $minimumPhpVersion = Zend_Registry::get('config')->General->minimum_php_version;
     $minimumMemoryLimit = Zend_Registry::get('config')->General->minimum_memory_limit;
     $infos = array();
     $infos['directories'] = Piwik::checkDirectoriesWritable();
     $infos['phpVersion_minimum'] = $minimumPhpVersion;
     $infos['phpVersion'] = phpversion();
     $infos['phpVersion_ok'] = version_compare($minimumPhpVersion, $infos['phpVersion']) === -1;
     // critical errors
     $extensions = @get_loaded_extensions();
     $needed_extensions = array('PDO', 'pdo_mysql', 'zlib', 'SPL');
     $infos['needed_extensions'] = $needed_extensions;
     $infos['missing_extensions'] = array();
     foreach ($needed_extensions as $needed_extension) {
         if (!in_array($needed_extension, $extensions)) {
             $infos['missing_extensions'][] = $needed_extension;
         }
     }
     // warnings
     $needed_functions = array('set_time_limit', 'mail');
     $infos['needed_functions'] = $needed_functions;
     $infos['missing_functions'] = array();
     foreach ($needed_functions as $needed_function) {
         if (!function_exists($needed_function)) {
             $infos['missing_functions'][] = $needed_function;
         }
     }
     $infos['gd_ok'] = false;
     if (in_array('gd', $extensions)) {
         $gdInfo = gd_info();
         $infos['gd_version'] = $gdInfo['GD Version'];
         preg_match('/([0-9]{1})/', $gdInfo['GD Version'], $gdVersion);
         if ($gdVersion[0] >= 2) {
             $infos['gd_ok'] = true;
         }
     }
     $infos['serverVersion'] = addslashes($_SERVER['SERVER_SOFTWARE']);
     $infos['serverOs'] = @php_uname();
     $infos['serverTime'] = date('H:i:s');
     $infos['registerGlobals_ok'] = ini_get('register_globals') == 0;
     $infos['memoryMinimum'] = $minimumMemoryLimit;
     $infos['memory_ok'] = true;
     // on windows the ini_get is not working?
     $infos['memoryCurrent'] = '?M';
     $raised = Piwik::raiseMemoryLimitIfNecessary();
     if ($memoryValue = Piwik::getMemoryLimitValue()) {
         $infos['memoryCurrent'] = $memoryValue . "M";
         $infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit;
     }
     return $infos;
 }