Gossamer Forum
Home : Products : Links 2.0 : Customization :

request. "maximum # of links waiting to be validated please try again tommorow.."

Quote Reply
request. "maximum # of links waiting to be validated please try again tommorow.."
Id really like to be able to set the maximumnumber of links waiting for validation to be say, ooh, 50, and then it wont accept any more until i start to validate them..

this would prevent from spam, and also mean that i don't get a huge amount of links that need to all be validated..

Anyone have any mod, or a way of doing this? I think it'd make a great modification, as it'd prevent from the spamming of thousands of links that some people get, and also you could say "sorry, we have currently reached the maximum number of links awaiting validation, and so as we don't have too many links queing up for validation, we can accept no more links today.. please check back tommorow" kinda thing?

Simon
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
to start this thread out..

Code:
open (VAL, "<$db_valid_name") or &cgierr("error in add_record. unable to open validate file: $db_valid_name. Reason: $!");
@valid = <VAL>
($#valid+1 >= 50) and &site_html_add_form_failure ("too many.. tommorrow!");
close VAL;
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
Hi widgetz Smile

Cool, so what would that bit of code do then? id guess it says the error message, but i doubt it's just that bit of code to do what i need... is it???

Id like it if it is Smile

Simon
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
 
after this:
Code:
# Validate the form input..
$status = &validate_record(%in);
if ($status eq "ok") {

put:
Code:
open (VAL, "<$db_valid_name") or &cgierr("error in add_record. unable to open validate file: $db_valid_name. Reason: $!");
@valid = <VAL>
($#valid+1 >= 50) and &site_html_add_form_failure ("too many.. tommorrow!") and return;
close VAL;
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
Hi Jerry,

I already have the database reffers set up to my sites ip address, www.hertsinternet.com and hertsinternet.com so that's ok..

ive heard that auto submission programs can spam saying they they are your site though.. fooling the script.

yes, i have icq, but i can't use it safely at the moment, as my virus protection has just died on me in the last 2 hours, and i have no virus protection, so im going NO WHERE near icq.. Wink

Simon
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
Jerry,

what file do i have to edit to place

Code:
open (VAL, "<$db_valid_name") or &cgierr("error in add_record. unable to open validate file: $db_valid_name. Reason: $!"); @valid = <VAL> ($#valid+1 >= 50) and &site_html_add_form_failure ("too many.. tommorrow!");close VAL;

in to?

is it the site_html.pl? or the add.cgi, or what?

Simon
_____________________________________________
Free Stuff resources http://hertsinternet.com
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
found out myself, by looking Wink

it's add.cgi.. i am trying it out now on my test site.

Simon
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
Jerry,

im getting an error 500, failed script. :O

Quote:
Illegal modulus of constant zero in file /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi at line 61, next 2 tokens "is_valid ="
syntax error in file /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi at line 61, next 2 tokens "map {"
syntax error in file /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi at line 66, next token "else"
Execution of /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi aborted due to compilation errors.
[Sun Aug 15 03:45:01 1999] [error] [client 62.172.25.79] Premature end of script headers: /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi

any ideas?

Simon
_____________________________________________
Improved rsource directory when i sort this
cgi problem out Smile http://hertsinternet.com
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
Ok, so ive realised that hypermart's part to prel is different from the webhost that i use for my proper site.. corrected that, and get........ an error!

Quote:
syntax error at /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi line 108, near "("
Execution of /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi aborted due to compilation errors.
[Sun Aug 15 03:58:04 1999] [error] [client 62.172.27.166] Premature end of script headers: /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi

im still non the wiser..

Simon
_____________________________________________
Free Stuff resources, and no annoying popup
banner ads (like my test site has!)
http://hertsinternet.com/resources/
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
It might be because of the line
Code:
@valid = <VAL>
, the fact that that isn't closed could be causing the errors throught the surrounding areas of the script.

Try putting a semi-colon after <VAL>, if it doesn't work, "hey" it won't hurt semicolons can follow any call.

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
webmaster@lh.yi.org
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
this is my add.cgi file.. (if it helps)

Code:
#!/usr/local/bin/perl
#
##edit above to /usr/bin/perl for .com
# -------------
# Links
# -------------
# Links Manager
#
# File: add.cgi
# Description: Adds a record marked unvalidated to the database and
# optionally emails someone.
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.0
#
# (c) 1998 Gossamer Threads Inc.
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================
#
# Setup Notes:
# Make sure the require statement below points to the config file.

# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \

require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}

# ========================================================

eval { &main; }; # Trap any fatal errors so the program hopefully
if ($@) { &cgierr("fatal error: $@"); } # never produces that nasty 500 server error page.
exit; # There are only two exit calls in the script, here and in in &cgierr.

sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

# We are processing the form.
if (keys %in != 0) {
&process_form;
}
# Otherwise we are displaying the form (in site_html.pl).
else {
if ($db_single_category) {
my %is_valid = map { $_ => 1 } &category_list;
$ENV{'HTTP_REFERER'} =~ s,/[^/]+\.[^/]+$,,;
$ENV{'HTTP_REFERER'} =~ m,$build_root_url/(.+?)/?$,;
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
}
else {
&site_html_add_form ();
}
}
}

sub process_form {
# --------------------------------------------------------
my ($key, $status, $line, $output);

# Check the referer.
if (@db_referers and $ENV{'HTTP_REFERER'}) {
$found = 0;
foreach (@db_referers) {
$ENV{'HTTP_REFERER'} =~ /$_/i and $found++ and last;
}
if (!$found) {
&site_html_add_failure ("Auto submission is not allowed in this directory. Please visit the site to add your entry.");
return;
}
}

# This will set system fields like Validated to their proper values.
foreach $key (keys %add_system_fields) {
$in{$key} = $add_system_fields{$key};
}

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

open (ID, "<$db_links_id_file_name") or &cgierr("error in process_form. unable to open id file: $db_links_id_file_name. Reason: $!");
$in{$db_key} = <ID> + 1; # Get next ID number
close ID;

# Validate the form input..
$status = &validate_record(%in);
if ($status eq "ok") {

open (VAL, "<$db_valid_name") or &cgierr("error in add_record. unable to open validate file: $db_valid_name. Reason: $!");
@valid = <VAL>
($#valid+1 >= 5) and &site_html_add_form_failure ("too many.. tommorrow!") and return;
close VAL;


# Update the counter.
open (ID, ">$db_links_id_file_name") or &cgierr("error in get_defaults. unable to open id file: $db_links_id_file_name. Reason: $!");
flock(ID, 2) unless (!$db_use_flock);
print ID $in{$db_key}; # update counter.
close ID; # automatically removes file lock

# Print out the validate input to a "validation database" where it is stored until
# the admin decides to add it into the real database.
open (VAL, ">>$db_valid_name") or &cgierr("error in add_record. unable to open validate file: $db_valid_name. Reason: $!");
flock(VAL, 2) unless (!$db_use_flock);
print VAL &join_encode(%in);
close VAL; # 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_add_success;
}
else {
&site_html_add_failure($status);
}
}

sub send_email {
# --------------------------------------------------------
# Sends an email to the admin, letting him know that there is
# a new link waiting to be validated. No error checking as we don't
# want users to see the informative &cgierr output.

# Check to make sure that there is an admin email address defined.
$db_admin_email or &cgierr("Admin Email Address Not Defined in config file!");

my $to = $db_admin_email;
my $from = $in{$db_cols[$db_contact_email]};
my $subject = "Addition to Database: $in{'Title'}\n";
my $msg = qq|
The following link is awaiting validation:

Title: $in{'Title'}
URL: $in{'URL'}
Category: $in{'Category'}
Description: $in{'Description'}
Contact Name: $in{'Contact Name'}
Contact Email: $in{'Contact Email'}

Remote Host: $ENV{'REMOTE_HOST'}
Referer: $ENV{'HTTP_REFERER'}

To validate, please go to:
$db_script_url

Sincerely,

Links Manager.
|;

# Then mail it away!
require "$db_lib_path/Mailer.pm";
my $mailer = new Mailer ( { smtp => $db_smtp_server,
sendmail => $db_mail_path,
from => $from,
subject => $subject,
to => $to,
msg => $msg,
log => $db_mailer_log
} ) or return;
$mailer->send or return;
}
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
yes! it works now, and i added the extra ; into the code..

but, it gets to the file to stop adding any more (i set it to 5 to test it) and i get an error message..

Code:
CGI ERROR
==========================================
Error Message : fatal error: Undefined subroutine &main::site_html_add_form_failure called at /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi line 108, chunk 5.

Script Location : /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi
Perl Version : 5.00404

Form Variables
-------------------------------------------

Environment Variables
-------------------------------------------
CONTENT_LENGTH : 216
CONTENT_TYPE : application/x-www-form-urlencoded
DOCUMENT_ROOT : /data1/hypermart.net
GATEWAY_INTERFACE : CGI/1.1
HTTP_ACCEPT : image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
HTTP_ACCEPT_ENCODING: gzip, deflate
HTTP_ACCEPT_LANGUAGE: en-us
HTTP_CONNECTION : Keep-Alive
HTTP_HOST : hertsinternet.hypermart.net
HTTP_REFERER : http://hertsinternet.hypermart.net/cgi-bin/resources/add.cgi
HTTP_USER_AGENT : Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; freeserve_IE4)
PATH : /usr/local/bin:/usr/local/sbin:/usr/local/libexec:/bin:/sbin:/usr/bin:/usr/sbin:/usr/contrib/bin:/usr/X11R6/bin:/usr/libexec:/usr/contrib/is ode/bin:/root/bin
QUERY_STRING :
REMOTE_ADDR : 212.140.75.142
REMOTE_PORT : 2038
REQUEST_METHOD : POST
REQUEST_URI : /cgi-bin/resources/add.cgi
SCRIPT_FILENAME : /data1/hypermart.net/hertsinternet/cgi-bin/resources/add.cgi
SCRIPT_NAME : /cgi-bin/resources/add.cgi
SCRIPT_URI : http://hertsinternet.hypermart.net/cgi-bin/resources/add.cgi
SCRIPT_URL : /cgi-bin/resources/add.cgi
SERVER_ADMIN : webmaster@hypermart.net
SERVER_NAME : hertsinternet.hypermart.net
SERVER_PORT : 80
SERVER_PROTOCOL : HTTP/1.1
SERVER_SIGNATURE :
SERVER_SOFTWARE : Apache/1.3.6 (Unix)

so it's not all working, unfortunately.

Some clever cgi programmer able to work this one out too?? *grin*

Simon
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
widgetz, have i ever mentioned that your a genius? *lol*

I think that if this works (which i presume it does Smile ) then it's going to be great.. i will probably set the value to a lot more than 50, as it's just a preventative measure, so i don't get swamped with links to validate..

will it prevent auto submitters, too?

Simon
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
hmm...

isn't this code used for spamming??

Code:
# Check the referer.
if (@db_referers and $ENV{'HTTP_REFERER'}) {
$found = 0;
foreach (@db_referers) {
$ENV{'HTTP_REFERER'} =~ /$_/i and $found++ and last;
}
if (!$found) {
&site_html_add_failure ("Auto submission is not allowed in this directory. Please visit the site to add your entry.");
return;
}
}

just edit your @db_referers in your links.cfg

simon.. you have icq?

jerry (17144049)
Quote Reply
Re: request. "maximum # of links waiting to be validated please try again tommorow.." In reply to
i thought you would know that..

Smile

it's really easy..

the line

($#valid+1 >= 50) and &site_html_add_failure or something..

change site_html_add_failure to the proper subroutine in site_html.pl.. i'm too lazy to check.. so.. Smile

jerry