View Single Post
  #1  
Old 06-23-2006, 04:07 AM
 
Jiser Jiser is offline
 

Senior Member
  
Join Date: Oct 2004
Posts: 118
 

Default Insert Keywords in Product/Category Links

HTML STATIC SEO MOD

Just for the people (especcially mr or ms Cart-Lab) who want the speed of HTML (even faster) and the ability to insert keywords in product/category links like in CDSEO LINKS hereby a lovely HTML SEO MOD

What does this script?
  • - It will allow you to insert specific site-related keywords into both product and category filenames. Like buy or sale or shop or whatever
    - It will allow you to insert specific category related keywords into the category filename. So if you're selling car parts of different brands. You can f.e in the category BMW=> Tires the keyword BMW. So the filename of the category filename of tires will be changed to tires-bmw etc
    - It will delete the useless hyphen between the category indicators (p-{page}-c-{categoryid} will be p{page}c{categoryid})
    - It will delete white spaces in the HTML code which increase the speed of the normal HTML Catalog => Special Thanks to the distributed script of NuAlpha!
    - It will prevent Search Engines from penalizing you for having duplicate content using two methods: 1: a simple robot.txt and 2: hyperlinks on home.php to the HTML root categories
    - It will generate the catalog in your x-cart rootfolder
    - It will auto-generate the HTML catalog each 24 hours or so

Remember to first backup your files!! I haven't tested everything of this mod yet....And don't write whole books in the keywords sections. The filenames are autolimited to 128 characters!
First thing first:

Run the fallowing SQL Queries:
Code:
alter table xcart_categories add cat_keywords varchar(255) not null; INSERT INTO xcart_config VALUES ('special_keywords', 'Enter the special keywords for filenames', '', 'SEO', 'Labels', '', 'TEXT'); INSERT INTO xcart_languages VALUES ('US', 'lbl_cat_keywords', 'lbl_cat_keywords', 'lbl_cat_keywords', 'Labels');

Open skin1/admin/main/category_modify.tpl

Find:
Code:
<TR> <TD height="10" class="FormButton" nowrap valign="top">{$lng.lbl_description}:</TD> <TD width="10" height="10"><FONT class="CustomerMessage"></FONT></TD> <TD height="10"> <TEXTAREA cols="65" rows="15" name="description"> {if $category_error ne ""}{$smarty.post.description|escape:"html"}{elseif $mode ne "add"}{$current_category.description|escape:"html"}{/if} </TEXTAREA> </TD> </TR>

Insert above:
Code:
<TR> <TD height="10" class="FormButton" nowrap valign="top">{$lng.lbl_cat_keywords}:</TD> <TD width="10" height="10"><FONT class="CustomerMessage"></FONT></TD> <TD height="10"> <TEXTAREA cols="65" rows="1" name="cat_keywords"> {if $category_error ne ""}{$smarty.post.cat_keywords|escape:"html"}{elseif $mode ne "add"}{$current_category.cat_keywords|escape:"html"}{/if} </TEXTAREA> </TD> </TR>



Open admin/html_catalog.php and replace existing code with:
Code:
<?php /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2004 Ruslan R. Fazliev <rrf@rrf.ru> | | All rights reserved. | +-----------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" | | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.x-cart.com/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. | | FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.| | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2004 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # $Id: html_catalog.php,v 1.53.2.4 2004/09/20 11:41:35 mclap Exp/Jiser $ # This script generates search engine friendly HTML catalog for X-cart @set_time_limit(20000); require "./auth.php"; if ($_SERVER[DOCUMENT_ROOT]) { # # Running from the web, make sure we authenticate the user # require $xcart_dir."/include/security.php"; } else { # # Running from command line # $command_line_mode = true; ini_set('html_errors', '0'); $REQUEST_METHOD = 'POST'; $start_category = ''; $mode = 'catalog_gen'; $namestyle = 'hyphen_4'; $process_subcats = 'checked'; $pages_per_pass = 0; $gen_action = 3; $process_staticpages = 'checked'; $lngcat[US] = '/..'; } $location[] = array(func_get_langvar_by_name("lbl_html_catalog"), ""); define ('DIR_CATALOG', '/'); $per_page = $config["Appearance"]["products_per_page"]; $max_name_length = 128; $php_scripts = array("search.php","giftcert.php","help.php", "cart.php", "product.php","register.php", "home.php", "pconf.php", "giftregs.php", "manufacturers.php"); $site_location = parse_url($http_location); $robot_cookies = array("is_robot=1"); $name_styles = array ( "hyphen" => array ( "category" => "{category_name}-p-{page}-c-{categoryid}.html", "product" => "{product_name}-p-{productid}.html", "staticpage" => "{page_name}-sp-{pageid}.html", "name_delim" => "_" ), "hyphen_4" => array ( "category" => "{category_name}-{page}c{categoryid}.html", "product" => "{product_name}-p{productid}.html", "staticpage" => "{page_name}-p{pageid}.html", "name_delim" => "-" ), "new" => array ( "category" => "{category_name}_page_{page}_c_{categoryid}.html", "product" => "{product_name}_p_{productid}.html", "staticpage" => "{page_name}_sp_{pageid}.html", "name_delim" => "_" ), # Old scheme (before 3.5.0) "default" => array ( "category" => "category_{categoryid}_{category_name}_page_{page}.html", "product" => "product_{productid}_{product_name}.html", "staticpage" => "page_{pageid}_{page_name}.html", "name_delim" => "_" ) ); function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } function func_mkdir($dir,$recursive=false) { if (empty($dir)) return true; if (!file_exists($dir)) { $r = mkdir($dir); if ($r) return true; if ($recursive) { return func_mkdir(dirname($dir)) && mkdir($dir); } return false; } elseif (is_dir($dir)) return true; return false; } function my_save_data($filename, $data) { global $hc_state; func_mkdir(dirname($filename)); $fp = fopen($filename, "w+"); if ($fp === false) { echo "<FONT color=\"red\">".func_get_langvar_by_name("lbl_cannot_save_file_N", array("file" => $filename))."</FONT>"; x_session_save(); exit; } fwrite($fp, $data); $hc_state["count"] ++; echo "$filename \n"; func_flush(); if ($hc_state["pages_per_pass"] > 0 && $hc_state["count"] > 0 && ($hc_state["count"] % $hc_state["pages_per_pass"]) == 0) { echo "<HR>"; func_html_location("html_catalog.php?mode=continue",1); } } function normalize_name($name) { global $max_name_length, $hc_state; static $r_match = false; static $r_repl = false; if ($r_match == false) { $r_match = array( "/[ \/".$hc_state["namestyle"]["name_delim"]."]+/S", "/[^A-Za-z0-9_".$hc_state["namestyle"]["name_delim"]."]+/S" ); $r_repl = array($hc_state["namestyle"]["name_delim"], ""); } if (strlen($name) > $max_name_length) $name = substr($name, 0, $max_name_length); $name = preg_replace($r_match, $r_repl, $name); return $name; } # # Generate filename for a category page # function category_filename($cat, $cat_keywords=false, $special_keywords=false, $page = 1){ global $max_name_length; global $sql_tbl; global $hc_state; if (empty($cat_name)) $cat_name = func_query_first_cell("SELECT category FROM $sql_tbl[categories] where categoryid='$cat'")."-".func_query_first_cell("SELECT cat_keywords FROM $sql_tbl[categories] where categoryid='$cat'")."-".func_query_first_cell("SELECT value FROM $sql_tbl[config] where name='special_keywords'"); if (empty($cat_name)) $cat_name = $cat; $cat_name = normalize_name($cat_name); $cat_name = preg_replace(array("!{category_name}!S", "!{page}!S", "!{categoryid}!S"),array($cat_name, $page, $cat),$hc_state["namestyle"]["category"]); return $cat_name; } # # Generate filename for a product page # function product_filename($productid, $special_keywords=false, $prod_name=false){ global $max_name_length, $sql_tbl; global $hc_state; if (empty($prod_name)) $prod_name = func_query_first_cell("SELECT product FROM $sql_tbl[products] WHERE productid = '$productid'")."-".func_query_first_cell("SELECT value FROM $sql_tbl[config] where name='special_keywords'"); $prod_name = normalize_name($prod_name); $prod_name = preg_replace(array("!{product_name}!S", "!{productid}!S"),array($prod_name, $productid),$hc_state["namestyle"]["product"]); return $prod_name; } function staticpage_filename($pageid, $page_name=false) { global $config; global $max_name_length, $sql_tbl; global $hc_state; if (empty($page_name)) $page_name = func_query_first_cell("SELECT title FROM $sql_tbl[pages] WHERE pageid='$pageid' AND level='E' AND language='$config[default_customer_language]'"); if (empty($page_name)) $page_name = $pageid; $page_name = normalize_name($page_name); $page_name = preg_replace(array("!{page_name}!S", "!{pageid}!S"),array($page_name, $pageid),$hc_state["namestyle"]["staticpage"]); return $page_name; } function category_callback($found) { global $hc_state; $cat = false; $fn = array(0,1); if (preg_match("/cat=([0-9]+)/S",$found[2], $m)) $fn[0] = $cat = $m[1]; if (preg_match("/page=([0-9]+)/S",$found[2], $m)) $fn[1] = $m[1]; return $found[1].$hc_state["catalog"]["webpath"].category_filename($fn[0],false,$fn[1]).$found[3]; } function product_callback($found) { global $hc_state; if (preg_match("/productid=([0-9]+)/S",$found[2], $m)) return $found[1].$hc_state["catalog"]["webpath"].product_filename($m[1]).$found[3]; return $found[1].$found[3]; }; function staticpage_callback($found) { global $hc_state; if (preg_match("/pageid=([0-9]+)/S",$found[2], $m)) return $found[1].$hc_state["catalog"]["webpath"].staticpage_filename($m[1]).$found[3]; return $found[1].$found[3]; }; # # Modify hyperlinksks to point to HTML pages of the catalogue # function process_page($page_src,$page_name) { global $php_scripts_long; global $XCART_SESSION_NAME; global $site_location; global $hc_state; # <SELECT name="sl" onChange="javascript: document.sl_form.submit()"> # <SELECT name="sl" onChange="javascript: window.location=document.sl_form.sl.value"> # # Remove the "select language" form if ($hc_state["remove_slform"]) { $page_src = preg_replace("!<FORM[^<>]*name=[^<>]*sl_form.*</FORM>!sUS","",$page_src); } else { $page_src = preg_replace("!(<SELECT[^<>]*name=[^<>]*sl.*)javascript: document.sl_form.submit\(\)([\">])!sUS","\\1javascript: window.location=document.sl_form.sl.value\\2",$page_src); foreach ($hc_state["catalog_dirs"] as $inst) { $path = $inst["webpath"].$page_name; $page_src = preg_replace("!(<FORM[^<>]*name=[^<>]*sl_form.*<OPTION[^<>]*value=\")".$inst["code"]."(\".*</FORM>)!sUS","\\1".$path."\\2",$page_src); $updated_lng[] = $inst["code"]; } if (isset($hc_state["remove_lng_line"])) $page_src = preg_replace("!<OPTION[^<>]*value=\"(".$hc_state["remove_lng_line"].")\".*</OPTION>!sUS","",$page_src); } # Modify links to categories $page_src = preg_replace_callback('/(<a[^<>]+href[ ]*=[ ]*["\']*)[^"\']*home.php\?(cat=[^"\'>]+)(["\'])/iS', "category_callback", $page_src); # FancyCategories links $page_src = preg_replace_callback('/(window.location[ ]*=[ ]*["\']*)[^"\']*home.php\?(cat=[^"\'>]+)(["\'])/iS', "category_callback", $page_src); # Modify links to products $page_src = preg_replace_callback('/(<a[^<>]+href[ ]*=[ ]*["\']*)[^"\']*product.php\?(productid=[^"\'>]+)(["\'>])/iUS', "product_callback", $page_src); if ($hc_state["process_staticpages"]) { # Modify links to static_pages $page_src = preg_replace_callback('/(<a[^<>]+href[ ]*=[ ]*["\']*)[^"\']*pages.php\?(pageid=[^"\'>]+)(["\'>])/iUS', "staticpage_callback", $page_src); } # Modify links to PHP scripts $page_src = preg_replace("/<a(.+)href[ ]*=[ ]*[\"']*(".$php_scripts_long.")([^\"^']*)[\"']/iUS", "<a\\1href=\"".$site_location["path"].DIR_CUSTOMER."/\\2\\3\"", $page_src); # Modify action values in HTML forms $page_src = preg_replace("/action[ ]*=[ ]*[\"']*(".$php_scripts_long.")([^\"^']*)[\"']/iUS", "action=\"".$site_location["path"].DIR_CUSTOMER."/\\1\"", $page_src); # Strip all PHP transsids if any while (preg_match("/<a(.+)href[ ]*=[ ]*[\"']*([^\"^']*)(\?".$XCART_SESSION_NAME."=|&".$XCART_SESSION_NAME."=)([^\"^']*)[\"']/iS", $page_src)) $page_src = preg_replace("/<a(.+)href[ ]*=[ ]*[\"']*([^\"^']*)(\?".$XCART_SESSION_NAME."=|&".$XCART_SESSION_NAME."=)([^\"^']*)[\"']/iS", "<a\\1href=\"\\2\"", $page_src); $page_src = preg_replace("/<input[ ]+type=\"hidden\"[ ]+name=\"".$XCART_SESSION_NAME."\"[ ]+value=\"[a-zA-z0-9]*\"[ ]*\/>/iS", "", $page_src); return $page_src; } if ($REQUEST_METHOD=="POST" && $mode=="catalog_gen" || $REQUEST_METHOD=="GET" && $mode=="continue") { require $xcart_dir."/include/safe_mode.php"; echo func_get_langvar_by_name("lbl_generating_catalog")." "; func_flush(); # variables initiation x_session_register("hc_state"); if (empty($hc_state) || $REQUEST_METHOD=="POST") { $hc_state=""; $hc_state["category_processed"] = false; $hc_state["catproducts_processed"] = false; $hc_state["last_cid"] = 0; $hc_state["last_pid"] = 0; $hc_state["cat_pages"] = 0; $hc_state["cat_page"] = 1; $hc_state["last_pageid"] = 0; $hc_state["count"] = 0; $hc_state["start_category"] = $start_category; $hc_state["pages_per_pass"] = $pages_per_pass; $hc_state["gen_action"] = $gen_action; $hc_state["process_subcats"] = isset($process_subcats); $hc_state["process_staticpages"] = isset($process_staticpages); $hc_state["time_start"] = getmicrotime(); if (!isset($name_styles[$namestyle])) { if(isset($name_styles["default"])) $namestyle = "default"; else { reset($name_styles); $namestyle = key($name_styles); } } $hc_state["namestyle"] = $name_styles[$namestyle]; $genlng = array(); $lngdel = array(); if (is_array($lngcat)) { foreach($lngcat as $code=>$path) { if (trim($path) != "") { $genlng[] = array("code"=>$code, "path"=>func_normalize_path($xcart_dir."/".$path), "webpath"=>func_normalize_path($site_location["path"]."/".$path."/","/")); } else { $lngdel[] = $code; } } } if (empty($genlng)) { $top_message["content"] = func_get_langvar_by_name("msg_err_hc_no_languages"); $top_message["type"] = "E"; func_header_location("html_catalog.php"); } if (!empty($lngdel)) $hc_state["remove_lng_line"] = implode("|", $lngdel); $hc_state["catalog_dirs"] = $genlng; $hc_state["catalog_idx"] = 0; # If only one language, then remove the "select language" form if (count($hc_state["catalog_dirs"]) == 1) $hc_state["remove_slform"] = true; if ($drop_pages == "on") { echo func_get_langvar_by_name("lbl_deleting_old_catalog")." "; func_flush(); $__tmp = func_query("SELECT filename FROM $sql_tbl[pages] WHERE level='R'"); $static_root_pages = array(); if (is_array($__tmp)) { foreach($__tmp as $__v) $static_root_pages[] = $__v["filename"]; } foreach ($hc_state["catalog_dirs"] as $catdir) { $dir = opendir ($catdir["path"]); while ($file = readdir ($dir)) { if (($file == ".") or ($file == "..") or ($file=="shop_closed.html") or (strstr($file,".html")!=".html")) continue; if (in_array($file, $static_root_pages)) continue; if ((filetype ($catdir["path"]."/".$file) != "dir")) { unlink ($catdir["path"]."/".$file); } } } } echo func_get_langvar_by_name("lbl_converting_pages_to_html")." "; func_flush(); # Dump X-cart home page to disk foreach ($hc_state["catalog_dirs"] as $catdir) { $hc_state["catalog"] = $catdir; list($http_headers, $page_src) = func_http_get_request($site_location["host"].":".$site_location["port"], $site_location["path"].DIR_CUSTOMER."/home.php", "sl=".$catdir["code"], $robot_cookies); if (!$hc_state["process_staticpages"]) $php_scripts [] = "pages.php"; $php_scripts_long = implode("|", $php_scripts); $page_src = process_page($page_src,"index.html"); my_save_data($catdir["path"]."/index.html", $page_src); } $hc_state["catalog"] = $hc_state["catalog_dirs"][$hc_state["catalog_idx"]]; } else { echo func_get_langvar_by_name("lbl_continue_converting_pages_to_html", array("count" => $hc_state["count"]))." "; func_flush(); if (!$hc_state["process_staticpages"]) $php_scripts [] = "pages.php"; $php_scripts_long = implode("|", $php_scripts); } # # Process static pages # if ($hc_state["process_staticpages"]) { $pages_data = db_query("SELECT pageid, title FROM $sql_tbl[pages] WHERE pageid > '$hc_state[last_pageid]' AND level='E' AND language='$config[default_customer_language]' ORDER BY pageid"); while ($page_data = db_fetch_array($pages_data)) { $hc_state["last_pageid"] = $page_data["pageid"]; list($http_headers, $page_src) = func_http_get_request($site_location["host"].":".$site_location["port"], $site_location["path"].DIR_CUSTOMER."/pages.php", "pageid=$page_data[pageid]&sl=".$hc_state["catalog"]["code"], $robot_cookies); $page_name = staticpage_filename($page_data["pageid"], $page_data["title"]); $page_src = process_page($page_src, $page_name); my_save_data($hc_state["catalog"]["path"]."/".$page_name, $page_src); } db_free_result($pages_data); } # # Let's generate the catalog # if ($hc_state["cat_pages"] > 0 || isset($hc_state["catproducts"])) $categories_cond = "categoryid>=".$hc_state["last_cid"]; else $categories_cond = "categoryid>".$hc_state["last_cid"]; if (!empty($hc_state["start_category"])) $categories_cond .= " AND (categoryid_path='".$hc_state["start_category"]."' ".(@$hc_state["process_subcats"]?" OR categoryid_path LIKE '$hc_state[start_category]/%'":"").") "; if (!$hc_state["process_subcats"]) { if (!empty($hc_state["start_category"])) $categories_cond .= " AND categoryid_path NOT LIKE '$hc_state[start_category]/%/%'"; else $categories_cond .= " AND categoryid_path NOT LIKE '%/%'"; } $categories_data = db_query("SELECT categoryid, category FROM $sql_tbl[categories] WHERE ".$categories_cond." ORDER BY categoryid"); $avail_condition = ""; if ($config["General"]["unlimited_products"] == "N" && $config["General"]["disable_outofstock_products"] == "Y") $avail_condition = " AND $sql_tbl[products].avail>0 "; if ($categories_data) { while ($category_data = db_fetch_array($categories_data)) { $hc_state["last_cid"] = $category_data["categoryid"]; if (($hc_state["gen_action"] & 1) === 1 && !isset($hc_state["catproducts"])) { if ($hc_state["cat_pages"]==0 && !isset($hc_state["cat_done"])) { $product_count = func_query_first_cell("SELECT COUNT(*) FROM $sql_tbl[products_categories], $sql_tbl[products] WHERE $sql_tbl[products_categories].categoryid = '$category_data[categoryid]' AND $sql_tbl[products_categories].productid = $sql_tbl[products].productid".$avail_condition); $pages = ceil($product_count/$per_page); if ($pages == 0) $pages = 1; $first = 1; $hc_state["cat_pages"] = $pages; $hc_state["cat_done"] = false; } else { $first = $hc_state["cat_page"]+1; $pages = $hc_state["cat_pages"]; } # process pages of category if (!isset($hc_state["cat_done"]) || !@$hc_state["cat_done"]) { for ($i = $first; $i <= $pages; $i++) { list($http_headers, $page_src) = func_http_get_request($site_location["host"].":".$site_location["port"], $site_location["path"].DIR_CUSTOMER."/home.php", "cat=$category_data[categoryid]&page=$i&sl=".$hc_state["catalog"]["code"], $robot_cookies); $hc_state["cat_page"] = $i; $page_name = category_filename($category_data["categoryid"], $category_data["category"], $i); $page_src = process_page($page_src, $page_name); my_save_data($hc_state["catalog"]["path"]."/".$page_name, $page_src); } } unset($hc_state["cat_done"]); $hc_state["cat_page"] = 1; $hc_state["cat_pages"] = 0; } # process products in category if (($hc_state["gen_action"] & 2) === 2) { $prod_cond = " AND $sql_tbl[products].productid>".$hc_state["last_pid"]; $products_data = db_query("SELECT $sql_tbl[products].productid, $sql_tbl[products].product FROM $sql_tbl[products_categories], $sql_tbl[products] WHERE $sql_tbl[products_categories].categoryid=$category_data[categoryid] AND $sql_tbl[products_categories].productid=$sql_tbl[products].productid AND $sql_tbl[products].forsale='Y' $prod_cond ORDER BY $sql_tbl[products].productid"); if ($products_data) { $hc_state["catproducts"] = false; while($product_data = db_fetch_array($products_data)) { $hc_state["last_pid"] = $product_data["productid"]; list($http_headers, $page_src) = func_http_get_request($site_location["host"].":".$site_location["port"], $site_location["path"].DIR_CUSTOMER."/product.php", "productid=$product_data[productid]&sl=".$hc_state["catalog"]["code"], $robot_cookies); $page_name = product_filename($product_data["productid"], $product_data["product"]); $page_src = process_page($page_src, $page_name); my_save_data($hc_state["catalog"]["path"]."/".$page_name, $page_src); } $hc_state["last_pid"] = 0; unset($hc_state["catproducts"]); } } } } $hc_state["catalog_idx"]++; if (isset($hc_state["catalog_dirs"][$hc_state["catalog_idx"]])) { $hc_state["catalog"] = $hc_state["catalog_dirs"][$hc_state["catalog_idx"]]; $hc_state["category_processed"] = false; $hc_state["catproducts_processed"] = false; $hc_state["last_cid"] = 0; $hc_state["last_pid"] = 0; $hc_state["cat_pages"] = 0; $hc_state["cat_page"] = 1; $hc_state["last_pageid"] = 0; echo "<HR>"; func_html_location("html_catalog.php?mode=continue",20); } $time_end = getmicrotime(); echo " ".func_get_langvar_by_name("lbl_html_catalog_created_successfully")." "; echo func_get_langvar_by_name("lbl_time_elapsed_n_secs", array("sec" => round($time_end-$hc_state["time_start"],2))); x_session_unregister("hc_state"); # Modify PHP Settings # ####################### ini_set('max_execution_time', 60*60*4); // Make the maximum execution & input time 4 hours so that the script doesn't time-out. ini_set('max_input_time', 60*60*4); ob_implicit_flush(1); // Show the progress in the browser. # $Id: clean.php,v 1.2.0 2005/10/08 01:32:05 bjoshua Exp $ ############################################################################## ## ## HTML Catalog Cleaner ## ## ############################################################################## ## Strips every file in the HTML catalog directory of all excess white ## ## spaces. ## ############################################################################## ## Initially Created: 6/26/2004 # Define the constants. define('CATALOG_DIR', '/home/username/domains/yourdomain.com/public_html/'); define('BAR_LENGTH_REDUCER', 3); // If you have over 1000 HTML files in your catalog, you may wish to set this number higher. # Initialize variables. $successes = 0; $failures = 0; $filelength['init'] = 0; $filelength['final'] = 0; $cnt['tmp'] = 0; // Newline counter $cnt['tot'] = 0; // Totals counter $pblr = 0; // Progress bar length reducer variable # Initialize regular expressions. $regex = array("/[\t\n\r\f]+/" => '', // Newlines and tabs. '/\s+/' => ' ', // All excess white space. '/ * */i' => '', // Excess space after or before non-breaking space. '/> </' => '><' // Space between HTML tags. # Add anything else here as you need. # Ex: 'Search' => 'Replace' ); $java_saver = '|(<script[^>]*>.*?</script>)|si'; # Pad with 256 bytes for Internet Explorer to show output immediately. if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { for ($pad = 0; $pad < 256; $pad++) print("\t"); print("\n"); } print('Stripping the HTML files of excess spaces... '); # Open the directory and store the file list. if (is_dir(CATALOG_DIR)) { if ($dh = opendir(CATALOG_DIR)) { # Iterate over file list. while (($filename = readdir($dh)) !== false) { // Skip non-HTML files. if (strpos($filename, '.htm') !== false) $file_list[] = $filename; } closedir($dh); // Close the directory. } if (empty($file_list)) exit('<h3>No recognizable HTML files could be found in the directory "'.CATALOG_DIR.'"</h3>'); # Perform specific operations on the files. foreach ($file_list as $file) { $file_contents = file_get_contents(CATALOG_DIR.DIRECTORY_SEPARATOR.$file); $filelength['init'] += strlen($file_contents); # Examine document for javascript code blocks and preserve them for restoration. if (preg_match_all($java_saver, $file_contents, $got_java, PREG_SET_ORDER)) { foreach ($got_java as $java_chip) { if (is_array($java_chip)) $java_scripts[] = $java_chip[1]; } foreach ($regex as $search=>$replace) // Do each replacement. $file_contents = preg_replace($search, $replace, $file_contents); # Reverse the damage to the JavaScripts. if (preg_match_all($java_saver, $file_contents, $got_java, PREG_SET_ORDER)) { foreach ($got_java as $stripped_java) { if (is_array($stripped_java)) { # Find the stripped java and replace it with the original code. $file_contents = str_replace($stripped_java[1], current($java_scripts), $file_contents); next($java_scripts); } } } } else { foreach ($regex as $search=>$replace) // Do each replacement. $file_contents = preg_replace($search, $replace, $file_contents); } $fp = fopen(CATALOG_DIR.DIRECTORY_SEPARATOR.$file, 'w'); // Truncate file, then apply the modifications. if (!fwrite($fp, $file_contents)) { $failure_list[] = $file; // Log failures. $failures++; } else $successes++; fclose($fp); unset($java_scripts); $java_scripts = array(); $filelength['final'] += strlen($file_contents); if ($pblr == BAR_LENGTH_REDUCER) { // Progress bar length reducer. print('|'); // Lengthen the progess bar. $cnt['tmp']++; // Increment the newline counter. $pblr = 0; // Reset pblr counter. } else $pblr++; $cnt['tot']++; // Increment totals counter. if ($cnt['tmp'] == 250) { print(' '); $cnt['tmp']=0; // Reset the counter. } } } else exit(' '.CATALOG_DIR.' is not a directory! Please check the path and try again.'); print(' There were '.number_format($successes).' successful cleanings and '.number_format($failures).' failures out of a total of '.number_format($cnt['tot']).' files.</p>'. ' Your HTML Catalog files had a total combined length of '.number_format($filelength['init']).' characters.'. ' They now have a total length of '.number_format($filelength['final']).' characters.</p>'. 'That is a total of <u>'.number_format($filelength['init']-$filelength['final']).'</u> excess white spaces removed from your files. ' ); if (!empty($failure_list)) { print(' The following files could not be written to: '); $bg = 0; foreach ($failure_list as $failure) { # Show background color every other line for readability. print(($bg % 2 != 0 ? '<font style="background-color:#E0E0E0">' : ''). ''. $failure. ($bg % 2 != 0 ? '</font>' : ''). ' ' ); $bg++; } } } else { # # Grab all categories # x_session_unregister("hc_state"); $categories = func_query("SELECT * FROM $sql_tbl[categories] WHERE parentid=0 ORDER BY category"); # # Smarty display code goes here # $smarty->assign("cat_dir", $xcart_dir.DIR_CATALOG); $smarty->assign("cat_url", $http_location.DIR_CATALOG."/index.html"); $smarty->assign("default_catalog_path", DIR_CATALOG); $smarty->assign("categories", $categories); $smarty->assign("main","html_catalog"); # Assign the current location line $smarty->assign("location", $location); @include $xcart_dir."/modules/gold_display.php"; func_display("admin/home.tpl",$smarty); } ?>

Find the fallowing code:
Code:
/home/username/domains/yourdomain.com/public_html/

and


Code:
$lngcat[US] = '/..';

and rename those to your own situation


create a robots.txt and put the fallowing code in it:
Code:
User-agent: GoogleBot Disallow: /home.php$ User-agent: msnbot Disallow: /home.php$

Possibly you need to give your root folder the fallowing permissions: 777

Edit (/home/username/domains/yourdomain.com/public_html/admin) and create the fallowing cron:

Code:
05 02 * * * cd /home/username/domains/yourdomain.com/public_html/admin; /usr/local/bin/php -q -f html_catalog.php


Generate your store manually to the root folder

Open skin1/customer/categories.tpl

find:
Code:
<FONT class="CategoriesList"><A href="home.php?cat={$categories[cat_num].categoryid}" class="VertMenuItems">

replace with:
Code:
<FONT class="CategoriesList"><A href="{$categories[cat_num].category}-{$categories[cat_num].category}-{$config.SEO.special_keywords}-1c{$categories[cat_num].categoryid}.html" class="VertMenuItems">


Donation? I always like a nice editable HTML Sitemap [/b]
__________________
x-cart 4.05
Linux CENTOS
APACHE
Heavily customized
Reply With Quote