Thursday, December 1, 2011

Inspired by the canyoucrackit puzzle


I thought I'd design a little puzzle myself. Can you solve this one? This is not the solution to the canyoucrackit.co.uk puzzle but I think it might be a little harder to crack :D have fun.

Monday, October 5, 2009

creating animation

There was a time when people had to draw on acetate to make animations but now we have computers. So you'd think it would be easy to make a short animated commercial, you can even put animation into your powerpoint presentations. BUT can you put a pptx into windows movie maker, no, of course not. I found out there was a youtube competition to win $25000 worth of advertising, and I already had the idea but there was no way I was going to get that idea done, so I animated it. Easy enough, I thought. Then you come up against the road blocks that microsoft have so kindly put in your way. Anyway, it meant that I had to do something very similar to the 'old school' animators and animate it frame by frame which I did in Fireworks as an animated gif. These could then be put together in windows movie maker. Of course, then I wanted to record an audio track on there and do some editing of the audio track (something you used to be able to do in windows, but not in vista it seems). So, I had to find a program that would let me do that and I was lucky enough to find Free Audio Editor http://www.free-audio-editor.com/ which turned out to be a pretty great program. Want to see the finished result?

Click here http://www.youtube.com/watch?v=zWhf3kF8WiA

Tuesday, September 29, 2009

development of an PHP based IP to country redirect page

I like blogs that teach me something. With that in mind, I wanted to pass something on which might be useful for my readers. So here it is, a how to guide on developing a page which will redirect the visitor to a different page depending on where they are in the world. My site is built in PHP so that's what I'll be describing. Although it would be great to have a site for every country, I've developed one for the two countries where I live: the UK and the US.

There are two parts to the detection, 1 is the php page and the other is a database. To get the data for the database go here: http://ip-to-country.webhosting.info/node/view/6 and click on the CSV download. It's updated every month or so. Then comes the PHP.

The code is below, if you replace the myhost, mydata, mypassword, mydatabase and the web pages you want to redirect to then you should have a fully functional ip to country redirection.

// Replace this MYSQL server variables with actual configuration
$mysql_server = "myhost";
$mysql_user_name = "mydata";
$mysql_user_pass = "mypassord";

// Retrieve visitor IP address from server variable REMOTE_ADDR
$ipaddress = getenv(REMOTE_ADDR);

// Convert IP address to IP number for querying database
$ipno = abs(ip2long($ipaddress));

// Connect to the database server
$link = mysql_connect($mysql_server, $mysql_user_name, $mysql_user_pass) or die("Could not connect to MySQL database");

// Connect to the IP2Location database
mysql_select_db("mydatabase") or die("Could not select database");

// SQL query string to match the recordset that the IP number fall between the valid range
$query = "SELECT * FROM IPCountry WHERE $ipno <= ipTO AND $ipno >= ipFROM";

// Execute SQL query
$result = mysql_query($query) or die("IP2Location Query Failed");

// Retrieve the recordset (only one)
$row = mysql_fetch_object($result);

// Keep the country information into a variable
$CountryShort = $row->CountryShort;

// Free recordset and close database connection
mysql_free_result($result); mysql_close($link);

// If the visitors are from GB, redirect them to GB site
if ($CountryShort == "GB")
{
Header("Location: http://www.1lessjob.com/UK/");
}

elseif ($CountryShort == "US")
{
Header("Location: http://www.1lessjob.com/US/");
}
else
{
// Otherwise, redirect them to splash page
Header("Location: http://www.1lessjob.com/pick.html");
}
exit;

?>

In addition to those already mentioned thanks to the sites (http://us2.php.net/manual/en/function.ip2long.php and https://www.ip2location.com/articles/article2.htm) that helped me build my PHP ip to country detect/redirect.

This concludes my first blog post, hope you find it useful.