Muffinresearch Labs by Stuart Colville

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

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

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

  • Q…

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

  • http://www.muffinresearch.co.uk Stuart Colville

    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.

GNU screen: open tab in current working directory|(1)

A nice trick for having screen open a new tab in the same directory as the one you’re currently in. To use it add it to your .screenrc

# Open new window in current dir.
bind c stuff "screen -X chdir \$PWD;screen^M"
bind ^c stuff "screen -X chdir \$PWD;screen^M"

Hat tip: mteckert on SuperUser.com

Ubuntu: add-apt-repository: command not found|(2)

When you’re using a minimal Ubuntu install if you find the ‘add-apt-repository’ command is missing (it’s useful for adding PPAs and other repositories), then simply run:

sudo apt-get install python-software-properties

Photos on Flickr

© Copyright 2004-12 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.560s.