oxsysrequirements.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class oxSysRequirements
00010 {
00011 
00017     protected $_aRequiredModules = null;
00018 
00024     protected $_blSysReqStatus = null;
00025 
00031     protected $_aException = array('OXDELIVERY' => 'OXDELTYPE', 'OXSELECTLIST' => 'OXIDENT');
00032 
00038     protected $_aColumns = array(
00039         'OXID',
00040         'OXOBJECTID',
00041         'OXARTICLENID',
00042         'OXACTIONID',
00043         'OXARTID',
00044         'OXUSERID',
00045         'OXADDRESSUSERID',
00046         'OXCOUNTRYID',
00047         'OXSESSID',
00048         'OXITMID',
00049         'OXPARENTID',
00050         'OXAMITEMID',
00051         'OXAMTASKID',
00052         'OXVENDORID',
00053         'OXMANUFACTURERID',
00054         'OXROOTID',
00055         'OXATTRID',
00056         'OXCATID',
00057         'OXDELID',
00058         'OXDELSETID',
00059         'OXITMARTID',
00060         'OXFIELDID',
00061         'OXROLEID',
00062         'OXCNID',
00063         'OXANID',
00064         'OXARTICLENID',
00065         'OXCATNID',
00066         'OXDELIVERYID',
00067         'OXDISCOUNTID',
00068         'OXGROUPSID',
00069         'OXLISTID',
00070         'OXPAYMENTID',
00071         'OXDELTYPE',
00072         'OXROLEID',
00073         'OXSELNID',
00074         'OXBILLCOUNTRYID',
00075         'OXDELCOUNTRYID',
00076         'OXPAYMENTID',
00077         'OXCARDID',
00078         'OXPAYID',
00079         'OXIDENT',
00080         'OXDEFCAT',
00081         'OXBASKETID',
00082         'OXPAYMENTSID',
00083         'OXORDERID',
00084         'OXVOUCHERSERIEID',
00085     );
00086 
00092     protected $_sReqInfoUrl = "http://www.oxidforge.org/wiki/Installation";
00093 
00099     protected $_aInfoMap = array(
00100         "php_version"        => "PHP_version_at_least_5.3.25",
00101         "lib_xml2"           => "LIB_XML2",
00102         "php_xml"            => "DOM",
00103         "open_ssl"           => "OpenSSL",
00104         "soap"               => "SOAP",
00105         "j_son"              => "JSON",
00106         "i_conv"             => "ICONV",
00107         "tokenizer"          => "Tokenizer",
00108         "mysql_connect"      => "MySQL_client_connector_for_MySQL_5",
00109         "gd_info"            => "GDlib_v2_.5Bv1.5D_incl._JPEG_support",
00110         "mb_string"          => "mbstring",
00111         "bc_math"            => "BCMath",
00112         "allow_url_fopen"    => "allow_url_fopen_or_fsockopen_to_port_80",
00113         "php4_compat"        => "Zend_compatibility_mode_must_be_off",
00114         "request_uri"        => "REQUEST_URI_set",
00115         "ini_set"            => "ini_set_allowed",
00116         "register_globals"   => "register_globals_must_be_off",
00117         "memory_limit"       => "PHP_Memory_limit_.28min._14MB.2C_30MB_recommended.29",
00118         "unicode_support"    => "UTF-8_support",
00119         "file_uploads"       => "file_uploads_on",
00120         "mod_rewrite"        => "apache_mod_rewrite_module",
00121         "server_permissions" => "Files_.26_Folder_Permission_Setup",
00122         "zend_optimizer"     => "Zend_Optimizer",
00123         "bug53632"           => "Not_recommended_PHP_versions",
00124         "session_autostart"  => "session.auto_start_must_be_off",
00125         "magic_quotes_gpc"   => "magic_quotes_must_be_off"
00126         // "zend_platform_or_server"
00127     );
00128 
00134     protected function _getPhpIntSize()
00135     {
00136         return PHP_INT_SIZE;
00137     }
00138 
00144     public function __construct()
00145     {
00146     }
00147 
00160     public function __call($sMethod, $aArgs)
00161     {
00162         if (defined('OXID_PHP_UNIT')) {
00163             if (substr($sMethod, 0, 4) == "UNIT") {
00164                 $sMethod = str_replace("UNIT", "_", $sMethod);
00165             }
00166             if (method_exists($this, $sMethod)) {
00167                 return call_user_func_array(array(& $this, $sMethod), $aArgs);
00168             }
00169         }
00170 
00171         throw new oxSystemComponentException(
00172             "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")" . PHP_EOL
00173         );
00174     }
00175 
00181     public function getConfig()
00182     {
00183         return oxRegistry::getConfig();
00184     }
00185 
00191     public function isAdmin()
00192     {
00193         return isAdmin();
00194     }
00195 
00201     public function getRequiredModules()
00202     {
00203         if ($this->_aRequiredModules == null) {
00204             $aRequiredPHPExtensions = array(
00205                 'php_version',
00206                 'lib_xml2',
00207                 'php_xml',
00208                 'j_son',
00209                 'i_conv',
00210                 'tokenizer',
00211                 'mysql_connect',
00212                 'gd_info',
00213                 'mb_string',
00214                 'curl',
00215                 'bc_math',
00216                 'open_ssl',
00217                 'soap',
00218             );
00219 
00220             $aRequiredPHPConfigs = array(
00221                 'allow_url_fopen',
00222                 'php4_compat',
00223                 'request_uri',
00224                 'ini_set',
00225                 'register_globals',
00226                 'memory_limit',
00227                 'unicode_support',
00228                 'file_uploads',
00229                 'session_autostart',
00230                 'magic_quotes_gpc',
00231             );
00232 
00233             $aRequiredServerConfigs = array(
00234                 'mod_rewrite',
00235                 'server_permissions',
00236                 'bug53632'
00237             );
00238 
00239 
00240             if ($this->isAdmin()) {
00241                 $aRequiredServerConfigs[] = 'mysql_version';
00242             }
00243             $this->_aRequiredModules = array_fill_keys($aRequiredPHPExtensions, 'php_extennsions') +
00244                                        array_fill_keys($aRequiredPHPConfigs, 'php_config') +
00245                                        array_fill_keys($aRequiredServerConfigs, 'server_config');
00246         }
00247 
00248         return $this->_aRequiredModules;
00249     }
00250 
00259     public function checkBug53632()
00260     {
00261         if ($this->_getPhpIntSize() > 4) {
00262             return 2;
00263         }
00264 
00265         $iState = 1;
00266         if (version_compare($this->getPhpVersion(), "5.3", ">=")) {
00267             if (version_compare($this->getPhpVersion(), "5.3.5", ">=") && version_compare($this->getPhpVersion(), "5.3.7", "!=")) {
00268                 $iState = 2;
00269             }
00270         }
00271 
00272         return $iState;
00273     }
00274 
00280     public function checkCurl()
00281     {
00282         return extension_loaded('curl') ? 2 : 1;
00283     }
00284 
00290     public function checkMbString()
00291     {
00292         return extension_loaded('mbstring') ? 2 : 1;
00293     }
00294 
00303     public function checkServerPermissions($sPath = null, $iMinPerm = 777)
00304     {
00305         $sVerPrefix = '';
00306 
00307         clearstatcache();
00308         $sPath = $sPath ? $sPath : getShopBasePath();
00309 
00310         // special config file check
00311         $sFullPath = $sPath . "config.inc.php";
00312         if (!is_readable($sFullPath) ||
00313             ($this->isAdmin() && is_writable($sFullPath)) ||
00314             (!$this->isAdmin() && !is_writable($sFullPath))
00315         ) {
00316             return 0;
00317         }
00318 
00319         $sTmp = "$sPath/tmp{$sVerPrefix}/";
00320         if (class_exists('oxConfig')) {
00321             $sCfgTmp = $this->getConfig()->getConfigParam('sCompileDir');
00322             if (strpos($sCfgTmp, '<sCompileDir_') === false) {
00323                 $sTmp = $sCfgTmp;
00324             }
00325         }
00326 
00327         $aPathsToCheck = array(
00328             $sPath . "out/pictures{$sVerPrefix}/promo/",
00329             $sPath . "out/pictures{$sVerPrefix}/master/",
00330             $sPath . "out/pictures{$sVerPrefix}/generated/",
00331             $sPath . "out/pictures{$sVerPrefix}/media/", // @deprecated, use out/media instead
00332             $sPath . "out/media/",
00333             $sPath . "log/",
00334             $sTmp
00335         );
00336         $iModStat = 2;
00337         $sPathToCheck = reset($aPathsToCheck);
00338         while ($sPathToCheck) {
00339             // missing file/folder?
00340             if (!file_exists($sPathToCheck)) {
00341                 $iModStat = 0;
00342                 break;
00343             }
00344 
00345             if (is_dir($sPathToCheck)) {
00346                 // adding subfolders
00347                 $aSubF = glob($sPathToCheck . "*", GLOB_ONLYDIR);
00348                 if (is_array($aSubF)) {
00349                     foreach ($aSubF as $sNewFolder) {
00350                         $aPathsToCheck[] = $sNewFolder . "/";
00351                     }
00352                 }
00353             }
00354 
00355             // testing if file permissions >= $iMinPerm
00356             //if ( ( (int) substr( decoct( fileperms( $sFullPath ) ), 2 ) ) < $iMinPerm ) {
00357             if (!is_readable($sPathToCheck) || !is_writable($sPathToCheck)) {
00358                 $iModStat = 0;
00359                 break;
00360             }
00361 
00362             $sPathToCheck = next($aPathsToCheck);
00363         }
00364 
00365         return $iModStat;
00366     }
00367 
00374     protected function _getShopHostInfoFromConfig()
00375     {
00376         $sShopURL = $this->getConfig()->getConfigParam('sShopURL');
00377         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
00378             $sHost = $m[2];
00379             $iPort = (int) $m[4];
00380             $blSsl = (strtolower($m[1]) == 'https://');
00381             if (!$iPort) {
00382                 $iPort = $blSsl ? 443 : 80;
00383             }
00384             $sScript = rtrim($m[5], '/') . '/';
00385 
00386             return array(
00387                 'host' => $sHost,
00388                 'port' => $iPort,
00389                 'dir'  => $sScript,
00390                 'ssl'  => $blSsl,
00391             );
00392         } else {
00393             return false;
00394         }
00395     }
00396 
00403     protected function _getShopSSLHostInfoFromConfig()
00404     {
00405         $sSSLShopURL = $this->getConfig()->getConfigParam('sSSLShopURL');
00406         if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sSSLShopURL, $m)) {
00407             $sHost = $m[2];
00408             $iPort = (int) $m[4];
00409             $blSsl = (strtolower($m[1]) == 'https://');
00410             if (!$iPort) {
00411                 $iPort = $blSsl ? 443 : 80;
00412             }
00413             $sScript = rtrim($m[5], '/') . '/';
00414 
00415             return array(
00416                 'host' => $sHost,
00417                 'port' => $iPort,
00418                 'dir'  => $sScript,
00419                 'ssl'  => $blSsl,
00420             );
00421         }
00422 
00423         return false;
00424     }
00425 
00432     protected function _getShopHostInfoFromServerVars()
00433     {
00434         // got here from setup dir
00435         $sScript = $_SERVER['SCRIPT_NAME'];
00436         $iPort = (int) $_SERVER['SERVER_PORT'];
00437         $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
00438         if (!$iPort) {
00439             $iPort = $blSsl ? 443 : 80;
00440         }
00441         $sScript = rtrim(dirname(dirname($sScript)), '/') . '/';
00442 
00443         return array(
00444             'host' => $_SERVER['HTTP_HOST'],
00445             'port' => $iPort,
00446             'dir'  => $sScript,
00447             'ssl'  => $blSsl,
00448         );
00449     }
00450 
00456     protected function _getShopHostInfo()
00457     {
00458         if ($this->isAdmin()) {
00459             return $this->_getShopHostInfoFromConfig();
00460         } else {
00461             return $this->_getShopHostInfoFromServerVars();
00462         }
00463     }
00464 
00471     protected function _getShopSSLHostInfo()
00472     {
00473         if ($this->isAdmin()) {
00474             return $this->_getShopSSLHostInfoFromConfig();
00475         }
00476 
00477         return false;
00478     }
00479 
00486     public function checkModRewrite()
00487     {
00488         $iModStat = null;
00489         $aHostInfo = $this->_getShopHostInfo();
00490         $iModStat = $this->_checkModRewrite($aHostInfo);
00491 
00492         $aSSLHostInfo = $this->_getShopSSLHostInfo();
00493         // Don't need to check if mod status is already failed.
00494         if (0 != $iModStat && $aSSLHostInfo) {
00495             $iSSLModStat = $this->_checkModRewrite($aSSLHostInfo);
00496 
00497             // Send if failed, even if couldn't check another
00498             if (0 == $iSSLModStat) {
00499                 return 0;
00500             } elseif (1 == $iSSLModStat || 1 == $iModStat) {
00501                 return 1;
00502             }
00503 
00504             return min($iModStat, $iSSLModStat);
00505         }
00506 
00507         return $iModStat;
00508     }
00509 
00518     protected function _checkModRewrite($aHostInfo)
00519     {
00520         $sHostname = ($aHostInfo['ssl'] ? 'ssl://' : '') . $aHostInfo['host'];
00521         if ($rFp = @fsockopen($sHostname, $aHostInfo['port'], $iErrNo, $sErrStr, 10)) {
00522             $sReq = "POST {$aHostInfo['dir']}oxseo.php?mod_rewrite_module_is=off HTTP/1.1\r\n";
00523             $sReq .= "Host: {$aHostInfo['host']}\r\n";
00524             $sReq .= "User-Agent: OXID eShop setup\r\n";
00525             $sReq .= "Content-Type: application/x-www-form-urlencoded\r\n";
00526             $sReq .= "Content-Length: 0\r\n"; // empty post
00527             $sReq .= "Connection: close\r\n\r\n";
00528 
00529             $sOut = '';
00530             fwrite($rFp, $sReq);
00531             while (!feof($rFp)) {
00532                 $sOut .= fgets($rFp, 100);
00533             }
00534             fclose($rFp);
00535 
00536             $iModStat = (strpos($sOut, 'mod_rewrite_on') !== false) ? 2 : 0;
00537         } else {
00538             if (function_exists('apache_get_modules')) {
00539                 // it does not assure that mod_rewrite is enabled on current host, so setting 1
00540                 $iModStat = in_array('mod_rewrite', apache_get_modules()) ? 1 : 0;
00541             } else {
00542                 $iModStat = -1;
00543             }
00544         }
00545 
00546         return $iModStat;
00547     }
00548 
00554     public function checkAllowUrlFopen()
00555     {
00556         $iModStat = @ini_get('allow_url_fopen');
00557         $iModStat = ($iModStat && strcasecmp('1', $iModStat)) ? 2 : 1;
00558         if ($iModStat == 1) {
00559             $iErrNo = 0;
00560             $sErrStr = '';
00561             if ($oRes = @fsockopen('www.example.com', 80, $iErrNo, $sErrStr, 10)) {
00562                 $iModStat = 2;
00563                 fclose($oRes);
00564             }
00565         }
00566         $iModStat = (!$iModStat) ? 1 : $iModStat;
00567 
00568         return $iModStat;
00569     }
00570 
00577     public function checkPhp4Compat()
00578     {
00579         $sZendStatus = (strtolower((string) @ini_get('zend.ze1_compatibility_mode')));
00580 
00581         return in_array($sZendStatus, array('on', '1')) ? 0 : 2;
00582     }
00583 
00592     public function checkPhpVersion()
00593     {
00594         $sPhpVersion = $this->getPhpVersion();
00595         if (version_compare($sPhpVersion, '5.3', '<')) {
00596             $iModStat = 0;
00597         } elseif (version_compare($sPhpVersion, '5.3.0', '>=') && version_compare($sPhpVersion, '5.3.25', '<')) {
00598             $iModStat = 1;
00599         } elseif (version_compare($sPhpVersion, '5.3.25', '>=')) {
00600             $iModStat = 2;
00601         } else {
00602             $iModStat = 1;
00603         }
00604 
00605         return $iModStat;
00606     }
00607 
00613     public function getPhpVersion()
00614     {
00615         return PHP_VERSION;
00616     }
00617 
00623     public function checkRequestUri()
00624     {
00625         return (isset($_SERVER['REQUEST_URI']) || isset($_SERVER['SCRIPT_URI'])) ? 2 : 0;
00626     }
00627 
00633     public function checkLibXml2()
00634     {
00635         return class_exists('DOMDocument') ? 2 : 0;
00636     }
00637 
00643     public function checkPhpXml()
00644     {
00645         return class_exists('DOMDocument') ? 2 : 0;
00646     }
00647 
00653     public function checkJSon()
00654     {
00655         return extension_loaded('json') ? 2 : 0;
00656     }
00657 
00663     public function checkIConv()
00664     {
00665         return extension_loaded('iconv') ? 2 : 0;
00666     }
00667 
00673     public function checkTokenizer()
00674     {
00675         return extension_loaded('tokenizer') ? 2 : 0;
00676     }
00677 
00683     public function checkBcMath()
00684     {
00685         return extension_loaded('bcmath') ? 2 : 1;
00686     }
00687 
00693     public function checkOpenSsl()
00694     {
00695         return extension_loaded('openssl') ? 2 : 1;
00696     }
00697 
00703     public function checkSoap()
00704     {
00705         return extension_loaded('soap') ? 2 : 1;
00706     }
00707 
00713     public function checkMysqlConnect()
00714     {
00715         // MySQL module for MySQL5
00716         $iModStat = (extension_loaded('mysql') || extension_loaded('mysqli') || extension_loaded('pdo_mysql')) ? 2 : 0;
00717 
00718         // client version must be >=5
00719         if ($iModStat) {
00720             $sClientVersion = mysql_get_client_info();
00721             if (version_compare($sClientVersion, '5', '<')) {
00722                 $iModStat = 1;
00723                 if (version_compare($sClientVersion, '4', '<')) {
00724                     $iModStat = 0;
00725                 }
00726             } elseif (version_compare($sClientVersion, '5.0.36', '>=') &&
00727                       version_compare($sClientVersion, '5.0.38', '<')
00728             ) {
00729                 // mantis#0001003: Problems with MySQL version 5.0.37
00730                 $iModStat = 0;
00731             } elseif (version_compare($sClientVersion, '5.0.40', '>') &&
00732                       version_compare($sClientVersion, '5.0.42', '<')
00733             ) {
00734                 // mantis#0001877: Exclude MySQL 5.0.41 from system requirements as not fitting
00735                 $iModStat = 0;
00736             }
00737             if (strpos($sClientVersion, 'mysqlnd') !== false) {
00738                 // PHP 5.3 includes new mysqlnd extension
00739                 $iModStat = 2;
00740             }
00741         }
00742 
00743         return $iModStat;
00744     }
00745 
00753     public function checkMysqlVersion($sVersion = null)
00754     {
00755         if ($sVersion === null) {
00756             $aRez = oxDb::getDb()->getAll("SHOW VARIABLES LIKE 'version'");
00757             foreach ($aRez as $aRecord) {
00758                 $sVersion = $aRecord[1];
00759                 break;
00760             }
00761         }
00762 
00763         $iModStat = 0;
00764         if (version_compare($sVersion, '5.0.3', '>=') && version_compare($sVersion, '5.0.37', '<>')) {
00765             $iModStat = 2;
00766         }
00767 
00768         return $iModStat;
00769     }
00770 
00776     public function checkGdInfo()
00777     {
00778         $iModStat = extension_loaded('gd') ? 1 : 0;
00779         $iModStat = function_exists('imagecreatetruecolor') ? 2 : $iModStat;
00780         $iModStat = function_exists('imagecreatefromjpeg') ? $iModStat : 0;
00781 
00782         return $iModStat;
00783     }
00784 
00790     public function checkIniSet()
00791     {
00792         return (@ini_set('session.name', 'sid') !== false) ? 2 : 0;
00793     }
00794 
00800     public function checkRegisterGlobals()
00801     {
00802         $sGlobStatus = (strtolower((string) @ini_get('register_globals')));
00803 
00804         return in_array($sGlobStatus, array('on', '1')) ? 0 : 2;
00805     }
00806 
00812     public function checkMagicQuotesGpc()
00813     {
00814         if (function_exists('get_magic_quotes_gpc')) {
00815             return get_magic_quotes_gpc() ? 0 : 2;
00816         } else {
00817             return 2;
00818         }
00819     }
00820 
00826     public function checkMemoryLimit()
00827     {
00828         if ($sMemLimit = @ini_get('memory_limit')) {
00829             // CE - PE at least to 14 MB. We recomend a memory_limit of 30MB.
00830             $sDefLimit = '14M';
00831             $sRecLimit = '30M';
00832 
00833 
00834             $iMemLimit = $this->_getBytes($sMemLimit);
00835             $iModStat = ($iMemLimit >= $this->_getBytes($sDefLimit)) ? 1 : 0;
00836             $iModStat = $iModStat ? (($iMemLimit >= $this->_getBytes($sRecLimit)) ? 2 : $iModStat) : $iModStat;
00837 
00838         } else {
00839             $iModStat = -1;
00840         }
00841 
00842         return $iModStat;
00843     }
00844 
00850     protected function _getAdditionalCheck()
00851     {
00852         $sSelect = '';
00853         foreach ($this->_aException as $sTable => $sColumn) {
00854             $sSelect .= 'and ( TABLE_NAME != "' . $sTable . '" and COLUMN_NAME != "' . $sColumn . '" ) ';
00855         }
00856 
00857         return $sSelect;
00858     }
00859 
00865     public function checkCollation()
00866     {
00867         $myConfig = $this->getConfig();
00868 
00869         $aCollations = array();
00870         $sCollation = '';
00871         $sSelect = 'select TABLE_NAME, COLUMN_NAME, COLLATION_NAME from INFORMATION_SCHEMA.columns
00872                     where TABLE_NAME not like "oxv\_%" and table_schema = "' . $myConfig->getConfigParam('dbName') . '"
00873                     and COLUMN_NAME in ("' . implode('", "', $this->_aColumns) . '") ' . $this->_getAdditionalCheck() .
00874                    'ORDER BY TABLE_NAME, COLUMN_NAME DESC;';
00875         $aRez = oxDb::getDb()->getAll($sSelect);
00876         foreach ($aRez as $aRetTable) {
00877             if (!$sCollation) {
00878                 $sCollation = $aRetTable[2];
00879             } else {
00880                 if ($aRetTable[2] && $sCollation != $aRetTable[2]) {
00881                     $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
00882                 }
00883             }
00884         }
00885 
00886         if ($this->_blSysReqStatus === null) {
00887             $this->_blSysReqStatus = true;
00888         }
00889         if (count($aCollations) > 0) {
00890             $this->_blSysReqStatus = false;
00891         }
00892 
00893         return $aCollations;
00894     }
00895 
00901     public function checkDatabaseCluster()
00902     {
00903         return 2;
00904     }
00905 
00911     public function checkUnicodeSupport()
00912     {
00913         return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
00914     }
00915 
00921     public function checkFileUploads()
00922     {
00923         $dUploadFile = -1;
00924         $sFileUploads = @ini_get('file_uploads');
00925         if ($sFileUploads !== false) {
00926             if ($sFileUploads && ($sFileUploads == '1' || strtolower($sFileUploads) == 'on')) {
00927                 $dUploadFile = 2;
00928             } else {
00929                 $dUploadFile = 1;
00930             }
00931         }
00932 
00933         return $dUploadFile;
00934     }
00935 
00941     public function getSysReqStatus()
00942     {
00943         if ($this->_blSysReqStatus == null) {
00944             $this->_blSysReqStatus = true;
00945             $this->getSystemInfo();
00946             $this->checkCollation();
00947         }
00948 
00949         return $this->_blSysReqStatus;
00950     }
00951 
00966     public function getSystemInfo()
00967     {
00968         $aSysInfo = array();
00969         $aRequiredModules = $this->getRequiredModules();
00970         $this->_blSysReqStatus = true;
00971         foreach ($aRequiredModules as $sModule => $sGroup) {
00972             if (isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup]) {
00973                 $aSysInfo[$sGroup] = array();
00974             }
00975             $iModuleState = $this->getModuleInfo($sModule);
00976             $aSysInfo[$sGroup][$sModule] = $iModuleState;
00977             $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs($iModuleState);
00978         }
00979 
00980         return $aSysInfo;
00981     }
00982 
00990     public function getModuleInfo($sModule = null)
00991     {
00992         if ($sModule) {
00993             $iModStat = null;
00994             $sCheckFunction = "check" . str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
00995             $iModStat = $this->$sCheckFunction();
00996 
00997             return $iModStat;
00998         }
00999     }
01000 
01008     public function getReqInfoUrl($sIdent)
01009     {
01010         $sUrl = $this->_sReqInfoUrl;
01011         $aInfoMap = $this->_aInfoMap;
01012 
01013         // only known will be anchored
01014         if (isset($aInfoMap[$sIdent])) {
01015             $sUrl .= "#" . $aInfoMap[$sIdent];
01016         }
01017 
01018         return $sUrl;
01019     }
01020 
01028     protected function _getBytes($sBytes)
01029     {
01030         $sBytes = trim($sBytes);
01031         $sLast = strtolower($sBytes[strlen($sBytes) - 1]);
01032         switch ($sLast) {
01033             // The 'G' modifier is available since PHP 5.1.0
01034             // gigabytes
01035             case 'g':
01036                 $sBytes *= 1024;
01037             // megabytes
01038             case 'm':
01039                 $sBytes *= 1024;
01040             // kilobytes
01041             case 'k':
01042                 $sBytes *= 1024;
01043                 break;
01044         }
01045 
01046         return $sBytes;
01047     }
01048 
01059     protected function _checkTemplateBlock($sTemplate, $sBlockName)
01060     {
01061         $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
01062         if (!$sTplFile || !file_exists($sTplFile)) {
01063             // check if file is in admin theme
01064             $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, true);
01065             if (!$sTplFile || !file_exists($sTplFile)) {
01066                 return false;
01067             }
01068         }
01069 
01070         $sFile = file_get_contents($sTplFile);
01071         $sBlockNameQuoted = preg_quote($sBlockName, '/');
01072 
01073         return (bool) preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])' . $sBlockNameQuoted . '\1\s*\}\]/is', $sFile);
01074     }
01075 
01085     public function getMissingTemplateBlocks()
01086     {
01087         $oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
01088         $aCache = array();
01089         $oConfig = $this->getConfig();
01090 
01091         $sShpIdParam = $oDb->quote($oConfig->getShopId());
01092         $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
01093         $rs = $oDb->execute($sSql);
01094 
01095 
01096         $aRet = array();
01097         if ($rs != false && $rs->recordCount() > 0) {
01098             while (!$rs->EOF) {
01099                 $blStatus = false;
01100                 if (isset($aCache[$rs->fields['OXTEMPLATE']]) &&
01101                     isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])
01102                 ) {
01103                     $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
01104                 } else {
01105                     $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
01106 
01107                     $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
01108                 }
01109 
01110                 if (!$blStatus) {
01111                     $aRet[] = array(
01112                         'module'   => $rs->fields['OXMODULE'],
01113                         'block'    => $rs->fields['OXBLOCKNAME'],
01114                         'template' => $rs->fields['OXTEMPLATE'],
01115                     );
01116                 }
01117                 $rs->moveNext();
01118             }
01119         }
01120 
01121         return $aRet;
01122     }
01123 
01129     public function checkSessionAutostart()
01130     {
01131         $sStatus = (strtolower((string) @ini_get('session.auto_start')));
01132 
01133         return in_array($sStatus, array('on', '1')) ? 0 : 2;
01134     }
01135 }