#!/usr/bin/perl ####################################################################### # starwars.cgi version 1.1 # # This program recieves input from an HTML file. Four variables are # submitted: firstName, lastName, maidenName, and cityOfBirth. All # four are placed inside the hash %FORM. The pieces of information # (all strings) are then run through a few calculations to turn them # into a Star Wars style name. # # The Star Wars first name is the first half, rounded down, of the # person's first name, plus the first two letters of their last name. # The Star Wars last name is the first two letters of their mother's # maiden name, plus the first third, rounded up, of their birth city. # # This program is copyright (c)1999 Victor Andersen, all rights # reserved. Feel free to use and modify this program as long as # original credit is given to me and a link to my web site # www.fishdot.org is included. ####################################################################### # Read the form entries into a hash and URL-decode the text # read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+//d; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $FORM{$name} = $value; } print "Content-Type: text/html\n\n"; # You're gonna want to change the $datafile value to wherever you store the datafile (absolute path). # The file should be created in advance (unix command: touch starwars.dat) # The file should be have the global write permission set (unix command: chmod 666 starwars.dat) $datafile = "/home/sofia/public_html/games/name/starwars.dat"; # $cgi_path should be the path to the cgi itself, as seen in the URL # If you access http://www.yourdomain.com/cgi-local/starwars.cgi to execute the CGI, then "/cgi-local/starwars.cgi" would be the $cgi_path $cgi_path = "/games/name/index.cgi"; $firstName, $LastName, $maidenName, $cityOfBirth = ""; $first1 = lc substr ($FORM{lastName}, 0, length ($FORM{lastName}) / 2); $first2 = lc substr ($FORM{firstName}, 0, 2); $last1 = lc substr ($FORM{maidenName}, 0, 2); $last2 = lc substr ($FORM{cityOfBirth}, 0, (length ($FORM{cityOfBirth}) / 3) + (length ($FORM{cityOfBirth}) % 3)); $starWarsName = ucfirst $first1 . $first2 . " " . ucfirst $last1 . $last2; open (DATAFILE, "<$datafile") or do {print "Cannot open $datafile: $!";die $!;}; while () { @data = split (/\+/, $_); } unshift (@data, $starWarsName) unless grep (/\b$starWarsName/, @data); $data = join ('+', @data); close (DATAFILE); open (DATAFILE, ">$datafile") or do {print "Cannot open $datafile: $!";die $!;}; print DATAFILE $data; close (DATAFILE); $last5 = join (', ', @data[0,1,2,3,4]); # This script is designed to output the fishdot.org HTML template to surround the CGI results. # If you use this on your own site, it is suggested that you change the look a bit :) print < BlueHarvest.net - Star Wars Name Maker
Star Wars Games
EOF # end of HTML header if (length $FORM{ok} > 0) { if (length $FORM{firstName} == 0) { print "

ERROR: You forgot to enter your First Name.

"; $error = 1; } if (length $FORM{lastName} == 0) { print "

ERROR: You forgot to enter your Last Name.

"; $error = 1; } if (length $FORM{maidenName} == 0) { print "

ERROR: You forgot to enter your Mother's Maiden Name.

"; $error = 1; } if (length $FORM{cityOfBirth} == 0) { print "

ERROR: You forgot to enter your City Of Birth.

"; $error = 1; } if ($error == 1) { $firstName = $FORM{firstName}; $lastName= $FORM{lastName}; $maidenName = $FORM{maidenName}; $cityOfBirth = $FORM{cityOfBirth}; } unless ($error == 1) { print "Your Star Wars name is "; print $starWarsName; print ". Try again?"; } } # Once again, style and formatting are for the Fishdot look, so feel free to play around with the HTML portions print <<"EOF";

The Star Wars universe is rich with strange and exotic names such as Obi-Wan Kenobi, Bib Fortuna, Boba Fett, Qui-Gon Jinn, and many others. Have you ever wanted your own cool Star Wars name? Now you can! Just fill out this form and it will generate a Star Wars name for you.

Your First Name
Your Last Name
Your Mother's Maiden Name
Your City of Birth

The last five star wars names were: $last5

Back to games.


Disclaimer:
All data entered on this page is used only for displaying the results of the form. No personal data is saved, and no data is used for any other application. The script that returns your official Star Wars name was written by ToiletDuk.

Main Page
Chat | Download | Forum | Games | Gonk | Images | Links | Scoops | Sound | Video
| F.A.Q. | Send a Postcard
Navigate to:

Main Page

Star Wars
Chat Rooms
Forum
Games
Gonk Tribute
Links
Postcards
Scoops


Multimedia
Downloads
Images
Sound
Video


Misc.
About Blue
Banners
F.A.Q.
Search
What's new?
E-mail



EOF