Gossamer Forum
Home : Products : Links 2.0 : Discussions :

No links in top categories

Quote Reply
No links in top categories
Hi, Im currently trying to stop sites being added to my top level categories, I have got this working by using this code in add.cgi from a previous forum thread :

Code:
if ($in{'Category'} !~ "/") {
&html_add_failure ("You must choose a more specific topic!");
return;
}


My problem is I need to get the same check to occur in modify.cgi and am not sure how to amend the code and where to place it, any ideas please? Below is my Sub Process_Form from modify.cgi (I am also using a modify password mod) :

Code:
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 ("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);
}
}


Any help greatly appreciated,

grant
Subject Author Views Date
Thread No links in top categories grantw 3559 Mar 17, 2003, 5:03 AM
Thread Re: [grantw] No links in top categories
Paul 3461 Mar 17, 2003, 5:22 AM
Thread Re: [Paul] No links in top categories
grantw 3461 Mar 17, 2003, 6:39 AM
Thread Re: [grantw] No links in top categories
Paul 3456 Mar 17, 2003, 6:41 AM
Post Re: [Paul] No links in top categories
PerlFlunkie 3439 Mar 17, 2003, 1:42 PM