[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 seo.install.php

Zen Cart 源代码 seo.install.php




下载文件

文件名: seo.install.php
文件类型: PHP文件
文件大小: 15.33 KiB
MD5: 8256a2aae7ba936dca7d6173aff4eb40

seo.install.php - 关闭高亮
  1. <?php
  2. /*
  3.     +----------------------------------------------------------------------+
  4.     |   Ultimate SEO URLs For Zen Cart, version 2.100                        |
  5.     +----------------------------------------------------------------------+
  6.     |                                                                      |
  7.     |   Derrived from Ultimate SEO URLs v2.1 for osCommerce by Chemo         |
  8.     |                                                                      |
  9.     |   Portions Copyright 2005, Joshua Dechant                              |
  10.     |                                                                      |
  11.     |   Portions Copyright 2005, Bobby Easland                               |
  12.     |                                                                      |
  13.     |   Portions Copyright 2003 The zen-cart developers                      |
  14.     |                                                                      |
  15.     +----------------------------------------------------------------------+
  16.     | This source file is subject to version 2.0 of the GPL license,       |
  17.     | that is bundled with this package in the file LICENSE, and is        |
  18.     | available through the world-wide-web at the following url:           |
  19.     | http://www.zen-cart.com/license/2_0.txt.                             |
  20.     | If you did not receive a copy of the zen-cart license and are unable |
  21.     | to obtain it through the world-wide-web, please send a note to       |
  22.     | license@zen-cart.com so we can mail you a copy immediately.          |
  23.     +----------------------------------------------------------------------+
  24. */
  25.  
  26.     class SEO_URL_INSTALLER{
  27.         var $default_config;
  28.         var $db;
  29.         var $attributes;
  30.  
  31.         function SEO_URL_INSTALLER() {
  32.             $this->attributes = array();
  33.  
  34.             $x = 0;
  35.             $this->default_config = array();
  36.  
  37.             $this->default_config['SEO_ENABLED'] = array(
  38.                 'DEFAULT' => 'true',
  39.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '启用网址优化吗?', 'SEO_ENABLED', 'false', '是否启用网址优化? 这是整站的开关。<br /><br />请将根目录下的文件htaccess_sample改名为 .htaccess,并修改其中的 /shop/ 为您的zen cart目录。如果Zen Cart安装在网页服务器的根目录下,就设置为 /。<br /><br />打开网址优化后,请执行一次下面的重置缓存(reset)操作。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  40.             );
  41.             $x++;
  42.  
  43.             $this->default_config['SEO_ADD_CPATH_TO_PRODUCT_URLS'] = array(
  44.                 'DEFAULT' => 'false',
  45.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '在商品的网址中添加cPath吗?', 'SEO_ADD_CPATH_TO_PRODUCT_URLS', 'false', '在商品的网址后添加cPath (例如: some-product-p-1.html?cPath=xx).', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  46.             );
  47.             $x++;
  48.  
  49.             $this->default_config['SEO_ADD_CAT_PARENT'] = array(
  50.                 'DEFAULT' => 'true',
  51.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '商品分类的网址中包括上级分类名称吗?', 'SEO_ADD_CAT_PARENT', 'false', '在分类网址前增加上级分类名称 (例如: parent-category-c-1.html).', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  52.             );
  53.             $x++;
  54.  
  55.             /* START SEO-ADD-PRODUCT-CAT PATCH
  56.             *
  57.             * Patched to use SEO_ADD_PRODUCT_CAT
  58.             * This allows the use of a directory structure for urls.
  59.             * @author Andrew Ballanger
  60.             */
  61.             $this->default_config['SEO_ADD_PRODUCT_CAT'] = array(
  62.                 'DEFAULT' => 'true',
  63.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '商品的网址中包括上级分类名称吗?', 'SEO_ADD_PRODUCT_CAT', 'false', '在商品网址前加上级分类名称 (例如: category-c-1/product-p-1.html)。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  64.             );
  65.             $x++;
  66.             // END SEO-ADD-PRODUCT-CAT PATCH
  67.  
  68.             $this->default_config['SEO_URLS_FILTER_SHORT_WORDS'] = array(
  69.                 'DEFAULT' => '0',
  70.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '过滤太短的单词', 'SEO_URLS_FILTER_SHORT_WORDS', '0', '该设置从网址中过滤少于指定值的单词。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)"
  71.             );
  72.             $x++;
  73.  
  74.             $this->default_config['SEO_URLS_USE_W3C_VALID'] = array(
  75.                 'DEFAULT' => 'true',
  76.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '输出兼容W3C的网址 (参数)?', 'SEO_URLS_USE_W3C_VALID', 'false', '该设置输出兼容W3C的网址。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  77.             );
  78.             $x++;
  79.  
  80.             $this->default_config['USE_SEO_CACHE_GLOBAL'] = array(
  81.                 'DEFAULT' => 'true',
  82.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '打开缓存以减少查询次数吗?', 'USE_SEO_CACHE_GLOBAL', 'true', '该设置可以完全关闭缓存。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  83.             );
  84.             $x++;
  85.  
  86.             $this->default_config['USE_SEO_CACHE_PRODUCTS'] = array(
  87.                 'DEFAULT' => 'true',
  88.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '打开商品缓存吗?', 'USE_SEO_CACHE_PRODUCTS', 'true', '该设置可以关闭商品缓存。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  89.                 );
  90.             $x++;
  91.  
  92.             $this->default_config['USE_SEO_CACHE_CATEGORIES'] = array(
  93.                 'DEFAULT' => 'true',
  94.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '打开目录缓存吗?', 'USE_SEO_CACHE_CATEGORIES', 'true', '该设置可以关闭分类缓存。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  95.             );
  96.             $x++;
  97.  
  98.             $this->default_config['USE_SEO_CACHE_MANUFACTURERS'] = array(
  99.                 'DEFAULT' => 'true',
  100.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '打开厂家缓存吗?', 'USE_SEO_CACHE_MANUFACTURERS', 'true', '该设置可以关闭厂家缓存。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  101.             );
  102.             $x++;
  103.  
  104.             $this->default_config['USE_SEO_CACHE_ARTICLES'] = array(
  105.                 'DEFAULT' => 'true',
  106.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '打开文章缓存吗?', 'USE_SEO_CACHE_ARTICLES', 'true', '该设置可以关闭文章缓存。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  107.             );
  108.             $x++;
  109.  
  110.             $this->default_config['USE_SEO_CACHE_INFO_PAGES'] = array(
  111.                 'DEFAULT' => 'true',
  112.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '打开信息缓存吗?', 'USE_SEO_CACHE_INFO_PAGES', 'true', '该设置可以关闭信息缓存。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  113.             );
  114.             $x++;
  115.  
  116.             $this->default_config['USE_SEO_REDIRECT'] = array(
  117.                 'DEFAULT' => 'true',
  118.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '打开自动跳转吗?', 'USE_SEO_REDIRECT', 'true', '该设置实现自动跳转,发送301文件头实现旧网址转向新网址。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  119.             );
  120.             $x++;
  121.  
  122.             $this->default_config['SEO_REWRITE_TYPE'] = array(
  123.                 'DEFAULT' => 'Rewrite',
  124.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '选择网址重写类型', 'SEO_REWRITE_TYPE', 'Rewrite', '选择网址重写的格式。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''Rewrite''),')"
  125.             );
  126.             $x++;
  127.  
  128.             $this->default_config['SEO_CHAR_CONVERT_SET'] = array(
  129.                 'DEFAULT' => '',
  130.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '输入特殊字符转换', 'SEO_CHAR_CONVERT_SET', '', '该设置转换特殊字符。<br><br>格式<b>必须</b>为: <b>char=>conv,char2=>conv2</b>', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)"
  131.             );
  132.             $x++;
  133.  
  134.             $this->default_config['SEO_REMOVE_ALL_SPEC_CHARS'] = array(
  135.                 'DEFAULT' => 'false',
  136.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '要删除字母数字外的所有字符吗?', 'SEO_REMOVE_ALL_SPEC_CHARS', 'false', '该设置可以删除所有除字母和数字外的字符。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),')"
  137.             );
  138.             $x++;
  139.  
  140.             // START SEO-URLS-FILTER-PCRE PATCH
  141.             $this->default_config['SEO_URLS_FILTER_PCRE'] = array(
  142.                 'DEFAULT' => '',
  143.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '输入网址的 PCRE 过滤规则', 'SEO_URLS_FILTER_PCRE', '', '使用PCRE规则过滤生成的网址。<br><br>格式<b>必须</b>为: <b>find1=>replace1,find2=>replace2</b>. 在字符转换和删除特殊字符前运行。如果网址中要短横线 - ,可以使用空格。如果是反斜线,要输入两次', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)"
  144.             );
  145.             $x++;
  146.             // END SEO-URLS-FILTER-PCRE PATCH
  147.  
  148.             $this->default_config['SEO_URLS_CACHE_RESET'] = array(
  149.                 'DEFAULT' => 'false',
  150.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '重置缓存', 'SEO_URLS_CACHE_RESET', 'false', '该设置重置搜索引擎优化缓存的数据。', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), 'zen_reset_cache_data_seo_urls', 'zen_cfg_select_option(array(''reset'', ''false''),')"
  151.             );
  152.             $x++;
  153.  
  154.             //IMAGINADW.COM
  155.             $this->default_config['SEO_URLS_ONLY_IN'] = array(
  156.                 'DEFAULT' => 'index, product_info, products_new, products_all, featured_products, specials, contact_us, conditions, privacy, reviews, shippinginfo, faqs_all, site_map, gv_faq, discount_coupon, page, page_2, page_3, page_4',
  157.                 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, '输入需要优化的页面', 'SEO_URLS_ONLY_IN', 'index, product_info, products_new, products_all, featured_products, specials, contact_us, conditions, privacy, reviews, shippinginfo, faqs_all, site_map, gv_faq, discount_coupon, page, page_2, page_3, page_4, login, account, create_account, advanced_search, product_free_shipping_info, product_music_info, document_product_info, document_general_info, shopping_cart, unsubscribe', '本设置指定需要网址重写的页面,如果为空,所有页面网址都重写。<br><br>默认页面为: <b>index, product_info, products_new, products_all, featured_products, specials, contact_us, conditions, privacy, reviews, shippinginfo, faqs_all, site_map, gv_faq, discount_coupon, page, page_2, page_3, page_4, login, account, create_account, advanced_search, product_free_shipping_info, product_music_info, document_product_info, document_general_info, shopping_cart, unsubscribe</b>', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)"
  158.             );
  159.             $x++;
  160.  
  161.             $this->db = &$GLOBALS['db'];
  162.  
  163.             $this->init();
  164.         }
  165.  
  166. /**
  167.  * Initializer - if there are settings not defined the default config will be used and database settings installed.
  168.  * @author Bobby Easland
  169.  * @version 1.1
  170.  */
  171.     function init() {
  172.         foreach( $this->default_config as $key => $value ){
  173.             $container[] = defined($key) ? 'true' : 'false';
  174.         } # end foreach
  175.         $this->attributes['IS_DEFINED'] = in_array('false', $container) ? false : true;
  176.         switch(true){
  177.             case ( !$this->attributes['IS_DEFINED'] ):
  178.                 $this->eval_defaults();
  179.                 $sql = "SELECT configuration_key, configuration_value
  180.                         FROM " . TABLE_CONFIGURATION . "
  181.                         WHERE configuration_key LIKE '%SEO%'";
  182.                 $result = $this->db->Execute($sql);
  183.                 $num_rows = $result->RecordCount();
  184.                 $this->attributes['IS_INSTALLED'] = (sizeof($container) == $num_rows) ? true : false;
  185.                 if ( !$this->attributes['IS_INSTALLED'] ){
  186.                     $this->install_settings();
  187.                 }
  188.                 break;
  189.             default:
  190.                 $this->attributes['IS_INSTALLED'] = true;
  191.                 break;
  192.         } # end switch
  193.     } # end function
  194.  
  195. /**
  196.  * This function evaluates the default settings into defined constants
  197.  * @author Bobby Easland
  198.  * @version 1.0
  199.  */
  200.     function eval_defaults(){
  201.         foreach( $this->default_config as $key => $value ){
  202.             define($key, $value['DEFAULT']);
  203.         } # end foreach
  204.     } # end function
  205.  
  206. /**
  207.  * This function removes the database settings (configuration and cache)
  208.  * @author Bobby Easland
  209.  * @version 1.0
  210.  */
  211.     function uninstall_settings(){
  212.         $this->db->Execute("DELETE FROM `".TABLE_CONFIGURATION_GROUP."` WHERE `configuration_group_title` LIKE '%SEO%'");
  213.         $this->db->Execute("DELETE FROM `".TABLE_CONFIGURATION."` WHERE `configuration_key` LIKE '%SEO%'");
  214.  
  215.         /* START SEO-1.5-COMPATIBILITY
  216.          *
  217.          * Patched for compatibility with Zen Cart 1.5
  218.          * @author Andrew Ballanger
  219.          */
  220.         $this->db->Execute("DELETE FROM `".TABLE_ADMIN_PAGES."` WHERE `page_key`='configUltimateSEO'");
  221.         // END SEO-1.5-COMPATIBILITY
  222.  
  223.         // Version 2.200 is a branch off version 2.110 and does not use the same
  224.         // keys to add the admin pages as version 2.150.
  225.         // If the key used by version 2.150 is present remove the old key to
  226.         // avoid potential issues later down the road.
  227.         $this->db->Execute("DELETE FROM `".TABLE_ADMIN_PAGES."` WHERE `page_key`='UltimateSEO'");
  228.  
  229.         $this->db->Execute("DROP TABLE IF EXISTS " . TABLE_SEO_CACHE);
  230.     } # end function
  231.  
  232. /**
  233.  * This function installs the database settings
  234.  * @author Bobby Easland
  235.  * @version 1.0
  236.  */
  237.     function install_settings(){
  238.         $this->uninstall_settings();
  239.         $sort_order_query = "SELECT MAX(sort_order) as max_sort FROM `".TABLE_CONFIGURATION_GROUP."`";
  240.         $next_sort = $this->db->Execute($sort_order_query);
  241.         $next_sort = $next_sort->fields['max_sort'] + 1;
  242.         $insert_group = "INSERT INTO `".TABLE_CONFIGURATION_GROUP."` VALUES (NULL, '网址优化', '网址优化模块的选项', '".$next_sort."', '1')";
  243.         $this->db->Execute($insert_group);
  244.         $group_id = $this->db->insert_ID();
  245.  
  246.         /* START SEO-1.5-COMPATIBILITY
  247.          *
  248.          * Patched for compatibility with Zen Cart 1.5
  249.          * @author Andrew Ballanger
  250.          */
  251.         $page_sort_query = "SELECT MAX(sort_order) as max_sort FROM `". TABLE_ADMIN_PAGES ."` WHERE menu_key='configuration'";
  252.         $page_sort = $this->db->Execute($page_sort_query);
  253.         $page_sort = $page_sort->fields['max_sort'] + 1;
  254.         $insert_page = "INSERT INTO `" . TABLE_ADMIN_PAGES . "` VALUES ('configUltimateSEO', 'BOX_CONFIGURATION_ULTIMATE_SEO', 'FILENAME_CONFIGURATION', 'gID=" . $group_id . "', 'configuration', 'Y', '" . $page_sort . "')";
  255.         $this->db->Execute($insert_page);
  256.         // END SEO-1.5-COMPATIBILITY
  257.  
  258.         foreach ($this->default_config as $key => $value){
  259.             $sql = str_replace('GROUP_INSERT_ID', $group_id, $value['QUERY']);
  260.             $this->db->Execute($sql);
  261.         }
  262.  
  263.         $insert_cache_table = "CREATE TABLE " . TABLE_SEO_CACHE . " (
  264.           `cache_id` varchar(32) NOT NULL default '',
  265.           `cache_language_id` tinyint(1) NOT NULL default '0',
  266.           `cache_name` varchar(255) NOT NULL default '',
  267.           `cache_data` mediumtext NOT NULL,
  268.           `cache_global` tinyint(1) NOT NULL default '1',
  269.           `cache_gzip` tinyint(1) NOT NULL default '1',
  270.           `cache_method` varchar(20) NOT NULL default 'RETURN',
  271.           `cache_date` datetime NOT NULL default '0000-00-00 00:00:00',
  272.           `cache_expires` datetime NOT NULL default '0000-00-00 00:00:00',
  273.           PRIMARY KEY  (`cache_id`,`cache_language_id`),
  274.           KEY `cache_id` (`cache_id`),
  275.           KEY `cache_language_id` (`cache_language_id`),
  276.           KEY `cache_global` (`cache_global`)
  277.         ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
  278.         $this->db->Execute($insert_cache_table);
  279.     } # end function
  280. } # end class
  281. ?>