AJAP can be downloaded from http://sourceforge.net/projects/ajapshout/
I've currently got the shoutbox in my arcade page, users are using it quite well until some idiot decides to select their name and/or message as
'lllllllllllllllllllllllllllllllloooooooooooooooooooooooooooooolllllllllllllllllllllllllllll' and it messes up the whole layout of my arcade frames.
Is there any way of limiting the amount of input characters allowed?
AJAP-Shout of the following files:
readme.txt (readme file)
returnshouts.php (code that returns shouts)
script.js (javascript that runs the send item)
shoutbox.php (basically the shoutbox laybout/skin)
shouts.txt (shouts are added to this file)
spinner.gif (image is shown when a shout is sent)
sendshout.php (the script that sends the shout - see below)
I've got a feeling that if I wanted to do it, I'd edit the sendshout.php file.
function sendshout() {
//define shout varibles and st00f
$name = htmlspecialchars($_GET['name']);
$m = htmlspecialchars(strip_tags($_GET['message']));
if(!$name | !$m)
{
$message = "Blank Message Removed";
return $message;
die;
}
//define te xml file
$file = $_SERVER['DOCUMENT_ROOT']."/shoutbox/shouts.txt";
//cut lines, so we don't have so much data in our file
function cutline($filename,$line_no=-1) {
$strip_return=FALSE;
$data=file($filename);
$pipe=fopen($filename,'w');
$size=count($data);
if($line_no==-1) $skip=$size-1;
else $skip=$line_no-1;
for($line=0;$line<$size;$line++)
if($line!=$skip)
fputs($pipe,$data[$line]);
else
$strip_return=TRUE;
return $strip_return;
}
//strip the last result, don't mess with this, unless you know what you're doing, or course =)
//if the shoutbox is showing "Error on line x", and you recently changed this, check this and fix your file
$i = 1;
while($i<5)
{
cutline($file,1);
$i++;
}
//write the new shout
$fh = fopen($file, 'a') or die("Could not write to file.");
$shout = '
<tr>
<td align="right" width="18%">'.$name.' : </td>
<td align="left" width="81%">'.$m.'</td>
</tr>';
fwrite($fh, $shout);
fclose($fh);
//message on success
$message = "<input type=\"submit\" id=\"submit\" value=\"Send\"/>";
return $message;
}
//perform the function =)
echo(sendshout());
?>