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     public function __construct()
00128     {
00129     }
00130 
00142     public function __call( $sMethod, $aArgs )
00143     {
00144         if ( defined( 'OXID_PHP_UNIT' ) ) {
00145             if ( substr( $sMethod, 0, 4) == "UNIT" ) {
00146                 $sMethod = str_replace( "UNIT", "_", $sMethod );
00147             }
00148             if ( method_exists( $this, $sMethod)) {
00149                 return call_user_func_array( array( & $this, $sMethod ), $aArgs );
00150             }
00151         }
00152 
00153         throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
00154     }
00155 
00161     public function getConfig()
00162     {
00163         return oxConfig::getInstance();
00164     }
00165 
00171     public function getRequiredModules()
00172     {
00173         if ( $this->_aRequiredModules == null ) {
00174             $aRequiredPHPExtensions = array(
00175                                           'php_version',
00176                                           'lib_xml2',
00177                                           'php_xml',
00178                                           'j_son',
00179                                           'i_conv',
00180                                           'tokenizer',
00181                                           'mysql_connect',
00182                                           'gd_info',
00183                                           'mb_string',
00184                                           'curl',
00185                                           'bc_math',
00186                                           'open_ssl',
00187                                           'soap',
00188                                       );
00189 
00190             $aRequiredPHPConfigs = array(
00191                                        'allow_url_fopen',
00192                                        'php4_compat',
00193                                        'request_uri',
00194                                        'ini_set',
00195                                        'register_globals',
00196                                        'memory_limit',
00197                                        'unicode_support',
00198                                        'file_uploads',
00199                                        'session_autostart',
00200                                    );
00201 
00202             $aRequiredServerConfigs = array(
00203                                           'mod_rewrite',
00204                                           'server_permissions',
00205                                           'bug53632'
00206                                       );
00207 
00208 
00209             if ( isAdmin() ) {
00210                 $aRequiredServerConfigs[] = 'mysql_version';
00211             }
00212             $this->_aRequiredModules = array_fill_keys( $aRequiredPHPExtensions, 'php_extennsions' ) +
00213                                        array_fill_keys( $aRequiredPHPConfigs, 'php_config' ) +
00214                                        array_fill_keys( $aRequiredServerConfigs, 'server_config' );
00215         }
00216         return $this->_aRequiredModules;
00217     }
00218 
00227     public function checkBug53632()
00228     {
00229         $iState = 1;
00230         if ( version_compare( PHP_VERSION, "5.3", ">=" ) ) {
00231             if ( version_compare( PHP_VERSION, "5.3.5", ">=" ) && version_compare( PHP_VERSION, "5.3.7", "!=" ) ) {
00232                 $iState = 2;
00233             }
00234         } elseif ( version_compare( PHP_VERSION, '5.2', ">=" ) ) {
00235             $iState = version_compare( PHP_VERSION, "5.2.17", ">=" ) ? 2 : $iState;
00236         }
00237         return $iState;
00238     }
00239 
00245     public function checkCurl()
00246     {
00247         return extension_loaded( 'curl' ) ? 2 : 1;
00248     }
00249 
00255     public function checkMbString()
00256     {
00257         return extension_loaded( 'mbstring' ) ? 2 : 1;
00258     }
00259 
00268     public function checkServerPermissions( $sPath = null, $iMinPerm = 777 )
00269     {
00270         $sVerPrefix = '';
00271 
00272         clearstatcache();
00273         $sPath = $sPath ? $sPath : getShopBasePath();
00274 
00275         // special config file check
00276         $sFullPath = $sPath . "config.inc.php";
00277         if ( !is_readable( $sFullPath ) ||
00278              ( isAdmin() && is_writable( $sFullPath ) ) ||
00279              ( !isAdmin() && !is_writable( $sFullPath ) )
00280            ) {
00281             return 0;
00282         }
00283 
00284         $sTmp = "$sPath/tmp$sVerPrefix/";
00285         if (class_exists('oxConfig')) {
00286             $sCfgTmp = $this->getConfig()->getConfigParam('sCompileDir');
00287             if (strpos($sCfgTmp, '<sCompileDir_') === false) {
00288                 $sTmp = $sCfgTmp;
00289             }
00290         }
00291 
00292         $aPathsToCheck = array(
00293                             $sPath."out/pictures{$sVerPrefix}/promo/",
00294                             $sPath."out/pictures{$sVerPrefix}/media/",
00295                             $sPath."out/pictures{$sVerPrefix}/master/",
00296                             $sPath."out/pictures{$sVerPrefix}/generated/",
00297                             $sPath."log/",
00298                             $sTmp
00299                             );
00300         $iModStat = 2;
00301         $sPathToCheck = reset( $aPathsToCheck );
00302         while ( $sPathToCheck ) {
00303             // missing file/folder?
00304             if ( !file_exists( $sPathToCheck ) ) {
00305                 $iModStat = 0;
00306                 break;
00307             }
00308 
00309             if ( is_dir( $sPathToCheck ) ) {
00310                 // adding subfolders
00311                 $aSubF = glob( $sPathToCheck."*", GLOB_ONLYDIR );
00312                 if (is_array($aSubF)) {
00313                     foreach ( $aSubF as $sNewFolder ) {
00314                         $aPathsToCheck[] = $sNewFolder . "/";
00315                     }
00316                 }
00317             }
00318 
00319             // testing if file permissions >= $iMinPerm
00320             //if ( ( (int) substr( decoct( fileperms( $sFullPath ) ), 2 ) ) < $iMinPerm ) {
00321             if ( !is_readable( $sPathToCheck ) || !is_writable( $sPathToCheck ) ) {
00322                 $iModStat = 0;
00323                 break;
00324             }
00325 
00326             $sPathToCheck = next( $aPathsToCheck );
00327         }
00328 
00329         return $iModStat;
00330     }
00331 
00338     protected function _getShopHostInfoFromConfig()
00339     {
00340         $sShopURL = $this->getConfig()->getConfigParam( 'sShopURL' );
00341         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
00342             $sHost = $m[2];
00343             $iPort = (int)$m[4];
00344             $blSsl = (strtolower($m[1])=='https://');
00345             if (!$iPort) {
00346                 $iPort = $blSsl?443:80;
00347             }
00348             $sScript = rtrim($m[5], '/').'/';
00349             return array(
00350                     'host'=>$sHost,
00351                     'port'=>$iPort,
00352                     'dir'=>$sScript,
00353                     'ssl'=>$blSsl,
00354             );
00355         } else {
00356             return false;
00357         }
00358     }
00359 
00366     protected function _getShopSSLHostInfoFromConfig()
00367     {
00368         $sSSLShopURL = $this->getConfig()->getConfigParam( 'sSSLShopURL' );
00369         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sSSLShopURL, $m)) {
00370             $sHost = $m[2];
00371             $iPort = (int)$m[4];
00372             $blSsl = (strtolower($m[1])=='https://');
00373             if (!$iPort) {
00374                 $iPort = $blSsl?443:80;
00375             }
00376             $sScript = rtrim($m[5], '/').'/';
00377             return array(
00378                     'host'=>$sHost,
00379                     'port'=>$iPort,
00380                     'dir'=>$sScript,
00381                     'ssl'=>$blSsl,
00382             );
00383         }
00384         return false;
00385     }
00386 
00393     protected function _getShopHostInfoFromServerVars()
00394     {
00395         // got here from setup dir
00396         $sScript = $_SERVER['SCRIPT_NAME'];
00397         $iPort = (int) $_SERVER['SERVER_PORT'];
00398         $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
00399         if (!$iPort) {
00400             $iPort = $blSsl?443:80;
00401         }
00402         $sScript = rtrim(dirname(dirname( $sScript )), '/').'/';
00403         return array(
00404                     'host'=>$_SERVER['HTTP_HOST'],
00405                     'port'=>$iPort,
00406                     'dir'=>$sScript,
00407                     'ssl'=>$blSsl,
00408         );
00409     }
00410 
00416     protected function _getShopHostInfo()
00417     {
00418         if ( isAdmin() ) {
00419             return $this->_getShopHostInfoFromConfig();
00420         } else {
00421             return $this->_getShopHostInfoFromServerVars();
00422         }
00423     }
00424 
00431     protected function _getShopSSLHostInfo()
00432     {
00433         if ( isAdmin() ) {
00434             return $this->_getShopSSLHostInfoFromConfig();
00435         }
00436         return false;
00437     }
00438 
00445     public function checkModRewrite()
00446     {
00447         $iModStat = null;
00448         $aHostInfo = $this->_getShopHostInfo();
00449         $iModStat = $this->_checkModRewrite( $aHostInfo );
00450 
00451         $aSSLHostInfo = $this->_getShopSSLHostInfo();
00452         // Don't need to check if mod status is already failed.
00453         if ( 0 != $iModStat && $aSSLHostInfo ) {
00454             $iSSLModStat = $this->_checkModRewrite( $aSSLHostInfo );
00455 
00456             // Send if failed, even if couldn't check another
00457             if ( 0 == $iSSLModStat ) {
00458                 return 0;
00459             } elseif ( 1 == $iSSLModStat || 1 == $iModStat ) {
00460                 return 1;
00461             }
00462 
00463             return min( $iModStat, $iSSLModStat );
00464         }
00465 
00466         return $iModStat;
00467     }
00468 
00477     protected function _checkModRewrite($aHostInfo)
00478     {
00479         if ( $rFp = @fsockopen( ($aHostInfo['ssl']?'ssl://':'').$aHostInfo['host'], $aHostInfo['port'], $iErrNo, $sErrStr, 10 ) ) {
00480             $sReq  = "POST {$aHostInfo['dir']}oxseo.php?mod_rewrite_module_is=off HTTP/1.1\r\n";
00481             $sReq .= "Host: {$aHostInfo['host']}\r\n";
00482             $sReq .= "User-Agent: OXID eShop setup\r\n";
00483             $sReq .= "Content-Type: application/x-www-form-urlencoded\r\n";
00484             $sReq .= "Content-Length: 0\r\n"; // empty post
00485             $sReq .= "Connection: close\r\n\r\n";
00486 
00487             $sOut = '';
00488             fwrite( $rFp, $sReq );
00489             while ( !feof( $rFp ) ) {
00490                 $sOut .= fgets( $rFp, 100 );
00491             }
00492             fclose( $rFp );
00493 
00494             $iModStat = ( strpos( $sOut, 'mod_rewrite_on' ) !== false ) ? 2 : 0;
00495         } else {
00496             if ( function_exists( 'apache_get_modules' ) ) {
00497                 // it does not assure that mod_rewrite is enabled on current host, so setting 1
00498                 $iModStat = in_array( 'mod_rewrite', apache_get_modules() ) ? 1 : 0;
00499             } else {
00500                 $iModStat = -1;
00501             }
00502         }
00503         return $iModStat;
00504     }
00505 
00511     public function checkAllowUrlFopen()
00512     {
00513         $iModStat = @ini_get('allow_url_fopen');
00514         $iModStat = ( $iModStat && strcasecmp( '1', $iModStat ) ) ? 2 : 1;
00515         if ( $iModStat == 1 ) {
00516             $iErrNo  = 0;
00517             $sErrStr = '';
00518             if ( $oRes = @fsockopen( 'www.example.com', 80, $iErrNo, $sErrStr, 10 ) ) {
00519                 $iModStat = 2;
00520                 fclose( $oRes );
00521             }
00522         }
00523         $iModStat = ( !$iModStat ) ? 1 : $iModStat;
00524         return $iModStat;
00525     }
00526 
00533     public function checkPhp4Compat()
00534     {
00535         $sZendStatus = ( strtolower( (string) @ini_get( 'zend.ze1_compatibility_mode' ) ) );
00536         return in_array( $sZendStatus, array( 'on', '1' ) ) ? 0 : 2;
00537     }
00538 
00547     public function checkPhpVersion()
00548     {
00549         $iModStat = ( version_compare( PHP_VERSION, '5.2', '<' ) ) ? 0 : false;
00550         $iModStat = ( $iModStat !== false ) ? $iModStat : ( (version_compare( PHP_VERSION, '5.2.0', '>=' ) && version_compare( PHP_VERSION, '5.2.10', '<' )) ? 1 : false );
00551         $iModStat = ( $iModStat !== false ) ? $iModStat : ( version_compare( PHP_VERSION, '5.2.10', '>=' ) ? 2 : 1 );
00552         return $iModStat;
00553     }
00554 
00560     public function checkRequestUri()
00561     {
00562         return ( isset( $_SERVER['REQUEST_URI'] ) || isset( $_SERVER['SCRIPT_URI'] ) ) ? 2 : 0;
00563     }
00564 
00570     public function checkLibXml2()
00571     {
00572         return class_exists( 'DOMDocument' ) ? 2 : 0;
00573     }
00574 
00580     public function checkPhpXml()
00581     {
00582         return class_exists( 'DOMDocument' ) ? 2 : 0;
00583     }
00584 
00590     public function checkJSon()
00591     {
00592         return extension_loaded( 'json' ) ? 2 : 0;
00593     }
00594 
00600     public function checkIConv()
00601     {
00602         return extension_loaded( 'iconv' ) ? 2 : 0;
00603     }
00604 
00610     public function checkTokenizer()
00611     {
00612         return extension_loaded( 'tokenizer' ) ? 2 : 0;
00613     }
00614 
00620     public function checkBcMath()
00621     {
00622         return extension_loaded( 'bcmath' ) ? 2 : 1;
00623     }
00624 
00630     public function checkOpenSsl()
00631     {
00632         return extension_loaded( 'openssl' ) ? 2 : 1;
00633     }
00634 
00640     public function checkSoap()
00641     {
00642         return extension_loaded( 'soap' ) ? 2 : 1;
00643     }
00644 
00650     public function checkMysqlConnect()
00651     {
00652         // MySQL module for MySQL5
00653         $iModStat = ( extension_loaded( 'mysql' ) || extension_loaded( 'mysqli' ) || extension_loaded( 'pdo_mysql' ) ) ? 2 : 0;
00654 
00655         // client version must be >=5
00656         if ( $iModStat ) {
00657             $sClientVersion = mysql_get_client_info();
00658             if (version_compare( $sClientVersion, '5', '<' )) {
00659                 $iModStat = 1;
00660                 if (version_compare( $sClientVersion, '4', '<' )) {
00661                     $iModStat = 0;
00662                 }
00663             } elseif (version_compare($sClientVersion, '5.0.36', '>=') && version_compare($sClientVersion, '5.0.38', '<')) {
00664                 // mantis#0001003: Problems with MySQL version 5.0.37
00665                 $iModStat = 0;
00666             } elseif (version_compare($sClientVersion, '5.0.40', '>') && version_compare($sClientVersion, '5.0.42', '<')) {
00667                 // mantis#0001877: Exclude MySQL 5.0.41 from system requirements as not fitting
00668                 $iModStat = 0;
00669             }
00670             if ( strpos($sClientVersion, 'mysqlnd') !== false ) {
00671                 // PHP 5.3 includes new mysqlnd extension
00672                 $iModStat = 2;
00673             }
00674         }
00675         return $iModStat;
00676     }
00677 
00685     public function checkMysqlVersion( $sVersion = null )
00686     {
00687         if ( $sVersion === null ) {
00688             $aRez = oxDb::getDb()->getAll( "SHOW VARIABLES LIKE 'version'" );
00689             foreach ( $aRez as $aRecord ) {
00690                 $sVersion = $aRecord[1];
00691                 break;
00692             }
00693         }
00694 
00695         $iModStat = 0;
00696         if ( version_compare( $sVersion, '5.0.3', '>=' ) && version_compare( $sVersion, '5.0.37', '<>' ) ) {
00697             $iModStat = 2;
00698         }
00699 
00700         return $iModStat;
00701     }
00702 
00708     public function checkGdInfo()
00709     {
00710         $iModStat = extension_loaded( 'gd' ) ? 1 : 0;
00711         $iModStat = function_exists( 'imagecreatetruecolor' ) ? 2 : $iModStat;
00712         $iModStat = function_exists( 'imagecreatefromjpeg' ) ? $iModStat : 0;
00713         return $iModStat;
00714     }
00715 
00721     public function checkIniSet()
00722     {
00723         return ( @ini_set('session.name', 'sid' ) !== false ) ? 2 : 0;
00724     }
00725 
00731     public function checkRegisterGlobals()
00732     {
00733         $sGlobStatus = ( strtolower( (string) @ini_get( 'register_globals' ) ) );
00734         return in_array( $sGlobStatus, array( 'on', '1' ) ) ? 0 : 2;
00735     }
00736 
00742     public function checkMemoryLimit()
00743     {
00744         if ( $sMemLimit = @ini_get('memory_limit') ) {
00745                 // CE - PE at least to 14 MB. We recomend a memory_limit of 30MB.
00746                 $sDefLimit = '14M';
00747                 $sRecLimit = '30M';
00748 
00749 
00750             $iMemLimit = $this->_getBytes( $sMemLimit );
00751             $iModStat = ( $iMemLimit >= $this->_getBytes( $sDefLimit ) ) ? 1 : 0;
00752             $iModStat = $iModStat ? ( ( $iMemLimit >= $this->_getBytes( $sRecLimit ) ) ? 2 : $iModStat ) : $iModStat;
00753 
00754         } else {
00755             $iModStat = -1;
00756         }
00757         return $iModStat;
00758     }
00759 
00765     public function checkZendOptimizer()
00766     {
00771         return 2;
00772     }
00773 
00779     public function checkZendPlatformOrServer()
00780     {
00781         if (function_exists( 'output_cache_get' )) {
00782             return 2;
00783         }
00784         if (function_exists( 'zend_disk_cache_fetch' )) {
00785             return 2;
00786         }
00787         if (function_exists( 'zend_shm_cache_fetch' )) {
00788             return 2;
00789         }
00790         return 1;
00791     }
00792 
00798     protected function _getAdditionalCheck()
00799     {
00800         $sSelect = '';
00801         foreach ( $this->_aException as $sTable => $sColumn ) {
00802             $sSelect .= 'and ( t.TABLE_NAME != "'.$sTable.'" and c.COLUMN_NAME != "'.$sColumn.'" ) ';
00803         }
00804         return $sSelect;
00805     }
00806 
00812     public function checkCollation()
00813     {
00814         $myConfig = $this->getConfig();
00815 
00816         $aCollations = array();
00817         $sCollation = '';
00818 
00819         $sSelect = 'select t.TABLE_NAME, c.COLUMN_NAME, c.COLLATION_NAME from INFORMATION_SCHEMA.tables t ' .
00820                    'LEFT JOIN INFORMATION_SCHEMA.columns c ON t.TABLE_NAME = c.TABLE_NAME  ' .
00821                    'where t.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00822                    'and c.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00823                    'and c.COLUMN_NAME in ("'.implode('", "', $this->_aColumns).'") ' . $this->_getAdditionalCheck() .
00824                    ' ORDER BY (t.TABLE_NAME = "oxarticles") DESC';
00825         $aRez = oxDb::getDb()->getAll($sSelect);
00826         foreach ( $aRez as $aRetTable ) {
00827             if ( !$sCollation ) {
00828                 $sCollation = $aRetTable[2];
00829             } else {
00830                 if ( $aRetTable[2] && $sCollation != $aRetTable[2]) {
00831                     $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
00832                 }
00833             }
00834         }
00835 
00836         if ( $this->_blSysReqStatus === null ) {
00837             $this->_blSysReqStatus = true;
00838         }
00839         if ( count($aCollations) > 0 ) {
00840             $this->_blSysReqStatus = false;
00841         }
00842         return $aCollations;
00843     }
00844 
00850     public function checkDatabaseCluster()
00851     {
00852         return 2;
00853     }
00854 
00860     public function checkUnicodeSupport()
00861     {
00862         return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
00863     }
00864 
00870     public function checkFileUploads()
00871     {
00872         $dUploadFile = -1;
00873         $sFileUploads = @ini_get('file_uploads');
00874         if ( $sFileUploads !== false ) {
00875             if ( $sFileUploads && ( $sFileUploads == '1' || strtolower($sFileUploads) == 'on') ) {
00876                 $dUploadFile = 2;
00877             } else {
00878                 $dUploadFile = 1;
00879             }
00880         }
00881         return $dUploadFile;
00882     }
00883 
00889     public function getSysReqStatus()
00890     {
00891         if ( $this->_blSysReqStatus == null ) {
00892             $this->_blSysReqStatus = true;
00893             $this->getSystemInfo();
00894             $this->checkCollation();
00895         }
00896         return $this->_blSysReqStatus;
00897     }
00898 
00913     public function getSystemInfo()
00914     {
00915         $aSysInfo = array();
00916         $aRequiredModules = $this->getRequiredModules();
00917         $this->_blSysReqStatus = true;
00918         foreach ( $aRequiredModules as $sModule => $sGroup ) {
00919             if ( isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup] ) {
00920                 $aSysInfo[$sGroup] = array();
00921             }
00922             $iModuleState = $this->getModuleInfo( $sModule );
00923             $aSysInfo[$sGroup][$sModule] = $iModuleState;
00924             $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs( $iModuleState );
00925         }
00926         return $aSysInfo;
00927     }
00928 
00936     public function getModuleInfo( $sModule = null )
00937     {
00938         if ( $sModule ) {
00939             $iModStat = null;
00940             $sCheckFunction = "check".str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
00941             $iModStat = $this->$sCheckFunction();
00942 
00943             return $iModStat;
00944         }
00945     }
00946 
00954     public function getReqInfoUrl( $sIdent)
00955     {
00956         $sUrl = $this->_sReqInfoUrl;
00957         $aInfoMap = $this->_aInfoMap;
00958 
00959         // only known will be anchored
00960         if ( isset( $aInfoMap[$sIdent] ) ) {
00961             $sUrl .= "#".$aInfoMap[$sIdent];
00962         }
00963 
00964         return $sUrl;
00965     }
00966 
00974     protected function _getBytes( $sBytes )
00975     {
00976         $sBytes = trim( $sBytes );
00977         $sLast = strtolower($sBytes[strlen($sBytes)-1]);
00978         switch( $sLast ) {
00979             // The 'G' modifier is available since PHP 5.1.0
00980             case 'g':
00981                 $sBytes *= 1024;
00982             case 'm':
00983                 $sBytes *= 1024;
00984             case 'k':
00985                 $sBytes *= 1024;
00986                 break;
00987         }
00988 
00989         return $sBytes;
00990     }
00991 
01002     protected function _checkTemplateBlock($sTemplate, $sBlockName)
01003     {
01004         $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
01005         if (!$sTplFile || !file_exists($sTplFile)) {
01006             // check if file is in admin theme
01007             $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, true);
01008             if (!$sTplFile || !file_exists($sTplFile)) {
01009                 return false;
01010             }
01011         }
01012 
01013         $sFile = file_get_contents($sTplFile);
01014         $sBlockNameQuoted = preg_quote($sBlockName, '/');
01015         return (bool)preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])'.$sBlockNameQuoted.'\1\s*\}\]/is', $sFile);
01016     }
01017 
01027     public function getMissingTemplateBlocks()
01028     {
01029         $oDb = oxDb::getDb( oxDb::FETCH_MODE_ASSOC );
01030         $aCache = array();
01031         $oConfig = $this->getConfig();
01032 
01033         $sShpIdParam = $oDb->quote($oConfig->getShopId());
01034         $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
01035         $rs = $oDb->execute($sSql);
01036 
01037 
01038         $aRet = array();
01039         if ($rs != false && $rs->recordCount() > 0) {
01040             while (!$rs->EOF) {
01041                 $blStatus = false;
01042                 if (isset($aCache[$rs->fields['OXTEMPLATE']]) && isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])) {
01043                     $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
01044                 } else {
01045                     $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
01046                     $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
01047                 }
01048 
01049                 if (!$blStatus) {
01050                     $aRet[] = array(
01051                                 'module'   => $rs->fields['OXMODULE'],
01052                                 'block'    => $rs->fields['OXBLOCKNAME'],
01053                                 'template' => $rs->fields['OXTEMPLATE'],
01054                             );
01055                 }
01056                 $rs->moveNext();
01057             }
01058         }
01059 
01060         return $aRet;
01061     }
01062 
01068     public function checkSessionAutostart()
01069     {
01070         $sStatus = ( strtolower( (string) @ini_get( 'session.auto_start' ) ) );
01071         return in_array( $sStatus, array( 'on', '1' ) ) ? 0 : 2;
01072     }
01073 }