Gossamer Forum
Home : Products : Links 2.0 : Customization :

How to disable "add a link" feature?

Quote Reply
How to disable "add a link" feature?
Hi all,

I've got a site that still runs Links 2.0 and I want to completely turn off the "Add a link" feature. Why would I do that, you ask? Because the directory is being unmercifully spammed and I haven't the energy to implement the groovy hacks others have created that require the user to type in a validation code. Frankly, I've got enough links in the directory that a few thousand more over-hyped claims of wonder products won't make any difference; so it's closin' time at the directory saloon, if you will.

I've already removed the form to add a link from the add.html page, but the spammers must have some script that calls the add.cgi script directly so they can bypass the web form.

What can I do to prevent people from bypassing the form? (which I have already removed).

I don't care if they get a server error, but I'd prefer a nice little message that says, "Sorry. The feature you requested is no longer availiable".

Suggestions?

Last edited by:

DH123: Nov 19, 2005, 4:36 PM
Quote Reply
Re: [DH123] How to disable "add a link" feature? In reply to
Do you want to keep add.cgi? If not, just remove add.cgi - if you still want to keep it, then try to rename add.cgi to some other name like addit.cgi and chmod to 755 and see if it still works and if it does then only you can access it but you will need to change your add.html form to point it to the new name <form name=".../pathtocgidir/addit.cgi">

Last edited by:

socrates: Nov 19, 2005, 8:23 PM
Quote Reply
Re: [DH123] How to disable "add a link" feature? In reply to
As Socrates said, you will need to remove or rename add.cgi. I would just leave it at that, and remove all links to the add feature from your other pages. If that's too much (like, editing each template separately), then make a change to add.cgi, like so:

Code:

sub main {
# --------------------------------------------------------
&site_html_add_failure;

}


Then edit the add_failure.html template to contain the message you want. This will present the failure page no matter what, and the form will NOT be processed, no matter where it comes from.


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Nov 19, 2005, 10:01 PM
Quote Reply
Re: [PerlFlunkie] How to disable "add a link" feature? In reply to
Perl Flunkie,

I like your idea of just leaving add.cgi as is but changing the sub main section to point to a catchall message on the add_failure.html page.

Socrates,

I like your suggestion as well, but as Perl Flunkie surmised, I'm a lazy coder and just sending all form attempts to a failure message suits my style.

UPDATE: I tried the code

Code:
sub main {
# --------------------------------------------------------
&site_html_add_failure ("This directory is closed to new submissions.");


}

but I get just a blank page on the site that says, "Unkown Tag: Title".

It doesn't seem to be calling the add_error.html page. Any suggestions?


Thanks, guys :)

Last edited by:

DH123: Nov 20, 2005, 11:05 AM
Quote Reply
Re: [DH123] How to disable "add a link" feature? In reply to
Try this:

sub main {
# --------------------------------------------------------

&site_html_add_failure ("This directory is closed to new submissions.");
return;
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] How to disable "add a link" feature? In reply to
I thought that might be the problem too, but I tried it and it didn't work with the "return;" statement either.

Hmmm? Very strange!
Quote Reply
Re: [DH123] How to disable "add a link" feature? In reply to
Ok, try this longer version:

sub main {
# --------------------------------------------------------
local (%in) = &parse_form;
# We are processing the form.
if (keys %in != 0) {
&site_html_add_failure ("This site no longer accepting new links.");
}
# Otherwise we are displaying the form (in site_html.pl).
else {
&site_html_add_failure ("This site no longer accepting new links.");
}
}
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] How to disable "add a link" feature? In reply to
Yes, that works, with a couple of modifications:
  • I removed the extra closing curly bracket "}" from your suggested code for "sub main",
  • most important, I removed the form field code from the add_error.html page.
For some reason, removing the form code from the add_error.html page was the key.

So, I think your original suggestions would've worked had I removed the form field code from the start.

Thanks again for all your help!
Quote Reply
Re: [DH123] How to disable "add a link" feature? In reply to
"oops" on the bracket... Blush

Yes, the first change I posted should work, now that you point out the source of the error; the form has tags (like <%Title%>) so that whatever was entered in the form on the add page is carried over to the failure page. If you had fixed the <%Title%> tag error, it would then go to the next tag (<%URL%>)and give an error. Removing the whole form solves the problem, which is the fact that the form is no longer being processed by add.cgi.

If you want to have a better (longer) explanation of why you no longer accept new submissions, just put that right into the add_failure.html page, and remove the part in parenthesis from the add.cgi:

&site_html_add_failure;


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Nov 22, 2005, 10:18 AM
Quote Reply
Re: [PerlFlunkie] How to disable "add a link" feature? In reply to
PerlFlunkie,

Good advice. I'll fix up that add_error.html so it gives a more user-friendly error message.

I'd put a "thumbs-up" smiley here, but they don't have one :)