This will output an “online” image if the server you are trying to connect to is online, and “offline” if it is offline. It supports multiple ports…

Online/Offline Status Webchecker by Daniel Austin MBCS.
Multiple ports option added by Niall Davies.
$online = "online.gif"; /* Link to Online image */
$offline = "offline.gif";    /* Link to Offline image */
if ($host == "")
$host = "";
if (StrStr($host, ":")) {
$port = SubStr($host, StrPos($host, ":")+1, StrLen($host));
$host = SubStr($host, 0, StrPos($host, ":"));
settype($port, "integer");
} else {
$port = 80;
$host = "tcp://$host";
$is_online = false;
$fd = @fsockopen($host, $port, $errno, $errmsg, 2);
if ($fd)
$is_online = true;
if ($is_online)
$img = $online;
$img = $offline;
$imgsize = @filesize($img);
header("Content-type: image/gif");
header("Content-length: $imgsize");

This script will generate a random string… (ideal for URL shorteners, Pastebins and confirm URLs.)

Niall Davies' Random String Generator
This program makes a random string containing hexidecimal characters.
Ideal for URL shorteners, Pastebins, etc.
Originally scripted for
Function RandStr()
/* You will need to configure this part... */
$min_number_of_chars = 3;
$max_number_of_chars = 5;
/* No configuring now... */
$number_of_chars = rand($min_number_of_chars, $max_number_of_chars);
$string = '';
for ($x=1; $x <= $number_of_chars; $x++) {
$new = RandChar();
$string .= $new;
return $string;
Function RandChar()
$upper = Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
$lower = Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
$which = rand(0,2);
switch ($which) {
case 0:    return $upper[rand(0,count($upper)-1)];
case 1: return $lower[rand(0,count($lower)-1)];
case 2: return rand(0,9);

This script will connect to mySQL and select the db (and assumes the db name is the same as the user and the host is localhost if blank). Again feel free to do whatever you want with this code.
<?php/*     Niall Davies' mySQL connect/select Database document
Configure below to the details your mySQL Server has, include_once
into all pages of your website that need connection to SQL. If you
get any errors contact me at
$mysql_host = "";     /* mySQL Host - If unknown or "localhost", leave blank */
$mysql_user = "";    /* mySQL User */
$mysql_pass = "";    /* mySQL Password */
$mysql_db = ""; /* Usually the same as mySQL user, if so, leave blank */
/*     ---------------------------------------------------
No more configuration is needed.
If you wish to edit the script below, go ahead
No support is offered for edited code.
/* See if host is specified */
if ($mysql_host == "") {
$mysql_host = "localhost";    /* Assume host is "localhost" */
/* See if DB is specified */
if ($mysql_db == "") {
$mysql_db = $mysql_user;    /* Use same as Username (standard) */
/* See if User and Pass is specified */
if ($mysql_user == "" || $mysql_pass == "" || $mysql_user == NULL || $mysql_pass == NULL) {
/* Echo out Error */
$error = "User and/or Password not specified for connection to mySQL";
/* Connect to mySQL */
$mysql_connect = @mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$mysql_select_db = @mysql_select_db($mysql_db);
/* Check for errors and Debug */
if (!$mysql_connect) {    /* Couldnt connect to SQL */
/* Echo Out Error */
$error = "Could not connect to mySQL with host $mysql_host and user $mysql_user (".mysql_error().")";
if (!$mysql_select_db) {    /* Couldnt select DB */
$error = "Could not select the $mysql_db database (".mysql_error().")";
/*     ----------------------------------------------------
Thank you for using my mySQL connect/select DB script
For more scripts from me go to
Copyright (c) 2010 Niall Davies.

This script has been requested a few times, and is for IRC networks to use. It uses the GET method, and will print a ban appeal message to post to an IRC networks forums, feel free to do anything with this.
IRC Ban appeal script. Originally made for the TechnoGeek IRC Network.
By Niall Davies
Feel free to take this comment out, even though it wont make any difference to the output of the code.
/* This will show the BANNEDBY user (use ?bannedby=nickhere) */
echo ('I was banned by: '.$_GET["bannedby"]);
echo ('<br/>');
/* This will show the time you were banned (use &date=timehere) */
echo ('The time I was banned: '.$_GET["date"]);
echo ('<br/>');
/* This will show the time you were banned for (use &bannedfor=legnthoftimehere) */
echo ('Time i was banned for: '.$_GET["bannedfor"]);
echo ('<br/>');
/* This will show the reason you were banned (use &reason=reason here) */
echo ('The reason I was banned was: '.$_GET["reason"]);
echo ('<br/>');
/* This will show your hostname. (use &ip=hostname here) */
echo ('The Hostmask I was using was: '.$_GET["ip"]);
echo ('<br/>');
/* This will show the user's nickname (use &nick=nick here) */
echo ('The Nick I was using was: '.$_GET["nick"]);
echo ('<br/>');
/* This will show if they were in a blacklist, and which one. (use &blacklist=blacklist) */
if ($_GET["blacklist"] != NULL) {
echo ('The Blacklist you were in was: '.$_GET["blacklist"]);
echo ('<br/>');

Okay.. you may have or may not have noticed that I have made some coding changes to the site, I now have the menu, header, footer and image in seperate files and using PHP Include I have “embedded” them in to the page.

You will notice now that on the main site the photo is chosen at random (out of 4 or 5 photos I think), I like this because it means i can add more photos or change it at a later date.. this is also in a document i am using for PHP include, so if i wanted to add more photos I wouldn’t have to edit every page to do it.

I know, i havent yet changed the theme on my blog and it is “default” i will be getting round to this but at the moment i have more important things to do.. I have had to find time to even write this blog post….

Just to be geeky.. hehe, here are the pages that are used in PHP Include (If you have time to take a look)


This means i can change say the “menu.php” document and it will change the Menu on every page…

Also on image.php you will see that it shows a random picture, like it does above the Links bar..  here is the coding that makes that work (It is quite complicated but oh well)

Function ShowRandomPic()
/* show a random pic */
$pics = Array();

/* define pics here, start from 0, no gaps between numbers allowed */
$pics[0]["src"] = "cool.jpg";
$pics[0]["txt"] = "Me =)";

$pics[1]["src"] = "fueholiday2007.jpg";
$pics[1]["txt"] = "Fuerteventura 2007";

$pics[2]["src"] = "beer.jpg";
$pics[2]["txt"] = "Enjoying Glass of Beer =)";

$pics[3]["src"] = "bass.jpg";
$pics[3]["txt"] = "Playing bass in Eric's studio";

$pics[4]["src"] = "blue.jpg";
$pics[4]["txt"] = "Niall's blue hair";

/* end of pics */

/* make random number generator more random */
srand((double) microtime() * 1000000);

/* choose a random number */
$i = rand(0, (count($pics)-1));
$img = $pics[$i]["src"];
$txt = $pics[$i]["txt"];

/* output the tag */
echo ""$txt"";


Its i suppose quite hard to understand for a beginner, for people who understand PHP, they will know what that means.

So yh.. some major changes (mainly PHP Include) and also the “updating picture thing”

Thanks for reading,
Niall =)