############################################################################## # B U G F I X E S # # # # Last Modified: 16 Aug 1999 # ############################################################################## # # # This is a series of changes that might make things a little easier for you # # as you work with DBMan. Here are the changes included: # # # # -- A bug in sub query prevented "-gt" and "-lt" searches from working # # properly on date fields. # # -- A bug in sub validate_record would not allow blank date fields # # -- A bug in a previously released mod of sub get_date resulted in an # # incorrect date in log files # # -- There is no link on the login form for users to sign up for an account# # # ############################################################################## ################################################################################ ######## script: db.cgi ######## ######## replace ######## ######## part of ######## ######## sub query ######## ######## ######## ######## What it does -- ######## ######## fixes a bug to allow "greater than" and "less than" dates ######## ################################################################################ else { # Otherwise this is a regular search, and we only want records $i = 0; # that match everything the user specified for. foreach $column (@db_cols) { if ($in{$column} =~ /^\>(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'"); push (@search_gt_fields, $i); $in{"$column-gt"} = $1; $i++; next; } if ($in{$column} =~ /^\<(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'"); push (@search_lt_fields, $i); $in{"$column-lt"} = $1; $i++; next; } if ($in{$column} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{$column}) or return "Invalid date format: '$in{$column}'"); push(@search_fields, $i); $i++; next; } if ($in{"$column-gt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-gt"}) or return qq|Invalid date format: '$in{"$column-gt"}'|); push(@search_gt_fields, $i); } if ($in{"$column-lt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-lt"}) or return qq|Invalid date format: '$in{"$column-lt"}'|); push(@search_lt_fields, $i); } $i++; } } ################################################################################ ######## script: db.cgi ######## ######## replace ######## ######## sub validate_record ######## ######## ######## ######## What it does -- ######## ######## fixes a bug that did not allow blank dates ######## ################################################################################ sub validate_record { # -------------------------------------------------------- # Verifies that the information passed through the form and stored # in %in matches a valid record. It checks first to see that if # we are adding, that a duplicate ID key does not exist. It then # checks to see that fields specified as not null are indeed not null, # finally it checks against the reg expression given in the database # definition. my ($col, @input_err, $errstr, $err, $line, @lines, @data); if ($in{'add_record'}) { # don't need to worry about duplicate key if modifying open (DB, "<$db_file_name") or &cgierr("error in validate_records. unable to open db file: $db_file_name.\nReason: $!"); if ($db_use_flock) { flock(DB, 1); } LINE: while () { (/^#/) and next LINE; (/^\s*$/) and next LINE; $line = $_; chomp ($line); @data = &split_decode($line); if ($data[$db_key_pos] eq $in{$db_key}) { return "duplicate key error"; } } close DB; } foreach $col (@db_cols) { if ($in{$col} =~ /^\s*$/) { # entry is null or only whitespace ($db_not_null{$col}) and # entry is not allowed to be null. push(@input_err, "$col (Can not be left blank)"); # so let's add it as an error } else { # else entry is not null. ($db_valid_types{$col} && !($in{$col} =~ /$db_valid_types{$col}/)) and push(@input_err, "$col (Invalid format)"); # but has failed validation. (length($in{$col}) > $db_lengths{$col}) and push (@input_err, "$col (Too long. Max length: $db_lengths{$col})"); if ($db_sort{$col} eq "date") { push (@input_err, "$col (Invalid date format)") unless &date_to_unix($in{$col}); } } } if ($#input_err+1 > 0) { # since there are errors, let's build foreach $err (@input_err) { # a string listing the errors $errstr .= "
  • $err"; # and return it. } return ""; } else { return "ok"; # no errors, return ok. } } ################################################################################ ######## script: db.cgi ######## ######## replace ######## ######## sub get_date ######## ######## ######## ######## What it does -- ######## ######## allows you to pass a value to the subroutine in order to return######## ######## a date other than the current one ######## ################################################################################ sub get_date { # -------------------------------------------------------- # Returns the date in the format "dd-mmm-yyyy". ####################################################################################### # # # Warning: If you change the default format, you must also modify the &date_to_unix # # subroutine which converts your date format into a unix time in seconds for sorting # # purposes. # # # # If you have changed the date format in sub date_to_unix, be sure to make appropriate# # changes here. The structure of the date must be identical between sub date_to_unix # # and sub get_date. # # # ####################################################################################### my ($time1) = $_[0]; ($time1) or ($time1 = time()); my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1); my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!; ($day < 10) and ($day = "0$day"); $year = $year + 1900; return "$day-$months[$mon]-$year"; } ################################################################################ ######## script: html.pl ######## ######## replace ######## ######## sub html_login_form ######## ######## ######## ######## What it does -- ######## ######## Creates a link to the signup form. ######## ################################################################################ sub html_login_form { # -------------------------------------------------------- # The login screen. &html_print_headers; print qq| $html_title: Login.
    |; if ($auth_signup) { print qq|
    $html_title: Login

    <$font_title> Log On

    <$font>Welcome! You need to have an active account to access $html_title. For the demo, you can use userid/passwords: 'admin/admin', 'author/author', 'guest/guest'.

    User ID:
    Password:

    <$font>You can sign up for an account online right here.

    |; } print qq|

    |; }