OXID eShop CE  4.9.9
 All Classes Files Functions Variables Pages
oxsysrequirements.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
17  protected $_aRequiredModules = null;
18 
24  protected $_blSysReqStatus = null;
25 
31  protected $_aException = array('OXDELIVERY' => 'OXDELTYPE', 'OXSELECTLIST' => 'OXIDENT');
32 
38  protected $_aColumns = array(
39  'OXID',
40  'OXOBJECTID',
41  'OXARTICLENID',
42  'OXACTIONID',
43  'OXARTID',
44  'OXUSERID',
45  'OXADDRESSUSERID',
46  'OXCOUNTRYID',
47  'OXSESSID',
48  'OXITMID',
49  'OXPARENTID',
50  'OXAMITEMID',
51  'OXAMTASKID',
52  'OXVENDORID',
53  'OXMANUFACTURERID',
54  'OXROOTID',
55  'OXATTRID',
56  'OXCATID',
57  'OXDELID',
58  'OXDELSETID',
59  'OXITMARTID',
60  'OXFIELDID',
61  'OXROLEID',
62  'OXCNID',
63  'OXANID',
64  'OXARTICLENID',
65  'OXCATNID',
66  'OXDELIVERYID',
67  'OXDISCOUNTID',
68  'OXGROUPSID',
69  'OXLISTID',
70  'OXPAYMENTID',
71  'OXDELTYPE',
72  'OXROLEID',
73  'OXSELNID',
74  'OXBILLCOUNTRYID',
75  'OXDELCOUNTRYID',
76  'OXPAYMENTID',
77  'OXCARDID',
78  'OXPAYID',
79  'OXIDENT',
80  'OXDEFCAT',
81  'OXBASKETID',
82  'OXPAYMENTSID',
83  'OXORDERID',
84  'OXVOUCHERSERIEID',
85  );
86 
92  protected $_sReqInfoUrl = "http://www.oxidforge.org/wiki/Installation";
93 
99  protected $_aInfoMap = array(
100  "php_version" => "PHP_version_at_least_5.3.25",
101  "lib_xml2" => "LIB_XML2",
102  "php_xml" => "DOM",
103  "open_ssl" => "OpenSSL",
104  "soap" => "SOAP",
105  "j_son" => "JSON",
106  "i_conv" => "ICONV",
107  "tokenizer" => "Tokenizer",
108  "mysql_connect" => "MySQL_client_connector_for_MySQL_5",
109  "gd_info" => "GDlib_v2_.5Bv1.5D_incl._JPEG_support",
110  "mb_string" => "mbstring",
111  "bc_math" => "BCMath",
112  "allow_url_fopen" => "allow_url_fopen_or_fsockopen_to_port_80",
113  "php4_compat" => "Zend_compatibility_mode_must_be_off",
114  "request_uri" => "REQUEST_URI_set",
115  "ini_set" => "ini_set_allowed",
116  "register_globals" => "register_globals_must_be_off",
117  "memory_limit" => "PHP_Memory_limit_.28min._14MB.2C_30MB_recommended.29",
118  "unicode_support" => "UTF-8_support",
119  "file_uploads" => "file_uploads_on",
120  "mod_rewrite" => "apache_mod_rewrite_module",
121  "server_permissions" => "Files_.26_Folder_Permission_Setup",
122  "zend_optimizer" => "Zend_Optimizer",
123  "bug53632" => "Not_recommended_PHP_versions",
124  "session_autostart" => "session.auto_start_must_be_off",
125  "magic_quotes_gpc" => "magic_quotes_must_be_off"
126  // "zend_platform_or_server"
127  );
128 
134  protected function _getPhpIntSize()
135  {
136  return PHP_INT_SIZE;
137  }
138 
144  public function __construct()
145  {
146  }
147 
160  public function __call($sMethod, $aArgs)
161  {
162  if (defined('OXID_PHP_UNIT')) {
163  if (substr($sMethod, 0, 4) == "UNIT") {
164  $sMethod = str_replace("UNIT", "_", $sMethod);
165  }
166  if (method_exists($this, $sMethod)) {
167  return call_user_func_array(array(& $this, $sMethod), $aArgs);
168  }
169  }
170 
171  throw new oxSystemComponentException(
172  "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")" . PHP_EOL
173  );
174  }
175 
181  public function getConfig()
182  {
183  return oxRegistry::getConfig();
184  }
185 
191  public function isAdmin()
192  {
193  return isAdmin();
194  }
195 
201  public function getRequiredModules()
202  {
203  if ($this->_aRequiredModules == null) {
204  $aRequiredPHPExtensions = array(
205  'php_version',
206  'lib_xml2',
207  'php_xml',
208  'j_son',
209  'i_conv',
210  'tokenizer',
211  'mysql_connect',
212  'gd_info',
213  'mb_string',
214  'curl',
215  'bc_math',
216  'open_ssl',
217  'soap',
218  );
219 
220  $aRequiredPHPConfigs = array(
221  'allow_url_fopen',
222  'php4_compat',
223  'request_uri',
224  'ini_set',
225  'register_globals',
226  'memory_limit',
227  'unicode_support',
228  'file_uploads',
229  'session_autostart',
230  'magic_quotes_gpc',
231  );
232 
233  $aRequiredServerConfigs = array(
234  'mod_rewrite',
235  'server_permissions',
236  'bug53632'
237  );
238 
239 
240  if ($this->isAdmin()) {
241  $aRequiredServerConfigs[] = 'mysql_version';
242  }
243  $this->_aRequiredModules = array_fill_keys($aRequiredPHPExtensions, 'php_extennsions') +
244  array_fill_keys($aRequiredPHPConfigs, 'php_config') +
245  array_fill_keys($aRequiredServerConfigs, 'server_config');
246  }
247 
249  }
250 
259  public function checkBug53632()
260  {
261  if ($this->_getPhpIntSize() > 4) {
262  return 2;
263  }
264 
265  $iState = 1;
266  if (version_compare($this->getPhpVersion(), "5.3", ">=")) {
267  if (version_compare($this->getPhpVersion(), "5.3.5", ">=") && version_compare($this->getPhpVersion(), "5.3.7", "!=")) {
268  $iState = 2;
269  }
270  }
271 
272  return $iState;
273  }
274 
280  public function checkCurl()
281  {
282  return extension_loaded('curl') ? 2 : 1;
283  }
284 
290  public function checkMbString()
291  {
292  return extension_loaded('mbstring') ? 2 : 1;
293  }
294 
303  public function checkServerPermissions($sPath = null, $iMinPerm = 777)
304  {
305  $sVerPrefix = '';
306 
307  clearstatcache();
308  $sPath = $sPath ? $sPath : getShopBasePath();
309 
310  // special config file check
311  $sFullPath = $sPath . "config.inc.php";
312  if (!is_readable($sFullPath) ||
313  ($this->isAdmin() && is_writable($sFullPath)) ||
314  (!$this->isAdmin() && !is_writable($sFullPath))
315  ) {
316  return 0;
317  }
318 
319  $sTmp = "$sPath/tmp{$sVerPrefix}/";
320  if (class_exists('oxConfig')) {
321  $sCfgTmp = $this->getConfig()->getConfigParam('sCompileDir');
322  if (strpos($sCfgTmp, '<sCompileDir_') === false) {
323  $sTmp = $sCfgTmp;
324  }
325  }
326 
327  $aPathsToCheck = array(
328  $sPath . "out/pictures{$sVerPrefix}/promo/",
329  $sPath . "out/pictures{$sVerPrefix}/master/",
330  $sPath . "out/pictures{$sVerPrefix}/generated/",
331  $sPath . "out/pictures{$sVerPrefix}/media/", // @deprecated, use out/media instead
332  $sPath . "out/media/",
333  $sPath . "log/",
334  $sTmp
335  );
336  $iModStat = 2;
337  $sPathToCheck = reset($aPathsToCheck);
338  while ($sPathToCheck) {
339  // missing file/folder?
340  if (!file_exists($sPathToCheck)) {
341  $iModStat = 0;
342  break;
343  }
344 
345  if (is_dir($sPathToCheck)) {
346  // adding subfolders
347  $aSubF = glob($sPathToCheck . "*", GLOB_ONLYDIR);
348  if (is_array($aSubF)) {
349  foreach ($aSubF as $sNewFolder) {
350  $aPathsToCheck[] = $sNewFolder . "/";
351  }
352  }
353  }
354 
355  // testing if file permissions >= $iMinPerm
356  //if ( ( (int) substr( decoct( fileperms( $sFullPath ) ), 2 ) ) < $iMinPerm ) {
357  if (!is_readable($sPathToCheck) || !is_writable($sPathToCheck)) {
358  $iModStat = 0;
359  break;
360  }
361 
362  $sPathToCheck = next($aPathsToCheck);
363  }
364 
365  return $iModStat;
366  }
367 
374  protected function _getShopHostInfoFromConfig()
375  {
376  $sShopURL = $this->getConfig()->getConfigParam('sShopURL');
377  if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
378  $sHost = $m[2];
379  $iPort = (int) $m[4];
380  $blSsl = (strtolower($m[1]) == 'https://');
381  if (!$iPort) {
382  $iPort = $blSsl ? 443 : 80;
383  }
384  $sScript = rtrim($m[5], '/') . '/';
385 
386  return array(
387  'host' => $sHost,
388  'port' => $iPort,
389  'dir' => $sScript,
390  'ssl' => $blSsl,
391  );
392  } else {
393  return false;
394  }
395  }
396 
403  protected function _getShopSSLHostInfoFromConfig()
404  {
405  $sSSLShopURL = $this->getConfig()->getConfigParam('sSSLShopURL');
406  if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sSSLShopURL, $m)) {
407  $sHost = $m[2];
408  $iPort = (int) $m[4];
409  $blSsl = (strtolower($m[1]) == 'https://');
410  if (!$iPort) {
411  $iPort = $blSsl ? 443 : 80;
412  }
413  $sScript = rtrim($m[5], '/') . '/';
414 
415  return array(
416  'host' => $sHost,
417  'port' => $iPort,
418  'dir' => $sScript,
419  'ssl' => $blSsl,
420  );
421  }
422 
423  return false;
424  }
425 
432  protected function _getShopHostInfoFromServerVars()
433  {
434  // got here from setup dir
435  $sScript = $_SERVER['SCRIPT_NAME'];
436  $iPort = (int) $_SERVER['SERVER_PORT'];
437  $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
438  if (!$iPort) {
439  $iPort = $blSsl ? 443 : 80;
440  }
441  $sScript = rtrim(dirname(dirname($sScript)), '/') . '/';
442 
443  return array(
444  'host' => $_SERVER['HTTP_HOST'],
445  'port' => $iPort,
446  'dir' => $sScript,
447  'ssl' => $blSsl,
448  );
449  }
450 
456  protected function _getShopHostInfo()
457  {
458  if ($this->isAdmin()) {
459  return $this->_getShopHostInfoFromConfig();
460  } else {
461  return $this->_getShopHostInfoFromServerVars();
462  }
463  }
464 
471  protected function _getShopSSLHostInfo()
472  {
473  if ($this->isAdmin()) {
474  return $this->_getShopSSLHostInfoFromConfig();
475  }
476 
477  return false;
478  }
479 
486  public function checkModRewrite()
487  {
488  $iModStat = null;
489  $aHostInfo = $this->_getShopHostInfo();
490  $iModStat = $this->_checkModRewrite($aHostInfo);
491 
492  $aSSLHostInfo = $this->_getShopSSLHostInfo();
493  // Don't need to check if mod status is already failed.
494  if (0 != $iModStat && $aSSLHostInfo) {
495  $iSSLModStat = $this->_checkModRewrite($aSSLHostInfo);
496 
497  // Send if failed, even if couldn't check another
498  if (0 == $iSSLModStat) {
499  return 0;
500  } elseif (1 == $iSSLModStat || 1 == $iModStat) {
501  return 1;
502  }
503 
504  return min($iModStat, $iSSLModStat);
505  }
506 
507  return $iModStat;
508  }
509 
518  protected function _checkModRewrite($aHostInfo)
519  {
520  $sHostname = ($aHostInfo['ssl'] ? 'ssl://' : '') . $aHostInfo['host'];
521  if ($rFp = @fsockopen($sHostname, $aHostInfo['port'], $iErrNo, $sErrStr, 10)) {
522  $sReq = "POST {$aHostInfo['dir']}oxseo.php?mod_rewrite_module_is=off HTTP/1.1\r\n";
523  $sReq .= "Host: {$aHostInfo['host']}\r\n";
524  $sReq .= "User-Agent: OXID eShop setup\r\n";
525  $sReq .= "Content-Type: application/x-www-form-urlencoded\r\n";
526  $sReq .= "Content-Length: 0\r\n"; // empty post
527  $sReq .= "Connection: close\r\n\r\n";
528 
529  $sOut = '';
530  fwrite($rFp, $sReq);
531  while (!feof($rFp)) {
532  $sOut .= fgets($rFp, 100);
533  }
534  fclose($rFp);
535 
536  $iModStat = (strpos($sOut, 'mod_rewrite_on') !== false) ? 2 : 0;
537  } else {
538  if (function_exists('apache_get_modules')) {
539  // it does not assure that mod_rewrite is enabled on current host, so setting 1
540  $iModStat = in_array('mod_rewrite', apache_get_modules()) ? 1 : 0;
541  } else {
542  $iModStat = -1;
543  }
544  }
545 
546  return $iModStat;
547  }
548 
554  public function checkAllowUrlFopen()
555  {
556  $iModStat = @ini_get('allow_url_fopen');
557  $iModStat = ($iModStat && strcasecmp('1', $iModStat)) ? 2 : 1;
558  if ($iModStat == 1) {
559  $iErrNo = 0;
560  $sErrStr = '';
561  if ($oRes = @fsockopen('www.example.com', 80, $iErrNo, $sErrStr, 10)) {
562  $iModStat = 2;
563  fclose($oRes);
564  }
565  }
566  $iModStat = (!$iModStat) ? 1 : $iModStat;
567 
568  return $iModStat;
569  }
570 
577  public function checkPhp4Compat()
578  {
579  $sZendStatus = (strtolower((string) @ini_get('zend.ze1_compatibility_mode')));
580 
581  return in_array($sZendStatus, array('on', '1')) ? 0 : 2;
582  }
583 
592  public function checkPhpVersion()
593  {
594  $sPhpVersion = $this->getPhpVersion();
595  if (version_compare($sPhpVersion, '5.3', '<')) {
596  $iModStat = 0;
597  } elseif (version_compare($sPhpVersion, '5.3.0', '>=') && version_compare($sPhpVersion, '5.3.25', '<')) {
598  $iModStat = 1;
599  } elseif (version_compare($sPhpVersion, '5.3.25', '>=')) {
600  $iModStat = 2;
601  } else {
602  $iModStat = 1;
603  }
604 
605  return $iModStat;
606  }
607 
613  public function getPhpVersion()
614  {
615  return PHP_VERSION;
616  }
617 
623  public function checkRequestUri()
624  {
625  return (isset($_SERVER['REQUEST_URI']) || isset($_SERVER['SCRIPT_URI'])) ? 2 : 0;
626  }
627 
633  public function checkLibXml2()
634  {
635  return class_exists('DOMDocument') ? 2 : 0;
636  }
637 
643  public function checkPhpXml()
644  {
645  return class_exists('DOMDocument') ? 2 : 0;
646  }
647 
653  public function checkJSon()
654  {
655  return extension_loaded('json') ? 2 : 0;
656  }
657 
663  public function checkIConv()
664  {
665  return extension_loaded('iconv') ? 2 : 0;
666  }
667 
673  public function checkTokenizer()
674  {
675  return extension_loaded('tokenizer') ? 2 : 0;
676  }
677 
683  public function checkBcMath()
684  {
685  return extension_loaded('bcmath') ? 2 : 1;
686  }
687 
693  public function checkOpenSsl()
694  {
695  return extension_loaded('openssl') ? 2 : 1;
696  }
697 
703  public function checkSoap()
704  {
705  return extension_loaded('soap') ? 2 : 1;
706  }
707 
713  public function checkMysqlConnect()
714  {
715  // MySQL module for MySQL5
716  $iModStat = (extension_loaded('mysql') || extension_loaded('mysqli') || extension_loaded('pdo_mysql')) ? 2 : 0;
717 
718  // client version must be >=5
719  if ($iModStat) {
720  $sClientVersion = mysql_get_client_info();
721  if (version_compare($sClientVersion, '5', '<')) {
722  $iModStat = 1;
723  if (version_compare($sClientVersion, '4', '<')) {
724  $iModStat = 0;
725  }
726  } elseif (version_compare($sClientVersion, '5.0.36', '>=') &&
727  version_compare($sClientVersion, '5.0.38', '<')
728  ) {
729  // mantis#0001003: Problems with MySQL version 5.0.37
730  $iModStat = 0;
731  } elseif (version_compare($sClientVersion, '5.0.40', '>') &&
732  version_compare($sClientVersion, '5.0.42', '<')
733  ) {
734  // mantis#0001877: Exclude MySQL 5.0.41 from system requirements as not fitting
735  $iModStat = 0;
736  }
737  if (strpos($sClientVersion, 'mysqlnd') !== false) {
738  // PHP 5.3 includes new mysqlnd extension
739  $iModStat = 2;
740  }
741  }
742 
743  return $iModStat;
744  }
745 
753  public function checkMysqlVersion($sVersion = null)
754  {
755  if ($sVersion === null) {
756  $aRez = oxDb::getDb()->getAll("SHOW VARIABLES LIKE 'version'");
757  foreach ($aRez as $aRecord) {
758  $sVersion = $aRecord[1];
759  break;
760  }
761  }
762 
763  $iModStat = 0;
764  if (version_compare($sVersion, '5.0.3', '>=') && version_compare($sVersion, '5.0.37', '<>')) {
765  $iModStat = 2;
766  }
767 
768  return $iModStat;
769  }
770 
776  public function checkGdInfo()
777  {
778  $iModStat = extension_loaded('gd') ? 1 : 0;
779  $iModStat = function_exists('imagecreatetruecolor') ? 2 : $iModStat;
780  $iModStat = function_exists('imagecreatefromjpeg') ? $iModStat : 0;
781 
782  return $iModStat;
783  }
784 
790  public function checkIniSet()
791  {
792  return (@ini_set('session.name', 'sid') !== false) ? 2 : 0;
793  }
794 
800  public function checkRegisterGlobals()
801  {
802  $sGlobStatus = (strtolower((string) @ini_get('register_globals')));
803 
804  return in_array($sGlobStatus, array('on', '1')) ? 0 : 2;
805  }
806 
812  public function checkMagicQuotesGpc()
813  {
814  if (function_exists('get_magic_quotes_gpc')) {
815  return get_magic_quotes_gpc() ? 0 : 2;
816  } else {
817  return 2;
818  }
819  }
820 
828  public function checkMemoryLimit($sMemLimit = null)
829  {
830  if ($sMemLimit === null) {
831  $sMemLimit = @ini_get('memory_limit');
832  }
833 
834  if ($sMemLimit) {
835  $sDefLimit = $this->_getMinimumMemoryLimit();
836  $sRecLimit = $this->_getRecommendMemoryLimit();
837 
838  $iMemLimit = $this->_getBytes($sMemLimit);
839 
840  if($iMemLimit === '-1') {
841  // -1 is equivalent to no memory limit
842  $iModStat = 2;
843  }
844  else {
845  $iModStat = ($iMemLimit >= $this->_getBytes($sDefLimit)) ? 1 : 0;
846  $iModStat = $iModStat ? (($iMemLimit >= $this->_getBytes($sRecLimit)) ? 2 : $iModStat) : $iModStat;
847  }
848 
849  } else {
850  $iModStat = -1;
851  }
852 
853  return $iModStat;
854  }
855 
861  protected function _getAdditionalCheck()
862  {
863  $sSelect = '';
864  foreach ($this->_aException as $sTable => $sColumn) {
865  $sSelect .= 'and ( TABLE_NAME != "' . $sTable . '" and COLUMN_NAME != "' . $sColumn . '" ) ';
866  }
867 
868  return $sSelect;
869  }
870 
876  public function checkCollation()
877  {
878  $myConfig = $this->getConfig();
879 
880  $aCollations = array();
881  $sCollation = '';
882  $sSelect = 'select TABLE_NAME, COLUMN_NAME, COLLATION_NAME from INFORMATION_SCHEMA.columns
883  where TABLE_NAME not like "oxv\_%" and table_schema = "' . $myConfig->getConfigParam('dbName') . '"
884  and COLUMN_NAME in ("' . implode('", "', $this->_aColumns) . '") ' . $this->_getAdditionalCheck() .
885  'ORDER BY TABLE_NAME, COLUMN_NAME DESC;';
886  $aRez = oxDb::getDb()->getAll($sSelect);
887  foreach ($aRez as $aRetTable) {
888  if (!$sCollation) {
889  $sCollation = $aRetTable[2];
890  } else {
891  if ($aRetTable[2] && $sCollation != $aRetTable[2]) {
892  $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
893  }
894  }
895  }
896 
897  if ($this->_blSysReqStatus === null) {
898  $this->_blSysReqStatus = true;
899  }
900  if (count($aCollations) > 0) {
901  $this->_blSysReqStatus = false;
902  }
903 
904  return $aCollations;
905  }
906 
912  public function checkDatabaseCluster()
913  {
914  return 2;
915  }
916 
922  public function checkUnicodeSupport()
923  {
924  return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
925  }
926 
932  public function checkFileUploads()
933  {
934  $dUploadFile = -1;
935  $sFileUploads = @ini_get('file_uploads');
936  if ($sFileUploads !== false) {
937  if ($sFileUploads && ($sFileUploads == '1' || strtolower($sFileUploads) == 'on')) {
938  $dUploadFile = 2;
939  } else {
940  $dUploadFile = 1;
941  }
942  }
943 
944  return $dUploadFile;
945  }
946 
952  public function getSysReqStatus()
953  {
954  if ($this->_blSysReqStatus == null) {
955  $this->_blSysReqStatus = true;
956  $this->getSystemInfo();
957  $this->checkCollation();
958  }
959 
960  return $this->_blSysReqStatus;
961  }
962 
977  public function getSystemInfo()
978  {
979  $aSysInfo = array();
980  $aRequiredModules = $this->getRequiredModules();
981  $this->_blSysReqStatus = true;
982  foreach ($aRequiredModules as $sModule => $sGroup) {
983  if (isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup]) {
984  $aSysInfo[$sGroup] = array();
985  }
986  $iModuleState = $this->getModuleInfo($sModule);
987  $aSysInfo[$sGroup][$sModule] = $iModuleState;
988  $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs($iModuleState);
989  }
990 
991  return $aSysInfo;
992  }
993 
1001  public function getModuleInfo($sModule = null)
1002  {
1003  if ($sModule) {
1004  $iModStat = null;
1005  $sCheckFunction = "check" . str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
1006  $iModStat = $this->$sCheckFunction();
1007 
1008  return $iModStat;
1009  }
1010  }
1011 
1019  public function getReqInfoUrl($sIdent)
1020  {
1021  $sUrl = $this->_sReqInfoUrl;
1022  $aInfoMap = $this->_aInfoMap;
1023 
1024  // only known will be anchored
1025  if (isset($aInfoMap[$sIdent])) {
1026  $sUrl .= "#" . $aInfoMap[$sIdent];
1027  }
1028 
1029  return $sUrl;
1030  }
1031 
1039  protected function _getBytes($sBytes)
1040  {
1041  $sBytes = trim($sBytes);
1042  $sLast = strtolower($sBytes[strlen($sBytes) - 1]);
1043  switch ($sLast) {
1044  // The 'G' modifier is available since PHP 5.1.0
1045  // gigabytes
1046  case 'g':
1047  $sBytes *= 1024;
1048  // megabytes
1049  case 'm':
1050  $sBytes *= 1024;
1051  // kilobytes
1052  case 'k':
1053  $sBytes *= 1024;
1054  break;
1055  }
1056 
1057  return $sBytes;
1058  }
1059 
1070  protected function _checkTemplateBlock($sTemplate, $sBlockName)
1071  {
1072  $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
1073  if (!$sTplFile || !file_exists($sTplFile)) {
1074  // check if file is in admin theme
1075  $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, true);
1076  if (!$sTplFile || !file_exists($sTplFile)) {
1077  return false;
1078  }
1079  }
1080 
1081  $sFile = file_get_contents($sTplFile);
1082  $sBlockNameQuoted = preg_quote($sBlockName, '/');
1083 
1084  return (bool) preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])' . $sBlockNameQuoted . '\1\s*\}\]/is', $sFile);
1085  }
1086 
1096  public function getMissingTemplateBlocks()
1097  {
1099  $aCache = array();
1100  $oConfig = $this->getConfig();
1101 
1102  $sShpIdParam = $oDb->quote($oConfig->getShopId());
1103  $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
1104  $rs = $oDb->execute($sSql);
1105 
1106 
1107  $aRet = array();
1108  if ($rs != false && $rs->recordCount() > 0) {
1109  while (!$rs->EOF) {
1110  $blStatus = false;
1111  if (isset($aCache[$rs->fields['OXTEMPLATE']]) &&
1112  isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])
1113  ) {
1114  $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
1115  } else {
1116  $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
1117 
1118  $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
1119  }
1120 
1121  if (!$blStatus) {
1122  $aRet[] = array(
1123  'module' => $rs->fields['OXMODULE'],
1124  'block' => $rs->fields['OXBLOCKNAME'],
1125  'template' => $rs->fields['OXTEMPLATE'],
1126  );
1127  }
1128  $rs->moveNext();
1129  }
1130  }
1131 
1132  return $aRet;
1133  }
1134 
1140  public function checkSessionAutostart()
1141  {
1142  $sStatus = (strtolower((string) @ini_get('session.auto_start')));
1143 
1144  return in_array($sStatus, array('on', '1')) ? 0 : 2;
1145  }
1146 
1152  protected function _getMinimumMemoryLimit()
1153  {
1154  $sDefLimit = '14M';
1155 
1156  return $sDefLimit;
1157  }
1158 
1164  protected function _getRecommendMemoryLimit()
1165  {
1166  $sRecLimit = '30M';
1167 
1168  return $sRecLimit;
1169  }
1170 }