NGPriest: Site GeoIP And Site Downtime

Ξ December 3rd, 2009 | → 0 Comments | ∇ Author: NGPriest |

Okays, after typing my previous post, i started working on a new project to make the site load faster, by moving all the content off random servers (as there was a 33% chance the files will get loaded from your nearest server.
(aka Malaysia would LAG Australian viewers)
which was never a problem for me, since i rarely read the site (all comments are emailed to me and all posts are normally bypassing the main site and into the admin panel)

So, this is the finished coding

Part 1:

<?php
require_once "/home/ngpriest/php/Net/GeoIP.php";
$geoip = Net_GeoIP::getInstance("/home/ngpriest/public_html/GeoIP.dat");
$CountryCode = $geoip->lookupCountryCode($_SERVER['REMOTE_ADDR']);
$CountryName = $geoip->lookupCountryName($_SERVER['REMOTE_ADDR']);
?>

This loads 2 variables, $CountryCode and $CountryName

Part 2

<?php
if ($CountryCode=="AU"){
	echo "Script for Australia";
}
elseif ($CountryCode=="MY"){
	echo "Script for Malaysia";
}
elseif ($CountryCode=="SG"){
	echo "Script for Singapore";
}
else {
	$k=rand(1,3);
	if ($k=="1"){
		echo "Script for Australia";
	}
	elseif ($k=="2"){
		echo "Script for Malaysia";
	}
	elseif ($k=="3"){
		echo "Script for Singapore";
	}
}
?>

So yeah, as you can see, we have 3 if, which asks if our $CountryCode is AU, MY or SG and if they aren’t, we’ll go back to the 33% of picking a random server

While implementing the above code, i screwed up the index.php file, which stores the main site, along with all additional main coding?

So, i searched for approx 1-2mins for a backup (and didn’t find any), i decided to write a new one?
And it looks closely like what it was before

But tell me if you find any bugs?

 

Comments

Name (required)

Email (required)

Website

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

Share your wisdom

RSS

    Welcome to

    NGPriest's Blog


    There are 5,505 posts and 302 comments so far. Feel invited to browse the archives, read the about or comment on the latest post.

    Search:

    • BananaStatio is 23/M/KL, KL, Malaysia
    • ChambyT is 1x/F/Sungai Bakap, Penang, Malaysia
    • chingyi1807 is 1x/F/Malaysia
    • CopyCatty is 1x/M/Hong Kong
    • crazymango is 15/F/Malaysia
    • Eliteratty is ??/M/???
    • HolySprings is 18/M/Sungai Bakap, Penang, Malaysia
    • jaigralia is unknown...
    • Jykur0 is 14/M/Indonesia
    • MakoJr is 1x/M/Singapore
    • NGPriest is 19/M/Brisbane, QLD, Australia
    • PoringCat098 is 1x/F/Malaysia
    • Saphira is 15/F/George Town, Penang, Malaysia
    • shiningthrust is 13/M/Singapore
      shiningthrust is Single
    • sianzxd is 18/M/George Town, Penang, Malaysia
    • Swifty13 is 1x/M/United Kingdom
    • WingzOfChaos is 15/M/Singapore
      Single/Lonely/Depressed

Random stuff!

  • Loved by Some,
    Hated by Many,
    Envied by Most,
    Yet Wanted by Plenty
  • 10% luck
    20% skill
    15% concentrated power of will
    5% pleasure
    50% pain
    100% reason to remember the name!
  • I write your name in my breath on the window, Sit and watch as it fades away
  • Hi honey.
    Guess what I did at work today?
    I wore a bomb.
    A nuclear bomb in a field of flowers.
    I could get lucky.
    Tomorrow I could have a bigger bomb.
    I could kill more people.
    Maybe they'll be innocent people.
    Children, maybe.
  • "You are like a plague, John Crichton,
    and you have ruined my life . . .
    and yet
    I just keep coming back."
  • I'll watch the night turn light blue
    But it's not the same without you
    Because it takes two to whisper quietly
    The silence isn't so bad
    Till I look at my hands and feel sad
    Cause the spaces between my fingers
    Are right where yours fit perfectly

Search