Zen Cart中文版网站安全

Zen Cart™软件使用的是GNU通用公共许可协议,您可以免费使用、修改Zen Cart™软件。

捐款网址: Zen Cart™ 团队

Zen Cart China

Zen Cart™ 源自: Copyright 2003 osCommerce

OSI Certified是开源动力的认证标志。

ZEN CART中文版安全建店的方法

下面是强化Zen Cart网店安全的几个步骤:

1. 删除/zc_install安装目录


2. 改名"/admin"目录



A- 用文本编辑器,例如记事本,打开文件admin/includes/configure.php


define('DIR_WS_ADMIN', '/admin/');
define('DIR_WS_CATALOG', '/');
define('DIR_WS_HTTPS_ADMIN', '/admin/');
define('DIR_WS_HTTPS_CATALOG', '/');


define('DIR_FS_ADMIN', '/home/mystore.com/www/public/admin/');
define('DIR_FS_CATALOG', '/home/mystore.com/www/public/');

B- 找到Zen Cart的/admin/目录,

C - 使用.htaccess文件来保护Admin目录,类似下面提到的,保存在/admin/includes目录下 (Zen Cart v1.2.7以上版本中已有该文件)

3. 设置configure.php文件为只读




如果您用的是Windows服务器,只要将文件设置为"所有人" "只读",如果在IIS下,是IUSR_xxxxx用户,或者"System"帐号,在Apache下,是"apache user"帐号。

4. 删除不用的管理员帐号

- 检查所有没有使用的管理员帐号并删除。特别注意是否有"Demo"帐号。

5. 强化管理员密码






  • 仅打开一个窗口访问管理页面
  • 登录管理页面后不要访问其他网站
  • 不用时请登出管理页面

6. 保护"自定义页面" "html_includes"中的内容

定义好您的自定义页面后,(管理页面->工具->页面编辑), 您要保护这些文件:

A. 用FTP软件下载备份,这些文件位于/includes/languages/english/html_includes目录。

B. 修改文件 CHMOD 644 或 444 (或 Windows下为“只读”)。见上面的CHMOD说明
/includes/languages/schinese/html_includes – 下面的所有文件/目录
提示: 设置为只读后,如果需要修改自定义页面,还需要重设为可读写。

7. 使用.htaccess文件来强化安全



目录中存在index.html 文件,但还没有.htaccess文件时,建议添加的.htaccess文件如下(取决于服务器的设置):

#.htaccess 用于保护文件
   OPTIONS -Indexes -ExecCGI
   IndexIgnore */*
   ### 先限制所有访问。然后,允许访问特定项目,见下面的 FilesMatch 部分.
   <FilesMatch .*>
    Order Deny,Allow
    Deny from all
   ### 说明: 仅在列表中增加允许的文件类型,取决于要保护的目录:
   <FilesMatch .*\.(js|css|jpg|gif|png|swf)>
    Order Deny,Allow
    Allow from all

In order for the above suggestions to work, your host must include either 'All' or all of these: 'Limit Options Indexes' parameters to the AllowOverride configuration in the server's apache/conf/httpd.conf file.
Some hosts don't like to let you use the OPTIONS directive, so you'll need to leave that line out or put a # in front of it.


您需要选择 -- 并使用 -- 适合您的服务器的方法。最好咨询您的主机提供商。



Protect your "images" and other folders

During initial installation, you are advised to set your images folder to read/write, so that you can use the Admin interface to upload product/category images without having to use FTP for each one. Similar recommendations are made to other files for various reasons.

However, leaving the images (or any other) folder in read/write mode means that hackers might be able to put malicious files in this (or other) folder(s) and thus create access points from which to attempt nasty exploits.

Thus, once your site is built and your images have been created/loaded, you should drop the security down from read/write to read. ie: change from CHMOD 777 down to 644 for files, and to 755 for folders.

File/Folder permissions settings

On Linux/Unix hosts, generally, permission-setting recommendations for basic security are:

  • folders/directories: 755
  • files: 644

On Windows hosts, setting files read-only is usually sufficient. Should double-check that the Internet Guest Account has limited (read-only) access.

Folder Purposes

The folders for which installation suggests read-write access for setup are these. If your site supports .htaccess protection, then you should use it for these folders. (The .htaccess files included with v1.3.9 and newer should already cover the basics.)

  • /cache
    This is used to cache session and database information. The BEST security protection for this is to move it to a folder "above" the webroot (public_html or htdocs or www) area, so that it's not accessible via a browser. (Requires changes to DIR_FS_SQL_CACHE setting in configure.php files as well as Admin > Configuration > Sessions > Session Directory.)
  • /images
    See other suggestions earlier.
  • /includes/languages/english/html_includes
    See other suggestions earlier.
  • /media
    This is only suggested read-write for the sake of being able to upload music-product media files via the admin. Could be done by FTP as an alternative.
  • /pub
    This is used on Linux/Unix hosts to have downloadable products made available to customers via a secure delivery method which doesn't disclose the 'real' location of files/data on your server (so that people can't share a URL and have their friends steal downloads from your site)
  • /admin/backups
    This is used by automated backup routines to store database backups. Optional.
  • /admin/images/graphs
    This is used by the Admin > Tools > Banner Manager for updating/displaying bar graphs related to banner usage. If not writable, feature is ignored.

Remove the print URL from your browser's headers

To stop the browser from printing a URL on the invoice or any other document on the web, follow these steps:

For Internet Explorer:
o Click on File then Page Setup
o At page setup, remove this two character combination: "&u" from the header or footer text box.

For Firefox:
o Click on File then Page Setup
On page setup window click on the tab "Margins & Header/Footer". In the "Header & Footer" section set all of the drop downs to --blank--. (Or at least remove all references to "Title" and "URL".)

Things to Check Up on Regularly

  1. Be sure you've done all the steps listed in this document
  2. Keep good backups of your website files and database
  3. Check your server's errorlog regularly for odd or suspicious activity
    • look for any links that went to a page that isn't in your site
    • look for links that have http after the index.php
  4. Check your website files regularly to be sure nothing's been added or altered
  5. Ask your webhost what they have done to be sure the server you're on is safe and secure so that outsiders cannot do any harm, and so that other websites on your server cannot be used to get to your site and cause any harm (in case they have security holes in them)
  6. If your business warrants, or you still want additional assurance (esp if running forum software on your site, or other scripts outside of Zen Cart), hire a security consultant to check your site regularly and give you peace of mind in exchange for a few dollars

版权所有 2010 Zen Cart 中文版