Comment insert to include IP Address
-
Constant Pligger
Comment insert to include IP Address
I run a site where 90% of comments / stories are by anonymous posts. Recently we have been having people from other sites spamming comments on the boards.
I have setup story submissions to include the IP address of the user ( by adding $linkres->link_field1 = $_SERVER['REMOTE_ADDR']; to the submit.php page) but I can't seem to find the page or query that handles the comment submissions.
Can anyone point me in the right direction to which page, class or function I will need to edit to include the IP Address to the comment insert query?
Also from what I have read registered user submissions are handled different then anonymous submissions, is this correct?
-
Constant Pligger
Well I found a simple fix / hack for this.
I guess since user accounts track the IP address within the user table the only need is to track anonymous posters IP's.
To track the IP address of anonymous comment posts you can do the following:
*Note this assumes the anonymous comments module is in use.
Create a new field in your comments table:
ipaddress, varchar 17
Open /modules/anonymous_comments/anonymous_comments_main.php
FIND:
$sql = "INSERT INTO " . table_comments . " (comment_user_id, comment_link_id, comment_date, comment_randkey, comment_content,`comment_anonymous_username`, `comment_anonymous_email`, `comment_anonymous_website` ) VALUES ($user_id, $link_id, NOW(), $randkey, '$comment_content', '$a_username','$a_email', '$a_website')";
REPLACE WITH:
$a_ipaddress = $_SERVER['REMOTE_ADDR'];
$sql = "INSERT INTO " . table_comments . " (comment_user_id, comment_link_id, comment_date, comment_randkey, comment_content,`comment_anonymous_username`, `comment_anonymous_email`, `comment_anonymous_website`,ipaddress ) VALUES ($user_id, $link_id, NOW(), $randkey, '$comment_content', '$a_username','$a_email', '$a_website', '$a_ipaddress')";
What this does:
All this will do is update the SQL insert string to include adding the ipaddress record with the $a_ipaddress value which is the value the server picks up for the users IP address.
With this information you can run queries to find all matching IP Addresses and delete all the spam for a specific IP, or find the IP used by a poster to ban by IP.
-
New Pligger
very good answer, congratulations
-
Constant Pligger
This maybe it.
See this post from me http://forums.pligg.com/questions-co...-geo-flag.html
How could 1 use $_SERVER['REMOTE_ADDR'] to fetch the anonymous users ip for a country code flag?
-
New Pligger
оффтоп: модеры, а можно как нить перепост себе вконтик сделать? не вижу кнопок, обычно внизу они
-
New Pligger
just a test, admin, del this message
just a test, admin, del this message
Similar Threads
-
By 12kerala in forum Questions & Comments
Replies: 4
Last Post: 04-24-2012, 01:24 PM
-
By urarcade in forum Questions & Comments
Replies: 2
Last Post: 05-09-2011, 12:27 PM
-
By calvin199 in forum Questions & Comments
Replies: 7
Last Post: 10-12-2010, 11:48 AM
-
By sirwanme in forum Questions & Comments
Replies: 0
Last Post: 08-15-2010, 06:16 AM
-
By glcaff in forum Questions & Comments
Replies: 2
Last Post: 04-30-2006, 08:42 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules