Gossamer Forum
Home : Products : Links 2.0 : Customization :

IP in dead link 2 -Glennu- ?

Quote Reply
IP in dead link 2 -Glennu- ?
Hello,

Can I view IP adresses when we submit a deadlink with deadlink 2 ?
How to create a cookies to allow only one submit per day?
Because I receive too much mall of people who wish to harm to me.

Thanks,

Steph

Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
You could log Ip's like this:

http://gossamer-threads.com/...w=collapsed&sb=5


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
Thank you

But I novice and I don't know where I must make changement with this script for deadlink 2 !

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




Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
Hello Glennu

I have the same problem...

It is possible to modify your script : "Using a cookie in rate.cgi " for your mod "deadlink mailer 2" ?
I'm novice and it's difficult for me to make changement...
I receive 500 mails per days !!! Help me :)

STeph

Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
Quick way to log ip's... open linkdead2.cgi and under:

my %in = &parse_form();

Add:

&logger;

Then at the bottom of the script add:

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

if (open (LOG, "<deadlink.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, ">deadlink.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;
}
else {
print ("not allowed to submit another deadlink") and return;
}
}
else {
open (LOG, ">deadlink.txt") or &cgierr ("Can't increment counter file deadlink.txt. Reason: $!");
print LOG "n$ENV{'REMOTE_ADDR'}";
close LOG;
}
}



Then just make a blank file called deadlink.txt.



Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
Hello,

Thank you very much but it doesn't work...
The deadlink.txt is ok, I've IP adresses in this file, but nothing when I submit links...

This is deadlink2.cgi :

#!/usr/bin/perl
# -------------
# Links
# -------------
# Links Manager
#
# File: linkdead.cgi
# Notifies the webmaster of a deadlink
# Author: Glenn Utteridge
# Based on and designed to be used with
#Links 2 by: 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:
# Make sure the require statement below points to the config file.
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 logger {
# --------------------------------------------------------
# Log the IP

if (open (LOG, "<deadlink.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, ">deadlink.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;
}
else {
print ("not allowed to submit another deadlink") and return;
}
}
else {
open (LOG, ">deadlink.txt") or &cgierr ("Can't increment counter file deadlink.txt. Reason: $!");
print LOG "n$ENV{'REMOTE_ADDR'}";
close LOG;
}
}

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

# Main Routine

# Sends an email to the admin, letting him know that there is a dead link.

my %in = &parse_form();
&logger;

# 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 = "Deadlink ID number: $in{'ID'}\n";
my $msg = qq|
The following link is reported to be dead:

ID number: $in{'ID'}
Site title: $in{'Title'}
Site URL: $in{'URL'}
Category: $in{'Category'}
Comment: $in{'Comment'}

To check the link, please go to:
$db_cgi_url/jump.cgi?ID=$in{'ID'}

Or to delete the link please go to:
$db_cgi_url/$db_script_path/admin.cgi?db=links&ID=$in{'ID'}&Title=&URL=&Date=&Category=---&Description=&Contact+Name=&Contact+Email=&Hits=&isNew=---&isPopular=---&Rating=&Votes=&ReceiveMail=---&Graphic=&Gwidth=&Gheight=&Priority=---&Password=&MonthHits=&isMonthPopular=---&DateAdded=&keyword=&mh=10&sb=---&so=ascend&delete_form=Search&delete=$in{'ID'}



Sincerely,

Visitor.
|;

# 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;
&site_html_deadlink_mail;
}

Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
You need to use the LOGGER subroutine in the add.cgi script.

Regards,

Eliot Lee
Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
Ok, but it's dor deadlink.cgi !
Are you sure ?

Laurent

Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
Uh...look at your previous statement:

In Reply To:

The deadlink.txt is ok, I've IP adresses in this file, but nothing when I submit links...


This statement indicates that you would like to LOG IP addresses when new links are added, thus, the script that you need to use the LOGGING codes for ADDING links is the add.cgi script.

Regards,

Eliot Lee
Quote Reply
Re: IP in dead link 2 -Glennu- ? In reply to
Ok, Excuse-me, my english is not very good !
I've already the problem...
The mod don't work in my deadlink2...

Laurent