Archive for the 'Programming' Category

January 2, 2009

PHP to redirect IP addresses to different page

If you would like to redirect browsers based on their IP the following method can be used to handle multiple IP’s.  You can choose to redirect entire networks or a single ip.

<?php
//array of ip’s you wish to block. Note that you can block an
//entire class by replacing it with 0, so to block [...]

August 25, 2008

Blocking by country and high connection counts hosting servers

Most of our hosting servers run Centos Linux but we have Windows servers too and a problem common to both is the occasional high volume of traffic generated by non organic growth.  I don’t mean that someones blog hits the front page of digg, rather a malicious or DDOS attack against a website.  On shared [...]

July 24, 2008

Three little characters  designed to make your life hell

On more than one occasion these characters  have turned up just when everything else seems fine.  Known as a “BOM” or Byte Order Mark they can be extremely annoying.
What is  ???
 is often seen at the top left corner of a web page.  When you open the source file and compare that to [...]

July 7, 2008

Limiting text input to characters and digits

To remove stuff such as punction and spaces (or anything you want) from a text box before sending to the server for validation you can use code like this, first the HTML:-

<input
name="name"
onblur="this.value = entrycheck(this.value);"
type="text"
size="20">

And then the following Javascript will remove invalid characters when the user moves to another field:-

<script type="text/javascript">
function namecheck(theInput) [...]

April 24, 2008

ASP code to block multiple ranges of IP’s from your site

It wasn’t long before I needed to expand upon banning a few IP’s. I needed to be able to ban whole networks so here’s the Q&D solution:-
First create a text file called ipsec.txt and enter some IP’s you wish to ban, to ban a network just leave off the end of the IP class [...]