for starters make the script use 'POST' not get
this will stop the text being echoed* and will also stop alot of attacks.
here is an easy way to make your script use POST.
/* if your running php4.1.2 or newer u will need this
$query_string1 = $POST[query_string1];
$query_string2 = $POST[query_string2];
(this just gets the query strings)
if you had a mail form the query strings might be..
$name
$email
etc
*/
/ CHECK REQUEST METHOD /
if ($REQUEST_METHOD == "GET" || $REQUEST_METHOD == "HEAD" || $REQUEST_METHOD == "PUT"){
echo"sorry bad request method - bye bye";
exit;
}
ok so now your script uses POST
so it cant be called from anywhere but your page & it wont show anything!..
altho it uses post people can still fake headers.. so to make it a bit more secure we add some referer checking.
/ CHECK REFERERS /
// array for allowed domains (lower case please)
$referers = array('yoursite.com', 'www.yoursite.com', 'yoursite.org', 'www.yoursite.org');
// add upper case referrers
$size = sizeof($referers);
for($i = 0; $i < $size; $i++){
$referers[] = strtoupper($referers[$i]);
}
// check referers
for($i = 0; $i < sizeof($referers); $i++){
if(substr($HTTP_SERVER_VARS['HTTP_REFERER'], 7, strlen($referers[$i]))
== $referers[$i]){
$bad_referer = FALSE;
break;
}
else{
$bad_referer = TRUE;
}
}
if($bad_referer){
echo "i dont like your referer";
exit;
}
ok so now our script has only 1 request method & it has referer checking., (better then most scripts so far)
by using POST people cant manually type there own input in the address bar so this basically solves your problem. they can make there own form and change the max length and it wont work because of there bad referers.
have fun