function _isIntegrityCorrect($cz_layout_path, $auto_set_active = false) { $cz_layout_path = $this->_prepareAbsFilePath($cz_layout_path); $integrity_info = $this->_getIntegrityInfoForCZLayout($cz_layout_path); if ($integrity_info === null) { return false; } global $application; $row_layout = _parse_cz_layout_ini_file($cz_layout_path, true); $layout_integrity = array('product_list' => $row_layout['ProductList'], 'product_info' => $row_layout['ProductInfo'], 'cms_page' => $row_layout['CMSPage']); if ($integrity_info['layout_md5'] != md5(serialize($layout_integrity))) { return false; } if (!file_exists($integrity_info['htaccess_path'])) { return false; } $lines = file($integrity_info['htaccess_path']); $hta_content = ''; $i = 0; while ($i < count($lines) and $lines[$i] != REWRITE_BLOCK_IDENT_BEGIN . "\n") { $i++; } while ($i < count($lines) and $lines[$i] != REWRITE_BLOCK_IDENT_END . "\n") { $hta_content .= $lines[$i]; $i++; } if ($i < count($lines)) { $hta_content .= $lines[$i]; } if ($integrity_info['htaccess_md5'] != md5($hta_content)) { return false; } $sefu_integrity = array('cats_template' => $application->getAppIni('SEFU_CATEGORY_QUERY_STRING_SUFFIX'), 'prods_template' => $application->getAppIni('SEFU_PRODUCT_QUERY_STRING_SUFFIX'), 'cms_template' => $application->getAppIni('SEFU_CMSPAGE_QUERY_STRING_SUFFIX')); if ($integrity_info['sefu_md5'] != md5(serialize($sefu_integrity))) { return false; } $sets_integrity = array('cats_prefix' => $this->settings['CATS_PREFIX'], 'prods_prefix' => $this->settings['PRODS_PREFIX'], 'cms_prefix' => $this->settings['CMS_PREFIX'], 'rewrite_scheme' => $this->settings['REWRITE_SCHEME']); if ($integrity_info['sets_md5'] != md5(serialize($sets_integrity))) { return false; } if ($integrity_info['mr_active'] == 'Y' and $auto_set_active) { $this->settings['ACTIVE'] = 'Y'; } return true; }
function static_checkLayoutFile($layout_config = NULL, $SITE_PATH = NULL, $PATH_LAYOUTS_CONFIG_FILE = NULL) { global $application; if ($layout_config === NULL) { $layout_config = $application->getAppIni('PATH_LAYOUTS_CONFIG_FILE'); } #check if the layouts-config.ini file exists if (!is_readable($layout_config)) { $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_001", "FILE" => $layout_config)); return $error; } else { if (sizeof($ini_errors = $application->isIniFileCorrect($layout_config)) > 0) { foreach ($ini_errors as $error) { list($error_code, $error_line) = each($error); $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => $error_code, "FILE" => $layout_config, "LINE" => $error_line)); return $error; } } else { $layout_array = @_parse_cz_layout_ini_file($layout_config, true); $application->Configs_array['Layouts'] = $layout_array; $application->cz_layout_config_ini_file = $layout_config; } } if (isset($application->Configs_array['Layouts'])) { # If the declared sections: [Category], [ProductInfo], [Cart], [Checkout], [Closed] exist and are valid # If the Default variable and the template file matching it exist in every block $necessary_checks = array("productlist" => array("section" => false, "default" => false, "template_file" => false), "productinfo" => array("section" => false, "default" => false, "template_file" => false), "cart" => array("section" => false, "default" => false, "template_file" => false), "closed" => array("section" => false, "default" => false, "template_file" => false)); foreach ($application->Configs_array['Layouts'] as $section_name => $section_arr) { $section_name = _ml_strtolower($section_name); switch ($section_name) { case "productlist": case "productinfo": case "cart": case "closed": $application->checkDefaultFileAndOther($section_name, $section_arr, $necessary_checks, $SITE_PATH, $PATH_LAYOUTS_CONFIG_FILE); break; default: break; } } //Output the fatal errors, if errors were detected in the layouts-config.ini file foreach ($necessary_checks as $section => $valid) { //If one of the [Category], [ProductInfo], [Cart], [Checkout], [Closed] sections is declared invalid if (!$valid['section']) { $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_002", "FILE" => $layout_config, "SECTION" => $section), $section); return $error; } //If the 'default' directive is declared invalid in one of the [Category], //[ProductInfo],[Cart],[Checkout],[Closed] sections if (!$valid['default']) { $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_003", "FILE" => $layout_config, "SECTION" => $section, "DIRECTIVE" => "Default")); return $error; } //If the file, declared in the 'default' directive doesn't exist in one of the //[Category],[ProductInfo],[Cart],[Checkout],[Closed] sections if (!($valid['template_file'] === true)) { $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_004", "FILE" => $layout_config, "SECTION" => $section, "DIRECTIVE" => "Default = " . $valid['template_file']), $valid['template_file']); return $error; } } } return array(); }