Gossamer Forum
Home : Products : Links 2.0 : Customization :

Block Multiple Submissions

Quote Reply
Block Multiple Submissions
How to add the routine from rate.cgi that stops multiple ratings to add.cgi to stop multiple submissions? I already have the BlockURLs mod and the Automatic Duplicate URL Check mod but now need to prevent multiple submissions from the same IP who is spamming with different URLs of the same content.

Quote Reply
Re: Block Multiple Submissions In reply to
Try adding a bit where a cookie is added. This will stop the less determined abusers, but not the more determined ones Frown.

I'm not very good with Perl and Cookies, so I'm afraid I can't offer you any sugestions, but maybe some of the other more experienced users such as Eliot can help you Wink

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Block Multiple Submissions In reply to
Um actually this was discussed like yesterday and the discussions can be found in both the Links2 Customization and Discussion forums....

Please search next time.

Also Andy - to brush up your cookie skills go to perl.com and seach the CGI docs for "cookie", surprisingly.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Block Multiple Submissions In reply to
Replace:

# We are processing the form.
if (keys %in != 0) {
&process_form;
}

With:

# We are processing the form.
if (keys %in != 0) {
&logger;
}



Add the sub:


sub logger {
# --------------------------------------------------------
# Log the IP

if (open (LOG, "<addsite.txt")) {
chomp (@IP = <LOG>);
foreach $ip (@IP) {
$ip eq $ENV{'REMOTE_ADDR'} and ($visited++ and last);
}
close LOG;
if (!$visited) {
push (@IP, $ENV{'REMOTE_ADDR'});
open (LOG, ">addsite.txt") or &cgierr ("Can't open for output counter file. Reason: $!");
if ($db_use_flock) { flock (LOG, 2) or &cgierr ("Can't get file lock. Reason: $!"); }
local $" = "\n";
print LOG "n@IP";
close LOG;
&process_form;
}
else {
&site_html_add_failure ("not allowed to submit another site") and return;
}
}
else {
open (LOG, ">addsite.txt") or &cgierr ("Can't increment counter file 'addsite.txt'. Reason: $!");
print LOG "n$ENV{'REMOTE_ADDR'}";
close LOG;
&process_form;
}
}


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Block Multiple Submissions In reply to
I found this cookie a long time ago. It allows a popup window to show only 1 time per day. It's neat because you can have a popup to present something important to your visitors, but the popup doesn't keep coming up each time that page is called.

Perhaps the cookie could be altered to help prevent spamming the add.cgi, rate.cgi, deadlink.cgi and other scripts.

I got this cookie at either (I think) http://javascript.internet.com or http://www.wsabstract.com.

Here it is:
ONE-TIME-A-DAY POPUP COOKIE

In Reply To:
var expDays = 1; // number of days the cookie should last

var page = "yourpage.html";
var windowprops = "width=550,height=125,location=no,toolbar=2,menubar=no,scrollbars=yes,resizable=yes,navbar=yes";

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);

window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
}
}
I hope this helps. Smile

DT


Quote Reply
Re: Block Multiple Submissions In reply to
Many thanks for the prompt response.

I have added Glen's mod to add.cgi and it is working like a dream: maybe one for the Resource Center?



Quote Reply
Re: Block Multiple Submissions In reply to
Is there a way to set up sub logger to allow 2 (or X) submissions per day, not just 1?

Many thanks. Smile

DT

Quote Reply
Re: Block Multiple Submissions In reply to
At http://javascript.internet.com it is in the Cookies section



Gene
Quote Reply
Re: Block Multiple Submissions In reply to
If you want it allow up to 2 submissions a day, change sub logger to:


sub logger {
# --------------------------------------------------------
# Log the IP

$time = time();

if (open (LOG, "<addsite.txt")) {
chomp ($old_time = <LOG>);
chomp (@IP = <LOG>);
(($time - $old_time) > 86400) and (@IP = ());
foreach $ip (@IP) {
$ip eq $ENV{'REMOTE_ADDR'} and ($visited++ and last);
}
close LOG;
if ($visited < 2) {
push (@IP, $ENV{'REMOTE_ADDR'});
open (LOG, ">addsite.txt") or &cgierr ("Can't open for output counter file. Reason: $!");
if ($db_use_flock) { flock (LOG, 2) or &cgierr ("Can't get file lock. Reason: $!"); }
local $" = "\n";
print LOG "n$time\n@IP";
close LOG;
&process_form;
}
else {
&site_html_add_failure ("not allowed to submit another site") and return;
}
}
else {
open (LOG, ">addsite.txt") or &cgierr ("Can't increment counter file 'addsite.txt'. Reason: $!");
print LOG "n$time\n$ENV{'REMOTE_ADDR'}";
close LOG;
&process_form;
}
}


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Block Multiple Submissions In reply to
Many thanks, Glennu! Smile

DT

Quote Reply
Re: Block Multiple Submissions In reply to
Way too many codes for the logging process. I wrote codes in this forum for rate.cgi that are only about five lines of code versus the 20 or so lines you are using.

Regards,

Eliot Lee
Quote Reply
Re: Block Multiple Submissions In reply to
I'm interested how? To open a logfile, check if the ip address apears more than twice and if not log the ip in just 5 lines?

Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Block Multiple Submissions In reply to
Instead of just stating that your code is better and shorter it would be nice if you posted it for us to see (and learn from) Smile

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Block Multiple Submissions In reply to
I've been trying glennu's code above that would allow up to 2 URL submissions from a single IP per day. So far, it's working great. Thanks, glennu!

I also wanted to see if I could allow up to 5 submissions per day. So, I changed

In Reply To:
if ($visited < 2) {
to

In Reply To:
if ($visited < 5) {
However, when I did this, I was able to submit more than 5. In fact, no error page ever came up no matter how many submissions I made. When I switched it back to 2, it worked okay, again.

Is there something else that I should be changing?

Thanks so much. Smile

DT



Quote Reply
Re: [glennu] Block Multiple Submissions In reply to
Hi Glenn,

I seem to be having trouble with this 2 submissions a day mod, it seems that there is only ever 1 date and 1 IP listed in the addsite.txt file, no matter how many submitters add a link.

So when the routine checks to see if visited the answer is always no, and hence it it will always allow multiple submissions.

I have implemented the mod exactly as your instructions above. Am I missing something? Unsure


Mark