PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
AYK
Hangin' Around


Joined: Apr 03, 2004
Posts: 32

PostPosted: Sun Apr 18, 2004 1:51 pm Reply with quote Back to top

Hello, I've been looking around but I can't seem to find a function for PHP dat registers the visitors IP.

I'm making a counter based on the fact that the viewing of index.php adds a row to my counter table where the date+time of the visit is stored too.
The counter value is MYSQL_NUM_ROWS. But I would like to add the vistitors IP adress also. Any ideas ?
View user's profile Send private message Visit poster's website
AYK
Hangin' Around


Joined: Apr 03, 2004
Posts: 32

PostPosted: Sun Apr 18, 2004 2:56 pm Reply with quote Back to top

DEVSHED forum provided my answer :

Code:
 $_SERVER['remote_addr']
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Sun Apr 18, 2004 3:22 pm Reply with quote Back to top

That will not work all the time especially with proxies and such. Try this instead Wink
Code:
if (isSet($_SERVER)) {
      if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) {
         $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
      } elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) {
         $realip = $_SERVER["HTTP_CLIENT_IP"];
      } else {
         $realip = $_SERVER["REMOTE_ADDR"];
      }

} else

   if (isSet($HTTP_SERVER_VARS)) {
      if (isSet($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"])) {
         $realip = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
      } elseif (isSet($HTTP_SERVER_VARS["HTTP_CLIENT_IP"])) {
         $realip = $HTTP_SERVER_VARS["HTTP_CLIENT_IP"];
      } else {
         $realip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
      }

} else {
      if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
         $realip = getenv( 'HTTP_X_FORWARDED_FOR' );
      } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
         $realip = getenv( 'HTTP_CLIENT_IP' );
      } else {
         $realip = getenv( 'REMOTE_ADDR' );
      }
}
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
AYK
Hangin' Around


Joined: Apr 03, 2004
Posts: 32

PostPosted: Sun Apr 18, 2004 3:56 pm Reply with quote Back to top

Thanks ! fantastic ! Very Happy Very Happy
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum