00001 <?php
00002
00006 class oxSysRequirements
00007 {
00013 protected $_aRequiredModules = null;
00014
00020 protected $_blSysReqStatus = null;
00021
00027 protected $_aException = array( 'OXDELIVERY' => 'OXDELTYPE',
00028 'OXSELECTLIST' => 'OXIDENT');
00029
00035 protected $_aColumns = array( 'OXID',
00036 'OXOBJECTID',
00037 'OXARTICLENID',
00038 'OXACTIONID',
00039 'OXARTID',
00040 'OXUSERID',
00041 'OXADDRESSUSERID',
00042 'OXCOUNTRYID',
00043 'OXSESSID',
00044 'OXITMID',
00045 'OXPARENTID',
00046 'OXAMITEMID',
00047 'OXAMTASKID',
00048 'OXVENDORID',
00049 'OXMANUFACTURERID',
00050 'OXROOTID',
00051 'OXATTRID',
00052 'OXCATID',
00053 'OXDELID',
00054 'OXDELSETID',
00055 'OXITMARTID',
00056 'OXFIELDID',
00057 'OXROLEID',
00058 'OXCNID',
00059 'OXANID',
00060 'OXARTICLENID',
00061 'OXCATNID',
00062 'OXDELIVERYID',
00063 'OXDISCOUNTID',
00064 'OXGROUPSID',
00065 'OXLISTID',
00066 'OXPAYMENTID',
00067 'OXDELTYPE',
00068 'OXROLEID',
00069 'OXSELNID',
00070 'OXBILLCOUNTRYID',
00071 'OXDELCOUNTRYID',
00072 'OXPAYMENTID',
00073 'OXCARDID',
00074 'OXPAYID',
00075 'OXIDENT',
00076 'OXDEFCAT',
00077 'OXBASKETID',
00078 'OXPAYMENTSID',
00079 'OXORDERID',
00080 'OXVOUCHERSERIEID');
00081
00087 protected $_sReqInfoUrl = "http://www.oxidforge.org/wiki/Installation";
00088
00094 protected $_aInfoMap = array( "php_version" => "PHP_version_at_least_5.2.0",
00095 "lib_xml2" => "LIB_XML2",
00096 "php_xml" => "DOM",
00097 "open_ssl" => "OpenSSL",
00098 "soap" => "SOAP",
00099 "j_son" => "JSON",
00100 "i_conv" => "ICONV",
00101 "tokenizer" => "Tokenizer",
00102 "mysql_connect" => "MySQL_client_connector_for_MySQL_5",
00103 "gd_info" => "GDlib_v2_.5Bv1.5D_incl._JPEG_support",
00104 "mb_string" => "mbstring",
00105 "bc_math" => "BCMath",
00106 "allow_url_fopen" => "allow_url_fopen_or_fsockopen_to_port_80",
00107 "php4_compat" => "Zend_compatibility_mode_must_be_off",
00108 "request_uri" => "REQUEST_URI_set",
00109 "ini_set" => "ini_set_allowed",
00110 "register_globals" => "register_globals_must_be_off",
00111 "memory_limit" => "PHP_Memory_limit_.28min._14MB.2C_30MB_recommended.29",
00112 "unicode_support" => "UTF-8_support",
00113 "mod_rewrite" => "apache_mod_rewrite_module",
00114 "server_permissions" => "Files_.26_Folder_Permission_Setup",
00115 "zend_optimizer" => "Zend_Optimizer",
00116 "bug53632" => "Not_recommended_PHP_versions",
00117
00118 );
00119
00125 public function __construct()
00126 {
00127 }
00128
00140 public function __call( $sMethod, $aArgs )
00141 {
00142 if ( defined( 'OXID_PHP_UNIT' ) ) {
00143 if ( substr( $sMethod, 0, 4) == "UNIT" ) {
00144 $sMethod = str_replace( "UNIT", "_", $sMethod );
00145 }
00146 if ( method_exists( $this, $sMethod)) {
00147 return call_user_func_array( array( & $this, $sMethod ), $aArgs );
00148 }
00149 }
00150
00151 throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
00152 }
00153
00159 public function getConfig()
00160 {
00161 return oxConfig::getInstance();
00162 }
00163
00169 public function getRequiredModules()
00170 {
00171 if ( $this->_aRequiredModules == null ) {
00172 $aRequiredPHPExtensions = array(
00173 'php_version',
00174 'lib_xml2',
00175 'php_xml',
00176 'j_son',
00177 'i_conv',
00178 'tokenizer',
00179 'mysql_connect',
00180 'gd_info',
00181 'mb_string',
00182 'curl',
00183 'bc_math',
00184 'open_ssl',
00185 'soap',
00186 );
00187
00188 $aRequiredPHPConfigs = array(
00189 'allow_url_fopen',
00190 'php4_compat',
00191 'request_uri',
00192 'ini_set',
00193 'register_globals',
00194 'memory_limit',
00195 'unicode_support'
00196 );
00197
00198 $aRequiredServerConfigs = array(
00199 'mod_rewrite',
00200 'server_permissions',
00201 'bug53632'
00202 );
00203
00204
00205 if ( isAdmin() ) {
00206 $aRequiredServerConfigs[] = 'mysql_version';
00207 }
00208 $this->_aRequiredModules = array_fill_keys( $aRequiredPHPExtensions, 'php_extennsions' ) +
00209 array_fill_keys( $aRequiredPHPConfigs, 'php_config' ) +
00210 array_fill_keys( $aRequiredServerConfigs, 'server_config' );
00211 }
00212 return $this->_aRequiredModules;
00213 }
00214
00223 public function checkBug53632()
00224 {
00225 $iState = 1;
00226 if ( version_compare( PHP_VERSION, "5.3", ">=" ) ) {
00227 if ( version_compare( PHP_VERSION, "5.3.5", ">=" ) && version_compare( PHP_VERSION, "5.3.7", "!=" ) ) {
00228 $iState = 2;
00229 }
00230 } elseif ( version_compare( PHP_VERSION, '5.2', ">=" ) ) {
00231 $iState = version_compare( PHP_VERSION, "5.2.17", ">=" ) ? 2 : $iState;
00232 }
00233 return $iState;
00234 }
00235
00241 public function checkCurl()
00242 {
00243 return extension_loaded( 'curl' ) ? 2 : 1;
00244 }
00245
00251 public function checkMbString()
00252 {
00253 return extension_loaded( 'mbstring' ) ? 2 : 1;
00254 }
00255
00264 public function checkServerPermissions( $sPath = null, $iMinPerm = 777 )
00265 {
00266 $sVerPrefix = '';
00267
00268 clearstatcache();
00269 $sPath = $sPath ? $sPath : getShopBasePath();
00270
00271
00272 $sFullPath = $sPath . "config.inc.php";
00273 if ( !is_readable( $sFullPath ) ||
00274 ( isAdmin() && is_writable( $sFullPath ) ) ||
00275 ( !isAdmin() && !is_writable( $sFullPath ) )
00276 ) {
00277 return 0;
00278 }
00279
00280 $sTmp = "$sPath/tmp$sVerPrefix/";
00281 if (class_exists('oxConfig')) {
00282 $sCfgTmp = $this->getConfig()->getConfigParam('sCompileDir');
00283 if (strpos($sCfgTmp, '<sCompileDir_') === false) {
00284 $sTmp = $sCfgTmp;
00285 }
00286 }
00287
00288 $aPathsToCheck = array(
00289 $sPath."out/pictures{$sVerPrefix}/promo/",
00290 $sPath."out/pictures{$sVerPrefix}/media/",
00291 $sPath."out/pictures{$sVerPrefix}/master/",
00292 $sPath."out/pictures{$sVerPrefix}/generated/",
00293 $sPath."log/",
00294 $sTmp
00295 );
00296 $iModStat = 2;
00297 $sPathToCheck = reset( $aPathsToCheck );
00298 while ( $sPathToCheck ) {
00299
00300 if ( !file_exists( $sPathToCheck ) ) {
00301 $iModStat = 0;
00302 break;
00303 }
00304
00305 if ( is_dir( $sPathToCheck ) ) {
00306
00307 $aSubF = glob( $sPathToCheck."*", GLOB_ONLYDIR );
00308 if (is_array($aSubF)) {
00309 foreach ( $aSubF as $sNewFolder ) {
00310 $aPathsToCheck[] = $sNewFolder . "/";
00311 }
00312 }
00313 }
00314
00315
00316
00317 if ( !is_readable( $sPathToCheck ) || !is_writable( $sPathToCheck ) ) {
00318 $iModStat = 0;
00319 break;
00320 }
00321
00322 $sPathToCheck = next( $aPathsToCheck );
00323 }
00324
00325 return $iModStat;
00326 }
00327
00334 protected function _getShopHostInfoFromConfig()
00335 {
00336 $sShopURL = $this->getConfig()->getConfigParam( 'sShopURL' );
00337 if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
00338 $sHost = $m[2];
00339 $iPort = (int)$m[4];
00340 $blSsl = (strtolower($m[1])=='https://');
00341 if (!$iPort) {
00342 $iPort = $blSsl?443:80;
00343 }
00344 $sScript = rtrim($m[5], '/').'/';
00345 return array(
00346 'host'=>$sHost,
00347 'port'=>$iPort,
00348 'dir'=>$sScript,
00349 'ssl'=>$blSsl,
00350 );
00351 } else {
00352 return false;
00353 }
00354 }
00355
00362 protected function _getShopSSLHostInfoFromConfig()
00363 {
00364 $sSSLShopURL = $this->getConfig()->getConfigParam( 'sSSLShopURL' );
00365 if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sSSLShopURL, $m)) {
00366 $sHost = $m[2];
00367 $iPort = (int)$m[4];
00368 $blSsl = (strtolower($m[1])=='https://');
00369 if (!$iPort) {
00370 $iPort = $blSsl?443:80;
00371 }
00372 $sScript = rtrim($m[5], '/').'/';
00373 return array(
00374 'host'=>$sHost,
00375 'port'=>$iPort,
00376 'dir'=>$sScript,
00377 'ssl'=>$blSsl,
00378 );
00379 }
00380 return false;
00381 }
00382
00389 protected function _getShopHostInfoFromServerVars()
00390 {
00391
00392 $sScript = $_SERVER['SCRIPT_NAME'];
00393 $iPort = (int) $_SERVER['SERVER_PORT'];
00394 $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
00395 if (!$iPort) {
00396 $iPort = $blSsl?443:80;
00397 }
00398 $sScript = rtrim(dirname(dirname( $sScript )), '/').'/';
00399 return array(
00400 'host'=>$_SERVER['HTTP_HOST'],
00401 'port'=>$iPort,
00402 'dir'=>$sScript,
00403 'ssl'=>$blSsl,
00404 );
00405 }
00406
00412 protected function _getShopHostInfo()
00413 {
00414 if ( isAdmin() ) {
00415 return $this->_getShopHostInfoFromConfig();
00416 } else {
00417 return $this->_getShopHostInfoFromServerVars();
00418 }
00419 }
00420
00427 protected function _getShopSSLHostInfo()
00428 {
00429 if ( isAdmin() ) {
00430 return $this->_getShopSSLHostInfoFromConfig();
00431 }
00432 return false;
00433 }
00434
00441 public function checkModRewrite()
00442 {
00443 $iModStat = null;
00444 $aHostInfo = $this->_getShopHostInfo();
00445 $iModStat = $this->_checkModRewrite( $aHostInfo );
00446
00447 $aSSLHostInfo = $this->_getShopSSLHostInfo();
00448
00449 if ( 0 != $iModStat && $aSSLHostInfo ) {
00450 $iSSLModStat = $this->_checkModRewrite( $aSSLHostInfo );
00451
00452
00453 if ( 0 == $iSSLModStat ) {
00454 return 0;
00455 } elseif ( 1 == $iSSLModStat || 1 == $iModStat ) {
00456 return 1;
00457 }
00458
00459 return min( $iModStat, $iSSLModStat );
00460 }
00461
00462 return $iModStat;
00463 }
00464
00473 protected function _checkModRewrite($aHostInfo)
00474 {
00475 if ( $rFp = @fsockopen( ($aHostInfo['ssl']?'ssl://':'').$aHostInfo['host'], $aHostInfo['port'], $iErrNo, $sErrStr, 10 ) ) {
00476 $sReq = "POST {$aHostInfo['dir']}oxseo.php?mod_rewrite_module_is=off HTTP/1.1\r\n";
00477 $sReq .= "Host: {$aHostInfo['host']}\r\n";
00478 $sReq .= "User-Agent: OXID eShop setup\r\n";
00479 $sReq .= "Content-Type: application/x-www-form-urlencoded\r\n";
00480 $sReq .= "Content-Length: 0\r\n";
00481 $sReq .= "Connection: close\r\n\r\n";
00482
00483 $sOut = '';
00484 fwrite( $rFp, $sReq );
00485 while ( !feof( $rFp ) ) {
00486 $sOut .= fgets( $rFp, 100 );
00487 }
00488 fclose( $rFp );
00489
00490 $iModStat = ( strpos( $sOut, 'mod_rewrite_on' ) !== false ) ? 2 : 0;
00491 } else {
00492 if ( function_exists( 'apache_get_modules' ) ) {
00493
00494 $iModStat = in_array( 'mod_rewrite', apache_get_modules() ) ? 1 : 0;
00495 } else {
00496 $iModStat = -1;
00497 }
00498 }
00499 return $iModStat;
00500 }
00501
00507 public function checkAllowUrlFopen()
00508 {
00509 $iModStat = @ini_get('allow_url_fopen');
00510 $iModStat = ( $iModStat && strcasecmp( '1', $iModStat ) ) ? 2 : 1;
00511 if ( $iModStat == 1 ) {
00512 $iErrNo = 0;
00513 $sErrStr = '';
00514 if ( $oRes = @fsockopen( 'www.example.com', 80, $iErrNo, $sErrStr, 10 ) ) {
00515 $iModStat = 2;
00516 fclose( $oRes );
00517 }
00518 }
00519 $iModStat = ( !$iModStat ) ? 1 : $iModStat;
00520 return $iModStat;
00521 }
00522
00529 public function checkPhp4Compat()
00530 {
00531 $sZendStatus = ( strtolower( (string) @ini_get( 'zend.ze1_compatibility_mode' ) ) );
00532 return in_array( $sZendStatus, array( 'on', '1' ) ) ? 0 : 2;
00533 }
00534
00541 public function checkPhpVersion()
00542 {
00543 $iModStat = ( version_compare( PHP_VERSION, '5.1', '>' ) ) ? 1 : 0;
00544 $iModStat = ( $iModStat == 0 ) ? $iModStat : ( version_compare( PHP_VERSION, '5.2', '>=' ) ? 2 : 1 );
00545 return $iModStat;
00546 }
00547
00553 public function checkRequestUri()
00554 {
00555 return ( isset( $_SERVER['REQUEST_URI'] ) || isset( $_SERVER['SCRIPT_URI'] ) ) ? 2 : 0;
00556 }
00557
00563 public function checkLibXml2()
00564 {
00565 return class_exists( 'DOMDocument' ) ? 2 : 0;
00566 }
00567
00573 public function checkPhpXml()
00574 {
00575 return class_exists( 'DOMDocument' ) ? 2 : 0;
00576 }
00577
00583 public function checkJSon()
00584 {
00585 return extension_loaded( 'json' ) ? 2 : 0;
00586 }
00587
00593 public function checkIConv()
00594 {
00595 return extension_loaded( 'iconv' ) ? 2 : 0;
00596 }
00597
00603 public function checkTokenizer()
00604 {
00605 return extension_loaded( 'tokenizer' ) ? 2 : 0;
00606 }
00607
00613 public function checkBcMath()
00614 {
00615 return extension_loaded( 'bcmath' ) ? 2 : 1;
00616 }
00617
00623 public function checkOpenSsl()
00624 {
00625 return extension_loaded( 'openssl' ) ? 2 : 1;
00626 }
00627
00633 public function checkSoap()
00634 {
00635 return extension_loaded( 'soap' ) ? 2 : 1;
00636 }
00637
00643 public function checkMysqlConnect()
00644 {
00645
00646 $iModStat = ( extension_loaded( 'mysql' ) || extension_loaded( 'mysqli' ) || extension_loaded( 'pdo_mysql' ) ) ? 2 : 0;
00647
00648
00649 if ( $iModStat ) {
00650 $sClientVersion = mysql_get_client_info();
00651 if (version_compare( $sClientVersion, '5', '<' )) {
00652 $iModStat = 1;
00653 if (version_compare( $sClientVersion, '4', '<' )) {
00654 $iModStat = 0;
00655 }
00656 } elseif (version_compare($sClientVersion, '5.0.36', '>=') && version_compare($sClientVersion, '5.0.38', '<')) {
00657
00658 $iModStat = 0;
00659 } elseif (version_compare($sClientVersion, '5.0.40', '>') && version_compare($sClientVersion, '5.0.42', '<')) {
00660
00661 $iModStat = 0;
00662 }
00663 if ( strpos($sClientVersion, 'mysqlnd') !== false ) {
00664
00665 $iModStat = 2;
00666 }
00667 }
00668 return $iModStat;
00669 }
00670
00678 public function checkMysqlVersion( $sVersion = null )
00679 {
00680 if ( $sVersion === null ) {
00681 $aRez = oxDb::getDb()->getAll( "SHOW VARIABLES LIKE 'version'" );
00682 foreach ( $aRez as $aRecord ) {
00683 $sVersion = $aRecord[1];
00684 break;
00685 }
00686 }
00687
00688 $iModStat = 0;
00689 if ( version_compare( $sVersion, '5.0.3', '>=' ) && version_compare( $sVersion, '5.0.37', '<>' ) ) {
00690 $iModStat = 2;
00691 }
00692
00693 return $iModStat;
00694 }
00695
00701 public function checkGdInfo()
00702 {
00703 $iModStat = extension_loaded( 'gd' ) ? 1 : 0;
00704 $iModStat = function_exists( 'imagecreatetruecolor' ) ? 2 : $iModStat;
00705 $iModStat = function_exists( 'imagecreatefromjpeg' ) ? $iModStat : 0;
00706 return $iModStat;
00707 }
00708
00714 public function checkIniSet()
00715 {
00716 return ( @ini_set('session.name', 'sid' ) !== false ) ? 2 : 0;
00717 }
00718
00724 public function checkRegisterGlobals()
00725 {
00726 $sGlobStatus = ( strtolower( (string) @ini_get( 'register_globals' ) ) );
00727 return in_array( $sGlobStatus, array( 'on', '1' ) ) ? 0 : 2;
00728 }
00729
00735 public function checkMemoryLimit()
00736 {
00737 if ( $sMemLimit = @ini_get('memory_limit') ) {
00738
00739 $sDefLimit = '14M';
00740 $sRecLimit = '30M';
00741
00742
00743 $iMemLimit = $this->_getBytes( $sMemLimit );
00744 $iModStat = ( $iMemLimit >= $this->_getBytes( $sDefLimit ) ) ? 1 : 0;
00745 $iModStat = $iModStat ? ( ( $iMemLimit >= $this->_getBytes( $sRecLimit ) ) ? 2 : $iModStat ) : $iModStat;
00746
00747 } else {
00748 $iModStat = -1;
00749 }
00750 return $iModStat;
00751 }
00752
00758 public function checkZendOptimizer()
00759 {
00764 return 2;
00765 }
00766
00772 public function checkZendPlatformOrServer()
00773 {
00774 if (function_exists( 'output_cache_get' )) {
00775 return 2;
00776 }
00777 if (function_exists( 'zend_disk_cache_fetch' )) {
00778 return 2;
00779 }
00780 if (function_exists( 'zend_shm_cache_fetch' )) {
00781 return 2;
00782 }
00783 return 1;
00784 }
00785
00791 protected function _getAdditionalCheck()
00792 {
00793 $sSelect = '';
00794 foreach ( $this->_aException as $sTable => $sColumn ) {
00795 $sSelect .= 'and ( t.TABLE_NAME != "'.$sTable.'" and c.COLUMN_NAME != "'.$sColumn.'" ) ';
00796 }
00797 return $sSelect;
00798 }
00799
00805 public function checkCollation()
00806 {
00807 $myConfig = $this->getConfig();
00808
00809 $aCollations = array();
00810 $sCollation = '';
00811
00812 $sSelect = 'select t.TABLE_NAME, c.COLUMN_NAME, c.COLLATION_NAME from INFORMATION_SCHEMA.tables t ' .
00813 'LEFT JOIN INFORMATION_SCHEMA.columns c ON t.TABLE_NAME = c.TABLE_NAME ' .
00814 'where t.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00815 'and c.TABLE_SCHEMA = "'.$myConfig->getConfigParam( 'dbName' ).'" ' .
00816 'and c.COLUMN_NAME in ("'.implode('", "', $this->_aColumns).'") ' . $this->_getAdditionalCheck() .
00817 ' ORDER BY (t.TABLE_NAME = "oxarticles") DESC';
00818 $aRez = oxDb::getDb()->getAll($sSelect);
00819 foreach ( $aRez as $aRetTable ) {
00820 if ( !$sCollation ) {
00821 $sCollation = $aRetTable[2];
00822 } else {
00823 if ( $aRetTable[2] && $sCollation != $aRetTable[2]) {
00824 $aCollations[$aRetTable[0]][$aRetTable[1]] = $aRetTable[2];
00825 }
00826 }
00827 }
00828
00829 if ( $this->_blSysReqStatus === null ) {
00830 $this->_blSysReqStatus = true;
00831 }
00832 if ( count($aCollations) > 0 ) {
00833 $this->_blSysReqStatus = false;
00834 }
00835 return $aCollations;
00836 }
00837
00843 public function checkDatabaseCluster()
00844 {
00845 return 2;
00846 }
00847
00853 public function checkUnicodeSupport()
00854 {
00855 return (@preg_match('/\pL/u', 'a') == 1) ? 2 : 1;
00856 }
00857
00863 public function getSysReqStatus()
00864 {
00865 if ( $this->_blSysReqStatus == null ) {
00866 $this->_blSysReqStatus = true;
00867 $this->getSystemInfo();
00868 $this->checkCollation();
00869 }
00870 return $this->_blSysReqStatus;
00871 }
00872
00887 public function getSystemInfo()
00888 {
00889 $aSysInfo = array();
00890 $aRequiredModules = $this->getRequiredModules();
00891 $this->_blSysReqStatus = true;
00892 foreach ( $aRequiredModules as $sModule => $sGroup ) {
00893 if ( isset($aSysInfo[$sGroup]) && !$aSysInfo[$sGroup] ) {
00894 $aSysInfo[$sGroup] = array();
00895 }
00896 $iModuleState = $this->getModuleInfo( $sModule );
00897 $aSysInfo[$sGroup][$sModule] = $iModuleState;
00898 $this->_blSysReqStatus = $this->_blSysReqStatus && ( bool ) abs( $iModuleState );
00899 }
00900 return $aSysInfo;
00901 }
00902
00910 public function getModuleInfo( $sModule = null )
00911 {
00912 if ( $sModule ) {
00913 $iModStat = null;
00914 $sCheckFunction = "check".str_replace(" ", "", ucwords(str_replace("_", " ", $sModule)));
00915 $iModStat = $this->$sCheckFunction();
00916
00917 return $iModStat;
00918 }
00919 }
00920
00928 public function getReqInfoUrl( $sIdent)
00929 {
00930 $sUrl = $this->_sReqInfoUrl;
00931 $aInfoMap = $this->_aInfoMap;
00932
00933
00934 if ( isset( $aInfoMap[$sIdent] ) ) {
00935 $sUrl .= "#".$aInfoMap[$sIdent];
00936 }
00937
00938 return $sUrl;
00939 }
00940
00948 protected function _getBytes( $sBytes )
00949 {
00950 $sBytes = trim( $sBytes );
00951 $sLast = strtolower($sBytes[strlen($sBytes)-1]);
00952 switch( $sLast ) {
00953
00954 case 'g':
00955 $sBytes *= 1024;
00956 case 'm':
00957 $sBytes *= 1024;
00958 case 'k':
00959 $sBytes *= 1024;
00960 break;
00961 }
00962
00963 return $sBytes;
00964 }
00965
00976 protected function _checkTemplateBlock($sTemplate, $sBlockName)
00977 {
00978 $sTplFile = $this->getConfig()->getTemplatePath($sTemplate, false);
00979 if (!$sTplFile || !file_exists($sTplFile)) {
00980 return false;
00981 }
00982
00983 $sFile = file_get_contents($sTplFile);
00984 $sBlockNameQuoted = preg_quote($sBlockName, '/');
00985 return (bool)preg_match('/\[\{\s*block\s+name\s*=\s*([\'"])'.$sBlockNameQuoted.'\1\s*\}\]/is', $sFile);
00986 }
00987
00997 public function getMissingTemplateBlocks()
00998 {
00999 $oDb = oxDb::getDb( true );
01000 $aCache = array();
01001 $oConfig = $this->getConfig();
01002
01003 $sShpIdParam = $oDb->quote($oConfig->getShopId());
01004 $sSql = "select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam";
01005 $rs = $oDb->execute($sSql);
01006 $aRet = array();
01007 if ($rs != false && $rs->recordCount() > 0) {
01008 while (!$rs->EOF) {
01009 $blStatus = false;
01010 if (isset($aCache[$rs->fields['OXTEMPLATE']]) && isset($aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']])) {
01011 $blStatus = $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']];
01012 } else {
01013 $blStatus = $this->_checkTemplateBlock($rs->fields['OXTEMPLATE'], $rs->fields['OXBLOCKNAME']);
01014 $aCache[$rs->fields['OXTEMPLATE']][$rs->fields['OXBLOCKNAME']] = $blStatus;
01015 }
01016
01017 if (!$blStatus) {
01018 $aRet[] = array(
01019 'module' => $rs->fields['OXMODULE'],
01020 'block' => $rs->fields['OXBLOCKNAME'],
01021 'template' => $rs->fields['OXTEMPLATE'],
01022 );
01023 }
01024 $rs->moveNext();
01025 }
01026 }
01027
01028 return $aRet;
01029 }
01030 }