Ultra secure shoutbox lite (Rated 4.4)Description:
OK written this tiny shoutbox (under 30 lines of code).
Features:
- :) to Image converter
- Swear filter
- Ultra Secure
- Flood Control
- IP Banning
- CSS for customisation
All in under 30 lines of code including the form and CSS styles!!
This was a little test to see who could produce the smallest most secure shout box ever.
This is my effort and I'm pretty pleased with it!
Check it out here (http://www.rendells.net/shout/shout.php) Code starts here
-- SQL to create shoutbox table
CREATE TABLE `shout` (
`message` text NOT NULL,
`time` int(11) NOT NULL,
`ip` text NOT NULL,
`name` text NOT NULL,
`banned` tinyint(4) NOT NULL default '0'
) TYPE=MyISAM;
-- shout.php
<style type="text/css">
body,textarea,input,h2 {font-size: 8pt; font-family: arial;}
h1 {font-size: 10pt; font-family: arial; color: #FFFFFF; background-color: #4C5D8D;}
</style>
<?PHP
$connection = mysql_connect('dbhost','dbusername','dbpasswd') or die(mysql_error());
mysql_select_db('database_name', $connection) or die(mysql_error());
function filter($text) {
$replace=array(':)'=>' <img src="smile.gif">',':('=>' <img src="sad.gif">',':D'=>' <img src="biggrin.gif">',':p'=>' <img src="tongue.gif">',';)'=>' <img src="wink.gif">','\''=>'',';'=>'','--'=>'');
foreach($replace as $old=>$new) $text = str_replace($old,$new,$text);
return $text ;
}
if(isset($_POST['submit'])) {
$result = mysql_query("select max(`time`), max(`banned`) from `shout` where `ip` = '".$_SERVER['REMOTE_ADDR']."'");
$result = mysql_fetch_array($result);
$name = filter(wordwrap(htmlentities($_POST['name']),25,'<br />',1));
$message = filter( substr( wordwrap( nl2br( htmlentities($_POST['message'])),32,'<br />',1),0,250));
if (((time() - $result[0]) > 30) && ($result[1]!=1))
mysql_query("insert into shout(`name`,`time`,`message`,`ip`) values('$name','".time()."','$message','".$_SERVER['REMOTE_ADDR']."')");
else echo "<div style=\"background-color:#99CCFF;\"><h2>Slow down!</h2 ></div>";
}
$resultSet = mysql_query("select `name`, `time`, `message` from `shout` order by `time` desc limit 5");
while ($record = mysql_fetch_assoc($resultSet))
echo "<div><h1>".$record['name']." - ".date("H:i",$record['time'])."</h1>\n".$record['message']."</div>" ;
?>
<form action="shout.php" method="post" name="shout">
<input name="name" type="text" value="" size="23" maxlength="20"><br />
<textarea name="message" cols="20" rows="5" maxlength="100"></textarea><br />
<input name="submit" type="submit" value="submit">
</form>
Submitted by Devscripts on 05-09-2003 17:16 |