Show IP when post is creation by anonymus user

maralikpl - December 26, 2007 - 17:07
Project:Drupal
Version:7.x-dev
Component:theme system
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Show IP (add IP to comments and post) creation by anonymus user

#1

gpk - December 26, 2007 - 20:52
Version:5.5» 7.x-dev
Priority:critical» normal

In your node.tpl.php http://drupal.org/node/11816 you could modify $submitted to include $_SERVER['REMOTE_ADDR'].

No new features are being added to Drupal 5.x (or 6.x for that matter). If you think this is an important feature for Drupal core then there is more chance of your suggestion being acted upon if you explain why you think this needs to be included (i.e. why the method I described above, using custom themeing, is not good enough).

Best,

#2

budiw - February 1, 2008 - 08:06

Is there any modules for drupal 5.x ?

#3

gpk - February 1, 2008 - 08:55

This is crude and untested, but is simple (and should work!):

In your theme's node.tpl.php, change

<?php
print $submitted
?>

to something like
<?php
print str_replace(variable_get('anonymous', t('Anonymous')), variable_get('anonymous', t('Anonymous')) . "($_SERVER['REMOTE_ADDR'])", $submitted)
?>

A more elegant way would be to overwrite the theme's $submitted variable using in template.php - see info. here http://drupal.org/node/16383.

I am coming round to the point of view that an option to display Anonymous users' IP address would be of value.

#4

gpk - February 1, 2008 - 22:19

OK well I posted a lot of rubbish at #3. Somehow I forgot that $_SERVER['REMOTE_ADDR'] will be the IP address of the person viewing the post, not the creator. Oops :-P

A standard Drupal installation does not capture the user's IP address when a new page/node is created. However, it *does* capture the IP address of users when they post a "comment" (i.e. a reply to an existing post/page).

You would need to access it in your theme's comment.tpl.php, something like this (this is based on what Garland's comment.tpl.php already has):

<?php if ($submitted): ?>
  <span class="submitted">
  <?php print t('!date — !username' . ($comment->uid ? '' : '(@hostname)'), array('!username' => theme('username', $comment), '!date' => format_date($comment->timestamp), '@hostname' => $comment->hostname)); ?>
  </span>
<?php endif; ?>

 
 

Drupal is a registered trademark of Dries Buytaert.