PDA

View Full Version : Tutorial: Shoutbox



Colin-Roberts
30-09-2006, 12:26 PM
ok now im just bored not explained atall but w.e

Shoutbox.htm

<html>
<head>
<title>Shout box</title>
<style type="text/css"> body { background-color: #dedede; font-family: verdana; font-size: 10px; color: #000000; } </style>
</head>
<body>
<font size=1> <font face='verdana'>

<iframe name="messages" src="content.php" marginwidth="1" marginheight="0" height="200"

width="400" border="0" frameborder="0"></iframe>
<center>
<FORM name="shout" action="/addtag.php" method="POST" onSubmit="return wordFilter('form1',['name','email','subject','message']);">
<font size="1" face="verdana">
Your Name:<br>
<INPUT TYPE="TEXT" name="name" size="20"><br><br>
Your Message:<br>

<TEXTAREA NAME="message" COLS=16 ROWS=2></TEXTAREA><br>
<br>
<INPUT TYPE="Submit" name="submit" value="Submit Your Shout" size="20" >
</FORM>
</center>
</font>

</body>
</html>

addtag.php

<?php

$name = $_POST['name']; //form handler
$website = $_POST['website'];
$message = $_POST['message'];

if(empty($name) OR empty($message))
{
echo "

<script language='javascript'>

alert('You need to fill out both of the form fields...');

</script>
";

}
else
{

echo "

<script language='javascript'>

alert('Thanks for your message $name...'); //echos thank you message with name

</script>
";
$name = htmlspecialchars($name);
$message = htmlspecialchars($message);
$tag = ("<font size=\"1\" face=\"Verdana\">
<b>$name</b>: $message </font><br><br>");
function filter($tag)
{
$bad_words = explode(',', "tomato,lettuce,carrot,potato,broccoli,cucumber,pea" );
foreach ($bad_words as $naughty)
{
$tag = eregi_replace($naughty, "****", $tag);
}
return $tag;
}
function filter2($contents)
{
$bad_words = explode(',', "tomato,lettuce,carrot,potato,broccoli,cucumber,pea" );
foreach ($bad_words as $naughty)
{
$contents = eregi_replace($naughty, "****", $contents);
}
return $contents;
}

$read = fopen("content.txt", "r");
$contents = fread($read, filesize('content.txt')); // reads content.txt
fclose($read);

$write = fopen("content.txt", "w"); //insterts data into content.txt
fwrite($write, "$tag $contents");
fclose($write);
}
$input = $contents;
$output = filter($input);
echo $output;
$input = $tag;
$output = filter($input);
echo $output;

print "<meta http-equiv=\"refresh\" content=\"0;shoutbox.php\">";
//refreshes page
// Copyright 2006 - 2007 Colin-Roberts.net

?>
might want to change copyrite at bottom

Make a file called content.txt and chmod to 777

Content.php

<html>
<head>
<style type="text/css"> body { background-color: #fffffff; font-family: verdana; font-size: 10px; color: #000000; } </style>
<!--END WORD FILTER JAVASCRIPT-->
</head>
<body>
<left>
<META HTTP-EQUIV="refresh" CONTENT="20">
<?php include('content.txt'); ?>
</left>
</body>
</html>

thats it.

Want to hide these adverts? Register an account for free!