CHAPTER EIGHTEEN - MATTS ARCHIVE CGI SCRIPTS

We DO NOT provide technical support for these scripts. We have included some general information regarding these scripts. If you need additional support outside of what we have provided, please refer to Matt's Archives for more detailed information. We will not reply to support questions sent to us regarding these scripts, however, we will provide you the necessary server information that is required in these scripts. Contact Technical Support for this information.

Cgiemail
Guestbook
Free-for-All Links Page
Random Text Generator
WWW Board
Search.cgi
Permissions on scripts


Configuring CGI-bin Scripts Found At Matt's Free Archives

Cgiemail:

Cgiemail is another form processing script you can find at Matt's, totally different than FormMail. It is a program written in the C language that takes the contents of fill-in boxes on a form and emails them to a specified location. In addition to the form specification in the .html file, a mail specification in a .txt file is required to format the resulting email message.

This script should be placed in the cgi-bin directory of your server. And then have an action in your order.htm file to call it. It should look like this:

<form method=post action="http://www.yourdomain.com/cgi-bin/cgiemail/order.txt">

Details are provided below. While there are a number of subsections below this one, they all work together and are meant to be read from start to finish.

order.htm:

Look for a file in your www directory called order.htm. This is our example form we put on your site that shows how a form should be configured to work with Cgiemail. Look at it in a browser, and download it to your hard drive using FTP so you can see how it works. If you've never dealt with HTML forms before, don't worry, they're easy to create and understand.

The form prompts the user for data which is sent to the server as simple key-value pairs. Each <input> tag specifies a record. The key is given by the name attribute, and the value is given by the value attribute. The type attribute tells the browser what kind of data to expect. Now, try looking at the example.

Please note that the hidden items are used to transmit critical info to Cgiemail. They provide the location of the success file, the name of the person the results should be sent to, and the subject of the form. When making your own forms, you may want to change the email address in the "required-to" field, and likely the subject in the "subject" field. The first item tells Cgiemail what to show the user after successfully completing the form. You can, but don't need to customize this.

After that come the items that are actually presented to the user. You'll want to use type=text input items with cgiemail: it's a simple tool. The size=60 tells the browser how big to make the box. The name=something is required in each input tag, otherwise the browser wouldn't know how to send the data to the server. The value=" " attribute is correct in most cases, unless you want a default value in the form.

Note that if a field begins with required-, cgiemail will require that the user enter a value for this field. This is particularly useful if you want to require a user to submit their email address.

When the user presses the Submit button, the data goes to our machine where cgiemail starts doing something with it. What is does is controlled by the order.txt file discussed below.

By the way, you can name your HTML form anything you want to.

order.txt:

Now that we have all this data, what do we do with it? Mail it, of course! But for flexibility, cgiemail requires that you create a mail.txt file to show it what to send. (If you didn't want flexibility you'd use a mailto link.) The program will read this file, perform substitutions, and pass it to the mail system.

Make sure that you upload mail.txt in ASCII mode. Failure to upload mail.txt in ASCII mode will generate the message:

"Server Error: The server encountered an internal error or mis-configuration and was unable to complete your request."

There is already an example order.txt document in the forms directory in your www directory.

By the way, there's nothing magical about the name order.txt. Feel free to call it mail1.txt or form1.mail, or whatever suits you, as long as the form has the correct name for what you uploaded.

Note that the first several lines are mail headers. You probably shouldn't change that part, or the corresponding parts in your form. In particular, there must be a To: header or the mail won't go anywhere!

What cgiemail does is simply replace every string that looks like [key] with the value the user typed into the field with name=key. That's all. You can lay out your form as is best for your users, but lay out your mail.txt as is best for you to read. You can even insert gobs of text to help format the output. Only the [key] parts will be replaced by cgiemail.

Cgiemail does not report environmental variables like FormMail will, but other than that, it is an excellent program, allowing you more flexibility in the way you want your data returned by the form.

Back to the top


Guestbook:

Guestbook allows you to set up your own comments page. From there, visitors can add entries to your guestbook and they will be displayed with the most recent at the top and scrolling down, or vice versa. Other options include the ability to limit HTML in the entry, link to e-mail address with mailto tag, use a log to log entries, redirect to a different page after signing, emailing whenever a new entry is added, and much more.

You can obtain the guestbook script and its other necessary files from Matt's CGI Archives site as well.

You can change several of the configuration options by downloading the guestbook.cgi file from Matt's to your hard drive. Create a copy of the file and give it the same name, then edit the options as specified below. Keep your backup of the original guestbook.cgi in case you run into problems.

Option 1: $mail:

This option will allow you to be notified via an E-mail address when a new entry arrives in your guestbook. The entry will be mailed to you as a notification. If you should choose to turn this variable on you will need to fill in the 2 variables that go along with it:

$recipient - Your email address, so that the mailing program will know who to mail the entry to.

$mailprog - The location of your sendmail program on your host machine.

Option 2: $uselog:

This will allow you the ability to use the short log feature. It is already turned on so you will have to change it to 0 if you do not wish to use it. It has been implemented since there are probably many people who feel no need to have a log when people are making entries to a file anyway. Keep in mind that it will show errors which is one nice aspect about it.

Option 3: $linkmail:

Turning this option on will make the address links in your guestbook become hyperlinked. So instead of simply having (name@some.host) it will put (<a href="mailto:name@some.host">name@somehost</a> so that anyone can simply click on the address to email them.

Option 4: $separator:

This allows you to choose whether you want guestbook entries to be separated by a Paragraph Separator <p>, or a Horizontal Rule <hr>. By changing the 0 in the script to a 1, you will turn on the <hr> separator and turn off the <p> separator. The 0 option will do the reverse of that; turn on the <p> and turn off the <hr>.

Option 5: $redirection:

By choosing 1 you will enable auto redirection and 0 will return a page to the user telling them their entry has been received and click here to get back to the guestbook.

Option 6: $entry_order:

Set this option to 0 and the newest entries will be added below the rest of the entries. Keep this option at 1 and the guestbook will add the newest entries at the top.

Option 7: $remote_mail:

Many users of the guestbook have requested that a form letter be automatically sent to the remote user when they fill in the guestbook. Turning this option on will tell the script to automatically mail any user who leaves an email address. You can specify the contents of the mail message by editing the section of the script that sends mail to the remote user. By default it sends a message that says, "Thank you for adding to my guestbook." and then shows them their entry. If you should choose to turn this variable on, you will need to fill in the 2 variables that go along with it:

$recipient - Your email address so that the mailing program will know who to mail the entry to.

$mailprog - The location of your sendmail program on your host machine.

Option 8: $allow_html:

This option allows you to turn on or off the use of HTML tags by users of your guestbook. Setting this variable to 1 allows users to embed html tags such as <b> or <H1> or <a href=" "></a> into your html document. Setting this variable to 0 will not allow them to use any html syntax in their comments or any other field. You can still link to their comments or any other field. You can still link to their email address by turning $link_mail to 1.

There is also the ability for users to add their own URL and then their name is referenced to their URL in the guestbook.html file. This helps to eliminate the need for allow_html to be turned on, and lets users point you to a spot that will tell you more about them. Several users of the guestbook script have asked for this option. If you wish to disable the option, simply delete the following line from your addguest.html file:

URL: <input type=text name=url size=50>

The other file included with the guestbook is called:

guestbook.html:

This is the file that you will link to that will contain the Guestbook Entries. You may want to edit the title and heading spaces and customize the look any way you desire. Do not delete the line <!--begin--> from this guestbook, or else the script will have no way of knowing where to begin the editing. The <!--begin--> line is the only necessary line in your guestbook.html file, but the link to the addguest.html file is also a good idea. :-)

Back to the top


Free-For-All Links Page

Free For All Link Page allows you to set up a web page which your users can then add links to in specified categories. Newest links are added to the top of each category. A running total of the number of links present as well as the time when the last link was added is shown at the top of the page.br>
Back to the top


Random Text Generator

Just download this file to your hard drive and edit it with any random text you would like placed in an html document. Remember to keep the %% separator between quotes. You can use any html formatting tags you want to, including <href> tags so you can configure it as a random link generator.

You can put in as many quotes as you wish. Upload the random.txt file to your server in the same location you found it, remembering to upload it in ASCII or text mode.

The script uses SSI (Server Side Includes) so the page you want to use random text on must have the .sht, .shtm, or .shtml extension. On your page, just put this tag wherever you want the random text to appear:

<!--#exec cgi="/cgi-bin/randomtext.cgi"-->

That's all there is to it!

Back to the top


WWW Board

WWW Board is a threaded World Wide Web discussion forum and message board, which allows users to post new messages, follow-up to existing ones and more.

There are several options you may want to configure. First of all, the index.sht file in the bbs directory can be customized any way you wish as long as you leave the method and input tags the way they are.

Additionally, here are some options contained in the wwwboard.pl script itself which you may want to change, depending on your needs:

$show_faq = 1;

This option allows you to choose whether or not you want to display a link to the FAQ on every individual message page or not. It defaults to 1 and the link will be put in at the top of the message along with links to Follow-ups, Post Follow-up and Back to $title. Setting this to 0 will turn it off, and keeping it at 1 will keep the link. You need to create a faq.html file and put it inside the bbs directory. The FAQ can contain any information you want to give your visitors about how the board works, your organization, types of postings that will be allowed, etc.

$allow_html = 1;

This option lets you choose whether or not you want to allow HTML mark-up in your posts. If you do not want to allow it, then everything that a user submits that has <>'s around it will be cut out of the message. Setting this option to 1 will allow HTML in the posts and you can turn this option off by setting it to 0.

$quote_text = 1;

By keeping this option set to 1, the previous message will be quoted in the follow-up text input box. The quoted text will have a ':' placed in front of it so you can distinguish what had been said in the previous posts from what the current poster is trying to get across. Setting this option to 0 will leave the follow-up text box empty for the new poster.

$subject_line = 0;

There are three options for the way that you can display the subject line for the user posting a follow-up. Leaving this option at 0 which is the default value, will put the previous subject line into the follow-up form and allow users to edit the subject however they like. Setting this option to 1, however, will quote the subject, but simply display it to the user, not allowing him or her to edit the subject line. The third and final option can be achieved by setting the $subject_line variable to 2. If it is set to 2, the subject will not be quoted and instead the user will be prompted with an empty subject block in their follow-up subject line.

$use_time = 1;

This option allows you to choose whether or not you want to use the hour:minute:second time with the day/month/year time on the main page. Day/Month/Year will automatically be placed on the main wwwboard.html page when a new entry is added, but if you leave this variable at 1, the hour:minute:second time will also be put there. This is very useful for message boards that get a lot of posts, but if you would like to save space on your main page, you can set this to 0, causing the hour:minute:second display not to be added.

Back to the top


Search.cgi

Search will look at all your html pages for words you enter, and return all pages on a list with links. This script should be uploaded to your cgi-bin, and for Search.cgi to return a response, it needs to be activated. This is easily done by logging in via telnet and at the prompt after login type the following command:

chmod +r /www/yourdomain

Now you can access search.cgi with the following URL:

http://yourdomain.com/cgi-bin/search.cgi.

There is a configuration file called search_define.pl which accompanies search.cgi and sets up the variables for it. You can customize which files you wish to exclude from searches, and also the cosmetics of the search and results pages.

Back to the top


Single Page Shopping Cart

You can obtain a Single Page Shopping Cart from Matt's Archives as well. The configuration process is rather long and complicated and unless you are familiar with the language we recommend that you refer to Matt's Archive and download all the referring materials for this script.

Back to the top


Quick guidelines on using SSI's

Your domain is capable of supporting use of SSI's, support is limited to the exec cgi command and in order for the system to process the include you must save the page with a .shtml or .sht rather than .htm or .html.

Sample SSI:

<!--#exec cgi="/cgi-bin/count.cgi"-->
Please note as shown in the example above, the URL must be relative and not a full call, this would not work:

<!--#exec cgi="http://yourdomain.com/cgi-bin/count.cgi"-->

Back to the top


Permission Settings for scripts:

Type: Normal Site: Frontpage Site:
WWWBoard:
bbs dir
bbs/messages
bbs/index.sht
bbs/data
cgi-bin/wwwboard.pl

chmod777
chmod777
chmod666
chmod666
chmod755

chmod777
chmod777
chmod666
chmod666
chmod755

Guestbook:
Guestbook dir
Guestbook/guestbook.cgi
Guestbook/guestbook.setup
Guestbook/guestbook.html

chmod755
chmod755
chmod666
chmod666

chmod755
chmod777
chmod666
chmod666
Free For All Links:
links dir
links/links.htm
cgi-bin/links.pl

chmod755
chmod666
chmod755


chmod777
chmod666
chmod755

Graphic Counter:
counter dir
counter/logs
counter/ all other files
cgi-bin/counter


chmod775
chmod777
chmod666
chmod755

chmod777
chmod777
chmod666
chmod755
Cgi-bin always chmod 755 all
scripts chmod 755 in main bin

cgi-bin/counters (text counter)




chmod755



chmod777
Random Text:
random dir
random/random.txt

chmod775
chmod666

chmod777
chmod666
Password Admin:
password dir
All password files

chmod755
chmod666

chmod777
chmod666

 

Back to the top

 

 



ecommerce web hosting