New year, New site


Written by

Well, after much deliberation I have change my site once again.

My past website layout was nice and clean but a little too white for my likings and it wasn’t easy enough to update. I have thus opted for a more blog style site.

This should hopefully get me to update it more, I have chosen to turn comments off just to save me time moderating them for spam n stuff.

This change was not taken lightly as my previous site was completely hand written by myself and conformed to standards, which this new site currently does not; this will be rectified when I have time.

I hope you like the new style and find it just as easy to use as the previous.

Goodnight

PHP Log Function


Written by

Since developing several sites, I have found that the default error/notice output can be vague or not flag the error up where it is.
This is why I have developed a PHP function which logs what ever you want it to.

function logger($type,$action,$msg){
 // Three types of logging, debug(anything not User/Security/), user and Security (Sec)
 $ip = $_SERVER['REMOTE_ADDR'];
 $bool=TRUE;
 if(strtolower($type)=="user"){
 $buffer = "\r\n".date("d-m-y(H:i:s)")."; ".$action."; ".$msg."; ".$ip;
 }elseif(strtolower($type)=="sec"){
 $buffer = "\r\n".date("d-m-y(H:i:s)")."; ".$action."; ".$msg."; ".$ip;
 $type = "security";
 }else{
 $buffer = "\r\n".date("d-m-y(H:i:s)")."; ".$type."; ".$action."; ".$msg."; ".$ip;
 $type = "debug";
 }
 $logfile = "logs/".strtolower($type).".log";
 $handle = fopen($logfile, "a") or $bool = FALSE;
 if($bool!=FALSE)
 {
 $write = fwrite($handle, $buffer);
 if(!$write){
 $bool = FALSE;
 }
 fclose($handle);
 $bool = TRUE;
 }
return $bool;
}

Just call it up by doing

logger("MYSQL Error","MySQL_Connect","MySQL Error".mysql_error());

which for example will produce

01-01-11(22:31:27); MySQL Error; MySQL_Connect; Database Returned Error - You have an error in your SQL syntax; at line 1; 95.145.206.220

As you can see the logs are delimited with a semi-colon (;) which makes it easy to import that data into a spreadsheet.
The logs are saved in logs/ of the page that executes the function, but you can change this if required; there are 3 logs, ‘user‘,’security‘ and ‘debug‘.

The debug log catches any $type that is not ‘user‘ or ‘sec‘.

And finally it returns TRUE on log and FALSE on error.

Hope this code helps you as much as it’s helped me.

Useful wget options


Written by

Just because it took me ages to figure some of this out as –help is HUGE and doesn’t contain some of the options.

-c

Continue a Download

-r / --recursive

Recursive download

-L / --relative

relative Links only

--no-check-certificate

Don’t check the SSL certificate

--limit-rate=

Limit the rate of download ie 100k

Usage:

user@computer:$ wget -c -r -L --no-check-certificate --limit-rate=100k http://example.com/file

or

user@computer:$
wget -c --recursive --relative --no-check-certificate --limit-rate=100k http://example.com/file

Web2Messenger Gone


Written by

Well, after less than a year since I wrote the Web2Messenger (W2M) PHP API, it looks as though it has finally died.

When I was using the system for my dissertation and also writing the API, I did notice a lack of support and now finally it ha totally gone.

The forums return an SQL error and all the bots are offline which means all is sleepy in the W2M world.

It it sad to see such a service to but no worries, Microsoft have released some code for Windows Live Messenger to integrate into PHP.

Check it out over at CodePlex.

Web Systems for Uni


Written by

I have created two working systems for my university course, the first being my Server Status checker and the second being Wonderful Wiki, Wiki system.

Both these systems were created in PHP and are fully working. I will try and release the source code at some point for people to download and I may continue to develop the systems but in the foreseeable future these systems will just be archived and readily available.

Update: Please note, since I developed my dissertation; the server status checker, Twitter has removed the support for the authentication being used, so the demo may not work correctly.