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
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
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/",
00332 $sPath . "out/media/",
00333 $sPath . "log/",
00334 $sTmp
00335 );
00336 $iModStat = 2;
00337 $sPathToCheck = reset($aPathsToCheck);
00338 while ($sPathToCheck) {
00339
00340 if (!file_exists($sPathToCheck)) {
00341 $iModStat = 0;
00342 break;
00343 }
00344
00345 if (is_dir($sPathToCheck)) {
00346
00347 $aSubF = glob($sPathToCheck . "*", GLOB_ONLYDIR);
00348 if (is_array($aSubF)) {
00349 foreach ($aSubF as $sNewFolder) {
00350 $aPathsToCheck[] = $sNewFolder . "/";
00351 }
00352 }
00353 }
00354
00355
00356
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
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
00494 if (0 != $iModStat && $aSSLHostInfo) {
00495 $iSSLModStat = $this->_checkModRewrite($aSSLHostInfo);
00496
00497
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";
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
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
00716 $iModStat = (extension_loaded('mysql') || extension_loaded('mysqli') || extension_loaded('pdo_mysql')) ? 2 : 0;
00717
00718
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
00730 $iModStat = 0;
00731 } elseif (version_compare($sClientVersion, '5.0.40', '>') &&
00732 version_compare($sClientVersion, '5.0.42', '<')
00733 ) {
00734
00735 $iModStat = 0;
00736 }
00737 if (strpos($sClientVersion, 'mysqlnd') !== false) {
00738
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
00828 public function checkMemoryLimit($sMemLimit = null)
00829 {
00830 if ($sMemLimit === null) {
00831 $sMemLimit = @ini_get('memory_limit');
00832 }
00833
00834 if ($sMemLimit) {
00835 $sDefLimit = $this->_getMinimumMemoryLimit();
00836 $sRecLimit = $this->_getRecommendMemoryLimit();
00837
00838 $iMemLimit = $this->_getBytes($sMemLimit);
00839
00840 if($iMemLimit === '-1') {
00841
00842 $iModStat = 2;
00843 }
00844 else {
00845 $iModStat = ($iMemLimit >= $this->_getBytes($sDefLimit)) ? 1 : 0;
00846 $iModStat = $iModStat ? (($iMemLimit >= $this->_getBytes($sRecLimit)) ? 2 : $iModStat) : $iModStat;
00847 }
00848
00849 } else {
00850 $iModStat = -1;
00851 }
00852
00853 return $iModStat;
00854 }
00855
00861 protected function _getAdditionalCheck()
00862 {
00863 $sSelect = '';
00864 foreach ($this->_aException as $sTable => $sColumn) {
00865 $sSelect .= 'and ( TABLE_NAME != "' . $sTable . '" and COLUMN_NAME != "' . $sColumn . '" ) ';
00866 }
00867
00868 return $sSelect;
00869 }
00870
00876 public function checkCollation()
00877 {
00878 $myConfig = $this->getConfig();
00879
00880 $aCollations = array();
00881 $sCollation = '';
00882 $sSelect = 'select TABLE_NAME, COLUMN_NAME, COLLATION_NAME from INFORMATION_SCHEMA.columns
00883 where TABLE_NAME not like "oxv\_%" and table_schema = "' . $myConfig->getConfigParam('dbName') . '"
00884 and COLUMN_NAME in ("' . implode('", "', $this->_aColumns) . '") ' . $this->_getAdditionalCheck() .
00885 'ORDER BY TABLE_NAME, COLUMN_NAME DESC;';
00886 $aRez = oxDb::getDb()->getAll($sSelect);
00887 foreach ($aRez as $aRetTable) {
00888 if (!$sCollation) {
00889 $sCollation = $aRetTable[2];
00890 } else {
00891 if ($aRetTable[2] && $sCollation != $aRetTable[2]) {
00892 $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
00893 }
00894 }
00895 }
00896
00897 if ($this->_blSysReqStatus === null) {
00898 $this->_blSysReqStatus = true;
00899 }
00900 if (count($aCollations) > 0) {
00901 $this->_blSysReqStatus = false;
00902 }
00903
00904 return $aCollations;
00905 }
00906
00912 public function checkDatabaseCluster()
00913 {
00914 return 2;
00915 }
00916
00922 public function checkUnicodeSupport()
00923 {
00924 return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
00925 }
00926
00932 public function checkFileUploads()
00933 {
00934 $dUploadFile = -1;
00935 $sFileUploads = @ini_get('file_uploads');
00936 if ($sFileUploads !== false) {
00937 if ($sFileUploads && ($sFileUploads == '1' || strtolower($sFileUploads) == 'on')) {
00938 $dUploadFile = 2;
00939 } else {
00940 $dUploadFile = 1;
00941 }
00942 }
00943
00944 return $dUploadFile;
00945 }
00946
00952 public function getSysReqStatus()
00953 {
00954 if ($this->_blSysReqStatus == null) {
00955 $this->_blSysReqStatus = true;
00956 $this->getSystemInfo();
00957 $this->checkCollation();
00958 }
00959
00960 return $this->_blSysReqStatus;
00961 }
00962
00977 public function getSystemInfo()
00978 {
00979 $aSysInfo = array();
00980 $aRequiredModules = $this->getRequiredModules();
00981 $this->_blSysReqStatus = true;
00982 foreach ($aRequiredModules as $sModule => $sGroup) {
00983 if (isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup]) {
00984 $aSysInfo[$sGroup] = array();
00985 }
00986 $iModuleState = $this->getModuleInfo($sModule);
00987 $aSysInfo[$sGroup][$sModule] = $iModuleState;
00988 $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs($iModuleState);
00989 }
00990
00991 return $aSysInfo;
00992 }
00993
01001 public function getModuleInfo($sModule = null)
01002 {
01003 if ($sModule) {
01004 $iModStat = null;
01005 $sCheckFunction = "check" . str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
01006 $iModStat = $this->$sCheckFunction();
01007
01008 return $iModStat;
01009 }
01010 }
01011
01019 public function getReqInfoUrl($sIdent)
01020 {
01021 $sUrl = $this->_sReqInfoUrl;
01022 $aInfoMap = $this->_aInfoMap;
01023
01024
01025 if (isset($aInfoMap[$sIdent])) {
01026 $sUrl .= "#" . $aInfoMap[$sIdent];
01027 }
01028
01029 return $sUrl;
01030 }
01031
01039 protected function _getBytes($sBytes)
01040 {
01041 $sBytes = trim($sBytes);
01042 $sLast = strtolower($sBytes[strlen($sBytes) - 1]);
01043 switch ($sLast) {
01044
01045
01046 case 'g':
01047 $sBytes *= 1024;
01048
01049 case 'm':
01050 $sBytes *= 1024;
01051
01052 case 'k':
01053 $sBytes *= 1024;
01054 break;
01055 }
01056
01057 return $sBytes;
01058 }
01059
01070 protected function _checkTemplateBlock($sTemplate, $sBlockName)
01071 {
01072 $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
01073 if (!$sTplFile || !file_exists($sTplFile)) {
01074
01075 $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, true);
01076 if (!$sTplFile || !file_exists($sTplFile)) {
01077 return false;
01078 }
01079 }
01080
01081 $sFile = file_get_contents($sTplFile);
01082 $sBlockNameQuoted = preg_quote($sBlockName, '/');
01083
01084 return (bool) preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])' . $sBlockNameQuoted . '\1\s*\}\]/is', $sFile);
01085 }
01086
01096 public function getMissingTemplateBlocks()
01097 {
01098 $oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
01099 $aCache = array();
01100 $oConfig = $this->getConfig();
01101
01102 $sShpIdParam = $oDb->quote($oConfig->getShopId());
01103 $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
01104 $rs = $oDb->execute($sSql);
01105
01106
01107 $aRet = array();
01108 if ($rs != false && $rs->recordCount() > 0) {
01109 while (!$rs->EOF) {
01110 $blStatus = false;
01111 if (isset($aCache[$rs->fields['OXTEMPLATE']]) &&
01112 isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])
01113 ) {
01114 $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
01115 } else {
01116 $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
01117
01118 $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
01119 }
01120
01121 if (!$blStatus) {
01122 $aRet[] = array(
01123 'module' => $rs->fields['OXMODULE'],
01124 'block' => $rs->fields['OXBLOCKNAME'],
01125 'template' => $rs->fields['OXTEMPLATE'],
01126 );
01127 }
01128 $rs->moveNext();
01129 }
01130 }
01131
01132 return $aRet;
01133 }
01134
01140 public function checkSessionAutostart()
01141 {
01142 $sStatus = (strtolower((string) @ini_get('session.auto_start')));
01143
01144 return in_array($sStatus, array('on', '1')) ? 0 : 2;
01145 }
01146
01152 protected function _getMinimumMemoryLimit()
01153 {
01154 $sDefLimit = '14M';
01155
01156 return $sDefLimit;
01157 }
01158
01164 protected function _getRecommendMemoryLimit()
01165 {
01166 $sRecLimit = '30M';
01167
01168 return $sRecLimit;
01169 }
01170 }