Web Development
Cycle Routes
by Mike on Jul.02, 2010, under General, Projects, Web Development
A while ago I wrote how I was setting up a cycle routes website with my Dad. Well, it’s been up for a while now, and has one of the largest collection of cycle routes of any website in the UK.
Because of the website’s uniqueness, it has been spotted by a lot of the nation’s councils. We now feature on nearly every of the UK’s council’s websites, and generate a lot of interest in cycling from all ages.
We are often receiving requests for new routes in people’s areas, and we’re thinking of streamlining the site a little so that cycle enthusiasts and upload their own cycle routes, as was the original intention.
Check out the cycle routes website, have a look around, and get out on your bike.
CodeIgniter – The best framework for the job?
by Mike on Jun.18, 2010, under Findings, General, Web Development
Most web developers have their own code base that they refer back to on a regular basis. Many have even developed their own simple platforms that do a lot of the leg work for them, that they know inside out and can easily deploy on a new project.
More recently though, at least in the last 4-5 years, frameworks have been popping up left right and centre. From CakePHP, which is generally considered to be a little unstable, to the super-reliable ZendFramework, built by Zend – the PHP company.
Zend and Cake are not he only frameworks though. After trying a lot, I find my personal favourite to be CodeIgniter, which is built by EllisLabs.
CodeIgniter comes with libraries and helpers that can be activated at any point within the framework. These helpers try and simplify many tedious tasks involved with making web applications. Things like form validation is a breeze, and the functions used are much more powerful than something that can be drummed up quickly in any normal PHP app. Image manipulation is made easy, and emailing through PHP can be done well without needing to load in the bloated PEAR, which the documentation recommends.
CodeIgniter uses standard MVC (Model > View > Controller) to create it’s systems. Although at first glance this can seem a little silly and over-thought, but it makes life a lot easier for everyone involved. The MVC structure is standardised, reliable and fast, and every developer should follow suit with it very easily.
CodeIgniter also makes debugging applications very easy. The built-in profiler shows all of the POST, and GET data, aswell as all database queries. I used a customised version of the profiler that I tweaked to also show SESSION data.
When working with lots of small, simple queries CodeIgniter also makes life easy with active records, their database library. It allows queries to be written with a fraction of the amount of code. Let’s say we want to pull off everything from a table, simple: db->get(’table’) – no need to write a full query to do it. Active records do support large queries with unlimited amounts of JOINs, but my personal preference is to compile these myself and throw them into a normal query using the DB library’s db->query() method – probably because I’m used to the structure of the queries and the syntax so I can spot errors more easily. If you’re not hot on SQL though, you’ll probably benefit massively.
My personal framework recommendation is definitely CodeIgniter, but make sure you check out all of the others available too. CodeIgniter has a massive community that helps solve any problem you may have, the community includes forums and live chat rooms, which the EllisLabs developers often frequent.
Football Forum
by Mike on May.10, 2010, under General, Projects, Web Development
Well, as you probably know, I like making things to do with football. Notably Football Badges and Football Feeds, both of which are doing extremely well.
My new venture is something a little bit more large-scale. The football badges application gets around 250,000 new unique visits (at time of writing) per month, my goal is to syphon some of these over to the new project, the football forum. At time of writing the number one slot on Google for ‘Football Forum’ only has 25,000 members. This may seem a lot, but when you consider it’s only a tenth of my average monthly traffic on the football badges application, you’ll see that it’s entirely possible that it could be beaten.
Within 3 weeks of launching the forums already have approaching 200 active users. This may not seem like a lot, but consider that this sort of website is viral, and the rate of growth will only increase over time.
If you’re interested in football and want to speak to some like-minded individuals, then head over.
Football Forum
Pub Directory
by Mike on May.10, 2010, under General, Projects, Web Development
It’s been a while since I last posted, I’ve been ridiculously busy of late with a huge amount of projects coming underway, but there will be more news of that in the next few posts.
A project I started some time ago, which was started fairly randomly is the pub directory. It’s a website with (nearly) every pub in the UK listed. Although the search function isn’t great at the moment, there is the ability to search for a city and pub name – but everything does share the same search box, so searching something like ‘Winchester’ might bring up a few unwanted results.
Other than that the site is doing well. The pubs are all categorised by region, so it’s quite easy to find pubs around you. There are also several nice features, including the ability to add a review to the pub. The pub reviews don’t require any sign-ups, and are protected from spam by a reCaptcha form, which works excellently.
Have a look and see if you can find your pub: Pub Directory
British Kings and Queens
by Mike on Mar.09, 2010, under General, Projects, Web Development
So, another AdSense site is up and running. British Kings and Queens was built in PHP using CodeIgniter. There are a lot of pages, mostly generated from the database.
I wrote all of the content myself, which took around 4-5 hours. I’m hoping this unique content will pay off, but I’m currently not seeing much traffic.
Check the site out, I actually learnt quite a lot about British History and past Kings and Queens of Britiain whilst writing it.
British Kings and Queens
All Phobias
by Mike on Feb.24, 2010, under Findings, Projects, Web Development
A couple of nights ago I decided to do a little experiment. I was going to create a generic website with a few hundred pages of content, SEO the hell out of it, and see if I can earn anything from AdSense.
The website is All Phobias, and it lists every ‘known’ phobia out there. It’s written in PHP ontop of CodeIgniter. I created a small C app to scrape all of the data off a few different websites and generate some SQL for me. All in all the whole thing took about 4 hours to make. The design is some crappy free one I downloaded, as I’m not really interested in how it looks.
I’ve made sure every page has everything it should like unique titles, h1 tags and all the meta tags to go with it. I have also made a couple of blogs on external websites and made 5-10 posts on each, some linking to the site, and some not. I’ve submitted to some free submission sites, as well as linking from all of my major sites with a decent page rank.
I’ve submitted a hefty sitemap (I think there were 750 pages) to Google, but the domain is still in the incubation period, so I guess I’ll need to wait a couple of months to see any real progress.
Since the site went live 2 nights ago it’s earnt me a whopping £2. Which, to be honest, isn’t bad at all. If I can earn £1 a night from 2 nights work then I’ll be a happy man. Do the math on that, 15 sites per month, for 6 months, that would be ~£90 per day, or £2.7k a month. Not bad. My hope is that in 6-8 months time it will be top of Google for a lot of keywords ‘all phobias’, along with many of the actual phobia names and short descriptions (’fear of spiders’, for example), at which point the £1 a day would easily jump up to £5-10 per day, with a bit of luck.
Linux Portal – Linux News and Linux Articles
by Mike on Jan.31, 2010, under Projects, Web Development
So I’ve owned Linux Portal for as long as I can remember, but not really done much with it. Originally I created it to aggregate some of my favourite Linux RSS feeds from the sites I read the most, but it became a bit of an effort to maintain for something that had very little rewards, because of that I just left it with some RSS feeds with links to the articles on the home page. Nothing new and nothing interesting.
I recently decided to update it though. A similar principle but putting the sturdiness of WordPress to good use. I now use some of those same feeds that I used originally to pull in the articles. I then publish those articles to the blog as posts, all on-the-fly, and totally automated. I update the blog about once a week and it will grab new posts from the feed and publish them.
There were some initial teething problems though. I had ‘Post-to-twitter’ plug-in along with the Google Sitemap generator plug-in both running at the same time. So, when I added a new feed it would pull in around 50 posts. That meant grabbing all 50 posts from the source, then posting 50 new messages to Twitter (in quick succession), and on each post it would generate a new sitemap.xml, update robots.txt and notify 5 search engines of the change. Quite a massive task for one webserver really. Inevitably, the server came to a standstill every time. I’ve since solved it by disabling the plug-ins but if the site takes off I might create a cron job that checks for updates and then notifies Twitter and the sitemap plug-in to run periodically.
If you’re interested check the site out, there are Linux Articles and Linux News.
Enjoy
Football Badges 50,000
by Mike on Jan.26, 2010, under Projects, Web Development
Another milestone. Football Badges has now reach 50,000 active users. This is the largest Facebook application that I have created to date.
I will be releasing a new Facebook app in the next few days. It has some functionality and will hopefully keep users coming back to use the application, whereas Football Badges is a sort of one-off thing. Keep your eyes peels and the feed subscribed to!
SEO Friendly PHP Twitter Script
by Mike on Jan.25, 2010, under Web Development
There are loads of scripts out there for pulling in your Twitter posts. A lot, if not most of them, base themselves heavily on JavaScript. This is bad for 3 reasons:
- People with JS disabled can’t read them
- It’s bad for your website’s search engine rank (SEO) as the search bots can’t read them
- It slows user’s browsers down (if only slightly)
I have written a very simple PHP script that pulls in your Twitter posts, and outputs them in an unordered list. Feel free to use however you like:
<?php
// Your Twitter username
$username = 'mikemike86';
$rssUrl = "http://twitter.com/statuses/user_timeline/$username.rss";
$rss = @file_get_contents($rssUrl);
if($rss){
$xml = @simplexml_load_string($rss);
if($xml !== false){
$var=true;
foreach($xml->channel->item as $tweet){
//echo $tweet->pubDate."\n";
echo ''.substr($tweet->description,(strlen($username)+2))."\n\n";
if($var){
break;
}
}
} else {
echo "Error: RSS file not valid!";
}
} else {
echo "Error: RSS file not found. Username invalid or requires authentication";
}
?>
PHP json_encode Alternative
by Mike on Jan.25, 2010, under Web Development
The amount of times I’ve been working on a project and the environment hasn’t had the useful json_encode function installed due to PHP being < version 5.2 is quite worrying. So, I decided to write my own replacement. How very decent of me. You can use it as you will. I wrote this a long time ago, but I've noticed it's somehow wormed its way onto the php.net site under someone elses name, and someone else seems to be taking credit for it. Oh well...
<?php
if (!function_exists(’json_encode’))
{
function json_encode($a=false)
{
// Some basic debugging to ensure we have something returned
if (is_null($a)) return ‘null’;
if ($a === false) return ‘false’;
if ($a === true) return ‘true’;
if (is_scalar($a))
{
if (is_float($a))
{
// Always use “.” for floats.
return floatval(str_replace(”,”, “.”, strval($a)));
}
if (is_string($a))
{
static $jsonReplaces = array(array(”\\”, “/”, “\n”, “\t”, “\r”, “\b”, “\f”, ‘”‘), array(’\\\\’, ‘\\/’, ‘\\n’, ‘\\t’, ‘\\r’, ‘\\b’, ‘\\f’, ‘\”‘));
return ‘”‘ . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . ‘”‘;
}
else
return $a;
}
$isList = true;
for ($i = 0, reset($a); $i {
if (key($a) !== $i)
{
$isList = false;
break;
}
}
$result = array();
if ($isList)
{
foreach ($a as $v) $result[] = json_encode($v);
return ‘[' . join(',', $result) . ']‘;
}
else
{
foreach ($a as $k => $v) $result[] = json_encode($k).’:’.json_encode($v);
return ‘{’ . join(’,', $result) . ‘}’;
}
}
}
?>