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}/media/",
00319                             $sPath."out/pictures{$sVerPrefix}/master/",
00320                             $sPath."out/pictures{$sVerPrefix}/generated/",
00321                             $sPath."log/",
00322                             $sTmp
00323                             );
00324         $iModStat = 2;
00325         $sPathToCheck = reset( $aPathsToCheck );
00326         while ( $sPathToCheck ) {
00327             // missing file/folder?
00328             if ( !file_exists( $sPathToCheck ) ) {
00329                 $iModStat = 0;
00330                 break;
00331             }
00332 
00333             if ( is_dir( $sPathToCheck ) ) {
00334                 // adding subfolders
00335                 $aSubF = glob( $sPathToCheck."*", GLOB_ONLYDIR );
00336                 if (is_array($aSubF)) {
00337                     foreach ( $aSubF as $sNewFolder ) {
00338                         $aPathsToCheck[] = $sNewFolder . "/";
00339                     }
00340                 }
00341             }
00342 
00343             // testing if file permissions >= $iMinPerm
00344             //if ( ( (int) substr( decoct( fileperms( $sFullPath ) ), 2 ) ) < $iMinPerm ) {
00345             if ( !is_readable( $sPathToCheck ) || !is_writable( $sPathToCheck ) ) {
00346                 $iModStat = 0;
00347                 break;
00348             }
00349 
00350             $sPathToCheck = next( $aPathsToCheck );
00351         }
00352 
00353         return $iModStat;
00354     }
00355 
00362     protected function _getShopHostInfoFromConfig()
00363     {
00364         $sShopURL = $this->getConfig()->getConfigParam( 'sShopURL' );
00365         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
00366             $sHost = $m[2];
00367             $iPort = (int)$m[4];
00368             $blSsl = (strtolower($m[1])=='https://');
00369             if (!$iPort) {
00370                 $iPort = $blSsl?443:80;
00371             }
00372             $sScript = rtrim($m[5], '/').'/';
00373             return array(
00374                     'host'=>$sHost,
00375                     'port'=>$iPort,
00376                     'dir'=>$sScript,
00377                     'ssl'=>$blSsl,
00378             );
00379         } else {
00380             return false;
00381         }
00382     }
00383 
00390     protected function _getShopSSLHostInfoFromConfig()
00391     {
00392         $sSSLShopURL = $this->getConfig()->getConfigParam( 'sSSLShopURL' );
00393         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sSSLShopURL, $m)) {
00394             $sHost = $m[2];
00395             $iPort = (int)$m[4];
00396             $blSsl = (strtolower($m[1])=='https://');
00397             if (!$iPort) {
00398                 $iPort = $blSsl?443:80;
00399             }
00400             $sScript = rtrim($m[5], '/').'/';
00401             return array(
00402                     'host'=>$sHost,
00403                     'port'=>$iPort,
00404                     'dir'=>$sScript,
00405                     'ssl'=>$blSsl,
00406             );
00407         }
00408         return false;
00409     }
00410 
00417     protected function _getShopHostInfoFromServerVars()
00418     {
00419         // got here from setup dir
00420         $sScript = $_SERVER['SCRIPT_NAME'];
00421         $iPort = (int) $_SERVER['SERVER_PORT'];
00422         $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
00423         if (!$iPort) {
00424             $iPort = $blSsl?443:80;
00425         }
00426         $sScript = rtrim(dirname(dirname( $sScript )), '/').'/';
00427         return array(
00428                     'host'=>$_SERVER['HTTP_HOST'],
00429                     'port'=>$iPort,
00430                     'dir'=>$sScript,
00431                     'ssl'=>$blSsl,
00432         );
00433     }
00434 
00440     protected function _getShopHostInfo()
00441     {
00442         if ( $this->isAdmin() ) {
00443             return $this->_getShopHostInfoFromConfig();
00444         } else {
00445             return $this->_getShopHostInfoFromServerVars();
00446         }
00447     }
00448 
00455     protected function _getShopSSLHostInfo()
00456     {
00457         if ( $this->isAdmin() ) {
00458             return $this->_getShopSSLHostInfoFromConfig();
00459         }
00460         return false;
00461     }
00462 
00469     public function checkModRewrite()
00470     {
00471         $iModStat = null;
00472         $aHostInfo = $this->_getShopHostInfo();
00473         $iModStat = $this->_checkModRewrite( $aHostInfo );
00474 
00475         $aSSLHostInfo = $this->_getShopSSLHostInfo();
00476         // Don't need to check if mod status is already failed.
00477         if ( 0 != $iModStat && $aSSLHostInfo ) {
00478             $iSSLModStat = $this->_checkModRewrite( $aSSLHostInfo );
00479 
00480             // Send if failed, even if couldn't check another
00481             if ( 0 == $iSSLModStat ) {
00482                 return 0;
00483             } elseif ( 1 == $iSSLModStat || 1 == $iModStat ) {
00484                 return 1;
00485             }
00486 
00487             return min( $iModStat, $iSSLModStat );
00488         }
00489 
00490         return $iModStat;
00491     }
00492 
00501     protected function _checkModRewrite($aHostInfo)
00502     {
00503         if ( $rFp = @fsockopen( ($aHostInfo['ssl']?'ssl://':'').$aHostInfo['host'], $aHostInfo['port'], $iErrNo, $sErrStr, 10 ) ) {
00504             $sReq  = "POST {$aHostInfo['dir']}oxseo.php?mod_rewrite_module_is=off HTTP/1.1\r\n";
00505             $sReq .= "Host: {$aHostInfo['host']}\r\n";
00506             $sReq .= "User-Agent: OXID eShop setup\r\n";
00507             $sReq .= "Content-Type: application/x-www-form-urlencoded\r\n";
00508             $sReq .= "Content-Length: 0\r\n"; // empty post
00509             $sReq .= "Connection: close\r\n\r\n";
00510 
00511             $sOut = '';
00512             fwrite( $rFp, $sReq );
00513             while ( !feof( $rFp ) ) {
00514                 $sOut .= fgets( $rFp, 100 );
00515             }
00516             fclose( $rFp );
00517 
00518             $iModStat = ( strpos( $sOut, 'mod_rewrite_on' ) !== false ) ? 2 : 0;
00519         } else {
00520             if ( function_exists( 'apache_get_modules' ) ) {
00521                 // it does not assure that mod_rewrite is enabled on current host, so setting 1
00522                 $iModStat = in_array( 'mod_rewrite', apache_get_modules() ) ? 1 : 0;
00523             } else {
00524                 $iModStat = -1;
00525             }
00526         }
00527         return $iModStat;
00528     }
00529 
00535     public function checkAllowUrlFopen()
00536     {
00537         $iModStat = @ini_get('allow_url_fopen');
00538         $iModStat = ( $iModStat && strcasecmp( '1', $iModStat ) ) ? 2 : 1;
00539         if ( $iModStat == 1 ) {
00540             $iErrNo  = 0;
00541             $sErrStr = '';
00542             if ( $oRes = @fsockopen( 'www.example.com', 80, $iErrNo, $sErrStr, 10 ) ) {
00543                 $iModStat = 2;
00544                 fclose( $oRes );
00545             }
00546         }
00547         $iModStat = ( !$iModStat ) ? 1 : $iModStat;
00548         return $iModStat;
00549     }
00550 
00557     public function checkPhp4Compat()
00558     {
00559         $sZendStatus = ( strtolower( (string) @ini_get( 'zend.ze1_compatibility_mode' ) ) );
00560         return in_array( $sZendStatus, array( 'on', '1' ) ) ? 0 : 2;
00561     }
00562 
00571     public function checkPhpVersion()
00572     {
00573         $iModStat = ( version_compare( PHP_VERSION, '5.2', '<' ) ) ? 0 : false;
00574         $iModStat = ( $iModStat !== false ) ? $iModStat : ( (version_compare( PHP_VERSION, '5.2.0', '>=' ) && version_compare( PHP_VERSION, '5.2.10', '<' )) ? 1 : false );
00575         $iModStat = ( $iModStat !== false ) ? $iModStat : ( version_compare( PHP_VERSION, '5.2.10', '>=' ) ? 2 : 1 );
00576         return $iModStat;
00577     }
00578 
00584     public function checkRequestUri()
00585     {
00586         return ( isset( $_SERVER['REQUEST_URI'] ) || isset( $_SERVER['SCRIPT_URI'] ) ) ? 2 : 0;
00587     }
00588 
00594     public function checkLibXml2()
00595     {
00596         return class_exists( 'DOMDocument' ) ? 2 : 0;
00597     }
00598 
00604     public function checkPhpXml()
00605     {
00606         return class_exists( 'DOMDocument' ) ? 2 : 0;
00607     }
00608 
00614     public function checkJSon()
00615     {
00616         return extension_loaded( 'json' ) ? 2 : 0;
00617     }
00618 
00624     public function checkIConv()
00625     {
00626         return extension_loaded( 'iconv' ) ? 2 : 0;
00627     }
00628 
00634     public function checkTokenizer()
00635     {
00636         return extension_loaded( 'tokenizer' ) ? 2 : 0;
00637     }
00638 
00644     public function checkBcMath()
00645     {
00646         return extension_loaded( 'bcmath' ) ? 2 : 1;
00647     }
00648 
00654     public function checkOpenSsl()
00655     {
00656         return extension_loaded( 'openssl' ) ? 2 : 1;
00657     }
00658 
00664     public function checkSoap()
00665     {
00666         return extension_loaded( 'soap' ) ? 2 : 1;
00667     }
00668 
00674     public function checkMysqlConnect()
00675     {
00676         // MySQL module for MySQL5
00677         $iModStat = ( extension_loaded( 'mysql' ) || extension_loaded( 'mysqli' ) || extension_loaded( 'pdo_mysql' ) ) ? 2 : 0;
00678 
00679         // client version must be >=5
00680         if ( $iModStat ) {
00681             $sClientVersion = mysql_get_client_info();
00682             if (version_compare( $sClientVersion, '5', '<' )) {
00683                 $iModStat = 1;
00684                 if (version_compare( $sClientVersion, '4', '<' )) {
00685                     $iModStat = 0;
00686                 }
00687             } elseif (version_compare($sClientVersion, '5.0.36', '>=') && version_compare($sClientVersion, '5.0.38', '<')) {
00688                 // mantis#0001003: Problems with MySQL version 5.0.37
00689                 $iModStat = 0;
00690             } elseif (version_compare($sClientVersion, '5.0.40', '>') && version_compare($sClientVersion, '5.0.42', '<')) {
00691                 // mantis#0001877: Exclude MySQL 5.0.41 from system requirements as not fitting
00692                 $iModStat = 0;
00693             }
00694             if ( strpos($sClientVersion, 'mysqlnd') !== false ) {
00695                 // PHP 5.3 includes new mysqlnd extension
00696                 $iModStat = 2;
00697             }
00698         }
00699         return $iModStat;
00700     }
00701 
00709     public function checkMysqlVersion( $sVersion = null )
00710     {
00711         if ( $sVersion === null ) {
00712             $aRez = oxDb::getDb()->getAll( "SHOW VARIABLES LIKE 'version'" );
00713             foreach ( $aRez as $aRecord ) {
00714                 $sVersion = $aRecord[1];
00715                 break;
00716             }
00717         }
00718 
00719         $iModStat = 0;
00720         if ( version_compare( $sVersion, '5.0.3', '>=' ) && version_compare( $sVersion, '5.0.37', '<>' ) ) {
00721             $iModStat = 2;
00722         }
00723 
00724         return $iModStat;
00725     }
00726 
00732     public function checkGdInfo()
00733     {
00734         $iModStat = extension_loaded( 'gd' ) ? 1 : 0;
00735         $iModStat = function_exists( 'imagecreatetruecolor' ) ? 2 : $iModStat;
00736         $iModStat = function_exists( 'imagecreatefromjpeg' ) ? $iModStat : 0;
00737         return $iModStat;
00738     }
00739 
00745     public function checkIniSet()
00746     {
00747         return ( @ini_set('session.name', 'sid' ) !== false ) ? 2 : 0;
00748     }
00749 
00755     public function checkRegisterGlobals()
00756     {
00757         $sGlobStatus = ( strtolower( (string) @ini_get( 'register_globals' ) ) );
00758         return in_array( $sGlobStatus, array( 'on', '1' ) ) ? 0 : 2;
00759     }
00760 
00766     public function checkMemoryLimit()
00767     {
00768         if ( $sMemLimit = @ini_get('memory_limit') ) {
00769                 // CE - PE at least to 14 MB. We recomend a memory_limit of 30MB.
00770                 $sDefLimit = '14M';
00771                 $sRecLimit = '30M';
00772 
00773 
00774             $iMemLimit = $this->_getBytes( $sMemLimit );
00775             $iModStat = ( $iMemLimit >= $this->_getBytes( $sDefLimit ) ) ? 1 : 0;
00776             $iModStat = $iModStat ? ( ( $iMemLimit >= $this->_getBytes( $sRecLimit ) ) ? 2 : $iModStat ) : $iModStat;
00777 
00778         } else {
00779             $iModStat = -1;
00780         }
00781         return $iModStat;
00782     }
00783 
00789     public function checkZendOptimizer()
00790     {
00795         return 2;
00796     }
00797 
00803     public function checkZendPlatformOrServer()
00804     {
00805         if (function_exists( 'output_cache_get' )) {
00806             return 2;
00807         }
00808         if (function_exists( 'zend_disk_cache_fetch' )) {
00809             return 2;
00810         }
00811         if (function_exists( 'zend_shm_cache_fetch' )) {
00812             return 2;
00813         }
00814         return 1;
00815     }
00816 
00822     protected function _getAdditionalCheck()
00823     {
00824         $sSelect = '';
00825         foreach ( $this->_aException as $sTable => $sColumn ) {
00826             $sSelect .= 'and ( t.TABLE_NAME != "'.$sTable.'" and c.COLUMN_NAME != "'.$sColumn.'" ) ';
00827         }
00828         return $sSelect;
00829     }
00830 
00836     public function checkCollation()
00837     {
00838         $myConfig = $this->getConfig();
00839 
00840         $aCollations = array();
00841         $sCollation = '';
00842 
00843         $sSelect = 'select t.TABLE_NAME, c.COLUMN_NAME, c.COLLATION_NAME from INFORMATION_SCHEMA.tables t ' .
00844                    'LEFT JOIN INFORMATION_SCHEMA.columns c ON t.TABLE_NAME = c.TABLE_NAME  ' .
00845                    'where t.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00846                    'and c.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00847                    'and c.COLUMN_NAME in ("'.implode('", "', $this->_aColumns).'") ' . $this->_getAdditionalCheck() .
00848                    ' ORDER BY (t.TABLE_NAME = "oxarticles") DESC';
00849         $aRez = oxDb::getDb()->getAll($sSelect);
00850         foreach ( $aRez as $aRetTable ) {
00851             if ( !$sCollation ) {
00852                 $sCollation = $aRetTable[2];
00853             } else {
00854                 if ( $aRetTable[2] && $sCollation != $aRetTable[2]) {
00855                     $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
00856                 }
00857             }
00858         }
00859 
00860         if ( $this->_blSysReqStatus === null ) {
00861             $this->_blSysReqStatus = true;
00862         }
00863         if ( count($aCollations) > 0 ) {
00864             $this->_blSysReqStatus = false;
00865         }
00866         return $aCollations;
00867     }
00868 
00874     public function checkDatabaseCluster()
00875     {
00876         return 2;
00877     }
00878 
00884     public function checkUnicodeSupport()
00885     {
00886         return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
00887     }
00888 
00894     public function checkFileUploads()
00895     {
00896         $dUploadFile = -1;
00897         $sFileUploads = @ini_get('file_uploads');
00898         if ( $sFileUploads !== false ) {
00899             if ( $sFileUploads && ( $sFileUploads == '1' || strtolower($sFileUploads) == 'on') ) {
00900                 $dUploadFile = 2;
00901             } else {
00902                 $dUploadFile = 1;
00903             }
00904         }
00905         return $dUploadFile;
00906     }
00907 
00913     public function getSysReqStatus()
00914     {
00915         if ( $this->_blSysReqStatus == null ) {
00916             $this->_blSysReqStatus = true;
00917             $this->getSystemInfo();
00918             $this->checkCollation();
00919         }
00920         return $this->_blSysReqStatus;
00921     }
00922 
00937     public function getSystemInfo()
00938     {
00939         $aSysInfo = array();
00940         $aRequiredModules = $this->getRequiredModules();
00941         $this->_blSysReqStatus = true;
00942         foreach ( $aRequiredModules as $sModule => $sGroup ) {
00943             if ( isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup] ) {
00944                 $aSysInfo[$sGroup] = array();
00945             }
00946             $iModuleState = $this->getModuleInfo( $sModule );
00947             $aSysInfo[$sGroup][$sModule] = $iModuleState;
00948             $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs( $iModuleState );
00949         }
00950         return $aSysInfo;
00951     }
00952 
00960     public function getModuleInfo( $sModule = null )
00961     {
00962         if ( $sModule ) {
00963             $iModStat = null;
00964             $sCheckFunction = "check".str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
00965             $iModStat = $this->$sCheckFunction();
00966 
00967             return $iModStat;
00968         }
00969     }
00970 
00978     public function getReqInfoUrl( $sIdent)
00979     {
00980         $sUrl = $this->_sReqInfoUrl;
00981         $aInfoMap = $this->_aInfoMap;
00982 
00983         // only known will be anchored
00984         if ( isset( $aInfoMap[$sIdent] ) ) {
00985             $sUrl .= "#".$aInfoMap[$sIdent];
00986         }
00987 
00988         return $sUrl;
00989     }
00990 
00998     protected function _getBytes( $sBytes )
00999     {
01000         $sBytes = trim( $sBytes );
01001         $sLast = strtolower($sBytes[strlen($sBytes)-1]);
01002         switch( $sLast ) {
01003             // The 'G' modifier is available since PHP 5.1.0
01004             case 'g':
01005                 $sBytes *= 1024;
01006             case 'm':
01007                 $sBytes *= 1024;
01008             case 'k':
01009                 $sBytes *= 1024;
01010                 break;
01011         }
01012 
01013         return $sBytes;
01014     }
01015 
01026     protected function _checkTemplateBlock($sTemplate, $sBlockName)
01027     {
01028         $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
01029         if (!$sTplFile || !file_exists($sTplFile)) {
01030             // check if file is in admin theme
01031             $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, true);
01032             if (!$sTplFile || !file_exists($sTplFile)) {
01033                 return false;
01034             }
01035         }
01036 
01037         $sFile = file_get_contents($sTplFile);
01038         $sBlockNameQuoted = preg_quote($sBlockName, '/');
01039         return (bool)preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])'.$sBlockNameQuoted.'\1\s*\}\]/is', $sFile);
01040     }
01041 
01051     public function getMissingTemplateBlocks()
01052     {
01053         $oDb = oxDb::getDb( oxDb::FETCH_MODE_ASSOC );
01054         $aCache = array();
01055         $oConfig = $this->getConfig();
01056 
01057         $sShpIdParam = $oDb->quote($oConfig->getShopId());
01058         $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
01059         $rs = $oDb->execute($sSql);
01060 
01061 
01062         $aRet = array();
01063         if ($rs != false && $rs->recordCount() > 0) {
01064             while (!$rs->EOF) {
01065                 $blStatus = false;
01066                 if (isset($aCache[$rs->fields['OXTEMPLATE']]) && isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])) {
01067                     $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
01068                 } else {
01069                     $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
01070                     $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
01071                 }
01072 
01073                 if (!$blStatus) {
01074                     $aRet[] = array(
01075                                 'module'   => $rs->fields['OXMODULE'],
01076                                 'block'    => $rs->fields['OXBLOCKNAME'],
01077                                 'template' => $rs->fields['OXTEMPLATE'],
01078                             );
01079                 }
01080                 $rs->moveNext();
01081             }
01082         }
01083 
01084         return $aRet;
01085     }
01086 
01092     public function checkSessionAutostart()
01093     {
01094         $sStatus = ( strtolower( (string) @ini_get( 'session.auto_start' ) ) );
01095         return in_array( $sStatus, array( 'on', '1' ) ) ? 0 : 2;
01096     }
01097 }