Free web development scripts for the webmasterDevelopment Scripts

 Site Navigation
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 4 users online
 o Most users online: 67
 o Home
  o PHP
   o Online Communities
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Designer Baby Clothes
 o Advertise Here Make Money
 o Wedding Vendor Directory
 o OxyScripts
 o Open Source Design
 o devnet
 o designplace
 o Free Wedding Websites

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


Rate This Script

User Contributed Comments

On 06-09-2003 11:03 Devscripts said:

Let me know if you use this on your site please guys :)


On 27-09-2003 13:47 foo said:

It seems to have an error: Parse error: parse error, expecting `')'' in /my directory/shoutbox.php on line 9


On 29-09-2003 11:02 Devscripts said:

Make sure that you remove any newline characters that are added in when you copy and paste the code from the code area. If you still have trouble, post here and I will send you the code via email.


On 29-09-2003 11:10 Devscripts said:

OK I also changed one of the replace items which could have been causing a problem, so all should be well and good now :)


On 20-03-2005 23:43 Morse said:

Hi devscripts Have seen, and tried out your shoutbox, and i've found it remarkably good! So I was wondering, cause php aint a one of my forzas, if you maybe could help me getting your shoutbox int


On 20-03-2005 23:44 Morse said:

By the way, sorry for the soakingly bad lay out on my previous message ;)


Registered Members login
© Copyright 2003 - Devscripts.net