Muffinresearch Labs by Stuart Colville

PHP tip of the week: Getting IP addresses | Comments (2)

Posted in Code on 2nd December 2004, 1:07 pm by Stuart

Extracting the gateway IP address is straightforward:

$ip = $_SERVER['REMOTE_ADDR'];

To obtain the hostname of the gateway IP address just do the following:

$hostname = GetHostByName($_SERVER['REMOTE_ADDR']);

To get the local IP address of your user can sometimes be useful too. Here’s how:

$localip = $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'];

Post Tools

Comments: Add yours

1. On March 28th, 2005 at 4:57 pm Q... said:

I wanted to cite some of your posts in my forum. Couldn’t find your perma-links

2. On March 29th, 2005 at 8:27 am Stuart Colville said:

Hi, I’m as we speak working on the first draft of Joornal which will be a re-written blogging script to replace this one. There’s no question that permalinks will become a feature of this. Watch this space.







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Inspiring a Sense of Ownership|(0)

Former colleague Mike West talks about how inspiring a team’s sense of ownership around a project is the key to great things happening: http://mikewest.org/2008/11/the-inspiration-of-ownership. Quality stuff.

VMware Server: Convert Fixed Disk-images to Growable|(0)

Quick tip if you ever want to convert from a fixed disk image to an expandable one then the following command should do it:

sudo vmware-vdiskmanager -r source.vmdk -t 0 expandable.vmdk

Just replace “source” and “expandable” with your disk image file names. For more on what vmware-vdiskmanager can do for you type vmware-vdiskmanager -h

Photos on Flickr

© Copyright 2004-08 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by 1&1 This page was baked in 1.093s.