User account menu

  • Log in
BXTra.net

Breadcrumb

  • Home
  • Articles
  • Display IP Address for all comments in Drupal 6.16 - 6.20

Display IP Address for all comments in Drupal 6.16 - 6.20

By BXTra | 8:39 PM PDT, Wed March 17, 2010
Drupal

I have searched many places how to display user IP for each comment. There is no complete answer in any topics that I found. Therefore, I just tried each part of each information until I know how to do it. Below is what I did to make it work:

1. Search file "comment.module" here - > "modules/comment/comment.module"

1.1. Add c.hostname into query line number 939

FROM

$query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d';

TO

$query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, c.hostname, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d';

1.2 Add c.hostname into query line number 960

FROM

$query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';

TO

$query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, c.hostname, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';

2. Now, you should be able to use code <?php print $comment->hostname; ?> to display IP address. This command is to be use in file comment.tpl.php. (Theme Directory) Below is an example how to use it :

<div class="submitted">
     <?php print $submitted; ?>
     <?php print t('(IP Address : ' . $comment->hostname . ')'); ?>
</div>

Optional : If you want to display IP Address only for anonymous user. User the code below :

  <div class="submitted">
     <?php print $submitted; ?>
    <?php if (($comment->uid)==0): ?>
    	<?php print t('(IP Address : ' . $comment->hostname . ')'); ?>
    <?php endif; ?>
  </div>

 

More Info :
- Provide {comment}.hostname in comment_render() ( http://drupal.org/node/514928 )
- IP address in comment ( http://drupal.org/node/695112 )

About text formats
  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

  • Will the router get the Openvpn as a client option?
    6 years ago
  • cancellation
    6 years 1 month ago
  • Router ASUS RT-N12 D1 tomatoes passwort falsch
    7 years 8 months ago
  • WPS button = 30/30/30 hard reset button
    7 years 9 months ago
  • Save my day!
    8 years 3 months ago
  • How to
    8 years 6 months ago
  • Can i still access my modem (the one with the ISP provided)?
    8 years 6 months ago
  • A saving step!
    8 years 10 months ago
  • Problem with Asus n12e-c1
    9 years ago
  • don't use Hostgator
    9 years 2 months ago

© 2007 - 2023 BXTra.net. All Rights Reserved. 
Certain other content, photos and artwork displayed on BXTra.net are protected by copyright and are the property of their respective owners.

Privacy Policy