# User-friendly html.pl - for use on EZ Books site # # Save this file as -- html.pl -- and use it instead of the script by the same name # that comes with the DBMan archive. Be sure to read the notes that accompany the # script which follow the copyright information. # # ---------------------- # DBMan - EZ Books # ---------------------- # Database Administrator # # File: html.pl # Description: This file contains all the HTML that the program generates. # Owner: SeekHomes.com # Email: webmaster@seekhomes.com # Web: http://www.seekhomes.com/ # Version: 2.04 # # COPYRIGHT NOTICE: # # Copyright 1998-99 SeekHomes.com. All Rights Reserved. # # This program is being distributed as shareware. It may be used and # modified free of charge for personal, academic, government or non-profit # use, so long as this copyright notice and the header above remain intact. # Any commercial use should be registered. Please also send me an email, # and let me know where you are using this script. By using this program # you agree to indemnify SeekHomes.com from any liability. # # Selling the code for this program without prior written consent is # expressly forbidden. Obtain permission before redistributing this # program over the Internet or in any other medium. In all cases # copyright and header must remain intact. # # Please check the README file for full details on registration. # ===================================================================== # # # Notes on the "user-friendly html.pl": # # Look closely at the sections marked "HTML Globals," and "Page Layout" to # set up your database to appear the way you would like it to. # You can also edit the "Record Layout" section to create your own forms and # page displays. # In each of the rest of the subroutines, you will have several variables you can set # to your liking: # $page_title # $submit_button -- only on pages with forms -- the text of the submit button # $reset_button -- only on pages with forms -- the text of the reset button # Also, the form definitions have been moved a little so it is easier to know what you # can and cannot edit. To clarify things even more, each subroutine has the area where # you can enter any text you want to for that page. Enter or edit your own text between # # <-- Start page text --> # print qq| # and # |; # # <-- End page text --> # # If you have more than one DBMan database on your site and you would like to have all # the pages coordinate, you can cut the "HTML Globals" and "Page Layout" sections from # each of your html.pl scripts and place the sections in a separate file. Name the file # format.pl # and upload it into the same directory as the other DBMan scripts. Set the permissions # to 644 [-rw-r--r--]. Uncomment (that is, delete the # at the beginning of the line) # the next line in each of your html.pl scripts. # require $db_script_path . "/format.pl"; # #-------------------------------------------------------------------------------------- # 8-2-2000 -> Replaced all "View" descriptions with "Search" in all menus for accuracy # 8-8-2000 -> Display Record ID only if user is "admin" # 8-12-2000 -> Add Case Sensitivity reminder on User Login screen #-------------------------------------------------------------------------------------- ########################################################## ## HTML Globals ## ########################################################## # Put any globals you like in here for your html pages. $html_title = 'EZ Books Databases'; # Add your email address. Be sure to leave the \ before the @ $admin_email = 'ezbooks\@ezfindit.com'; # Set your font preferences below # font face for pages $face = "font face=Verdana, Arial, Helvetica"; # size of normal text $font = "$face size=2"; # an alternate color font $font_color = "$font color=Blue"; # size of title text $font_title = "$face size=4"; # color of error messages $error_color = "font color=red"; # large font for error messages $font_error = "$face size=4 color=red"; # EZ Books special fonts $fontred = "$face size=2 color=#E10000"; $fontmaroon = "$face size=2 color=maroon"; ########################################################## ## Page Layout ## ########################################################## sub html_page_top { # -------------------------------------------------------- # This is where you define what all of your web pages will look like. # You can change the background color, add a background image (be sure to use the # complete URL to your background image and not a relative URL), define the color of # normal text and links -- all just as you would do with a regular html page. # Be sure to leave in the first line -- &html_print_headers -- and to put your html # formatting between "print qq|" and "|;" &html_print_headers; print qq| $html_title: $page_title
$html_title: $page_title

<$font_title>$page_title

|; } sub html_error_page_top { # -------------------------------------------------------- # This subroutine should be almost identical to the previous one. The only difference # is that there are error messages included with the title and the title is in whatever # you have set your $error_color variable to be. &html_print_headers; print qq| $html_title: Error! $page_title
$html_title: Error: $page_title

<$font_title>Error: <$error_color>$page_title

|; } sub html_page_bottom { # -------------------------------------------------------- # Here is where you finish off your web pages. If you have not paid for the script, # be sure to leave the Gossamer Threads logo in place. # The second "print qq" statement is where you end off any tables or other formatting # that you started in the "page_top" subroutines. It makes it easier to see what # to do if you maintain the indenting of lines. print qq|


<$font>Copyright © 1998-2000 EZFindit.com & EZ Books <$font>[ home ]
|; print qq|


|; } sub html_search_again { # -------------------------------------------------------- # This prints out when search done by "default" user from # the web page and places "Search Again" at the bottom of # the results page. EZ Books (CB added 9/11/1999) print qq|

[ search again ]         [ other sites ]

|; } sub html_print_headers { # -------------------------------------------------------- # Print out the headers if they haven't already been printed. if (!$html_headers_printed) { print "Content-type: text/html\n\n"; $html_headers_printed = 1; } } sub html_footer { # -------------------------------------------------------- # Print the menu. # # We only print options that the user have permissions for. # print qq!

<$font>!; print qq!| Main !; print qq!| Add ! if ($per_add); print qq!| Search ! if ($per_view); if (!$per_admin && $auth_modify_own) { print qq!| Delete ! if ($per_del); print qq!| Modify ! if ($per_mod); } else { print qq!| Delete ! if ($per_del); print qq!| Modify ! if ($per_mod); } print qq!| List All ! if ($per_view); print qq!| Admin ! if ($per_admin); print qq!| Log Off !; print qq!|

!; } sub html_search_options { # -------------------------------------------------------- # Search options to be displayed at the bottom of search forms. # print qq~

<$font>Search Options:
Match Any Match Case Whole Words Reg. Expression
Keyword Search (will match against all fields)
Max. Returned Hits
Sort By: Sort Order:

Search Tips:
    - use '*' to match everything in a field)
    - put a '>' or '<' at the beginning to to do range searches.
~; } ########################################################## ## Record Layout ## ########################################################## sub html_record_form { # -------------------------------------------------------- # The form fields that will be displayed each time a record is # edited (including searching). You don't want to put the #

and
tags for each field. # The values to be displayed are in %rec and should be incorporated # into your form. You can use &build_select_field, &build_checkbox_field # and &build_radio_field to generate the respective input boxes. Text and # Textarea inputs can be inserted as is. If you turn on form auto # generation, the program will build the forms for you (all though they may # not be as nice). See the README for more info. my (%rec) = @_; my $font = $font_color; ($db_auto_generate and print &build_html_record_form(%rec) and return); print qq| |; if ($per_admin) { print qq| |; } else { print qq||; } print qq|
<$font>Auto Count:
(don't change)
    <$fontred> PLEASE SELECT CORRECT SCHOOL NAME
  <$fontred> PLEASE SELECT CORRECT SCHOOL NAME
<$font>School:  
<$font>Book Name:  
<$font>Class/Subject:  
<$font>Author(s):  
<$font>Publisher:  
<$font>Contact:  
<$font>Price:      (how much you want for the book)
<$font>Price New:      (bookstore new book cost + sales tax)
<$font>Price Used:      (bookstore used book cost + sales tax)
|; } sub html_record { # -------------------------------------------------------- # How a record will be displayed. This is used primarily in # returning search results and how it is formatted. The record to # be displayed will be in the %rec hash. my (%rec) = @_; # Load any defaults to put in the VALUE field. ($db_auto_generate and print &build_html_record(%rec) and return); print qq|
<$font_color>BOOK: <$fontmaroon>$rec{'Book'} <$font_color>University: <$fontred>$rec{'School'}
<$font_color>Class: <$font>$rec{'Class'}         <$font_color>PRICE: <$fontred>$rec{'Price'}         (<$font_color>New: <$font>$rec{'PriceNew'}       <$font_color>Used: <$font>$rec{'PriceUsed'})
<$font_color>Author(s): <$font>$rec{'Author'} <$font_color>Publisher: <$font>$rec{'Publisher'}
<$font_color>CONTACT:  <$font>$rec{'Contact'}
|; } ########################################################## ## Home Page ## ########################################################## sub html_home { # -------------------------------------------------------- # The database manager home page. $page_title = "Main Menu"; &html_page_top; # < -- Start page text -- > print qq| <$face size="1"> Permissions: |; print " Search " if ($per_view); print " Add " if ($per_add); print " Delete " if ($per_del); print " Modify " if ($per_mod); print " Admin " if ($per_admin); print " None " if (!($per_view || $per_add || $per_del || per_mod)); print qq|

<$font> The EZ Books database is set up so users can view other users' book posts, but you can only modify and delete your own records.

Explanation of the menu choices:

  • Main - main menu
  • Add - add/post your books
  • Search - search through all book posts
  • Delete - delete your own book posts
  • Modify - view/modify your own book posts

    |; # < -- End page text --> &html_footer; &html_page_bottom; } ########################################################## ## Adding ## ########################################################## sub html_add_form { # -------------------------------------------------------- # The add form page where the user fills out all the details # on the new record he would like to add. You should use # &html_record_form to print out the form as it makes # updating much easier. Feel free to edit &get_defaults # to change the default values. $page_title = "Add a New Record"; &html_page_top; $submit_button = "Add Record"; $reset_button = "Reset Form"; # < -- Start page text -- > print qq| |; # < -- End page text --> print qq|
    |; &html_record_form (&get_defaults); print qq|

     

    |; &html_footer; &html_page_bottom; } sub html_add_success { # -------------------------------------------------------- # The page that is returned upon a successful addition to # the database. You should use &get_record and &html_record # to verify that the record was inserted properly and to make # updating easier. $page_title = "Record Added"; &html_page_top; # < -- Start page text -- > print qq|

    <$font>The following record was successfully added to the database: |; # < -- End page text --> &html_record(&get_record($in{$db_key})); &html_footer; &html_page_bottom; } sub html_add_failure { # -------------------------------------------------------- # The page that is returned if the addition failed. An error message # is passed in explaining what happened in $message and the form is # reprinted out saving the input (by passing in %in to html_record_form). my ($message) = $_[0]; $page_title = "Unable to Add Record"; &html_error_page_top; $submit_button = "Add Record"; $reset_button = "Reset Form"; # < -- Start page text -- > print qq| <$font>There were problems with the following fields: $message

    Please fix any errors and submit the record again.

    |; # < -- End page text --> print qq|
    |; &html_record_form (%in); print qq|

     

    |; &html_footer; &html_page_bottom; } ########################################################## ## Viewing ## ########################################################## sub html_view_search { # -------------------------------------------------------- # This page is displayed when a user requests to search the # database for viewing. # Note: all searches must use GET method. # $page_title= "Search the Database"; &html_page_top; $submit_button = "View Records"; $reset_button = "Reset Form"; # < -- Start page text -- > print qq| |; # < -- End page text --> print qq|
    |; &html_record_form(); &html_search_options; print qq|

     

    |; if ($db_userid eq "default") { &html_search_again; } else { &html_footer; } &html_page_bottom; } sub html_view_success { # -------------------------------------------------------- # This page displays the results of a successful search. # You can use the following variables when displaying your # results: # # $numhits - the number of hits in this batch of results. # $maxhits - the max number of hits displayed. # $db_total_hits - the total number of hits. # $db_next_hits - html for displaying the next set of results. # my (@hits) = @_; my ($numhits) = ($#hits+1) / ($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); $page_title = "Search Results"; &html_page_top; # < -- Start page text -- > print qq|

    <$font> Your search returned $db_total_hits matches. |; # < -- End page text --> if ($db_next_hits) { print "
    <$font>Pages: $db_next_hits"; } # Go through each hit and convert the array to hash and send to # html_record for printing. for (0 .. $numhits - 1) { print "

    "; &html_record (&array_to_hash($_, @hits)); } if ($db_next_hits) { print "
    <$font>Pages: $db_next_hits"; } if ($db_userid eq "default") { &html_search_again; } else { &html_footer; } &html_page_bottom; } sub html_view_failure { # -------------------------------------------------------- # The search for viewing failed. The reason is stored in $message # and a new search form is printed out. my ($message) = $_[0]; &html_print_headers; print qq| $html_title: No Records Found.


    $html_title: No Records Found

    <$font_title>No Records Found

    <$font>

    There were no records found matching your search criteria.
    Please go back and try your search again using different options.

    [ search again ]       [ other sites ]


    <$font>Copyright © 1998-2000 EZFindit.com & EZ Books

    |; } ########################################################## ## Deleting ## ########################################################## sub html_delete_search { # -------------------------------------------------------- # The page is displayed when a user wants to delete records. First # the user has to search the database to pick which records to delete. # That's handled by this form. $page_title = "Search the Database for Deletion"; &html_page_top; $submit_button = "Search"; $reset_button = "Reset Form"; # < -- Start page text -- > print qq| <$font>

    Search the database for the records you wish to delete or list all:

    |; # < -- End page text --> print qq|
    |; &html_record_form(); &html_search_options; print qq|

     

    |; &html_footer; &html_page_bottom; } sub html_delete_form { # -------------------------------------------------------- # The user has searched the database for deletion and must now # pick which records to delete from the records returned. This page # should produce a checkbox with name=ID value=delete for each record. # We have to do a little work to convert the array @hits that contains # the search results to a hash for printing. my ($status, @hits) = &query("mod"); my ($numhits) = ($#hits+1) / ($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); my (%tmp); $page_title = "Delete Record(s)"; &html_page_top; $submit_button = "Delete Checked Record(s)"; $reset_button = "Reset Form"; if ($status ne "ok") { # There was an error searching! print qq|

    <$font_error>Error: $status

    |; &html_footer; &html_page_bottom; } else { # < -- Start page text -- > print qq|

    <$font> Check which records you wish to delete and then press "Delete Records":
    Your search returned $db_total_hits matches. |; # < -- End page text --> if ($db_next_hits) { print "
    <$font>Pages: $db_next_hits"; } print qq|

    |; # Go through each hit and convert the array to hash and send to # html_record for printing. Also add a checkbox with name=key and value=delete. print "

    "; for (0 .. $numhits - 1) { %tmp = &array_to_hash($_, @hits); print qq|
    |; &html_record (%tmp); print qq|
    \n|; } print qq|

     

    |; if ($db_next_hits) { print "
    <$font>Pages: $db_next_hits"; } &html_footer; &html_page_bottom; } } sub html_delete_success { # -------------------------------------------------------- # This page let's the user know that the records were successfully # deleted. my $message = shift; $page_title = "Record(s) Deleted"; &html_page_top; # < -- Start page text -- > print qq| <$font>The following records were deleted from the database: '$message'.

    |; # < -- End page text --> &html_footer; &html_page_bottom; } sub html_delete_failure { # -------------------------------------------------------- # This page let's the user know that some/all of the records were # not deleted (because they were not found in the database). # $errstr contains a list of records not deleted. my ($errstr) = $_[0]; $page_title = "Record(s) Not Deleted"; &html_error_page_top; # < -- Start page text -- > print qq| <$font>The records with the following keys were not found in the database: <$error_color>'$errstr'.

    |; # < -- End page text --> &html_footer; &html_page_bottom; } ########################################################## ## Modifying ## ########################################################## sub html_modify_search { # -------------------------------------------------------- # The page is displayed when a user wants to modify a record. First # the user has to search the database to pick which record to modify. # That's handled by this form. $page_title = "Search the Database for Modifying"; &html_page_top; $submit_button = "Search"; $reset_button = "Reset Form"; # < -- Start page text -- > print qq| <$font>

    Search the database for the records you wish to modify or list all:

    |; # < -- End page text --> print qq|
    |; &html_record_form(); &html_search_options; print qq|

     

    |; &html_footer; &html_page_bottom; } sub html_modify_form { # -------------------------------------------------------- # The user has searched the database for modification and must now # pick which record to modify from the records returned. This page # should produce a radio button with name=modify value=ID for each record. # We have to do a little work to convert the array @hits that contains # the search results to a hash for printing. my (%tmp); my ($status, @hits) = &query("mod"); my ($numhits) = ($#hits+1) / ($#db_cols+1); if (($numhits == 1) and !$in{'nh'}) { $in{'modify'} = $hits[$db_key_pos]; &html_modify_form_record(); return; } my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); $page_title = "Modify Record"; &html_page_top; $submit_button = "Modify Record"; $reset_button = "Reset Form"; if ($status ne "ok") { # Error searching database! print qq|

    <$font_error>Error: $status|; &html_footer; &html_page_bottom; } else { # < -- Start page text -- > print qq|

    <$font> Check which record you wish to modify and then press "Modify Records":
    Your search returned $db_total_hits matches. |; # < -- End page text --> if ($db_next_hits) { print "
    <$font>Pages: $db_next_hits"; } print qq|

    |; # Go through each hit and convert the array to hash and send to # html_record for printing. Also add a radio button with name=modify # and value=key. print "

    "; for (0 .. $numhits - 1) { %tmp = &array_to_hash($_, @hits); print qq|
    |; &html_record (%tmp); print qq|
    \n|; } print qq|

     

    <$font>Pages: $db_next_hits"; } &html_footer; &html_page_bottom; } } sub html_modify_form_record { # -------------------------------------------------------- # The user has picked a record to modify and it should appear # filled in here stored in %rec. If we can't find the record, # the user is sent to modify_failure. my (%rec) = &get_record($in{'modify'}); if (!%rec) { &html_modify_failure("unable to find record/no record specified: $in{'modify'}"); return; } $page_title = "Modify a Record"; &html_page_top; $submit_button = "Modify Record"; $reset_button = "Reset Form"; # < -- Start page text -- > print qq| |; # < -- End page text --> print qq|
    |; &html_record_form (%rec); print qq|

     

    |; &html_footer; &html_page_bottom; } sub html_modify_success { # -------------------------------------------------------- # The user has successfully modified a record, and this page will # display the modified record as a confirmation. $page_title = "Record Modified"; &html_page_top; # < -- Start page text -- > print qq| <$font>The following record was successfully modified:

    |; # < -- End page text --> &html_record(&get_record($in{$db_key})); &html_footer; &html_page_bottom; } sub html_modify_failure { # -------------------------------------------------------- # There was an error modifying the record. $message contains # the reason why. my ($message) = $_[0]; $page_title = "Unable to Modify Record"; &html_error_page_top; $submit_button = "Modify Record"; $reset_button = "Reset Form"; # < -- Start page text -- > print qq| <$font>There were problems modifying the record: <$error_color>$message
    Please fix any errors and submit the record again.

    |; # < -- End page text --> print qq|
    |; &html_record_form (%in); print qq|

     

    |; &html_footer; &html_page_bottom; } ########################################################## ## Authentication ## ########################################################## sub html_login_form { # -------------------------------------------------------- # The login screen. $page_title = "User Login - Post/Edit Books"; &html_page_top; $submit_button = "Logon"; $reset_button = "Cancel"; # < -- Start page text -- > print qq| <$font>You need to have an active User Account to access the $html_title and post books for sale.  If you do not have a User Account (User ID) click here and sign up for a new account. (it's free)

    |; # < -- End page text --> print qq|

    <$font_color>User ID:
    <$font_color>Password:
    Reminder: Both your User ID and Password are CASE SENSITIVE.

     

    |; # -------------------------------------------- # <- CB: Removed the code for EZ Books setup # -------------------------------------------- # if ($auth_signup) { # print qq|You can sign up for an account online right here.|; # } &html_page_bottom; } sub html_login_failure { # -------------------------------------------------------- # There was an error loggin in. The error message is stored in $message. my ($message) = $_[0]; $page_title = "Login Error"; &html_page_top; $submit_button = "Logon"; $reset_button = "Cancel"; # < -- Start page text -- > print qq| <$font>Oops, there was a problem logging into the system: <$error_color>$message.

    Please try logging in again, or contact the system administrator. |; # < -- End page text --> print qq|

    <$font_color>User ID:
    <$font_color>Password:

     

    |; if ($auth_signup) { print qq|You can sign up for an account online right here.|; } &html_page_bottom; } sub html_admin_display { # -------------------------------------------------------- # The displays the list of current users. my ($message, $user_list, $password, $permissions) = @_; $page_title = "User Management"; &html_page_top; $submit_button = "Update/Create User"; # < -- Start page text -- > print qq|

    <$font><$error_color>$message

    |; # < -- End page text --> print qq|
    <$font>User List: $user_list
    <$font>New Username:
    <$font>Change Password:
    <$font>Permissions:
    $permissions

    |; &html_footer; &html_page_bottom; } sub html_unauth { # -------------------------------------------------------- # A user tried to do something he was not authorized for. $page_title = "Unauthorized Action"; &html_error_page_top; # < -- Start page text -- > print qq| <$font>The database program received a command that you are not authorized for. |; # < -- End page text --> &html_footer; &html_page_bottom; } sub html_signup_form { # -------------------------------------------------------- # This form is displayed for new users who want to create an account. # my $error = shift; $page_title = "Create Account"; &html_page_top; $submit_button = "Create"; $reset_button = "Cancel"; # < -- Start page text -- > print qq| <$font>To create your own account, simply enter in your desired User ID and Password.  Make sure they are the same as the ones you just sumbitted in the New User page.

    |; # < -- End page text --> if ($error) { print "$error

    "; } print qq|
    <$font_color>User ID:
    <$font_color>Password:
    If your university is NEW to EZ Books (not currently on our lists) please allow 2-3 days for it to be setup.

     

    |; &html_page_bottom; } sub html_signup_success { # -------------------------------------------------------- # The user has successfully created a new account. $page_title = "New Account Created & Activated"; &html_page_top; $submit_button = "Logon"; $reset_button = "Cancel"; # < -- Start page text -- > print qq| <$font>Congratulations!  Your account has been set up and is active!
    Use your User ID and Password to log in and begin posting the books you want to sell. |; # < -- End page text --> print qq|

    <$font_color>User ID:
    <$font_color>Password:
    Don't forget!  If your university is NEW to EZ Books (not currently on our lists) please allow 1-2 days for it to be setup.

     

    |; &html_page_bottom; } ########################################################## ## Misc ## ########################################################## sub html_unkown_action { # -------------------------------------------------------- # The program received a command it did not recognize. $page_title = "Unknown Action"; &html_error_page_top; # < -- Start page text -- > print qq| <$font>The database program received a command that it did not understand.

    |; # < -- End page text --> &html_footer; &html_page_bottom; } 1;