Gossamer Forum
Home : Products : Links 2.0 : Customization :

Help needed - Submitters IP in links.db

Quote Reply
Help needed - Submitters IP in links.db
Hi everyone,

My first post after 3 years using and modifying links2 script:-)
I could not find a solution in the forum as usual, so I must ask for help here.
First to say , I dont undestand anything from perl, exept some basic commands, but I can follow instructions and thats the way I got my script doing everything I want.
What I am trying to do is to include the submitters IP into links.db. How do I get the IP printed on the add.cgi page so I can put it inside <%IP%> tags and very important, what code to write inside links.def to define it as a field.

Why I would like to do that: I got the blacklist mod installed and expanded to block Email's, URL's and IP's. Sometime submitters start changing urls and redirect their sites and I think their computer IP is the best way to stop them from submitting anymore to me. Thats why I want it to be there written on file and easy to access at any time.

Every help is appreciated

Thanks
Koki

Last edited by:

Koki: Mar 1, 2004, 9:18 AM
Quote Reply
Re: [Koki] Help needed - Submitters IP in links.db In reply to
Never mind. I got it working
Quote Reply
Re: [Koki] Help needed - Submitters IP in links.db In reply to
any chance of letting us in on how you did it?Smile
Crazy
Quote Reply
Re: [Dingle_B] Help needed - Submitters IP in links.db In reply to
Sure, no prob.

It might be an easy way to be done, but I dont know it. Thats what I build together from reading the board:

In links.def add DB number for the IP field. In my case is number 21. You may include it wherever you want.

# Database Definition: LINKS
# --------------------------------------------------------
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 200, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
Graphic => [14, 'alpha', 40, 75, 0, '', ''],
Gwidth => [15, 'alpha', 5, 5, 0, '', ''],
Gheight => [16, 'alpha', 5, 5, 0, '', ''],
Priority => [17, 'alpha', 0, 5, 1, 'No', 'No|Yes'],
RecipURL => [18, 'alpha', 40, 150, 1, 'http://', '^http|news|mailto|ftp'],
Type => [19, 'alpha', 0, 150, 1, '', ''],
Comments => [20, 'alpha', '40x3', 500, 0, '', ''],
IP => [21, 'alpha', 0, 150, 1, '', ''],
);

------------------------------------------------

Find this part and add the db number there as well:

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_alt = 5; $db_priority = 17; $db_recipurl = 18;
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_id = 0; $db_type = 19; $db_comments = 20;
$db_ip = 21;

----------------------------------------------------------

In site_html_templates.pl just before globals add the following line:

$ip = qq~$ENV{REMOTE_ADDR}~;

And the line inside GLOBALS marked red

# You can put variables here that you would like to use in any
# of your templates.
%globals = (
date => &get_date,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
css => $build_css_url,
db_dmoz_url => $db_dmoz_url,
ip => $ip,
banner => ''
);

-------------------------------------------------------------

DO NOT FORGET to change the LINKS.db with one more | per line. There is a working upgrade.pl script to help you with . I am attaching it here, because on many places in this board the code is corrupt or something , and is giving 500 error

Thats it.
Now you just need to include this variable <%ip%> somewhere inside your ADD.HTML in the <form> tags where you want the IP to appear or just inside a hidden tag like this <input type="hidden" name="IP" value="<%ip%>"> so it can be submitted.

Bye
Quote Reply
Re: [Koki] Help needed - Submitters IP in links.db In reply to
Not that it matters much, but shouldn't...

IP => [21, 'alpha', 0, 150, 1, '', ''],

be...

IP => [21, 'numer', 0, 150, 1, '', ''],


-Edit-

Hmm.. It's been ages since I actually did any modifications, I don't recall if the '.' (period) functions as numer(number) or alpha(letter).. No biggy as long as it's working anyways :)

Last edited by:

madtech: Mar 2, 2004, 7:40 PM
Quote Reply
Re: [madtech] Help needed - Submitters IP in links.db In reply to
Hi,

Yes I suppose it should, at least if there are numbers to be written:) I changed it few days ago, but did not post here the change. And in fact it works both ways...so I realy dont know how it should be the right perl "spelling":-) About the '.' (period) things, as I explaned above, I dont understand perl a bit:-) What I do is to replace the original code with the modifications I find in this board, cut some lines here and there until I get it working. If yes , fine, if the code is someway corrupt , or is wrong ...well I cant do much about it, so I say goodbye to it and start looking again for another one tat can help.

Bye




Last edited by:

Koki: Mar 3, 2004, 2:31 AM
Quote Reply
Re: [Koki] Help needed - Submitters IP in links.db In reply to
Thanks........



chuckCrazy