Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: [MOD] IP Address on comments v0.1 (admin section) for sNews 1.4  (Read 3613 times)

bramsyuur

  • Hero Member
  • *****
  • Karma: 23
  • Posts: 873
    • http://snews.vietbee.net

Hi to all!
This is a MOD suggested by edwardguillen in this forum.

UPDATED: Add a missing code line and a warm to notify the IP logger to the user.

With this mod, an extra colum that show the ip of the remote comment poster are stored into your database and it's only showed when you are logged in as a admin.

As a tipical message: Make a backup first!! ;)

Well, first of all, create an extra field with your phpmyadmin under your comments database table called:
ipremote with this options: Type=varchar(15) Null=Yes

Now, in your snews.php file, locate under //COMMENTS function this:
Code: [Select]
$id = $r['id'];And add, after, this line:
Code: [Select]
$ipremote = $_SERVER['REMOTE_ADDR'];Next, locate this line under //COMMENTS function, too:
Code: [Select]
mysql_query("INSERT INTO ". s('prefix')."comments(articleid,name,comment,time) VALUES('$articleid', '$name', '$comment', '$time')");And replace it with this one:
Code: [Select]
mysql_query("INSERT INTO ". s('prefix')."comments(articleid,name,comment,time,ipremote) VALUES('$articleid', '$name', '$comment', '$time', '$ipremote')");Next, few lines to down, locate this:
Code: [Select]
if  (date("Y", strtotime($r['time'])) == 1999 OR s('display_comment_time') == "NO") {
                        $date = "";
                } else {
                        echo $date;
                }
And replace with this one:
Code: [Select]
if  (date("Y", strtotime($r['time'])) == 1999 OR s('display_comment_time') == "NO") {
                        $date = "";
                if (isset($_SESSION['Logged_In'])) { echo " |IP: " .$r['ipremote']. ""; }
                } else {
                        echo " | ";
                        echo $date;
                if (isset($_SESSION['Logged_In'])) { echo " |IP: " .$r['ipremote']. ""; }
                }
Next, find this line (few lines to down):
Code: [Select]
And add afer this:
Code: [Select]

Finally, add under LANGUAGE VARIABLES, this line:
Code: [Select]
$l['ip_remote'] = "For security reasons your IP are logged";And this is all! :D
This is a screenshot when I'm logged in:

Thanks,
bram.
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] IP Address on comments v0.1 (admin section) for sNews 1.4
« Reply #1 on: June 09, 2006, 02:58:49 am »

excellent work, bramsyuur :)

a small suggestion for those who will use this mod - it would be polite to notify the user about his ip (perhaps a message in the comment form itself) - something like "IP logged" ;)
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
[MOD] IP Address on comments v0.1 (admin section) for sNews 1.4
« Reply #2 on: June 09, 2006, 03:56:27 am »

Hmmmm... yes that is a neat little script. Tell me though, in Spain and most of Europe, are most or all IPs static or do a lot of the ISPs there now provide dynamic ISPs?

The only reason I ask is that in Canada, high speed ISP services all pretty much use dynamic IPs, so a user's IP is different every time he connects. Knowing an IP address is useful for finding out who the ISP likely is but dynamic IPs make it impossible to ID or block a specific user using the IP... you would have to block the ISP's whole range of addresses and that could penalize good users.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] IP Address on comments v0.1 (admin section) for sNews 1.4
« Reply #3 on: June 09, 2006, 07:30:38 am »

good point. in that context, ip logging is useful only in overposting prevention snippet with predefined minimum time period between 2 posts from the same IP
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

bramsyuur

  • Hero Member
  • *****
  • Karma: 23
  • Posts: 873
    • http://snews.vietbee.net
[MOD] IP Address on comments v0.1 (admin section) for sNews 1.4
« Reply #4 on: June 09, 2006, 07:49:00 am »

@Mika,
Mod updated (and fixed) with your suggestions,
Thanks,
bram.
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol

David

  • Hero Member
  • *****
  • Karma: 7
  • Posts: 567
[MOD] IP Address on comments v0.1 (admin section) for sNews 1.4
« Reply #5 on: June 09, 2006, 08:41:24 am »

wow Bram..great mod ! Thanks for your work! :)
Logged