OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
oxsysrequirements.php
Go to the documentation of this file.
1 <?php
2 
7 {
13  protected $_aRequiredModules = null;
14 
20  protected $_blSysReqStatus = null;
21 
27  protected $_aException = array( 'OXDELIVERY' => 'OXDELTYPE',
28  'OXSELECTLIST' => 'OXIDENT');
29 
35  protected $_aColumns = array( 'OXID',
36  'OXOBJECTID',
37  'OXARTICLENID',
38  'OXACTIONID',
39  'OXARTID',
40  'OXUSERID',
41  'OXADDRESSUSERID',
42  'OXCOUNTRYID',
43  'OXSESSID',
44  'OXITMID',
45  'OXPARENTID',
46  'OXAMITEMID',
47  'OXAMTASKID',
48  'OXVENDORID',
49  'OXMANUFACTURERID',
50  'OXROOTID',
51  'OXATTRID',
52  'OXCATID',
53  'OXDELID',
54  'OXDELSETID',
55  'OXITMARTID',
56  'OXFIELDID',
57  'OXROLEID',
58  'OXCNID',
59  'OXANID',
60  'OXARTICLENID',
61  'OXCATNID',
62  'OXDELIVERYID',
63  'OXDISCOUNTID',
64  'OXGROUPSID',
65  'OXLISTID',
66  'OXPAYMENTID',
67  'OXDELTYPE',
68  'OXROLEID',
69  'OXSELNID',
70  'OXBILLCOUNTRYID',
71  'OXDELCOUNTRYID',
72  'OXPAYMENTID',
73  'OXCARDID',
74  'OXPAYID',
75  'OXIDENT',
76  'OXDEFCAT',
77  'OXBASKETID',
78  'OXPAYMENTSID',
79  'OXORDERID',
80  'OXVOUCHERSERIEID');
81 
87  protected $_sReqInfoUrl = "http://www.oxidforge.org/wiki/Installation";
88 
94  protected $_aInfoMap = array( "php_version" => "PHP_version_at_least_5.2.10",
95  "lib_xml2" => "LIB_XML2",
96  "php_xml" => "DOM",
97  "open_ssl" => "OpenSSL",
98  "soap" => "SOAP",
99  "j_son" => "JSON",
100  "i_conv" => "ICONV",
101  "tokenizer" => "Tokenizer",
102  "mysql_connect" => "MySQL_client_connector_for_MySQL_5",
103  "gd_info" => "GDlib_v2_.5Bv1.5D_incl._JPEG_support",
104  "mb_string" => "mbstring",
105  "bc_math" => "BCMath",
106  "allow_url_fopen" => "allow_url_fopen_or_fsockopen_to_port_80",
107  "php4_compat" => "Zend_compatibility_mode_must_be_off",
108  "request_uri" => "REQUEST_URI_set",
109  "ini_set" => "ini_set_allowed",
110  "register_globals" => "register_globals_must_be_off",
111  "memory_limit" => "PHP_Memory_limit_.28min._14MB.2C_30MB_recommended.29",
112  "unicode_support" => "UTF-8_support",
113  "file_uploads" => "file_uploads_on",
114  "mod_rewrite" => "apache_mod_rewrite_module",
115  "server_permissions" => "Files_.26_Folder_Permission_Setup",
116  "zend_optimizer" => "Zend_Optimizer",
117  "bug53632" => "Not_recommended_PHP_versions",
118  "session_autostart" => "session.auto_start_must_be_off",
119  // "zend_platform_or_server"
120  );
121 
127  protected function _getPhpIntSize()
128  {
129  return PHP_INT_SIZE;
130  }
131 
137  public function __construct()
138  {
139  }
140 
152  public function __call( $sMethod, $aArgs )
153  {
154  if ( defined( 'OXID_PHP_UNIT' ) ) {
155  if ( substr( $sMethod, 0, 4) == "UNIT" ) {
156  $sMethod = str_replace( "UNIT", "_", $sMethod );
157  }
158  if ( method_exists( $this, $sMethod)) {
159  return call_user_func_array( array( & $this, $sMethod ), $aArgs );
160  }
161  }
162 
163  throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
164  }
165 
171  public function getConfig()
172  {
173  return oxRegistry::getConfig();
174  }
175 
181  public function isAdmin()
182  {
183  return isAdmin();
184  }
185 
191  public function getRequiredModules()
192  {
193  if ( $this->_aRequiredModules == null ) {
194  $aRequiredPHPExtensions = array(
195  'php_version',
196  'lib_xml2',
197  'php_xml',
198  'j_son',
199  'i_conv',
200  'tokenizer',
201  'mysql_connect',
202  'gd_info',
203  'mb_string',
204  'curl',
205  'bc_math',
206  'open_ssl',
207  'soap',
208  );
209 
210  $aRequiredPHPConfigs = array(
211  'allow_url_fopen',
212  'php4_compat',
213  'request_uri',
214  'ini_set',
215  'register_globals',
216  'memory_limit',
217  'unicode_support',
218  'file_uploads',
219  'session_autostart',
220  );
221 
222  $aRequiredServerConfigs = array(
223  'mod_rewrite',
224  'server_permissions',
225  'bug53632'
226  );
227 
228 
229  if ( $this->isAdmin() ) {
230  $aRequiredServerConfigs[] = 'mysql_version';
231  }
232  $this->_aRequiredModules = array_fill_keys( $aRequiredPHPExtensions, 'php_extennsions' ) +
233  array_fill_keys( $aRequiredPHPConfigs, 'php_config' ) +
234  array_fill_keys( $aRequiredServerConfigs, 'server_config' );
235  }
237  }
238 
247  public function checkBug53632()
248  {
249  if ( $this->_getPhpIntSize() > 4 ) {
250  return 2;
251  }
252 
253  $iState = 1;
254  if ( version_compare( PHP_VERSION, "5.3", ">=" ) ) {
255  if ( version_compare( PHP_VERSION, "5.3.5", ">=" ) && version_compare( PHP_VERSION, "5.3.7", "!=" ) ) {
256  $iState = 2;
257  }
258  } elseif ( version_compare( PHP_VERSION, '5.2', ">=" ) ) {
259  $iState = version_compare( PHP_VERSION, "5.2.17", ">=" ) ? 2 : $iState;
260  }
261  return $iState;
262  }
263 
269  public function checkCurl()
270  {
271  return extension_loaded( 'curl' ) ? 2 : 1;
272  }
273 
279  public function checkMbString()
280  {
281  return extension_loaded( 'mbstring' ) ? 2 : 1;
282  }
283 
292  public function checkServerPermissions( $sPath = null, $iMinPerm = 777 )
293  {
294  $sVerPrefix = '';
295 
296  clearstatcache();
297  $sPath = $sPath ? $sPath : getShopBasePath();
298 
299  // special config file check
300  $sFullPath = $sPath . "config.inc.php";
301  if ( !is_readable( $sFullPath ) ||
302  ( $this->isAdmin() && is_writable( $sFullPath ) ) ||
303  ( !$this->isAdmin() && !is_writable( $sFullPath ) )
304  ) {
305  return 0;
306  }
307 
308  $sTmp = "$sPath/tmp$sVerPrefix/";
309  if (class_exists('oxConfig')) {
310  $sCfgTmp = $this->getConfig()->getConfigParam('sCompileDir');
311  if (strpos($sCfgTmp, '<sCompileDir_') === false) {
312  $sTmp = $sCfgTmp;
313  }
314  }
315 
316  $aPathsToCheck = array(
317  $sPath."out/pictures{$sVerPrefix}/promo/",
318  $sPath."out/pictures{$sVerPrefix}/master/",
319  $sPath."out/pictures{$sVerPrefix}/generated/",
320  $sPath."out/pictures{$sVerPrefix}/media/", // @deprecated, use out/media instead
321  $sPath."out/media/",
322  $sPath."log/",
323  $sTmp
324  );
325  $iModStat = 2;
326  $sPathToCheck = reset( $aPathsToCheck );
327  while ( $sPathToCheck ) {
328  // missing file/folder?
329  if ( !file_exists( $sPathToCheck ) ) {
330  $iModStat = 0;
331  break;
332  }
333 
334  if ( is_dir( $sPathToCheck ) ) {
335  // adding subfolders
336  $aSubF = glob( $sPathToCheck."*", GLOB_ONLYDIR );
337  if (is_array($aSubF)) {
338  foreach ( $aSubF as $sNewFolder ) {
339  $aPathsToCheck[] = $sNewFolder . "/";
340  }
341  }
342  }
343 
344  // testing if file permissions >= $iMinPerm
345  //if ( ( (int) substr( decoct( fileperms( $sFullPath ) ), 2 ) ) < $iMinPerm ) {
346  if ( !is_readable( $sPathToCheck ) || !is_writable( $sPathToCheck ) ) {
347  $iModStat = 0;
348  break;
349  }
350 
351  $sPathToCheck = next( $aPathsToCheck );
352  }
353 
354  return $iModStat;
355  }
356 
363  protected function _getShopHostInfoFromConfig()
364  {
365  $sShopURL = $this->getConfig()->getConfigParam( 'sShopURL' );
366  if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
367  $sHost = $m[2];
368  $iPort = (int)$m[4];
369  $blSsl = (strtolower($m[1])=='https://');
370  if (!$iPort) {
371  $iPort = $blSsl?443:80;
372  }
373  $sScript = rtrim($m[5], '/').'/';
374  return array(
375  'host'=>$sHost,
376  'port'=>$iPort,
377  'dir'=>$sScript,
378  'ssl'=>$blSsl,
379  );
380  } else {
381  return false;
382  }
383  }
384 
391  protected function _getShopSSLHostInfoFromConfig()
392  {
393  $sSSLShopURL = $this->getConfig()->getConfigParam( 'sSSLShopURL' );
394  if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sSSLShopURL, $m)) {
395  $sHost = $m[2];
396  $iPort = (int)$m[4];
397  $blSsl = (strtolower($m[1])=='https://');
398  if (!$iPort) {
399  $iPort = $blSsl?443:80;
400  }
401  $sScript = rtrim($m[5], '/').'/';
402  return array(
403  'host'=>$sHost,
404  'port'=>$iPort,
405  'dir'=>$sScript,
406  'ssl'=>$blSsl,
407  );
408  }
409  return false;
410  }
411 
418  protected function _getShopHostInfoFromServerVars()
419  {
420  // got here from setup dir
421  $sScript = $_SERVER['SCRIPT_NAME'];
422  $iPort = (int) $_SERVER['SERVER_PORT'];
423  $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
424  if (!$iPort) {
425  $iPort = $blSsl?443:80;
426  }
427  $sScript = rtrim(dirname(dirname( $sScript )), '/').'/';
428  return array(
429  'host'=>$_SERVER['HTTP_HOST'],
430  'port'=>$iPort,
431  'dir'=>$sScript,
432  'ssl'=>$blSsl,
433  );
434  }
435 
441  protected function _getShopHostInfo()
442  {
443  if ( $this->isAdmin() ) {
444  return $this->_getShopHostInfoFromConfig();
445  } else {
446  return $this->_getShopHostInfoFromServerVars();
447  }
448  }
449 
456  protected function _getShopSSLHostInfo()
457  {
458  if ( $this->isAdmin() ) {
459  return $this->_getShopSSLHostInfoFromConfig();
460  }
461  return false;
462  }
463 
470  public function checkModRewrite()
471  {
472  $iModStat = null;
473  $aHostInfo = $this->_getShopHostInfo();
474  $iModStat = $this->_checkModRewrite( $aHostInfo );
475 
476  $aSSLHostInfo = $this->_getShopSSLHostInfo();
477  // Don't need to check if mod status is already failed.
478  if ( 0 != $iModStat && $aSSLHostInfo ) {
479  $iSSLModStat = $this->_checkModRewrite( $aSSLHostInfo );
480 
481  // Send if failed, even if couldn't check another
482  if ( 0 == $iSSLModStat ) {
483  return 0;
484  } elseif ( 1 == $iSSLModStat || 1 == $iModStat ) {
485  return 1;
486  }
487 
488  return min( $iModStat, $iSSLModStat );
489  }
490 
491  return $iModStat;
492  }
493 
502  protected function _checkModRewrite($aHostInfo)
503  {
504  if ( $rFp = @fsockopen( ($aHostInfo['ssl']?'ssl://':'').$aHostInfo['host'], $aHostInfo['port'], $iErrNo, $sErrStr, 10 ) ) {
505  $sReq = "POST {$aHostInfo['dir']}oxseo.php?mod_rewrite_module_is=off HTTP/1.1\r\n";
506  $sReq .= "Host: {$aHostInfo['host']}\r\n";
507  $sReq .= "User-Agent: OXID eShop setup\r\n";
508  $sReq .= "Content-Type: application/x-www-form-urlencoded\r\n";
509  $sReq .= "Content-Length: 0\r\n"; // empty post
510  $sReq .= "Connection: close\r\n\r\n";
511 
512  $sOut = '';
513  fwrite( $rFp, $sReq );
514  while ( !feof( $rFp ) ) {
515  $sOut .= fgets( $rFp, 100 );
516  }
517  fclose( $rFp );
518 
519  $iModStat = ( strpos( $sOut, 'mod_rewrite_on' ) !== false ) ? 2 : 0;
520  } else {
521  if ( function_exists( 'apache_get_modules' ) ) {
522  // it does not assure that mod_rewrite is enabled on current host, so setting 1
523  $iModStat = in_array( 'mod_rewrite', apache_get_modules() ) ? 1 : 0;
524  } else {
525  $iModStat = -1;
526  }
527  }
528  return $iModStat;
529  }
530 
536  public function checkAllowUrlFopen()
537  {
538  $iModStat = @ini_get('allow_url_fopen');
539  $iModStat = ( $iModStat && strcasecmp( '1', $iModStat ) ) ? 2 : 1;
540  if ( $iModStat == 1 ) {
541  $iErrNo = 0;
542  $sErrStr = '';
543  if ( $oRes = @fsockopen( 'www.example.com', 80, $iErrNo, $sErrStr, 10 ) ) {
544  $iModStat = 2;
545  fclose( $oRes );
546  }
547  }
548  $iModStat = ( !$iModStat ) ? 1 : $iModStat;
549  return $iModStat;
550  }
551 
558  public function checkPhp4Compat()
559  {
560  $sZendStatus = ( strtolower( (string) @ini_get( 'zend.ze1_compatibility_mode' ) ) );
561  return in_array( $sZendStatus, array( 'on', '1' ) ) ? 0 : 2;
562  }
563 
572  public function checkPhpVersion()
573  {
574  $iModStat = ( version_compare( PHP_VERSION, '5.2', '<' ) ) ? 0 : false;
575  $iModStat = ( $iModStat !== false ) ? $iModStat : ( (version_compare( PHP_VERSION, '5.2.0', '>=' ) && version_compare( PHP_VERSION, '5.2.10', '<' )) ? 1 : false );
576  $iModStat = ( $iModStat !== false ) ? $iModStat : ( version_compare( PHP_VERSION, '5.2.10', '>=' ) ? 2 : 1 );
577  return $iModStat;
578  }
579 
585  public function checkRequestUri()
586  {
587  return ( isset( $_SERVER['REQUEST_URI'] ) || isset( $_SERVER['SCRIPT_URI'] ) ) ? 2 : 0;
588  }
589 
595  public function checkLibXml2()
596  {
597  return class_exists( 'DOMDocument' ) ? 2 : 0;
598  }
599 
605  public function checkPhpXml()
606  {
607  return class_exists( 'DOMDocument' ) ? 2 : 0;
608  }
609 
615  public function checkJSon()
616  {
617  return extension_loaded( 'json' ) ? 2 : 0;
618  }
619 
625  public function checkIConv()
626  {
627  return extension_loaded( 'iconv' ) ? 2 : 0;
628  }
629 
635  public function checkTokenizer()
636  {
637  return extension_loaded( 'tokenizer' ) ? 2 : 0;
638  }
639 
645  public function checkBcMath()
646  {
647  return extension_loaded( 'bcmath' ) ? 2 : 1;
648  }
649 
655  public function checkOpenSsl()
656  {
657  return extension_loaded( 'openssl' ) ? 2 : 1;
658  }
659 
665  public function checkSoap()
666  {
667  return extension_loaded( 'soap' ) ? 2 : 1;
668  }
669 
675  public function checkMysqlConnect()
676  {
677  // MySQL module for MySQL5
678  $iModStat = ( extension_loaded( 'mysql' ) || extension_loaded( 'mysqli' ) || extension_loaded( 'pdo_mysql' ) ) ? 2 : 0;
679 
680  // client version must be >=5
681  if ( $iModStat ) {
682  $sClientVersion = mysql_get_client_info();
683  if (version_compare( $sClientVersion, '5', '<' )) {
684  $iModStat = 1;
685  if (version_compare( $sClientVersion, '4', '<' )) {
686  $iModStat = 0;
687  }
688  } elseif (version_compare($sClientVersion, '5.0.36', '>=') && version_compare($sClientVersion, '5.0.38', '<')) {
689  // mantis#0001003: Problems with MySQL version 5.0.37
690  $iModStat = 0;
691  } elseif (version_compare($sClientVersion, '5.0.40', '>') && version_compare($sClientVersion, '5.0.42', '<')) {
692  // mantis#0001877: Exclude MySQL 5.0.41 from system requirements as not fitting
693  $iModStat = 0;
694  }
695  if ( strpos($sClientVersion, 'mysqlnd') !== false ) {
696  // PHP 5.3 includes new mysqlnd extension
697  $iModStat = 2;
698  }
699  }
700  return $iModStat;
701  }
702 
710  public function checkMysqlVersion( $sVersion = null )
711  {
712  if ( $sVersion === null ) {
713  $aRez = oxDb::getDb()->getAll( "SHOW VARIABLES LIKE 'version'" );
714  foreach ( $aRez as $aRecord ) {
715  $sVersion = $aRecord[1];
716  break;
717  }
718  }
719 
720  $iModStat = 0;
721  if ( version_compare( $sVersion, '5.0.3', '>=' ) && version_compare( $sVersion, '5.0.37', '<>' ) ) {
722  $iModStat = 2;
723  }
724 
725  return $iModStat;
726  }
727 
733  public function checkGdInfo()
734  {
735  $iModStat = extension_loaded( 'gd' ) ? 1 : 0;
736  $iModStat = function_exists( 'imagecreatetruecolor' ) ? 2 : $iModStat;
737  $iModStat = function_exists( 'imagecreatefromjpeg' ) ? $iModStat : 0;
738  return $iModStat;
739  }
740 
746  public function checkIniSet()
747  {
748  return ( @ini_set('session.name', 'sid' ) !== false ) ? 2 : 0;
749  }
750 
756  public function checkRegisterGlobals()
757  {
758  $sGlobStatus = ( strtolower( (string) @ini_get( 'register_globals' ) ) );
759  return in_array( $sGlobStatus, array( 'on', '1' ) ) ? 0 : 2;
760  }
761 
767  public function checkMemoryLimit()
768  {
769  if ( $sMemLimit = @ini_get('memory_limit') ) {
770  // CE - PE at least to 14 MB. We recomend a memory_limit of 30MB.
771  $sDefLimit = '14M';
772  $sRecLimit = '30M';
773 
774 
775  $iMemLimit = $this->_getBytes( $sMemLimit );
776  $iModStat = ( $iMemLimit >= $this->_getBytes( $sDefLimit ) ) ? 1 : 0;
777  $iModStat = $iModStat ? ( ( $iMemLimit >= $this->_getBytes( $sRecLimit ) ) ? 2 : $iModStat ) : $iModStat;
778 
779  } else {
780  $iModStat = -1;
781  }
782  return $iModStat;
783  }
784 
790  public function checkZendOptimizer()
791  {
796  return 2;
797  }
798 
804  public function checkZendPlatformOrServer()
805  {
806  if (function_exists( 'output_cache_get' )) {
807  return 2;
808  }
809  if (function_exists( 'zend_disk_cache_fetch' )) {
810  return 2;
811  }
812  if (function_exists( 'zend_shm_cache_fetch' )) {
813  return 2;
814  }
815  return 1;
816  }
817 
823  protected function _getAdditionalCheck()
824  {
825  $sSelect = '';
826  foreach ( $this->_aException as $sTable => $sColumn ) {
827  $sSelect .= 'and ( t.TABLE_NAME != "'.$sTable.'" and c.COLUMN_NAME != "'.$sColumn.'" ) ';
828  }
829  return $sSelect;
830  }
831 
837  public function checkCollation()
838  {
839  $myConfig = $this->getConfig();
840 
841  $aCollations = array();
842  $sCollation = '';
843 
844  $sSelect = 'select t.TABLE_NAME, c.COLUMN_NAME, c.COLLATION_NAME from INFORMATION_SCHEMA.tables t ' .
845  'LEFT JOIN INFORMATION_SCHEMA.columns c ON t.TABLE_NAME = c.TABLE_NAME ' .
846  'where t.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
847  'and c.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
848  'and c.COLUMN_NAME in ("'.implode('", "', $this->_aColumns).'") ' . $this->_getAdditionalCheck() .
849  ' ORDER BY (t.TABLE_NAME = "oxarticles") DESC';
850  $aRez = oxDb::getDb()->getAll($sSelect);
851  foreach ( $aRez as $aRetTable ) {
852  if ( !$sCollation ) {
853  $sCollation = $aRetTable[2];
854  } else {
855  if ( $aRetTable[2] && $sCollation != $aRetTable[2]) {
856  $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
857  }
858  }
859  }
860 
861  if ( $this->_blSysReqStatus === null ) {
862  $this->_blSysReqStatus = true;
863  }
864  if ( count($aCollations) > 0 ) {
865  $this->_blSysReqStatus = false;
866  }
867  return $aCollations;
868  }
869 
875  public function checkDatabaseCluster()
876  {
877  return 2;
878  }
879 
885  public function checkUnicodeSupport()
886  {
887  return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
888  }
889 
895  public function checkFileUploads()
896  {
897  $dUploadFile = -1;
898  $sFileUploads = @ini_get('file_uploads');
899  if ( $sFileUploads !== false ) {
900  if ( $sFileUploads && ( $sFileUploads == '1' || strtolower($sFileUploads) == 'on') ) {
901  $dUploadFile = 2;
902  } else {
903  $dUploadFile = 1;
904  }
905  }
906  return $dUploadFile;
907  }
908 
914  public function getSysReqStatus()
915  {
916  if ( $this->_blSysReqStatus == null ) {
917  $this->_blSysReqStatus = true;
918  $this->getSystemInfo();
919  $this->checkCollation();
920  }
921  return $this->_blSysReqStatus;
922  }
923 
938  public function getSystemInfo()
939  {
940  $aSysInfo = array();
941  $aRequiredModules = $this->getRequiredModules();
942  $this->_blSysReqStatus = true;
943  foreach ( $aRequiredModules as $sModule => $sGroup ) {
944  if ( isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup] ) {
945  $aSysInfo[$sGroup] = array();
946  }
947  $iModuleState = $this->getModuleInfo( $sModule );
948  $aSysInfo[$sGroup][$sModule] = $iModuleState;
949  $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs( $iModuleState );
950  }
951  return $aSysInfo;
952  }
953 
961  public function getModuleInfo( $sModule = null )
962  {
963  if ( $sModule ) {
964  $iModStat = null;
965  $sCheckFunction = "check".str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
966  $iModStat = $this->$sCheckFunction();
967 
968  return $iModStat;
969  }
970  }
971 
979  public function getReqInfoUrl( $sIdent)
980  {
981  $sUrl = $this->_sReqInfoUrl;
982  $aInfoMap = $this->_aInfoMap;
983 
984  // only known will be anchored
985  if ( isset( $aInfoMap[$sIdent] ) ) {
986  $sUrl .= "#".$aInfoMap[$sIdent];
987  }
988 
989  return $sUrl;
990  }
991 
999  protected function _getBytes( $sBytes )
1000  {
1001  $sBytes = trim( $sBytes );
1002  $sLast = strtolower($sBytes[strlen($sBytes)-1]);
1003  switch( $sLast ) {
1004  // The 'G' modifier is available since PHP 5.1.0
1005  case 'g':
1006  $sBytes *= 1024;
1007  case 'm':
1008  $sBytes *= 1024;
1009  case 'k':
1010  $sBytes *= 1024;
1011  break;
1012  }
1013 
1014  return $sBytes;
1015  }
1016 
1027  protected function _checkTemplateBlock($sTemplate, $sBlockName)
1028  {
1029  $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
1030  if (!$sTplFile || !file_exists($sTplFile)) {
1031  // check if file is in admin theme
1032  $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, true);
1033  if (!$sTplFile || !file_exists($sTplFile)) {
1034  return false;
1035  }
1036  }
1037 
1038  $sFile = file_get_contents($sTplFile);
1039  $sBlockNameQuoted = preg_quote($sBlockName, '/');
1040  return (bool)preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])'.$sBlockNameQuoted.'\1\s*\}\]/is', $sFile);
1041  }
1042 
1052  public function getMissingTemplateBlocks()
1053  {
1055  $aCache = array();
1056  $oConfig = $this->getConfig();
1057 
1058  $sShpIdParam = $oDb->quote($oConfig->getShopId());
1059  $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
1060  $rs = $oDb->execute($sSql);
1061 
1062 
1063  $aRet = array();
1064  if ($rs != false && $rs->recordCount() > 0) {
1065  while (!$rs->EOF) {
1066  $blStatus = false;
1067  if (isset($aCache[$rs->fields['OXTEMPLATE']]) && isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])) {
1068  $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
1069  } else {
1070  $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
1071  $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
1072  }
1073 
1074  if (!$blStatus) {
1075  $aRet[] = array(
1076  'module' => $rs->fields['OXMODULE'],
1077  'block' => $rs->fields['OXBLOCKNAME'],
1078  'template' => $rs->fields['OXTEMPLATE'],
1079  );
1080  }
1081  $rs->moveNext();
1082  }
1083  }
1084 
1085  return $aRet;
1086  }
1087 
1093  public function checkSessionAutostart()
1094  {
1095  $sStatus = ( strtolower( (string) @ini_get( 'session.auto_start' ) ) );
1096  return in_array( $sStatus, array( 'on', '1' ) ) ? 0 : 2;
1097  }
1098 }