The TigerTom OMNI Perl script, v1.2, February 2002. http://www.tigertom.com/perl-script.shtml. ================================================ INSTRUCTIONS for using this script are split between: Here, and in 'omni_config.cgi' and 'omni.cgi', and 'omni.html'. Open all four files and read them. ================================================ Changes to the previous version 1.1: ------------------------------------ 1. IMPORTANT: I've been using this script in my new site: http://www.internet-marketing-consultant.com. The changes I've made may have introduced errors into this script. *Let me know if you have problems.* 2. Some form-field names have been changed. This is to make future alterations of the cgi-code easier. 3. Many more variables can be assigned in the HTML of the form, rather than the 'omni_config.cgi' script. This means that different forms can call the same script more easily. 4. File names of the scripts have been changed. 5. Script now strips out '_' in form field names when printing out a receipt in the browser; this makes the output look more professional. 6. Removed sneaky check on whether the one-line advert had been tampered with (if it had, the script exited with an error). Just want to keep things simple, and if you need to tamper with it, you are a sad, sad man anyway :) 7. Line-wrapping is now confined to the 'message' form field, as the previous code was bugged, and was wrapping everything. 8. A stupid error in the cookie-setting sub-routine has been corrected. ================================================ Changes to the previous version 1.0: ------------------------------------ 1. The code for the main script has been split out into three cgi-scripts. This will make setting up this program easier (trust me!). 2. Stupid errors in the save-to-delimited-file, email-unsubscription, and shopping-cart sub-routines, have been corrected. 3. HTML output by the scripts has been cleaned up a little bit. 4. The script tries a little harder to guess what the user/webmaster wants, based on the form-field data sent to it. Changes to the previous version 0.1: ------------------------------------ 1. Shopping cart sub-routines added. This script will now add up the items the shopper selects, add a (fixed) shipping fee, and add tax at a fixed percentage. It will output an 'order-confirmation' page, before final processing. This new feature will require alterations to your order form. Examine the source code of the file 'omni.html' to see what's necessary. 2. The bulk email / mailing list function is now reliant on an delimited email database in the format 'J. Smith|jsmith@yahoo.com'. Users of the first version of this script can convert the 'subscriber.dat' database by using a text-editor with a 'find-and-replace' function to replace '<' with a '|', and '>' with nothing i.e. change the format to the one above. The new version of the bulk-mail subroutine is relatively robust, and may cope with what you've got, but why store up troubles for yourself? ============================================== Setup instructions: *************************************************** IMPORTANT: You will save yourself a lot of trouble if you use the 'omni.html' form as a template for your own. It's got all the form fields the script recognises, and in some cases *needs*, to function. *************************************************** If you have not set up a Perl script before go to http://www.tigertom.com/ebook/web/dem/index.html, and read 'The Black Book Of Web Design'. It has a section on setting up CGI scripts, and the problems that can occur. This is not a beginner's script. Depending on what features you want to activate, it may take you some time and tears to set up. ---------------------------------------------------------------------- Telnet to your server. Type 'whereis perl' (without the apostrophes) at the command prompt. Make a note of where perl is if you have it. Type 'whereis sendmail' (without the apostrophes) at the command prompt. Make a note of where sendmail is if you have it. Type 'whereis pgp' (without the apostrophes). Make a note of where PGP is if you have it. FTP the files: myemail.txt datafile.dat subscriber.dat ...to your chosen sub-directory of your cgi-bin. Telnet to your cgi-bin. CHMOD these files to 606. [Type 'chmod 606 *.txt *.dat' at the command line, without the apostrophes, to do the lot in one go.] Once the script is working properly you can change the content of the text files to whatever you want. ************ The cgi scripts ***************** ----------------- 'omni_config.cgi' ----------------- Open the 'omni_config.cgi' script in a good text editor. Change the first line of the script to where perl is on your server. Change the rest of variables as instructed within the script. ---------- 'omni.cgi' ---------- Open the 'omni.cgi' script in a good text editor (NOT Windows Notepad; use WordPad instead). Change the first line of the script to where perl is on your server. Read the rest of the instructions at the top of the script. Specifically, comment-out those sub-routine calls you don't need, to make the script run faster. ----------------- 'omni_lib.cgi' ----------------- Leave this file alone. ======= Upload the all three cgi-script files to your cgi-bin, and CHMOD them to 705. ======= *********************** The form page ******************************* Open the file 'omni.html' in your text editor. Change the form action line to point to your version of the tigertom.cgi script in your cgi-bin. Change the hidden variables as requested. Save it, and FTP it to your public_html directory on your server. Test that it works, then customise it as you like. ********* IF you want to use PGP ************* This script requires PGP version 2.6.2 on your web server. It *might* work with version 6, but I don't know for sure. It won't work with version 5. Generate or find the 'pubring.pgp' and 'ranseed.bin' files of your PGP key, on your own home computer. [Find a pc version of PGP that will output keys with the file extension .pgp]. Telnet to your cgi-bin, and do the following: Create these sub-directories in your cgi-bin: tigerpgp tigertemp [Type 'mkdir tigerpgp' at the command line, without the apostrophes, to create that directory] CHMOD these sub-directories to 700. FTP the files: pubring.pgp ranseed.bin ...to the 'tigerpgp' subdirectory. CHMOD these files to 700. *********** Weak CC Encryption *********** If you don't have PGP, this script will weakly encrypt the credit-card number and expiry date [see 'omni_config.cgi']. To decrypt the card number and date, simply enter: 1. The encrypted card number and 2. expiry date, and 3. your password, in the appropriate fields in 'omni.html', hit the submit button, and voila! ******************* Email Attached Files ******************* If you want to email zip, .tar.gz, hqx or .exe files as attached files: Create a subdirectory 'dump' in your cgi-bin. FTP the files you want to email to this sub-directory, and specify their names in the your form's hidden text. Your form should have code in it like this : [This blank value allows the customer to deselect a file] Using radio buttons and the same NAME means only one file can be selected by the customer, and then uuencoded and emailed. NOTE: The script can only handle one file at a time. Put the absolute path to 'dump' in the appropriate place in 'omni_config.cgi' =================================================================== IMPORTANT: Bulk Mail Outs... You can't set this script to use ALL its functions at the same time. Specifically, the bulk-emailing option will negate a lot of the other functions, and could cause the script to crash. Why would you want to do a bulk mail-out AND email a zip-file and set a cookie at the same time anyway? Deactivate this option [see the instructions in the script], to use the other features. If you want to do bulk mail-outs, set it up in another copy of the script, and turn most of the OTHER functions OFF. ======## End of setup. See the other the files for more instructions ##======= Bloat: Why is this script so FAT? Well, I wanted a script which duplicated the functions of a proprietary secure order script developed by my web-host, in case I had to change servers. So I went looking at other scripts, learned a bit of Perl, cobbled together a hybrid which had all the features I wanted. Then I found more features I thought would be good. Since most scripts have similar features - read in the data, send an email - it wasn't hard to add other useful subroutines. The problem with this is that it makes the script operation slower. Left as-is, your server will struggle to run it. SO TURN OFF THE FEATURES YOU DON'T WANT [see 'omni.cgi' for instructions]. Practice script energy conservation, and your webhost will bless you for it. It'll save YOU a lot bother too. TIP: Set up various versions of this script, commenting out the sub-routines you don't want. You could also delete the actual sub-routines as well. If you don't want the bulk mail sub routine, for example, you can try deleting all text starting at (and including): sub send_bulk_mail { and ending after the last '}' at the end of the routine. Make sure the script is working, and that you keep a back-up copy, before you do this! Done successfully, it will speed up the script. Apologia: I'm not a programmer, I'm a philosopher. This script is a hack job. If you have suggestions for improvements, specificially useful code, I'd be delighted to hear from you. If you can document problems you're having, that would be good too. What is not useful are emails along the lines of "I get 500 server error, help!", "What is 'sendmail', and where can I find it?". These will be ignored. I can set it up for you, at a cost of $50.00, and you'll need to send me your username and password to your server to do so, obviously. Still keen for assistance...? :) Download the shareware version of the 'Black Book' at http://www.tigertom.com/orderin.html, search for Perl tutorials on the 'net, take a break, and try it again tomorrow. 3am setups are prone to failure! Fin. 'Tiger' Tom O' Donnell, LONDON, October 2001.