Ejemplo n.º 1
0
 /**
  * Replaces the tags in the template with values.
  *
  * @ to complete the method
  * @return string the string with replaced tags
  * @param string $text the string with tags
  * @param array $vars the array of compatabilities of tags and its values
  */
 function replace($text, $vars)
 {
     global $application;
     $text = strtr($text, $vars);
     $prepared_tpl_file = $application->getAppIni('PATH_CACHE_DIR') . '_tpl_' . md5($text);
     asc_file_put_contents($prepared_tpl_file, $text);
     ob_start();
     include $prepared_tpl_file;
     $out = ob_get_clean();
     return $out;
 }
 function saveHTAcontent($hta_content, $layout_path)
 {
     $return = array();
     global $application;
     $row_layout = _parse_cz_layout_ini_file($layout_path, true);
     if (isset($row_layout['Site']['SitePath'])) {
         $dest_file_path = $row_layout['Site']['SitePath'] . '.htaccess';
     } else {
         $dest_file_path = $application->appIni["PATH_ASC_ROOT"] . '.htaccess';
     }
     if (file_exists($dest_file_path) and !is_writable($dest_file_path)) {
         $return[] = 'ERR_CANT_WRITE_FILE';
         return $return;
     }
     if (!is_writable(dirname($dest_file_path))) {
         $return[] = 'ERR_CANT_WRITE_FILE';
         return $return;
     }
     #                     ,
     if (file_exists($dest_file_path)) {
         $file = new CFile($dest_file_path);
         $lines = array_map("rtrim", $file->getLines());
         $out_content = '';
         $i = 0;
         while ($i < count($lines) and $lines[$i] != REWRITE_BLOCK_IDENT_BEGIN) {
             $out_content .= $lines[$i] . "\n";
             $i++;
         }
         $out_content .= $hta_content;
         $i++;
         while ($i < count($lines) and $lines[$i] != REWRITE_BLOCK_IDENT_END) {
             $i++;
         }
         $i++;
         while ($i < count($lines)) {
             $out_content .= $lines[$i] . "\n";
             $i++;
         }
     } else {
         $out_content = $hta_content;
     }
     asc_file_put_contents($dest_file_path, $out_content);
     $layout_integrity = array('product_list' => $row_layout['ProductList'], 'product_info' => $row_layout['ProductInfo'], 'cms_page' => $row_layout['CMSPage']);
     $htaccess_md5 = md5($hta_content);
     $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'));
     $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']);
     $tables = $this->getTables();
     $integrity_table = $tables['mr_integrity']['columns'];
     $query = new DB_Replace('mr_integrity');
     $query->addReplaceValue($layout_path, $integrity_table['layout_path']);
     $query->addReplaceValue(md5(serialize($layout_integrity)), $integrity_table['layout_md5']);
     $query->addReplaceValue($dest_file_path, $integrity_table['htaccess_path']);
     $query->addReplaceValue($htaccess_md5, $integrity_table['htaccess_md5']);
     $query->addReplaceValue(md5(serialize($sefu_integrity)), $integrity_table['sefu_md5']);
     $query->addReplaceValue(md5(serialize($sets_integrity)), $integrity_table['sets_md5']);
     $application->db->PrepareSQL($query);
     $application->db->DB_Exec();
     //                    .      ,        ,                     .
     $this->enableMRforLayout($layout_path);
     return $return;
 }
 function removeHtaccessCode()
 {
     global $application;
     $hta_file_path = $application->appIni["PATH_ASC_ROOT"] . '.htaccess';
     $code = $this->getErrDocCode();
     $hta_content = file_get_contents($hta_file_path);
     asc_file_put_contents($hta_file_path, str_replace($code, '', $hta_content));
 }