#!/usr/bin/perl # ### ADMIN SCRIPT FOR ULTIMATE GUESTBOOK ## # # Ultimate Guestbook is copyright Madrona Park, Inc. # # User assumes all liability that # may result due to installation problems and/or # content posted on your guestbook. User must also # keep all copyright notices on applicable pages. # # For more info on the Ultimate Guest Book, # see http://www.scriptkeeper.com # #For info on Madrona Park, Inc, see http://www.madronapark.com ################################################################ print ("Content-type: text/html\n\n"); eval { ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX / or Windows / ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \ #substitute all require files here for the file require "gb_variables.pl"; require "ugb_lib.pl"; require "gb_styles.pl"; }; if ($@) { print "Error including required files: $@\n"; print "Make sure these files exist, permissions are set properly, and paths are set correctly."; exit; } &ReadParse; $action = $in{'action'}; if ($action eq "edit") { &Edit; } if ($action eq "styles") { &Styles; } if ($action eq "genvars") { &GenVars; } if ($action eq "setgenvars") { &SetGenVars; } if ($action eq "enterstyles") { &EnterStyles; } if ($action eq "enteredit") { &EnterEdit; } if ($action eq "sendstyles") { &SendStyles; } if ($action eq "entergenvar") { &EnterGenVar; } if ($action eq "env") { &Env; } if ($action eq "mdelete") { &MDelete; } if ($action eq "deleteentry") { &DeleteEntry; } sub DeleteEntry { &ValidatePW; @entries = &OpenFile("$GB_NON_CGI_Path/entries.file"); foreach $uno(@entries) { @thisline = split(/\|\|/, $uno); chomp($thisline[6]); unless ($thisline[6] eq "$in{'number'}") { push(@revised, $uno); } } &Lock("lock.file"); open(REVISED, ">$GB_NON_CGI_Path/entries.file"); foreach $one(@revised) { chomp($one); print REVISED "$one\n"; } close(REVISED); &Unlock("lock.file"); #send onscreen confirmation print<



Thank you! We have deleted the guestbook entry you specified. You are now being taken back to the guestbook automatically. Please wait two seconds.

Click here if you do not want to wait any longer (or if your browser does not automatically forward you).

ForwardHTML } sub MDelete { &StandardHTML("This feature is coming soon. You can delete individual entries from the guestbook itself."); } sub EnterEdit { &ValidatePW; $PageTitle = "Delete a Guestbook Entry"; &HEADERHTML; print< Enter the ID Number of the guestbook entry you would like to delete.

ID Number:



Ultimate Guestbook, Version 1.0
� Madrona Park, Inc., 1999.

THIS } #end Enter Edit sub ValidatePW { if ($in{'setpw'} ne "true") { &CheckPW; if ($check ne "true") { &StandardHTML("You did not enter valid passwords. Please use your back button to try again."); exit; } } } sub EnterGenVar { if ($CopyrightWording ne "") { $CopyrightWording = &UnHTML($CopyrightWording); } if ($AddEntryInfo ne "") { $AddEntryInfo = &UnHTML($AddEntryInfo); } if ($IntroText ne "") { $IntroText = &UnHTML($IntroText); } if ($ConfirmAddWording ne "") { $ConfirmAddWording = &UnHTML($ConfirmAddWording); } $Password1 = $in{'password1'}; $Password2 = $in{'password2'}; &ValidatePW; if ($GB_CGI_Path eq "") { @cgipath = split(/\//, $ENV{'SCRIPT_FILENAME'}); pop(@cgipath); $GB_CGI_Path = join("\/", @cgipath); $VariablesPath = $GB_CGI_Path; } if ($GB_NON_CGI_Path eq "") { $GB_NON_CGI_Path = "$ENV{'DOCUMENT_ROOT'}/uguestbook"; } if ($NonCGIURL eq "") { $NonCGIURL = "http://$ENV{'HTTP_HOST'}/uguestbook"; $CGIURL = "http://$ENV{'HTTP_HOST'}/cgi-bin"; $BBEmail = "$ENV{'SERVER_ADMIN'}"; } if ($Censor eq "ON") { $CensorON = "CHECKED"; } else { $CensorOFF = "CHECKED"; } if ($TimeFormat eq "24HR") { $Time24HR = "CHECKED"; } else { $TimeAMPM = "CHECKED"; } if ($DateFormat eq "Euro") { $DateEuro = "CHECKED"; } elsif ($DateFormat eq "EuroExpanded") { $DateEuroX = "CHECKED"; } elsif ($DateFormat eq "USExpanded") { $DateUSX = "CHECKED"; } else { $DateUS = "CHECKED"; } if ($Field2Hyper eq "Email") { $F2HyperEmail = "CHECKED"; } elsif ($Field2Hyper eq "URL") { $F2HyperURL = "CHECKED"; } else { $F2HyperNone = "CHECKED"; } if ($Field3Hyper eq "Email") { $F3HyperEmail = "CHECKED"; } elsif ($Field3Hyper eq "URL") { $F3HyperURL = "CHECKED"; } else { $F3HyperNone = "CHECKED"; } if ($HTMLAllow eq "yes") { $HTMLyes = "CHECKED"; } else { $HTMLno = "CHECKED"; } if ($UBBCodeAllow eq "yes") { $UBBCodeyes = "CHECKED"; } else { $UBBCodeno = "CHECKED"; } $PageTitle = "Set General Variables"; &HEADERHTML; print<click here.

absolute paths
Absolute paths reflect the physical locations of directories on a server. They are the complete locations, not the locations from the web root, but from the server root. Absolute paths on Win32/NT servers are displayed differently than on UNIX systems. For instance, note the following samples for UNIX and NT:

For UNIX servers:     /usr/home/yourdomain/www/cgi-bin
For Win32/NT servers:     C:/home/yourdomain/cgi-bin

Note: the paths listed above are examples, not your actual paths.

If you are installing on Win32/NT, be sure to use the format above for your absolute paths (note the forward slashes, rather than backward slashes).
If you are installing for the first time, the Ultimate Guestbook will attempt to provide complete or partial absolute paths for you. These paths may not be accurate or complete, but they will give you a headstart. All absolute path fields MUST be provided for your UBB to run.

Absolute Path for your Ultimate Guestbook CGI DIRECTORY
Absolute Path of your Ultimate Guestbook NON CGI Directory
Absolute Path to Directory Where Your Custom Variable Files Reside
You should use the same absolute path that you used for your CGI directory above. If for some reason you cannot write to files in your CGI directory, however, you should place these files (gb_variables.pl and gb_styles.pl) in a directory below the web root so that they cannot be accessed by anyone from the browser.
URLs
Please provide the following complete hyperlinks. Use complete hyperlinks, such as http://www.yourdomain.com/cgi-bin, rather than relative links such as "/cgi-bin"
URL for your Ultimate Guestbook CGI Directory
URL for your Ultimate Guestbook Non-CGI Directory
Display Options
Please complete the following fields, which provide information such as your Guestbook Name, links, the email address to be displayed, headers and footers to use on each page, etc.
Your Email Address
This is email address that will be shown so that users can contact you
Name of Your Guestbook
Link #1 Name
You can have two links that appear at the bottom of most guestbook pages. These links could be anything you like- your homepage, another area of your website, an outside link, etc. Type the name of the first link.
Link #1 URL
Type the complete URL for Link #1 (as in "http://www.cnn.com").
Link #2 Name
You can have two links that appear at the bottom of most guestbook pages. These links could be anything you like- your homepage, another area of your website, an outside link, etc. Type the name of the second link.
Link #2 URL
Type the complete URL for Link #2 (as in "http://www.cnn.com").
Introduction Text
This text will appear on your primary guestbook summary page- the first page that visitors to your guestbook see. This wording should introduce your guestbook and encourage them to add an entry to it.
Add Entry Text
This text will appear on "Add Entry" page. You can customize your wording in the field to the right.
Add Entry Submit Button Wording
This text will appear on the submit button on the "Add Entry" page. You can customize your wording in the field to the right.
Confirm New Entry Text
This text will appear after someone adds a new entry to your guestbook. You can customize your wording in the field to the right.
Header
You can add your own customized header graphic, ad banner, text, etc. This header will appear at the top of each primary UBB page. This is completely optional. Leave this field blank if you don't need to use it.
Footer
You can add your own customized footer graphic, ad banner, text, etc. This header will appear near the bottom of each primary UBB page. This is completely optional. Leave this field blank if you don't need to use it.
Your Copyright Wording
This wording will appear in smaller print directly above the copyright wording concerning the UBB program itself. You can leave this blank or provide any wording you like.
Date/Time Display Options
The UBB can display dates and times in a number of different formats. Remember that the times listed are based on the location of your web server, which may be different than the time zone where you reside/work. You can change the time zone displayed by using the Time Zone Offset field. For instance, if you are on the East Coast of the US, but your server is on the West Coast of the US, you could use EST as your Time Zone to display, but you would have to offset the server time to reflect that (by typing a 3 in the Time Zone Offset field, reflecting the 3 hours difference). If the Time Zone difference is negative, use a begative number (as in -2).
Time Zone
The time of each posting is based on the time zone where your server is located. If you want your users to know the time zone, provide it here (e.g., ET, CT, PT, etc.). You may also leave this blank if you would prefer not to show a time zone. You may type a different time zone than your server uses, but if you do so be sure to provide a time zone offset in the next field.
Server Time Zone Offset
You can offset the time drawn from your web server. For instance, if your server time is EST (US), but you want all time to reflect Pacific Time (US), you would have to offset your server time by placing the time zone difference in this field (for this example, that would be -3. You would place -3 in this field). The default is for there to be no server time zone offset (0).
Date Format
US Format (Month-Day-Year, as in 04-02-1998)
US Expanded Format (Month Day, Year; as in April 2, 1998)
European Format (Day-Month-Year, as in 02-04-1998)
European Expanded Format (Month Day, Year; as in 2 April 1998)
Time Format
You can have time displayed in AM/PM format, or in 24-hour format.
Use AM/PM Time Format
User 24-Hour Format Time (eg, 23:15)
Guestbook Fields
With the Ultimate Guestbook, you can set up to four input fields. Only the first and fourth fields are required. The second and third fields are optional.
Field 1
This field is REQUIRED. This is typically the guestbook writer's NAME, but you can change the field to represent something else, if you prefer. Or perhaps you would rather refer to the field as "Author"... change it if you like in the field to the right. You can also set the field size and maximum field size for this field. Set those to the right as well, or leave the defaults. Note: if you leave these fields blank, the Ultimate Guestbook will assign the default settings for this field.
Field #1 Name:
Field #1 Size:
Field #1 Maximum Size:
Field 2
This field is OPTIONAL. This is typically the guestbook writer's Email address, but you can change the field to represent something else, if you prefer. Leave the field blank if you do not wish to use this field. Set this field's properties to the right.
Field #2 Name:
Field #2 Size:
Field #2 Maximum Size:

We will automatically add hyperlinks if this field is an email address or URL. Please select one of the following:
Email
URL
No Hyperlink

Field 3
This field is OPTIONAL. This is typically the guestbook writer's URL, but you can change the field to represent something else, if you prefer. Leave the field blank if you do not wish to use this field. Set this field's properties to the right.
Field #3 Name:
Field #3 Size:
Field #3 Maximum Size:

We will automatically add hyperlinks if this field is an email address or URL. Please select one of the following:
Email
URL
No Hyperlink

Field 4
This field is REQUIRED. This is a text area, not a text field (for those of you that know HTML). This is typically the guestbook writer's entry, but you can change the field to represent something else, if you prefer. Note: if you leave this field blank, the Ultimate Guestbook will assign the default setting for this field.
Field #4 Name:
Miscellaneous Options
Below are numerous configuration options for your UBB.

Censor Option
You may have certain words censored on your guestbook. Words you choose to censor will be replaced by asterisks. To activate the censor function, check the "yes" button below. To deactivate, press the "no" button. List all censored words in the field to the right. yes no

Censor Words
Type all words you want censored in the field below. Do not use commas to separate words, just use spaces. For example, type "dog cat boy", rather than "dog, cat, boy." If you type "dog", all words containing the string "dog" would be censored (dogma, for instance, would appear as "***ma"). To censor more accurately, you can require that censors occur only for exact words. You can do this by placing a censor word in curly braces, as in {dog}. Signifying "dog" in the curly braces would mean that dogma would appear as dogma, but dog would appear as "***". Thus your censor list may appear as cat "{dog} {barn} barn."
Maximum Entries To Display Per Page
You can select the number of entries to display per page. The default (recommended) number is 25.
Allow HTML in Entries?
You may allow HTML to be used in guestbook entries, if you desire. This is NOT recommended, however, because incorrect HTML syntax can cause erratic display of your guestbook pages.
Allow HTML
Don't Allow HTML
Allow UBB Code in Entries?
UBB Code is a much safer way of allowing people to add hyperlinks, email links, and images to their entries, without using HTML.
Allow UBB Code
Don't Allow UBB Code


Enter your two passwords:

(NOTE: if you are configuring your guestbook for the first time, the passwords you typed on the previous page will be inserted below for you. Just press on the button below)

Password #1:
Password #2:

THIS } # end EnterGenVar sr sub GenVars { $PageTitle = "Set General Variables"; &HEADERHTML; #check to see if passwords have been set if (-e "$GB_NON_CGI_Path/gbpassword.pl") { #if username and password have been set, query for Passwords &AuthenticateWording("entergenvar"); } else { #if passwords have not been set, query user to set them now &QueryToSetPW; } } ## END genvars SR ## sub Env { print<

$BBName

Your Environmental Variables

Use these to help you figure out your absolute file paths, and other system information.

Your Perl Version: $]

TOP foreach $envline (%ENV) { print $envline; print "
\n"; } print<

BOTTOM } # END ENV SR sub HEADERHTML { print<


$PageTitle

HEADER } #end HEADERHTML sr sub SetGenVars { #make sure path is correct if (-e "$in{'GB_NON_CGI_Path'}/frown.gif") { if (-e "$in{'GB_NON_CGI_Path'}/gbpassword.pl") { &CheckPW; if ($check eq "true") { &SetVars; } else { &StandardHTML("Sorry, did not enter the correct passwords. We cannot process your variables until this is corrected. Use your back button to try again."); } } else { &SetPW; &SetVars; } } else { &StandardHTML("Sorry, but you do not seem to have entered the correct absolute path for your NON CGI directory. Your other absolute paths may also be incorrect. We cannot process your variables until this is corrected. Use your back button to try again."); } } ##END Set Gen Vars sub SetVars { if ($in{'Field1'} eq "") { $in{'Field1'} = "Name"; } if ($in{'Field4'} eq "") { $in{'Field4'} = "Guestbook Entry"; } if ($in{'Field1Size'} eq "") { $in{'Field1Size'} = "20"; } if ($in{'Field1MaxSize'} eq "") { $in{'Field1MaxSize'} = "40"; } open (FILE, ">$in{'VariablesPath'}/gb_variables.pl") or die("Unable to open setup file for writing."); foreach $one(@in) { ($Name, $Value) = split ("=", $one); $Name = &decodeURL($Name); $Value = &decodeURL($Value); $Value =~ s/\@/\\@/g; $Value =~ s/"/\\"/g; if (($Name eq "AddEntryInfo") || ($Name eq "IntroText") || ($Name eq "ConfirmAddWording")) { $Value = &ConvertReturns($Value); $Value =~ s/(

)+/

/ig; } else { $Value = &EliminateReturns($Value); } print FILE ("\$$Name = \"$Value\";\n"); } print FILE ("1;\n"); close (FILE); chmod (0777, "$in{'VariablesPath'}/gb_variables.pl"); &StandardHTML("Thank you! Your general variables have been set! If you are configuring your guestbook for the first time, don't forget to set your style variables as well."); } #end Setvars sr sub SetPW { $Password1 = &decodeURL($in{'password1'}); $Password2 = &decodeURL($in{'password2'}); open (SETIT, ">$in{'GB_NON_CGI_Path'}/gbpassword.pl"); print SETIT "$Password1\n"; print SETIT "$Password2"; close (SETIT); chmod (0666, "$in{'GB_NON_CGI_Path'}/gbpassword.pl"); } #end SetPW sr sub CheckPW { if (($in{'action'} eq "entergenvar") || ($in{'action'} eq "enterstyles") || ($in{'action'} eq "sendstyles") || ($in{'action'} eq "deleteentry")){ $ThePath = "$GB_NON_CGI_Path"; } else { $ThePath = "$in{'GB_NON_CGI_Path'}"; } open (READIT, "$ThePath/gbpassword.pl"); @pw = ; close (READIT); $Password1 = decodeURL($in{'password1'}); $Password2 = decodeURL($in{'password2'}); chomp($pw[0]); chomp($pw[1]); if (($Password1 eq "$pw[0]") && ($Password2 eq "$pw[1]")) { $check = "true"; } else { $check = "false"; } } # end CheckPW sr sub Styles { $PageTitle = "Set Style Variables"; &HEADERHTML; #check to see if passwords have been set if (-e "$GB_NON_CGI_Path/gbpassword.pl") { #if username and password have been set, query for Passwords &AuthenticateWording("enterstyles"); } else { #if passwords have not been set, query user to set them now &QueryToSetPW; } } ## END Styles SR ## sub Edit { $PageTitle = "Delete A Guestbook Entry"; &HEADERHTML; #check to see if passwords have been set if (-e "$GB_NON_CGI_Path/gbpassword.pl") { #if username and password have been set, query for Passwords print<Note: only users knowing this guestbook's passwords may delete this entry.

If you don't remember your passwords, open the file entitled "gbpassword.pl" in your guestbook NON CGI directory. The two passwords are listed in that file.

NOTE: Guestbook Entry Number $in{'number'} will be deleted when you press the submit button below.

Password #1
Password #2

Threads } else { #if passwords have not been set, query user to set them now &QueryToSetPW; } } ## END Edit SR ## sub AuthenticateWording { my $action = shift; print<Note: only users knowing this guestbook's passwords may perform this function.

If you don't remember your passwords, open the file entitled "gbpassword.pl" in your guestbook NON CGI directory. The two passwords are listed in that file.

Password #1
Password #2

Threads } sub QueryToSetPW { print<Welcome!

To administer your guestbook, you need to set two passwords, which will be used whenever you want to access this control panel area. By using passwords, you can ensure that no one else can make changes to your guestbook but you (or others you give the passwords to).

You need to set two passwords. These passwords can be identical, but we recommend that you set two different words. These words should contain only letters or numbers. All passwords are case-sensitive. This means that if you enter a password of "Wally", "WALLY" will not match it.

Set your guestbook passwords below!

Note: You will be directed to the general variables area after you enter your passwords. Please set your general variables before setting styles.

Password #1
Password #2


Ultimate Guestbook
� Madrona Park, Inc., 1999.

Threads } #end QueryToSetPW sub EnterStyles { &ValidatePW; $PageTitle = "Set Style Variables"; &HEADERHTML; if ($CopyrightTextColor eq "") { $CopyrightTextColor = "#C0C0C0"; } if ($TextSize eq "") { $TextSize = "2"; } if ($FontFace eq "") { $FontFace = "Verdana, Arial"; } if ($TextColor eq "") { $TextColor = "#000000"; } if ($LinkColor eq "") { $LinkColor = "#000080"; } if ($VisitedLinkColor eq "") { $VisitedLinkColor = "#808000"; } if ($TableStripTextColor eq "") { $TableStripTextColor = "#000080"; } if ($GBTitlePic eq "") { $GBTitlePic = "ugb.jpg"; } if ($AddEntryPic eq "") { $AddEntryPic = "addentry.jpg"; } if ($TableWidth eq "") { $TableWidth = "95%"; } if ($PostedByColor eq "") { $PostedByColor = "#800000"; } if ($BGColor eq "") { $BGColor = "#FFFFFF"; } else { if ($BGColor =~ /=/) { ($junk, $BGColor) = split (/=/, $BGColor); chomp($BGColor); } } if ($TableColorStrip eq "") { $TableColorStrip = ""; } else { if ($TableColorStrip =~ /=/) { ($junk, $TableColorStrip) = split (/=/, $TableColorStrip); chomp($TableColorStrip); } } print< You can easily change the font face and/or color, graphics, and background colors used throughout your guestbook using this control panel page. Note: these changes affect only the guestbook pages, not any of the control panel pages. For all colors, we recommend using hexadecimal codes (i.e, #FFFFFF for "white", etc.).

Color Options
  Page Background Color
Format - #FFFFFF
StyleHTML &Colors; print<
  Text Color
Style2 &Colors; print<
  Link Color
Style3 &Colors; print<
  Visited Link Color
Style4 &Colors; print<
  Table Header Strip Text Color
Style5 &Colors; print<
  Table Header Strip Background Color
Style6 &Colors; print<
  First Alternating Table Row Color
Style7 &Colors; print<
  Second Alternating Table Row Color
Style8 &Colors; print<
  Copyright Text Color
Style9 &Colors; print<
  "Posted" Date/Time Text Color
The color of the text that appears on the Date/Time line for each entry
Style11 &Colors; print<
  Table Border Color
You can create a colored border that will surround your tables, if you like. Leave this field blank if you do not want a colored border.
Style11a &Colors; print<
Miscellaneous Graphic Options
  Font Face (e.g., Verdana)
We recommend you use a backup font as well. For example: to use Verdana as your first choice, with Arial as a conditional font for those users that don't have Verdana as a font on their system, you would type "Verdana, Arial")

  Table Width
You may use either exact pixels (recommended: 600) or a percentage (recommended: 90%)
  Text Size
We recommend using size 2... but depending on your font face, you may want to alter this.
  Page Background Graphic
Not recommended to be used, but you can add a background graphic to your pages. If you do so, you should upload the graphic into your NON CGI directory and place the name of the background graphic in this field. For example, background.gif.
Graphic Images

Recommended graphic sizes: if you are creating your own graphics, we recommend that the following sizes (in pixels) be used (in order to fit with layout of the BB):

  • Title/logo graphic- 500 wide by 105 high
  • Add Entry graphic - 155 wide by 75 high


Don't forget: if you are using your own custom graphics instead of one of the standard graphics shown above, be sure to upload (FTP) your custom graphics to your Guestbook NON CGI directory.

  Guestbook Title Graphic:
  Add Entry Graphic:

Enter Passwords For This Guestbook

Password #1
Password #2




Ultimate Guestbook
� Madrona Park, Inc., 1999.

Style12 } # end EnterStyles sr sub Colors { print< Select New Color?    TheColors } # end colors sr sub SendStyles { if (-e "$GB_NON_CGI_Path/gbpassword.pl") { &CheckPW; if ($check eq "true") { &SetStyles; } else { &StandardHTML("Sorry, did not enter the correct passwords. We cannot process your variables until this is corrected. Use your back button to try again."); } } else { &StandardHTML("You don't seem to have set your guestbook passwords. Please reset them by accessing your General Variables. Click here."); } } ##END Set Gen Vars sub SetStyles { ## don't allow bgcolor and copyright color to be the same if ($in{'BGColor'} eq "$in{'CopyrightTextColor'}") { $in{'CopyrightTextColor'} = "$in{'TextColor'}"; } open (FILE, ">$VariablesPath/gb_styles.pl") or die("Unable to open setup file for writing."); foreach $one(@in) { ($Name, $Value) = split ("=", $one); $Name = &decodeURL($Name); $Value = &decodeURL($Value); $Value =~ s/\@/\\@/g; $Value =~ s/"/\\"/g; print FILE ("\$$Name = \"$Value\";\n"); } print FILE ("1;\n"); close (FILE); chmod (0777, "$VariablesPath/gb_styles.pl"); &StandardHTML("Thank you! Your style variables have been set!"); } #end SendStyles sr