| CGI Help by David Efflandt |
This site is to provide general assistance with CGI at free.prohosting.com. Regular prohosting.com sites have more capabilies, like sendmail and other features that are not available on free sites. But anything posted here should also work on the regular sites.
The information posted here will be free for your own use, but customized scripts may require a fee.
Many systems, including prohosting.com run CGI as the user. So it should never be necessary to give any file or directory 777 permission, regardless of what script instructions say, unless you specifically want to allow another user to modify your files. CGI scripts typically have 755 permission. If you have something you need to keep private, you can limit permissions of CGI scripts to 700 and data files accessed by CGI to 600. However, make sure that the script runs properly first. Don't change file permissions so no one can see it and then ask us why your script will not run. To change file permissions from your ftp program, you would usually use a command like: site chmod 755 scriptname.cgi. Note that web pages are NOT accessed as you, so they still need read permission for anybody (644).
Note that the actual system path to your files is different than it appears to be from ftp. The Admin link on the main free.prohosting.com site can tell you what your system path is or you could determine the path to a particular directory by uploading the following (as ASCII text) and running it as a CGI script:
#!/bin/sh
echo Content-type: text/plain
echo
echo The system path to this script is:
pwd
If you have a directory where you want to store data files that are only accessible by CGI from another directory or a place to store password files, you can lock out all web access by putting the following directives in an .htaccess file:
order deny,allow
deny from all
You can also password protect access to directories or files by using the web server to authenticate the user from your own password file. This involves setting up a password file and an .htaccess file with directives to tell the webserver how to authenticate and the location of your password file. The password file is a list of username, colon (:) and crypted passwords:
bob:IzqvoG6c.madQ
george:lPR0UlTECuVWM
harry:0LWt1IWgWjFyc
If you don't have shell access the htpasswd program on a Unix system that produces 13 character crypted passwords, you can use my crypt.cgi. If you crypt passwords on another system and the crypted passwords end up with more than 13 characters, they may not work at prohosting.com. Your password file can have any name, but assuming you call it .htpasswd and put it in a dir called hidden (which might deny access to all per the above), the .htaccess file might contain something like this:
AuthType Basic
AuthName "My Friends"
AuthUserFile /usr/home1/username/html/hidden/.htpasswd
require valid-user
Or you could limit a directory to only a specific user (like yourself) with: require user george
Note: When your browser asks you for your password, you enter your username and plain text password. The webserver will crypt your password and compare it with the crypted password in the file. If it is a match, you are in. If not, you get 2 more chances before you are out.
For more details on authentication see the require directive and related links on the Apache website.
Additional CGI scripts are available from www.de-srv.com or my home site.
Please include ICQ# or e-mail address if expecting a reply from the message panel.