oxsysrequirements.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxSysRequirements
00007 {
00013     protected $_aRequiredModules = null;
00014 
00020     protected $_blSysReqStatus = null;
00021 
00027     protected $_aException = array( 'OXDELIVERY'   => 'OXDELTYPE',
00028                                     'OXSELECTLIST' => 'OXIDENT');
00029 
00035     protected $_aColumns = array( 'OXID',
00036                                   'OXOBJECTID',
00037                                   'OXARTICLENID',
00038                                   'OXACTIONID',
00039                                   'OXARTID',
00040                                   'OXUSERID',
00041                                   'OXADDRESSUSERID',
00042                                   'OXCOUNTRYID',
00043                                   'OXSESSID',
00044                                   'OXITMID',
00045                                   'OXPARENTID',
00046                                   'OXAMITEMID',
00047                                   'OXAMTASKID',
00048                                   'OXVENDORID',
00049                                   'OXMANUFACTURERID',
00050                                   'OXROOTID',
00051                                   'OXATTRID',
00052                                   'OXCATID',
00053                                   'OXDELID',
00054                                   'OXDELSETID',
00055                                   'OXITMARTID',
00056                                   'OXFIELDID',
00057                                   'OXROLEID',
00058                                   'OXCNID',
00059                                   'OXANID',
00060                                   'OXARTICLENID',
00061                                   'OXCATNID',
00062                                   'OXDELIVERYID',
00063                                   'OXDISCOUNTID',
00064                                   'OXGROUPSID',
00065                                   'OXLISTID',
00066                                   'OXPAYMENTID',
00067                                   'OXDELTYPE',
00068                                   'OXROLEID',
00069                                   'OXSELNID',
00070                                   'OXBILLCOUNTRYID',
00071                                   'OXDELCOUNTRYID',
00072                                   'OXPAYMENTID',
00073                                   'OXCARDID',
00074                                   'OXPAYID',
00075                                   'OXIDENT',
00076                                   'OXDEFCAT',
00077                                   'OXBASKETID',
00078                                   'OXPAYMENTSID',
00079                                   'OXORDERID',
00080                                   'OXVOUCHERSERIEID');
00081 
00087     protected $_sReqInfoUrl = "http://www.oxidforge.org/wiki/Installation";
00088 
00094     protected $_aInfoMap    = array( "php_version"        => "PHP_version_at_least_5.2.10",
00095                                      "lib_xml2"           => "LIB_XML2",
00096                                      "php_xml"            => "DOM",
00097                                      "open_ssl"           => "OpenSSL",
00098                                      "soap"               => "SOAP",
00099                                      "j_son"              => "JSON",
00100                                      "i_conv"             => "ICONV",
00101                                      "tokenizer"          => "Tokenizer",
00102                                      "mysql_connect"      => "MySQL_client_connector_for_MySQL_5",
00103                                      "gd_info"            => "GDlib_v2_.5Bv1.5D_incl._JPEG_support",
00104                                      "mb_string"          => "mbstring",
00105                                      "bc_math"            => "BCMath",
00106                                      "allow_url_fopen"    => "allow_url_fopen_or_fsockopen_to_port_80",
00107                                      "php4_compat"        => "Zend_compatibility_mode_must_be_off",
00108                                      "request_uri"        => "REQUEST_URI_set",
00109                                      "ini_set"            => "ini_set_allowed",
00110                                      "register_globals"   => "register_globals_must_be_off",
00111                                      "memory_limit"       => "PHP_Memory_limit_.28min._14MB.2C_30MB_recommended.29",
00112                                      "unicode_support"    => "UTF-8_support",
00113                                      "file_uploads"       => "file_uploads_on",
00114                                      "mod_rewrite"        => "apache_mod_rewrite_module",
00115                                      "server_permissions" => "Files_.26_Folder_Permission_Setup",
00116                                      "zend_optimizer"     => "Zend_Optimizer",
00117                                      "bug53632"           => "Not_recommended_PHP_versions",
00118                                      "session_autostart"  => "session.auto_start_must_be_off",
00119                                      // "zend_platform_or_server"
00120                                       );
00121 
00127     protected function _getPhpIntSize()
00128     {
00129         return PHP_INT_SIZE;
00130     }
00131 
00137     public function __construct()
00138     {
00139     }
00140 
00152     public function __call( $sMethod, $aArgs )
00153     {
00154         if ( defined( 'OXID_PHP_UNIT' ) ) {
00155             if ( substr( $sMethod, 0, 4) == "UNIT" ) {
00156                 $sMethod = str_replace( "UNIT", "_", $sMethod );
00157             }
00158             if ( method_exists( $this, $sMethod)) {
00159                 return call_user_func_array( array( & $this, $sMethod ), $aArgs );
00160             }
00161         }
00162 
00163         throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
00164     }
00165 
00171     public function getConfig()
00172     {
00173         return oxRegistry::getConfig();
00174     }
00175 
00181     public function isAdmin()
00182     {
00183         return isAdmin();
00184     }
00185 
00191     public function getRequiredModules()
00192     {
00193         if ( $this->_aRequiredModules == null ) {
00194             $aRequiredPHPExtensions = array(
00195                                           'php_version',
00196                                           'lib_xml2',
00197                                           'php_xml',
00198                                           'j_son',
00199                                           'i_conv',
00200                                           'tokenizer',
00201                                           'mysql_connect',
00202                                           'gd_info',
00203                                           'mb_string',
00204                                           'curl',
00205                                           'bc_math',
00206                                           'open_ssl',
00207                                           'soap',
00208                                       );
00209 
00210             $aRequiredPHPConfigs = array(
00211                                        'allow_url_fopen',
00212                                        'php4_compat',
00213                                        'request_uri',
00214                                        'ini_set',
00215                                        'register_globals',
00216                                        'memory_limit',
00217                                        'unicode_support',
00218                                        'file_uploads',
00219                                        'session_autostart',
00220                                    );
00221 
00222             $aRequiredServerConfigs = array(
00223                                           'mod_rewrite',
00224                                           'server_permissions',
00225                                           'bug53632'
00226                                       );
00227 
00228 
00229             if ( $this->isAdmin() ) {
00230                 $aRequiredServerConfigs[] = 'mysql_version';
00231             }
00232             $this->_aRequiredModules = array_fill_keys( $aRequiredPHPExtensions, 'php_extennsions' ) +
00233                                        array_fill_keys( $aRequiredPHPConfigs, 'php_config' ) +
00234                                        array_fill_keys( $aRequiredServerConfigs, 'server_config' );
00235         }
00236         return $this->_aRequiredModules;
00237     }
00238 
00247     public function checkBug53632()
00248     {
00249         if ( $this->_getPhpIntSize() > 4 ) {
00250             return 2;
00251         }
00252 
00253         $iState = 1;
00254         if ( version_compare( PHP_VERSION, "5.3", ">=" ) ) {
00255             if ( version_compare( PHP_VERSION, "5.3.5", ">=" ) && version_compare( PHP_VERSION, "5.3.7", "!=" ) ) {
00256                 $iState = 2;
00257             }
00258         } elseif ( version_compare( PHP_VERSION, '5.2', ">=" ) ) {
00259             $iState = version_compare( PHP_VERSION, "5.2.17", ">=" ) ? 2 : $iState;
00260         }
00261         return $iState;
00262     }
00263 
00269     public function checkCurl()
00270     {
00271         return extension_loaded( 'curl' ) ? 2 : 1;
00272     }
00273 
00279     public function checkMbString()
00280     {
00281         return extension_loaded( 'mbstring' ) ? 2 : 1;
00282     }
00283 
00292     public function checkServerPermissions( $sPath = null, $iMinPerm = 777 )
00293     {
00294         $sVerPrefix = '';
00295 
00296         clearstatcache();
00297         $sPath = $sPath ? $sPath : getShopBasePath();
00298 
00299         // special config file check
00300         $sFullPath = $sPath . "config.inc.php";
00301         if ( !is_readable( $sFullPath ) ||
00302              ( $this->isAdmin() && is_writable( $sFullPath ) ) ||
00303              ( !$this->isAdmin() && !is_writable( $sFullPath ) )
00304            ) {
00305             return 0;
00306         }
00307 
00308         $sTmp = "$sPath/tmp$sVerPrefix/";
00309         if (class_exists('oxConfig')) {
00310             $sCfgTmp = $this->getConfig()->getConfigParam('sCompileDir');
00311             if (strpos($sCfgTmp, '<sCompileDir_') === false) {
00312                 $sTmp = $sCfgTmp;
00313             }
00314         }
00315 
00316         $aPathsToCheck = array(
00317                             $sPath."out/pictures{$sVerPrefix}/promo/",
00318                             $sPath."out/pictures{$sVerPrefix}/master/",
00319                             $sPath."out/pictures{$sVerPrefix}/generated/",
00320                             $sPath."out/pictures{$sVerPrefix}/media/", // @deprecated, use out/media instead
00321                             $sPath."out/media/",
00322                             $sPath."log/",
00323                             $sTmp
00324                             );
00325         $iModStat = 2;
00326         $sPathToCheck = reset( $aPathsToCheck );
00327         while ( $sPathToCheck ) {
00328             // missing file/folder?
00329             if ( !file_exists( $sPathToCheck ) ) {
00330                 $iModStat = 0;
00331                 break;
00332             }
00333 
00334             if ( is_dir( $sPathToCheck ) ) {
00335                 // adding subfolders
00336                 $aSubF = glob( $sPathToCheck."*", GLOB_ONLYDIR );
00337                 if (is_array($aSubF)) {
00338                     foreach ( $aSubF as $sNewFolder ) {
00339                         $aPathsToCheck[] = $sNewFolder . "/";
00340                     }
00341                 }
00342             }
00343 
00344             // testing if file permissions >= $iMinPerm
00345             //if ( ( (int) substr( decoct( fileperms( $sFullPath ) ), 2 ) ) < $iMinPerm ) {
00346             if ( !is_readable( $sPathToCheck ) || !is_writable( $sPathToCheck ) ) {
00347                 $iModStat = 0;
00348                 break;
00349             }
00350 
00351             $sPathToCheck = next( $aPathsToCheck );
00352         }
00353 
00354         return $iModStat;
00355     }
00356 
00363     protected function _getShopHostInfoFromConfig()
00364     {
00365         $sShopURL = $this->getConfig()->getConfigParam( 'sShopURL' );
00366         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
00367             $sHost = $m[2];
00368             $iPort = (int)$m[4];
00369             $blSsl = (strtolower($m[1])=='https://');
00370             if (!$iPort) {
00371                 $iPort = $blSsl?443:80;
00372             }
00373             $sScript = rtrim($m[5], '/').'/';
00374             return array(
00375                     'host'=>$sHost,
00376                     'port'=>$iPort,
00377                     'dir'=>$sScript,
00378                     'ssl'=>$blSsl,
00379             );
00380         } else {
00381             return false;
00382         }
00383     }
00384 
00391     protected function _getShopSSLHostInfoFromConfig()
00392     {
00393         $sSSLShopURL = $this->getConfig()->getConfigParam( 'sSSLShopURL' );
00394         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sSSLShopURL, $m)) {
00395             $sHost = $m[2];
00396             $iPort = (int)$m[4];
00397             $blSsl = (strtolower($m[1])=='https://');
00398             if (!$iPort) {
00399                 $iPort = $blSsl?443:80;
00400             }
00401             $sScript = rtrim($m[5], '/').'/';
00402             return array(
00403                     'host'=>$sHost,
00404                     'port'=>$iPort,
00405                     'dir'=>$sScript,
00406                     'ssl'=>$blSsl,
00407             );
00408         }
00409         return false;
00410     }
00411 
00418     protected function _getShopHostInfoFromServerVars()
00419     {
00420         // got here from setup dir
00421         $sScript = $_SERVER['SCRIPT_NAME'];
00422         $iPort = (int) $_SERVER['SERVER_PORT'];
00423         $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
00424         if (!$iPort) {
00425             $iPort = $blSsl?443:80;
00426         }
00427         $sScript = rtrim(dirname(dirname( $sScript )), '/').'/';
00428         return array(
00429                     'host'=>$_SERVER['HTTP_HOST'],
00430                     'port'=>$iPort,
00431                     'dir'=>$sScript,
00432                     'ssl'=>$blSsl,
00433         );
00434     }
00435 
00441     protected function _getShopHostInfo()
00442     {
00443         if ( $this->isAdmin() ) {
00444             return $this->_getShopHostInfoFromConfig();
00445         } else {
00446             return $this->_getShopHostInfoFromServerVars();
00447         }
00448     }
00449 
00456     protected function _getShopSSLHostInfo()
00457     {
00458         if ( $this->isAdmin() ) {
00459             return $this->_getShopSSLHostInfoFromConfig();
00460         }
00461         return false;
00462     }
00463 
00470     public function checkModRewrite()
00471     {
00472         $iModStat = null;
00473         $aHostInfo = $this->_getShopHostInfo();
00474         $iModStat = $this->_checkModRewrite( $aHostInfo );
00475 
00476         $aSSLHostInfo = $this->_getShopSSLHostInfo();
00477         // Don't need to check if mod status is already failed.
00478         if ( 0 != $iModStat && $aSSLHostInfo ) {
00479             $iSSLModStat = $this->_checkModRewrite( $aSSLHostInfo );
00480 
00481             // Send if failed, even if couldn't check another
00482             if ( 0 == $iSSLModStat ) {
00483                 return 0;
00484             } elseif ( 1 == $iSSLModStat || 1 == $iModStat ) {
00485                 return 1;
00486             }
00487 
00488             return min( $iModStat, $iSSLModStat );
00489         }
00490 
00491         return $iModStat;
00492     }
00493 
00502     protected function _checkModRewrite($aHostInfo)
00503     {
00504         if ( $rFp = @fsockopen( ($aHostInfo['ssl']?'ssl://':'').$aHostInfo['host'], $aHostInfo['port'], $iErrNo, $sErrStr, 10 ) ) {
00505             $sReq  = "POST {$aHostInfo['dir']}oxseo.php?mod_rewrite_module_is=off HTTP/1.1\r\n";
00506             $sReq .= "Host: {$aHostInfo['host']}\r\n";
00507             $sReq .= "User-Agent: OXID eShop setup\r\n";
00508             $sReq .= "Content-Type: application/x-www-form-urlencoded\r\n";
00509             $sReq .= "Content-Length: 0\r\n"; // empty post
00510             $sReq .= "Connection: close\r\n\r\n";
00511 
00512             $sOut = '';
00513             fwrite( $rFp, $sReq );
00514             while ( !feof( $rFp ) ) {
00515                 $sOut .= fgets( $rFp, 100 );
00516             }
00517             fclose( $rFp );
00518 
00519             $iModStat = ( strpos( $sOut, 'mod_rewrite_on' ) !== false ) ? 2 : 0;
00520         } else {
00521             if ( function_exists( 'apache_get_modules' ) ) {
00522                 // it does not assure that mod_rewrite is enabled on current host, so setting 1
00523                 $iModStat = in_array( 'mod_rewrite', apache_get_modules() ) ? 1 : 0;
00524             } else {
00525                 $iModStat = -1;
00526             }
00527         }
00528         return $iModStat;
00529     }
00530 
00536     public function checkAllowUrlFopen()
00537     {
00538         $iModStat = @ini_get('allow_url_fopen');
00539         $iModStat = ( $iModStat && strcasecmp( '1', $iModStat ) ) ? 2 : 1;
00540         if ( $iModStat == 1 ) {
00541             $iErrNo  = 0;
00542             $sErrStr = '';
00543             if ( $oRes = @fsockopen( 'www.example.com', 80, $iErrNo, $sErrStr, 10 ) ) {
00544                 $iModStat = 2;
00545                 fclose( $oRes );
00546             }
00547         }
00548         $iModStat = ( !$iModStat ) ? 1 : $iModStat;
00549         return $iModStat;
00550     }
00551 
00558     public function checkPhp4Compat()
00559     {
00560         $sZendStatus = ( strtolower( (string) @ini_get( 'zend.ze1_compatibility_mode' ) ) );
00561         return in_array( $sZendStatus, array( 'on', '1' ) ) ? 0 : 2;
00562     }
00563 
00572     public function checkPhpVersion()
00573     {
00574         $iModStat = ( version_compare( PHP_VERSION, '5.2', '<' ) ) ? 0 : false;
00575         $iModStat = ( $iModStat !== false ) ? $iModStat : ( (version_compare( PHP_VERSION, '5.2.0', '>=' ) && version_compare( PHP_VERSION, '5.2.10', '<' )) ? 1 : false );
00576         $iModStat = ( $iModStat !== false ) ? $iModStat : ( version_compare( PHP_VERSION, '5.2.10', '>=' ) ? 2 : 1 );
00577         return $iModStat;
00578     }
00579 
00585     public function checkRequestUri()
00586     {
00587         return ( isset( $_SERVER['REQUEST_URI'] ) || isset( $_SERVER['SCRIPT_URI'] ) ) ? 2 : 0;
00588     }
00589 
00595     public function checkLibXml2()
00596     {
00597         return class_exists( 'DOMDocument' ) ? 2 : 0;
00598     }
00599 
00605     public function checkPhpXml()
00606     {
00607         return class_exists( 'DOMDocument' ) ? 2 : 0;
00608     }
00609 
00615     public function checkJSon()
00616     {
00617         return extension_loaded( 'json' ) ? 2 : 0;
00618     }
00619 
00625     public function checkIConv()
00626     {
00627         return extension_loaded( 'iconv' ) ? 2 : 0;
00628     }
00629 
00635     public function checkTokenizer()
00636     {
00637         return extension_loaded( 'tokenizer' ) ? 2 : 0;
00638     }
00639 
00645     public function checkBcMath()
00646     {
00647         return extension_loaded( 'bcmath' ) ? 2 : 1;
00648     }
00649 
00655     public function checkOpenSsl()
00656     {
00657         return extension_loaded( 'openssl' ) ? 2 : 1;
00658     }
00659 
00665     public function checkSoap()
00666     {
00667         return extension_loaded( 'soap' ) ? 2 : 1;
00668     }
00669 
00675     public function checkMysqlConnect()
00676     {
00677         // MySQL module for MySQL5
00678         $iModStat = ( extension_loaded( 'mysql' ) || extension_loaded( 'mysqli' ) || extension_loaded( 'pdo_mysql' ) ) ? 2 : 0;
00679 
00680         // client version must be >=5
00681         if ( $iModStat ) {
00682             $sClientVersion = mysql_get_client_info();
00683             if (version_compare( $sClientVersion, '5', '<' )) {
00684                 $iModStat = 1;
00685                 if (version_compare( $sClientVersion, '4', '<' )) {
00686                     $iModStat = 0;
00687                 }
00688             } elseif (version_compare($sClientVersion, '5.0.36', '>=') && version_compare($sClientVersion, '5.0.38', '<')) {
00689                 // mantis#0001003: Problems with MySQL version 5.0.37
00690                 $iModStat = 0;
00691             } elseif (version_compare($sClientVersion, '5.0.40', '>') && version_compare($sClientVersion, '5.0.42', '<')) {
00692                 // mantis#0001877: Exclude MySQL 5.0.41 from system requirements as not fitting
00693                 $iModStat = 0;
00694             }
00695             if ( strpos($sClientVersion, 'mysqlnd') !== false ) {
00696                 // PHP 5.3 includes new mysqlnd extension
00697                 $iModStat = 2;
00698             }
00699         }
00700         return $iModStat;
00701     }
00702 
00710     public function checkMysqlVersion( $sVersion = null )
00711     {
00712         if ( $sVersion === null ) {
00713             $aRez = oxDb::getDb()->getAll( "SHOW VARIABLES LIKE 'version'" );
00714             foreach ( $aRez as $aRecord ) {
00715                 $sVersion = $aRecord[1];
00716                 break;
00717             }
00718         }
00719 
00720         $iModStat = 0;
00721         if ( version_compare( $sVersion, '5.0.3', '>=' ) && version_compare( $sVersion, '5.0.37', '<>' ) ) {
00722             $iModStat = 2;
00723         }
00724 
00725         return $iModStat;
00726     }
00727 
00733     public function checkGdInfo()
00734     {
00735         $iModStat = extension_loaded( 'gd' ) ? 1 : 0;
00736         $iModStat = function_exists( 'imagecreatetruecolor' ) ? 2 : $iModStat;
00737         $iModStat = function_exists( 'imagecreatefromjpeg' ) ? $iModStat : 0;
00738         return $iModStat;
00739     }
00740 
00746     public function checkIniSet()
00747     {
00748         return ( @ini_set('session.name', 'sid' ) !== false ) ? 2 : 0;
00749     }
00750 
00756     public function checkRegisterGlobals()
00757     {
00758         $sGlobStatus = ( strtolower( (string) @ini_get( 'register_globals' ) ) );
00759         return in_array( $sGlobStatus, array( 'on', '1' ) ) ? 0 : 2;
00760     }
00761 
00767     public function checkMemoryLimit()
00768     {
00769         if ( $sMemLimit = @ini_get('memory_limit') ) {
00770                 // CE - PE at least to 14 MB. We recomend a memory_limit of 30MB.
00771                 $sDefLimit = '14M';
00772                 $sRecLimit = '30M';
00773 
00774 
00775             $iMemLimit = $this->_getBytes( $sMemLimit );
00776             $iModStat = ( $iMemLimit >= $this->_getBytes( $sDefLimit ) ) ? 1 : 0;
00777             $iModStat = $iModStat ? ( ( $iMemLimit >= $this->_getBytes( $sRecLimit ) ) ? 2 : $iModStat ) : $iModStat;
00778 
00779         } else {
00780             $iModStat = -1;
00781         }
00782         return $iModStat;
00783     }
00784 
00790     public function checkZendOptimizer()
00791     {
00796         return 2;
00797     }
00798 
00804     public function checkZendPlatformOrServer()
00805     {
00806         if (function_exists( 'output_cache_get' )) {
00807             return 2;
00808         }
00809         if (function_exists( 'zend_disk_cache_fetch' )) {
00810             return 2;
00811         }
00812         if (function_exists( 'zend_shm_cache_fetch' )) {
00813             return 2;
00814         }
00815         return 1;
00816     }
00817 
00823     protected function _getAdditionalCheck()
00824     {
00825         $sSelect = '';
00826         foreach ( $this->_aException as $sTable => $sColumn ) {
00827             $sSelect .= 'and ( t.TABLE_NAME != "'.$sTable.'" and c.COLUMN_NAME != "'.$sColumn.'" ) ';
00828         }
00829         return $sSelect;
00830     }
00831 
00837     public function checkCollation()
00838     {
00839         $myConfig = $this->getConfig();
00840 
00841         $aCollations = array();
00842         $sCollation = '';
00843 
00844         $sSelect = 'select t.TABLE_NAME, c.COLUMN_NAME, c.COLLATION_NAME from INFORMATION_SCHEMA.tables t ' .
00845                    'LEFT JOIN INFORMATION_SCHEMA.columns c ON t.TABLE_NAME = c.TABLE_NAME  ' .
00846                    'where t.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00847                    'and c.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00848                    'and c.COLUMN_NAME in ("'.implode('", "', $this->_aColumns).'") ' . $this->_getAdditionalCheck() .
00849                    ' ORDER BY (t.TABLE_NAME = "oxarticles") DESC';
00850         $aRez = oxDb::getDb()->getAll($sSelect);
00851         foreach ( $aRez as $aRetTable ) {
00852             if ( !$sCollation ) {
00853                 $sCollation = $aRetTable[2];
00854             } else {
00855                 if ( $aRetTable[2] && $sCollation != $aRetTable[2]) {
00856                     $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
00857                 }
00858             }
00859         }
00860 
00861         if ( $this->_blSysReqStatus === null ) {
00862             $this->_blSysReqStatus = true;
00863         }
00864         if ( count($aCollations) > 0 ) {
00865             $this->_blSysReqStatus = false;
00866         }
00867         return $aCollations;
00868     }
00869 
00875     public function checkDatabaseCluster()
00876     {
00877         return 2;
00878     }
00879 
00885     public function checkUnicodeSupport()
00886     {
00887         return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
00888     }
00889 
00895     public function checkFileUploads()
00896     {
00897         $dUploadFile = -1;
00898         $sFileUploads = @ini_get('file_uploads');
00899         if ( $sFileUploads !== false ) {
00900             if ( $sFileUploads && ( $sFileUploads == '1' || strtolower($sFileUploads) == 'on') ) {
00901                 $dUploadFile = 2;
00902             } else {
00903                 $dUploadFile = 1;
00904             }
00905         }
00906         return $dUploadFile;
00907     }
00908 
00914     public function getSysReqStatus()
00915     {
00916         if ( $this->_blSysReqStatus == null ) {
00917             $this->_blSysReqStatus = true;
00918             $this->getSystemInfo();
00919             $this->checkCollation();
00920         }
00921         return $this->_blSysReqStatus;
00922     }
00923 
00938     public function getSystemInfo()
00939     {
00940         $aSysInfo = array();
00941         $aRequiredModules = $this->getRequiredModules();
00942         $this->_blSysReqStatus = true;
00943         foreach ( $aRequiredModules as $sModule => $sGroup ) {
00944             if ( isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup] ) {
00945                 $aSysInfo[$sGroup] = array();
00946             }
00947             $iModuleState = $this->getModuleInfo( $sModule );
00948             $aSysInfo[$sGroup][$sModule] = $iModuleState;
00949             $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs( $iModuleState );
00950         }
00951         return $aSysInfo;
00952     }
00953 
00961     public function getModuleInfo( $sModule = null )
00962     {
00963         if ( $sModule ) {
00964             $iModStat = null;
00965             $sCheckFunction = "check".str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
00966             $iModStat = $this->$sCheckFunction();
00967 
00968             return $iModStat;
00969         }
00970     }
00971 
00979     public function getReqInfoUrl( $sIdent)
00980     {
00981         $sUrl = $this->_sReqInfoUrl;
00982         $aInfoMap = $this->_aInfoMap;
00983 
00984         // only known will be anchored
00985         if ( isset( $aInfoMap[$sIdent] ) ) {
00986             $sUrl .= "#".$aInfoMap[$sIdent];
00987         }
00988 
00989         return $sUrl;
00990     }
00991 
00999     protected function _getBytes( $sBytes )
01000     {
01001         $sBytes = trim( $sBytes );
01002         $sLast = strtolower($sBytes[strlen($sBytes)-1]);
01003         switch( $sLast ) {
01004             // The 'G' modifier is available since PHP 5.1.0
01005             case 'g':
01006                 $sBytes *= 1024;
01007             case 'm':
01008                 $sBytes *= 1024;
01009             case 'k':
01010                 $sBytes *= 1024;
01011                 break;
01012         }
01013 
01014         return $sBytes;
01015     }
01016 
01027     protected function _checkTemplateBlock($sTemplate, $sBlockName)
01028     {
01029         $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
01030         if (!$sTplFile || !file_exists($sTplFile)) {
01031             // check if file is in admin theme
01032             $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, true);
01033             if (!$sTplFile || !file_exists($sTplFile)) {
01034                 return false;
01035             }
01036         }
01037 
01038         $sFile = file_get_contents($sTplFile);
01039         $sBlockNameQuoted = preg_quote($sBlockName, '/');
01040         return (bool)preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])'.$sBlockNameQuoted.'\1\s*\}\]/is', $sFile);
01041     }
01042 
01052     public function getMissingTemplateBlocks()
01053     {
01054         $oDb = oxDb::getDb( oxDb::FETCH_MODE_ASSOC );
01055         $aCache = array();
01056         $oConfig = $this->getConfig();
01057 
01058         $sShpIdParam = $oDb->quote($oConfig->getShopId());
01059         $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
01060         $rs = $oDb->execute($sSql);
01061 
01062 
01063         $aRet = array();
01064         if ($rs != false && $rs->recordCount() > 0) {
01065             while (!$rs->EOF) {
01066                 $blStatus = false;
01067                 if (isset($aCache[$rs->fields['OXTEMPLATE']]) && isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])) {
01068                     $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
01069                 } else {
01070                     $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
01071                     $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
01072                 }
01073 
01074                 if (!$blStatus) {
01075                     $aRet[] = array(
01076                                 'module'   => $rs->fields['OXMODULE'],
01077                                 'block'    => $rs->fields['OXBLOCKNAME'],
01078                                 'template' => $rs->fields['OXTEMPLATE'],
01079                             );
01080                 }
01081                 $rs->moveNext();
01082             }
01083         }
01084 
01085         return $aRet;
01086     }
01087 
01093     public function checkSessionAutostart()
01094     {
01095         $sStatus = ( strtolower( (string) @ini_get( 'session.auto_start' ) ) );
01096         return in_array( $sStatus, array( 'on', '1' ) ) ? 0 : 2;
01097     }
01098 }