[an error occurred while processing this directive]

 
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.

Sample CGI Scripts

E-mail of Form Data

The sendmail program is currently disabled on free sites due to past spamming. This puts a real damper on form handling.  About the only thing you can do at this time is save the data to a file and check it regularly.  Note that CGI runs as you, so if you have data that you don't want others to read, you can write it in a file with 600 permission in a 700 permission directory and access it via ftp.

General CGI Info

CGI scripts are basically text files with instructions for an interpreter. DOS/Win and Mac systems end text lines differently than Unix, and scripts will not run and data files may not work properly if not converted to Unix line endings. This is usually simply a matter of setting your ftp program to ASCII mode when uploading scripts. This should automatically convert line endings for the file destination (whether uploading or downloading). Some ftp programs have an Auto mode, but you may have to add CGI, PL, and any other filename extensions to the list that should be considered text. If in doubt, upload as ASCII.  However, binary files, like images, word processing files, etc. that really are binary should be uploaded as binary.

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

Protecting Files or Directories from Web Access

You can set various Apache webserver directives in an .htaccess file (beginning with a dot) to restrict web access or other server settings.  The settings in .htaccess apply to the directory it is in and lower unless limited with <File>, <Directory shell_path>, or <Location url_path> tags.

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.


CGI Scripts

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.

The ICQ Online-Message Panel
Sender Name (optional):
Sender EMail (optional):
Message:

My Personal Communication Center  What is ICQ, Download
Install this Online Message Panel on your homepage
Use of the ICQOnline-Message Panel is subject to Terms of Service
© 1999 ICQ Inc. All Rights Reserved.


The free information presented here is provided with no warranties of any kind
Please contact webmaster if you have questions or problems with this site