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 :

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

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) :

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;
@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>) {
@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.");
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 the visitor to the success page.
else {
# Let's change that error message from a comma delimted list to an html
# bulleted list.

Any help greatly appreciated,

Subject Author Views Date
Thread No links in top categories grantw 2246 Mar 17, 2003, 5:03 AM
Thread Re: [grantw] No links in top categories
Paul 2193 Mar 17, 2003, 5:22 AM
Thread Re: [Paul] No links in top categories
grantw 2192 Mar 17, 2003, 6:39 AM
Thread Re: [grantw] No links in top categories
Paul 2187 Mar 17, 2003, 6:41 AM
Post Re: [Paul] No links in top categories
PerlFlunkie 2170 Mar 17, 2003, 1:42 PM