Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Modify.cgi

Quote Reply
Modify.cgi
Hello!

I've a question! If someone wants to modify his site, but he forgot i.e. to enter his email-address, the modify_error-file will be loaded. Then there is written "There were the following errors trying to modify your resource:" After that the error-notification appears. I want that there is a point before the error, for example:
. Link was not found in the database

I copied the following code out of the modify.cgi. Can someone please modify this code so that there is a point before the error-notification? For example:
. Link was not found in the database
The point only must be a little bit higher.

Please help me!!

sub process_form {
# --------------------------------------------------------
my ($key, $status, @values, $found);
local (%original);

# Make sure we have a link to modify.
!$in{'Current URL'} and &site_html_modify_failure ("You did not specify link to modify") and return;

# Let's check to make sure the link we want to update is actually
# in the database.
open (DB, "<$db_file_name") or &cgierr("Error in validate_records. Unable to open db file: $db_file_name. Reason: $!");
$found = 0;
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
if ($data[$db_url] eq $in{'Current URL'}) {
$in{$db_key} = $data[0];
$found = 1;
%original = &array_to_hash (0, @data);
last LINE;
}
}
close DB;
!$found and &site_html_modify_failure ("Link was not found in the database") and return;

# Since we have a valid link, let's make sure the system fields are set to their
# proper values. We will simply copy over the original field values. This is to stop
# people from trying to modify system fields like number of hits, etc.
foreach $key (keys %add_system_fields) {
$in{$key} = $original{$key};
}

# Set date variable to today's date.
$in{$db_cols[$db_modified]} = &get_date;

# Validate the form input..
$status = &validate_record(%in);
if ($status eq "ok") {
# First make sure the link isn't already in there.
open (MOD, "<$db_modified_name") or &cgierr ("Error opening modified database: $db_modified_name. Reason: $!");
while (<MOD>) {
chomp;
@values = split /\|/;
if ($values[0] eq $in{$db_key}) {
close MOD;
&site_html_modify_failure("A request to modify this record has already been received. Please try again later.");
return;
}
}
close MOD;

# Print out the modified record to a "modified database" where it is stored until
# the admin decides to add it into the real database.
open (MOD, ">>$db_modified_name") or &cgierr("Error in modify.cgi. Unable to open modification database: $db_modified_name. Reason: $!");
flock(MOD, $LOCK_EX) unless (!$db_use_flock);
print MOD &join_encode(%in);
close MOD; # automatically removes file lock

# Send the admin an email message notifying of new addition.
&send_email;
# Send the visitor to the success page.
&site_html_modify_success;
}
else {
# Let's change that error message from a comma delimted list to an html
# bulleted list.
&site_html_modify_failure($status);
}
}

Sincerely,
Dan Murha
Quote Reply
Re: [DanMurha] Modify.cgi In reply to
Just add <li> before the message Crazy
Quote Reply
Re: [RedRum] Modify.cgi In reply to
Can you give me an example please?
--------------
close DB;
!$found and &site_html_modify_failure ("Link was not found in the database") and return;
--------------
Can you paste <li> in this code? I don't know where I should add it!