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 oxConfig::getInstance();
00174     }
00175 
00181     public function getRequiredModules()
00182     {
00183         if ( $this->_aRequiredModules == null ) {
00184             $aRequiredPHPExtensions = array(
00185                                           'php_version',
00186                                           'lib_xml2',
00187                                           'php_xml',
00188                                           'j_son',
00189                                           'i_conv',
00190                                           'tokenizer',
00191                                           'mysql_connect',
00192                                           'gd_info',
00193                                           'mb_string',
00194                                           'curl',
00195                                           'bc_math',
00196                                           'open_ssl',
00197                                           'soap',
00198                                       );
00199 
00200             $aRequiredPHPConfigs = array(
00201                                        'allow_url_fopen',
00202                                        'php4_compat',
00203                                        'request_uri',
00204                                        'ini_set',
00205                                        'register_globals',
00206                                        'memory_limit',
00207                                        'unicode_support',
00208                                        'file_uploads',
00209                                        'session_autostart',
00210                                    );
00211 
00212             $aRequiredServerConfigs = array(
00213                                           'mod_rewrite',
00214                                           'server_permissions',
00215                                           'bug53632'
00216                                       );
00217 
00218 
00219             if ( isAdmin() ) {
00220                 $aRequiredServerConfigs[] = 'mysql_version';
00221             }
00222             $this->_aRequiredModules = array_fill_keys( $aRequiredPHPExtensions, 'php_extennsions' ) +
00223                                        array_fill_keys( $aRequiredPHPConfigs, 'php_config' ) +
00224                                        array_fill_keys( $aRequiredServerConfigs, 'server_config' );
00225         }
00226         return $this->_aRequiredModules;
00227     }
00228 
00237     public function checkBug53632()
00238     {
00239         if ( $this->_getPhpIntSize() > 4 ) {
00240             return 2;
00241         }
00242   
00243         $iState = 1;
00244         if ( version_compare( PHP_VERSION, "5.3", ">=" ) ) {
00245             if ( version_compare( PHP_VERSION, "5.3.5", ">=" ) && version_compare( PHP_VERSION, "5.3.7", "!=" ) ) {
00246                 $iState = 2;
00247             }
00248         } elseif ( version_compare( PHP_VERSION, '5.2', ">=" ) ) {
00249             $iState = version_compare( PHP_VERSION, "5.2.17", ">=" ) ? 2 : $iState;
00250         }
00251         return $iState;
00252     }
00253 
00259     public function checkCurl()
00260     {
00261         return extension_loaded( 'curl' ) ? 2 : 1;
00262     }
00263 
00269     public function checkMbString()
00270     {
00271         return extension_loaded( 'mbstring' ) ? 2 : 1;
00272     }
00273 
00282     public function checkServerPermissions( $sPath = null, $iMinPerm = 777 )
00283     {
00284         $sVerPrefix = '';
00285 
00286         clearstatcache();
00287         $sPath = $sPath ? $sPath : getShopBasePath();
00288 
00289         // special config file check
00290         $sFullPath = $sPath . "config.inc.php";
00291         if ( !is_readable( $sFullPath ) ||
00292              ( isAdmin() && is_writable( $sFullPath ) ) ||
00293              ( !isAdmin() && !is_writable( $sFullPath ) )
00294            ) {
00295             return 0;
00296         }
00297 
00298         $sTmp = "$sPath/tmp$sVerPrefix/";
00299         if (class_exists('oxConfig')) {
00300             $sCfgTmp = $this->getConfig()->getConfigParam('sCompileDir');
00301             if (strpos($sCfgTmp, '<sCompileDir_') === false) {
00302                 $sTmp = $sCfgTmp;
00303             }
00304         }
00305 
00306         $aPathsToCheck = array(
00307                             $sPath."out/pictures{$sVerPrefix}/promo/",
00308                             $sPath."out/pictures{$sVerPrefix}/media/",
00309                             $sPath."out/pictures{$sVerPrefix}/master/",
00310                             $sPath."out/pictures{$sVerPrefix}/generated/",
00311                             $sPath."log/",
00312                             $sTmp
00313                             );
00314         $iModStat = 2;
00315         $sPathToCheck = reset( $aPathsToCheck );
00316         while ( $sPathToCheck ) {
00317             // missing file/folder?
00318             if ( !file_exists( $sPathToCheck ) ) {
00319                 $iModStat = 0;
00320                 break;
00321             }
00322 
00323             if ( is_dir( $sPathToCheck ) ) {
00324                 // adding subfolders
00325                 $aSubF = glob( $sPathToCheck."*", GLOB_ONLYDIR );
00326                 if (is_array($aSubF)) {
00327                     foreach ( $aSubF as $sNewFolder ) {
00328                         $aPathsToCheck[] = $sNewFolder . "/";
00329                     }
00330                 }
00331             }
00332 
00333             // testing if file permissions >= $iMinPerm
00334             //if ( ( (int) substr( decoct( fileperms( $sFullPath ) ), 2 ) ) < $iMinPerm ) {
00335             if ( !is_readable( $sPathToCheck ) || !is_writable( $sPathToCheck ) ) {
00336                 $iModStat = 0;
00337                 break;
00338             }
00339 
00340             $sPathToCheck = next( $aPathsToCheck );
00341         }
00342 
00343         return $iModStat;
00344     }
00345 
00352     protected function _getShopHostInfoFromConfig()
00353     {
00354         $sShopURL = $this->getConfig()->getConfigParam( 'sShopURL' );
00355         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
00356             $sHost = $m[2];
00357             $iPort = (int)$m[4];
00358             $blSsl = (strtolower($m[1])=='https://');
00359             if (!$iPort) {
00360                 $iPort = $blSsl?443:80;
00361             }
00362             $sScript = rtrim($m[5], '/').'/';
00363             return array(
00364                     'host'=>$sHost,
00365                     'port'=>$iPort,
00366                     'dir'=>$sScript,
00367                     'ssl'=>$blSsl,
00368             );
00369         } else {
00370             return false;
00371         }
00372     }
00373 
00380     protected function _getShopSSLHostInfoFromConfig()
00381     {
00382         $sSSLShopURL = $this->getConfig()->getConfigParam( 'sSSLShopURL' );
00383         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sSSLShopURL, $m)) {
00384             $sHost = $m[2];
00385             $iPort = (int)$m[4];
00386             $blSsl = (strtolower($m[1])=='https://');
00387             if (!$iPort) {
00388                 $iPort = $blSsl?443:80;
00389             }
00390             $sScript = rtrim($m[5], '/').'/';
00391             return array(
00392                     'host'=>$sHost,
00393                     'port'=>$iPort,
00394                     'dir'=>$sScript,
00395                     'ssl'=>$blSsl,
00396             );
00397         }
00398         return false;
00399     }
00400 
00407     protected function _getShopHostInfoFromServerVars()
00408     {
00409         // got here from setup dir
00410         $sScript = $_SERVER['SCRIPT_NAME'];
00411         $iPort = (int) $_SERVER['SERVER_PORT'];
00412         $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
00413         if (!$iPort) {
00414             $iPort = $blSsl?443:80;
00415         }
00416         $sScript = rtrim(dirname(dirname( $sScript )), '/').'/';
00417         return array(
00418                     'host'=>$_SERVER['HTTP_HOST'],
00419                     'port'=>$iPort,
00420                     'dir'=>$sScript,
00421                     'ssl'=>$blSsl,
00422         );
00423     }
00424 
00430     protected function _getShopHostInfo()
00431     {
00432         if ( isAdmin() ) {
00433             return $this->_getShopHostInfoFromConfig();
00434         } else {
00435             return $this->_getShopHostInfoFromServerVars();
00436         }
00437     }
00438 
00445     protected function _getShopSSLHostInfo()
00446     {
00447         if ( isAdmin() ) {
00448             return $this->_getShopSSLHostInfoFromConfig();
00449         }
00450         return false;
00451     }
00452 
00459     public function checkModRewrite()
00460     {
00461         $iModStat = null;
00462         $aHostInfo = $this->_getShopHostInfo();
00463         $iModStat = $this->_checkModRewrite( $aHostInfo );
00464 
00465         $aSSLHostInfo = $this->_getShopSSLHostInfo();
00466         // Don't need to check if mod status is already failed.
00467         if ( 0 != $iModStat && $aSSLHostInfo ) {
00468             $iSSLModStat = $this->_checkModRewrite( $aSSLHostInfo );
00469 
00470             // Send if failed, even if couldn't check another
00471             if ( 0 == $iSSLModStat ) {
00472                 return 0;
00473             } elseif ( 1 == $iSSLModStat || 1 == $iModStat ) {
00474                 return 1;
00475             }
00476 
00477             return min( $iModStat, $iSSLModStat );
00478         }
00479 
00480         return $iModStat;
00481     }
00482 
00491     protected function _checkModRewrite($aHostInfo)
00492     {
00493         if ( $rFp = @fsockopen( ($aHostInfo['ssl']?'ssl://':'').$aHostInfo['host'], $aHostInfo['port'], $iErrNo, $sErrStr, 10 ) ) {
00494             $sReq  = "POST {$aHostInfo['dir']}oxseo.php?mod_rewrite_module_is=off HTTP/1.1\r\n";
00495             $sReq .= "Host: {$aHostInfo['host']}\r\n";
00496             $sReq .= "User-Agent: OXID eShop setup\r\n";
00497             $sReq .= "Content-Type: application/x-www-form-urlencoded\r\n";
00498             $sReq .= "Content-Length: 0\r\n"; // empty post
00499             $sReq .= "Connection: close\r\n\r\n";
00500 
00501             $sOut = '';
00502             fwrite( $rFp, $sReq );
00503             while ( !feof( $rFp ) ) {
00504                 $sOut .= fgets( $rFp, 100 );
00505             }
00506             fclose( $rFp );
00507 
00508             $iModStat = ( strpos( $sOut, 'mod_rewrite_on' ) !== false ) ? 2 : 0;
00509         } else {
00510             if ( function_exists( 'apache_get_modules' ) ) {
00511                 // it does not assure that mod_rewrite is enabled on current host, so setting 1
00512                 $iModStat = in_array( 'mod_rewrite', apache_get_modules() ) ? 1 : 0;
00513             } else {
00514                 $iModStat = -1;
00515             }
00516         }
00517         return $iModStat;
00518     }
00519 
00525     public function checkAllowUrlFopen()
00526     {
00527         $iModStat = @ini_get('allow_url_fopen');
00528         $iModStat = ( $iModStat && strcasecmp( '1', $iModStat ) ) ? 2 : 1;
00529         if ( $iModStat == 1 ) {
00530             $iErrNo  = 0;
00531             $sErrStr = '';
00532             if ( $oRes = @fsockopen( 'www.example.com', 80, $iErrNo, $sErrStr, 10 ) ) {
00533                 $iModStat = 2;
00534                 fclose( $oRes );
00535             }
00536         }
00537         $iModStat = ( !$iModStat ) ? 1 : $iModStat;
00538         return $iModStat;
00539     }
00540 
00547     public function checkPhp4Compat()
00548     {
00549         $sZendStatus = ( strtolower( (string) @ini_get( 'zend.ze1_compatibility_mode' ) ) );
00550         return in_array( $sZendStatus, array( 'on', '1' ) ) ? 0 : 2;
00551     }
00552 
00561     public function checkPhpVersion()
00562     {
00563         $iModStat = ( version_compare( PHP_VERSION, '5.2', '<' ) ) ? 0 : false;
00564         $iModStat = ( $iModStat !== false ) ? $iModStat : ( (version_compare( PHP_VERSION, '5.2.0', '>=' ) && version_compare( PHP_VERSION, '5.2.10', '<' )) ? 1 : false );
00565         $iModStat = ( $iModStat !== false ) ? $iModStat : ( version_compare( PHP_VERSION, '5.2.10', '>=' ) ? 2 : 1 );
00566         return $iModStat;
00567     }
00568 
00574     public function checkRequestUri()
00575     {
00576         return ( isset( $_SERVER['REQUEST_URI'] ) || isset( $_SERVER['SCRIPT_URI'] ) ) ? 2 : 0;
00577     }
00578 
00584     public function checkLibXml2()
00585     {
00586         return class_exists( 'DOMDocument' ) ? 2 : 0;
00587     }
00588 
00594     public function checkPhpXml()
00595     {
00596         return class_exists( 'DOMDocument' ) ? 2 : 0;
00597     }
00598 
00604     public function checkJSon()
00605     {
00606         return extension_loaded( 'json' ) ? 2 : 0;
00607     }
00608 
00614     public function checkIConv()
00615     {
00616         return extension_loaded( 'iconv' ) ? 2 : 0;
00617     }
00618 
00624     public function checkTokenizer()
00625     {
00626         return extension_loaded( 'tokenizer' ) ? 2 : 0;
00627     }
00628 
00634     public function checkBcMath()
00635     {
00636         return extension_loaded( 'bcmath' ) ? 2 : 1;
00637     }
00638 
00644     public function checkOpenSsl()
00645     {
00646         return extension_loaded( 'openssl' ) ? 2 : 1;
00647     }
00648 
00654     public function checkSoap()
00655     {
00656         return extension_loaded( 'soap' ) ? 2 : 1;
00657     }
00658 
00664     public function checkMysqlConnect()
00665     {
00666         // MySQL module for MySQL5
00667         $iModStat = ( extension_loaded( 'mysql' ) || extension_loaded( 'mysqli' ) || extension_loaded( 'pdo_mysql' ) ) ? 2 : 0;
00668 
00669         // client version must be >=5
00670         if ( $iModStat ) {
00671             $sClientVersion = mysql_get_client_info();
00672             if (version_compare( $sClientVersion, '5', '<' )) {
00673                 $iModStat = 1;
00674                 if (version_compare( $sClientVersion, '4', '<' )) {
00675                     $iModStat = 0;
00676                 }
00677             } elseif (version_compare($sClientVersion, '5.0.36', '>=') && version_compare($sClientVersion, '5.0.38', '<')) {
00678                 // mantis#0001003: Problems with MySQL version 5.0.37
00679                 $iModStat = 0;
00680             } elseif (version_compare($sClientVersion, '5.0.40', '>') && version_compare($sClientVersion, '5.0.42', '<')) {
00681                 // mantis#0001877: Exclude MySQL 5.0.41 from system requirements as not fitting
00682                 $iModStat = 0;
00683             }
00684             if ( strpos($sClientVersion, 'mysqlnd') !== false ) {
00685                 // PHP 5.3 includes new mysqlnd extension
00686                 $iModStat = 2;
00687             }
00688         }
00689         return $iModStat;
00690     }
00691 
00699     public function checkMysqlVersion( $sVersion = null )
00700     {
00701         if ( $sVersion === null ) {
00702             $aRez = oxDb::getDb()->getAll( "SHOW VARIABLES LIKE 'version'" );
00703             foreach ( $aRez as $aRecord ) {
00704                 $sVersion = $aRecord[1];
00705                 break;
00706             }
00707         }
00708 
00709         $iModStat = 0;
00710         if ( version_compare( $sVersion, '5.0.3', '>=' ) && version_compare( $sVersion, '5.0.37', '<>' ) ) {
00711             $iModStat = 2;
00712         }
00713 
00714         return $iModStat;
00715     }
00716 
00722     public function checkGdInfo()
00723     {
00724         $iModStat = extension_loaded( 'gd' ) ? 1 : 0;
00725         $iModStat = function_exists( 'imagecreatetruecolor' ) ? 2 : $iModStat;
00726         $iModStat = function_exists( 'imagecreatefromjpeg' ) ? $iModStat : 0;
00727         return $iModStat;
00728     }
00729 
00735     public function checkIniSet()
00736     {
00737         return ( @ini_set('session.name', 'sid' ) !== false ) ? 2 : 0;
00738     }
00739 
00745     public function checkRegisterGlobals()
00746     {
00747         $sGlobStatus = ( strtolower( (string) @ini_get( 'register_globals' ) ) );
00748         return in_array( $sGlobStatus, array( 'on', '1' ) ) ? 0 : 2;
00749     }
00750 
00756     public function checkMemoryLimit()
00757     {
00758         if ( $sMemLimit = @ini_get('memory_limit') ) {
00759                 // CE - PE at least to 14 MB. We recomend a memory_limit of 30MB.
00760                 $sDefLimit = '14M';
00761                 $sRecLimit = '30M';
00762 
00763 
00764             $iMemLimit = $this->_getBytes( $sMemLimit );
00765             $iModStat = ( $iMemLimit >= $this->_getBytes( $sDefLimit ) ) ? 1 : 0;
00766             $iModStat = $iModStat ? ( ( $iMemLimit >= $this->_getBytes( $sRecLimit ) ) ? 2 : $iModStat ) : $iModStat;
00767 
00768         } else {
00769             $iModStat = -1;
00770         }
00771         return $iModStat;
00772     }
00773 
00779     public function checkZendOptimizer()
00780     {
00785         return 2;
00786     }
00787 
00793     public function checkZendPlatformOrServer()
00794     {
00795         if (function_exists( 'output_cache_get' )) {
00796             return 2;
00797         }
00798         if (function_exists( 'zend_disk_cache_fetch' )) {
00799             return 2;
00800         }
00801         if (function_exists( 'zend_shm_cache_fetch' )) {
00802             return 2;
00803         }
00804         return 1;
00805     }
00806 
00812     protected function _getAdditionalCheck()
00813     {
00814         $sSelect = '';
00815         foreach ( $this->_aException as $sTable => $sColumn ) {
00816             $sSelect .= 'and ( t.TABLE_NAME != "'.$sTable.'" and c.COLUMN_NAME != "'.$sColumn.'" ) ';
00817         }
00818         return $sSelect;
00819     }
00820 
00826     public function checkCollation()
00827     {
00828         $myConfig = $this->getConfig();
00829 
00830         $aCollations = array();
00831         $sCollation = '';
00832 
00833         $sSelect = 'select t.TABLE_NAME, c.COLUMN_NAME, c.COLLATION_NAME from INFORMATION_SCHEMA.tables t ' .
00834                    'LEFT JOIN INFORMATION_SCHEMA.columns c ON t.TABLE_NAME = c.TABLE_NAME  ' .
00835                    'where t.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00836                    'and c.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00837                    'and c.COLUMN_NAME in ("'.implode('", "', $this->_aColumns).'") ' . $this->_getAdditionalCheck() .
00838                    ' ORDER BY (t.TABLE_NAME = "oxarticles") DESC';
00839         $aRez = oxDb::getDb()->getAll($sSelect);
00840         foreach ( $aRez as $aRetTable ) {
00841             if ( !$sCollation ) {
00842                 $sCollation = $aRetTable[2];
00843             } else {
00844                 if ( $aRetTable[2] && $sCollation != $aRetTable[2]) {
00845                     $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
00846                 }
00847             }
00848         }
00849 
00850         if ( $this->_blSysReqStatus === null ) {
00851             $this->_blSysReqStatus = true;
00852         }
00853         if ( count($aCollations) > 0 ) {
00854             $this->_blSysReqStatus = false;
00855         }
00856         return $aCollations;
00857     }
00858 
00864     public function checkDatabaseCluster()
00865     {
00866         return 2;
00867     }
00868 
00874     public function checkUnicodeSupport()
00875     {
00876         return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
00877     }
00878 
00884     public function checkFileUploads()
00885     {
00886         $dUploadFile = -1;
00887         $sFileUploads = @ini_get('file_uploads');
00888         if ( $sFileUploads !== false ) {
00889             if ( $sFileUploads && ( $sFileUploads == '1' || strtolower($sFileUploads) == 'on') ) {
00890                 $dUploadFile = 2;
00891             } else {
00892                 $dUploadFile = 1;
00893             }
00894         }
00895         return $dUploadFile;
00896     }
00897 
00903     public function getSysReqStatus()
00904     {
00905         if ( $this->_blSysReqStatus == null ) {
00906             $this->_blSysReqStatus = true;
00907             $this->getSystemInfo();
00908             $this->checkCollation();
00909         }
00910         return $this->_blSysReqStatus;
00911     }
00912 
00927     public function getSystemInfo()
00928     {
00929         $aSysInfo = array();
00930         $aRequiredModules = $this->getRequiredModules();
00931         $this->_blSysReqStatus = true;
00932         foreach ( $aRequiredModules as $sModule => $sGroup ) {
00933             if ( isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup] ) {
00934                 $aSysInfo[$sGroup] = array();
00935             }
00936             $iModuleState = $this->getModuleInfo( $sModule );
00937             $aSysInfo[$sGroup][$sModule] = $iModuleState;
00938             $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs( $iModuleState );
00939         }
00940         return $aSysInfo;
00941     }
00942 
00950     public function getModuleInfo( $sModule = null )
00951     {
00952         if ( $sModule ) {
00953             $iModStat = null;
00954             $sCheckFunction = "check".str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
00955             $iModStat = $this->$sCheckFunction();
00956 
00957             return $iModStat;
00958         }
00959     }
00960 
00968     public function getReqInfoUrl( $sIdent)
00969     {
00970         $sUrl = $this->_sReqInfoUrl;
00971         $aInfoMap = $this->_aInfoMap;
00972 
00973         // only known will be anchored
00974         if ( isset( $aInfoMap[$sIdent] ) ) {
00975             $sUrl .= "#".$aInfoMap[$sIdent];
00976         }
00977 
00978         return $sUrl;
00979     }
00980 
00988     protected function _getBytes( $sBytes )
00989     {
00990         $sBytes = trim( $sBytes );
00991         $sLast = strtolower($sBytes[strlen($sBytes)-1]);
00992         switch( $sLast ) {
00993             // The 'G' modifier is available since PHP 5.1.0
00994             case 'g':
00995                 $sBytes *= 1024;
00996             case 'm':
00997                 $sBytes *= 1024;
00998             case 'k':
00999                 $sBytes *= 1024;
01000                 break;
01001         }
01002 
01003         return $sBytes;
01004     }
01005 
01016     protected function _checkTemplateBlock($sTemplate, $sBlockName)
01017     {
01018         $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
01019         if (!$sTplFile || !file_exists($sTplFile)) {
01020             // check if file is in admin theme
01021             $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, true);
01022             if (!$sTplFile || !file_exists($sTplFile)) {
01023                 return false;
01024             }
01025         }
01026 
01027         $sFile = file_get_contents($sTplFile);
01028         $sBlockNameQuoted = preg_quote($sBlockName, '/');
01029         return (bool)preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])'.$sBlockNameQuoted.'\1\s*\}\]/is', $sFile);
01030     }
01031 
01041     public function getMissingTemplateBlocks()
01042     {
01043         $oDb = oxDb::getDb( oxDb::FETCH_MODE_ASSOC );
01044         $aCache = array();
01045         $oConfig = $this->getConfig();
01046 
01047         $sShpIdParam = $oDb->quote($oConfig->getShopId());
01048         $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
01049         $rs = $oDb->execute($sSql);
01050 
01051 
01052         $aRet = array();
01053         if ($rs != false && $rs->recordCount() > 0) {
01054             while (!$rs->EOF) {
01055                 $blStatus = false;
01056                 if (isset($aCache[$rs->fields['OXTEMPLATE']]) && isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])) {
01057                     $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
01058                 } else {
01059                     $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
01060                     $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
01061                 }
01062 
01063                 if (!$blStatus) {
01064                     $aRet[] = array(
01065                                 'module'   => $rs->fields['OXMODULE'],
01066                                 'block'    => $rs->fields['OXBLOCKNAME'],
01067                                 'template' => $rs->fields['OXTEMPLATE'],
01068                             );
01069                 }
01070                 $rs->moveNext();
01071             }
01072         }
01073 
01074         return $aRet;
01075     }
01076 
01082     public function checkSessionAutostart()
01083     {
01084         $sStatus = ( strtolower( (string) @ini_get( 'session.auto_start' ) ) );
01085         return in_array( $sStatus, array( 'on', '1' ) ) ? 0 : 2;
01086     }
01087 }