Table of Contents

Safemode Hack

The safemodehack option tries to solve problems with creating and deleting server-created directories on servers having safe_mode or safe_mode_gid enabled. It is not thoroughly tested yet so any feedback is welcome.

When to use this hack

On some hosts with restrictive settings there are limitations on PHP‘s filesystem functions, e.g. mkdir() etc. To be more specific, the settings are:

  1. safe_mode = On
  2. safe_mode_gid = On

Under these settings, any filesystem-based software such as Image-Handler can’t work in the normal way. The only way to bypass this is to use FTP functions. That’s it!

Note: On some servers where PHP is run as CGI (Server API: CGI) instead of PHP being set up as Apache2 module (Server API: Apache 2.0 Handler) directory creation may work even with safe_mode settings enabled.

Usage

To enable it, set safemodehack to 1 and enter your FTP credentials into the config file located at admin/includes/extra_configures/bmz_io_conf.php. If you have already tried running a contribution creating directories without the safemode hack, you have to remove the subdirectories and files of your cache directory to have them recreated with the correct UID in order for everything to work.

example:

$conf['safemodehack'] = 1;
$conf['ftp']['host'] = 'localhost';
$conf['ftp']['port'] = '21';
$conf['ftp']['user'] = 'user';
$conf['ftp']['pass'] = 'password';
$conf['ftp']['root'] = '/home/user';

So how does the ftp root option work?

When a contribution using the safemode hack tries to create a directory it strips the root part from the path before creating it over over FTP.

Examples:

Scenario 1: You are running the server yourself

Imagine you installed Zen-Cart in /home/user/htdocs/shop with /home/user/htdocs/shop/images as image directory. When you log in with FTP you are chrooted to ‘/home/user’. For this setup you should set your $conf[’ftp’][’root’] to /home/user/. So if a contribution using the safemode hack tries to create the directory /home/user/htdocs/shop/images/mydir the safemode hack strips the root part resulting in htdocs/shop/images/mydir. This directory then will be created via FTP.

If your FTP Server doesn’t use any chroot (eg. you can cd up to /) you can leave the root option empty.

Scenario 2: You are with a webhost

If you are registered with a webhost and if you have installed Zen-Cart on your webspace, you already know the absolute path in which Zen-Cart resides. This is usually something like /srv/www/htdocs/your-ftp-username/html/shop, but you can find it out, by e.g. clicking on Tools → Server Info in your Admin Panel of Zen-Cart or by checking the PHP environment using this short script:

<?php phpinfo(); ?>

Both options will print the webserver’s PHP settings on the screen where you will find all the details. Alternatively, of course, you can always ask your webhost. So, if for example the username for your webspace is web123, and if you are chrooted to /srv/www/htdocs/web123, you have to set the root value to:

$conf['ftp']['root'] = '/srv/www/htdocs/web123';
 
zen-cart/safemodehack.txt · Last modified: 2006/01/25 12:33 by 129.217.139.253
 
Recent changes RSS feed Valid XHTML 1.0 Valid CSS