I just opened my wheelie bin and a wasp flew out. What kind of sick person would throw a wasp in a bin? 1 day ago



May 10
30th

Things that I learnt holding my first competition


I’ve never run a competition before and, thanks to Creative, my first opportunity has just concluded.

And what did I learn?

Well, a lot. First of all, the questions I should be asking the prize providers. Instead I kept badgering them as I kept asking some pretty basic questions…

  • When do you want the competition to start?
  • How long do you want the competition to run for
  • Are the prizes all for one person, all a “first” prize, or staged (first prize, second prize, etc)
  • How long until delivery
  • What will you provide if a product is no longer available?

Whilst running the competition I kept an eye on the entries to ensure that I wasn’t receiving multiple entries per person or household. And, after only 24 hours, I appeared to have found a problem – 3 people, each with an AOL email address, and the same IP address. Suspicious? It looked like it to me.

However, the fact that AOL is their ISP is the key here – they use a proxy-based system, meaning that many users may share the same IP address. Wikipedia has discussed such an issue before on their own site.

The database I created to hold winner details held a name, address, email, competition answer and IP address. Based on the AOL problems I now realise that I should also store a time stamp and user agent. I’ll be making these changes for next time.

I did a lot of work on the competition coding to ensure SQL injection problems. None-the-less I realised a few days ago that although the competition entry form disappears after the closing date, the code to submit the form details into the database still exists. This means that a third party script could inject entries (although not anything that would affect security) after this time. Again, this will now be fixed for future.

Lastly, I had so many entries that just trying to keep track of “rule breakers” became a lot, lot harder – more work on flagging such things at the point of competition entry will be useful, and I feel an automated email coming on!

Meanwhile, I have contacted the 3 winners and am just awaiting a confirmation of their postal addresses before details are announced.


Share this on del.icio.us Digg this! Email this Share this on Facebook Share this on LinkedIn Send this page to Print Friendly Share this on Reddit Share it on StumbleUpon Tweet This!


May 10
19th

ZyXEL NSA210 Review


I’ve had my ZyXEL NAS now for a couple of months, so I thought it was only fair that I should review it ;)

The device itself was a lot smaller than I was expecting, being not bigger than the hard drive that goes in it. It’s made robustly of metal, with the exception of the plastic front panel. It has rubber feet underneath, but is more sturdily mounted on a the provided plastic cradle – this is a useful addition but cheaply made.

The front panel consists of a number of status lights, a power and sync button and a USB socket.  All other connections are on the back  – SATA, eSATA, Gigabyte Ethernet,  and another USB port.

I had also purchased a 1TB Western Digital Caviar Green – not the quickest, but energy conscious and quiet. Putting the drive in is a case of undoing a screw on the underneath of the front panel, lifting the panel away and then pushing the drive into place.

You turn the NAS on and it takes a few minutes to initialise. First time you use it, however, you have to install the provided (or downloaded) firmware, which you do from your PC. After this is done you access the NAS via a web-based admin. panel.

The administration section is detailed and includes many useful options. A media server is included allowing you access to your videos and music anywhere on the network. Additionally, there are options to set up downloads to your NAS, allowing you, for instance, to kick off a large download at night and turn your PC off.  This includes Torrent options. You can also set up feeds, such as Podcasts, which will download automatically.

To access the NAS data you can map the drive to your PC or access it via a network shortcut. Additional access options available include FTP and  a web publishing feature that allows you to access data from a browser.

The NAS can also be set up with timing options allowing you to dictate times when it will turn itself on and off, and also reboot itself.

Connect a printer to the USB port and configure it via the admin menu and you have a simple, but useful, network printer.

And if all these options aren’t enough, you can download and install, from the admin menu, further tools including WordPress, MySQL and Gallery.

NSA210 Administration Screen

So, what’s it like in use? Excellent. I use few of the more advanced features, I’ll admit. I use my NAS, primarily, as a backup device. A good external hard drive isn’t much less, so I went for a NAS for the networking options that it does give me. Also, because it comes diskless, I know that the disk can be easily replaced – many others come with a disk and firmware built in – you may be able to replace the drive but, often, adding the firmware back on is difficult or even impossible. That’s not the case here – in the case of a drive failure, I simply slot a new one in and re-install the firmware.

PC Pro tests mentioned that it was quite slow, but I’ve not noticed in comparison to my previous Maxtor model. That was particularly slow when trying to access the data, something the ZyXEL doesn’t have a problem with. And that, above basic transfer speed, makes it feel a lot quicker in use.

It’s tucked away, next to my printer and is quiet and efficient in use. For home users it’s ideal.


Share this on del.icio.us Digg this! Email this Share this on Facebook Share this on LinkedIn Send this page to Print Friendly Share this on Reddit Share it on StumbleUpon Tweet This!


Mar 09
11th

Optimize and Backup your MySQL databases


At the moment I’m juggling 3 MySQL databases. It could very easily be more.

I usually use phpMyAdmin for backing them up but restrictions on port forwarding has meant I can’t do this whilst at work1. So, I wrote myself a script to do this. And optimize the tables as well.

An extract of the script is below… mine allows me to choose the database and compression type and then populates the appropriate database fields (username, password, etc) but for generic usage purposes, the script below should be fine for other people to use and build upon.

if ($compression=="None") {$comp_cmd=""; $comp_ext="sql";}
if ($compression=="Gzip") {$comp_cmd=" | gzip"; $comp_ext="gzip";}
if ($compression=="Zip") {$comp_cmd=" | zip"; $comp_ext="zip";}    

mysql_connect($host,$user,$password);
mysql_select_db($database);
$query="SHOW TABLE STATUS FROM ".$database;
$result=mysql_query($query);
$num=mysql_numrows($result);
$compressed=0;
$i=0;
while ($i < $num) {
   $table=mysql_result($result,$i,"Name");
   $gain=mysql_result($result,$i,"Data_free");
   if ($gain!=0) {
       if ($compressed==0) {echo "<br/>Compressing tables...<br/><br/>\n";}
       echo "Table ".$table." - ".$gain." bytes gained<br>\n";
       $query="OPTIMIZE TABLE ".$table;
       $optimise=mysql_query($query);
       $compressed=$compressed+$gain;
   }
   $i++;
}
if ($compressed!=0) {
   echo "<br/>".$compressed." bytes gained in total<br/>";
} else {
   echo "<br/>No tables were optimised.<br/>";
}
$backupFile = "backup/".$name."_".date("Ymd").'.'.$comp_ext;
$command = "mysqldump --opt --extended-insert --complete-insert --hex-blob
--host=".$host." --user=".$user." --password='".$password."' ".$database.
$comp_cmd." > $backupFile";
exec($command, $ret_arr, $ret_code);
if ($ret_code==0) {
   echo "<br/>Database backed up: <a href=\"".$backupFile."\">download</a>.\n";
} else {
   echo "<br/>The database could not be backed up - the return code was ".
$ret_code.".\n";
};

Before running the above, you need to populate the following fields…

$database – your MySQL database
$user – your MySQL username
$password – your MySQL password
$host – your MySQL host name
$name – used to name your backup
$compression – this is the type of compression you wish to apply and should be either None, Zip or Gzip.

When run any tables that require optimizing will be, well, optimized and the details output. Finally a backup is made of the database and a link displayed so that you can download it.

Downloads are placed in a folder named /download, so make sure you add write permissions for this folder. The filename will be xxx_yymmdd, where xxx is the name you specified in $name and yymmdd is the date. Obviously the extension will be based on the type of compression you requested.

Whilst trying to write this code I came across various scripts and resources which did something similar but often didn’t work (grrr) for one reason or another. In particular, often the backup files are create empty if you have the MySQLdump parameters wrong. One thing you might spot that I’ve worked around – and here’s my tip for the day – is that I’ve placed single quotes around the password. This was because one of my passwords had an ampersand in it and, well, MySQLdump doesn’t like it.

Enjoy, play and let me know how you get on!

  1. and I have a tendency to forget if I leave it until the evening at home []


Share this on del.icio.us Digg this! Email this Share this on Facebook Share this on LinkedIn Send this page to Print Friendly Share this on Reddit Share it on StumbleUpon Tweet This!
53 queries in 0.959 seconds.