php for the soul, plus other stuff

Well, here we go. I came up with a “new” website concept on Saturday night so, you guessed it, my assignment got forgotten and I did an all-nighter. Long story short, it’s pretty much all finished, just doing touch-ups to it now. I’ll leave descriptions etc til it’s online, which is hopefully in next few days. Main issue is finding an available domain name!! I have finally gained an appreciation of the hatred felt for domain squatters. That, and how frustrating it is to attempt to name a blog….

Back to the other day, when I decided I better get it together and become another WordPress blogger, it was unbelievable how many 14 yr-old girls had decided to start blogs in 2004/2005 and made the first post then never again!! Seriously! And, before you say I was choosing dumb names (ie that 14 yr-old girls would choose), I will refer you to possible options:

  • myblog – 12 yr-old girl, couldn’t even post, only made comments to the default posts and pages (Sept 23, 2005)
  • qwerty – I take the “14 yr-old girls” bit back, nothing doing here (Nov 2, 2005)
  • ifelse – no idea who, China (end of 2005)
  • rofl – one hit wonder (Oct 23, 2005)
  • over9000 – Eastern European, the most used one so far (31 Aug – 27 Sept 2007)

I’ll stop there before I have a heart attack (check this out if you want one too!!). Anyway, moving on, I found a name (and not a bad one, may I say) and here it is.

In other news….my  RSS feed for this blog is up and rolling (Wahoo!), and I have got a whole lot of stuff done with php. So, here’s a lovely tid-bit as promised:

I’ve just been using
$ip=$_SERVER['REMOTE_ADDR'];
to get the ip of my site visitor. This is correct, but a bit of geeking the ‘net today led to this bit of work by scriptgoddess, and then built out a bit:
function getAddress() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else {
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}

As a quick run down, if it doesn’t come absolutely clearly to you, we first check for $_SERVER['HTTP_CLIENT_IP'] (shared internet), and allocate that that as the address. If this isn’t available, we then move to $_SERVER['HTTP_X_FORWARDED_FOR'] (the ip a proxy was forwarding on behalf of), if required; otherwise we default to $_SERVER['REMOTE_ADDR']. This provides us with the most precise “real” ip address for the user visiting our site. The main hurdle we have overcome now is the inability to accurately map geo-demographics visiting your site. Purely using $ip=$_SERVER['REMOTE_ADDR'] will result in some ISPs and proxies claiming stupid volumes of traffic, while not allowing you to accurately target your content (and advertising!!).

I have to say I’m getting over the layout of my code in this theme (I just changed it twice), so I’m going to give up on posting code for now, and finish my web work. One of tomorrow’s tasks is now to find a new theme I like that supports displaying code in a useful manner.

Advertisements

About Cameron
I'm a final year Computer Science/Information Systems major. Already finished my BA in Politics/Philosophy. I do web and software freelance on the side, while I finish studying. Hoping to be self-employed by the end of my degree, otherwise off into the real-world I go....

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: