Monthly Archives June 2007

PHP monitor server log

PHP monitor server log
Occasionally you'll be working on a webserver and not have SSH access to it. Below is a simple script I've written that reads a server log (in this case the error log) and outputs a portion of it to a webpage.
PLAIN TEXT
PHP:

$no_lines = 25;

 

$filename = $_SERVER['DOCUMENT_ROOT']."/../logs/error.log";

$handle = fopen($filename, "r");

$contents = fread($handle, filesize($filename));

fclose($handle);

 

$contents [...]

Mailto Hyperlinks Stop Spam Bots!

Everyone hates spam, I hate it even more than most people. If you put an email address on a website, as a mailto hyperlink, then it's likely that spam bots will find this address and start sending annoying emails.
One way to get around this is to use a clever technique which I discovered over at [...]

Vim Key Mappings

One of the things I always found awkward about Vim is stretching for the ESC key to get out of insert mode.
Here's a little trick that I like to add into my .vimrc file:
PLAIN TEXT
CODE:

map  <space> i

imap <S-space> <esc>

This will let you escape insert mode by pressing shift and space and enter insert mode [...]

IE7 Clicky Sounds Do my Nut in!

I'm not a fan of applications that use sounds effects, one of the first things I do when configuring a new PC is to set the Windows Sound scheme to 'No Sounds'. IE7 has the hugely annoying feature where a click sound is made when you click a link with the middle mouse button (this [...]