32 || strlen($_REQUEST['shout_comment']) > 255)
$_REQUEST['op'] = 'get';
switch($_REQUEST['op'])
{
case 'add':
//make sure there is no HTML to get in the way
strip_tags($_REQUEST['shout_comment']);
$sql = "INSERT INTO ".$database['prefix']."shoutbox (name, comment) VALUES ('".$_REQUEST['shout_name']."','". $_REQUEST['shout_comment']."')";
$recordSet = $db->Execute($sql);
if ($recordSet === false)
{
$error->setError(ERR_DATABASE, $sql);
return false;
}
//don't break, we want to always retreive the updated data
case 'get':
$sql = "SELECT * FROM ".$database['prefix']."shoutbox ORDER BY 'timestamp' DESC";
$recordSet = $db->Execute($sql);
if ($recordSet === false)
{
$error->setError(ERR_DATABASE, $sql);
return false;
}
//now that we have them, format the first 4, or show more depending on user action.
$return_data = ""; //initialize variable for good measure.
if(!isset($_REQUEST['sn']) || !is_numeric($_REQUEST['sn']))
$shout_num = 4; //4 is default
else
$shout_num = $_REQUEST['sn'];
for($i=0; $i < $shout_num; $i++)
{
if($recordSet->EOF)
return;
$recordSet->fields['comment'] = wordwrap($recordSet->fields['comment'], 36, "\n
\n", 1);
$return_data .= "
".$recordSet->fields['comment']."
by: ".$recordSet->fields['name']."