function init()
 {
     $availableAdapters = Piwik_Db::getAdapters();
     $adapters = array();
     foreach ($availableAdapters as $adapter => $port) {
         $adapters[$adapter] = $adapter;
     }
     $formElements = array(array('text', 'host', Piwik_Translate('Installation_DatabaseSetupServer'), 'value=' . 'localhost'), array('text', 'username', Piwik_Translate('Installation_DatabaseSetupLogin')), array('password', 'password', Piwik_Translate('Installation_DatabaseSetupPassword')), array('text', 'dbname', Piwik_Translate('Installation_DatabaseSetupDatabaseName')), array('text', 'tables_prefix', Piwik_Translate('Installation_DatabaseSetupTablePrefix'), 'value=' . 'piwik_'), array('select', 'adapter', Piwik_Translate('Installation_DatabaseSetupAdapter'), $adapters));
     $this->addElements($formElements);
     $formRules = array();
     foreach ($formElements as $row) {
         if ($row[1] != 'password' && $row[1] != 'tables_prefix') {
             $formRules[] = array($row[1], Piwik_Translate('General_Required', $row[2]), 'required');
         }
     }
     $this->addRules($formRules);
     $this->addElement('submit', 'submit', Piwik_Translate('Installation_SubmitGo'));
 }
	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;
	}
Beispiel #3
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;
 }