[color=green]/************* CONFIGURATION *****************/
// your database file, it will be created automatically if it doesnt exist[/color]
$filename = "./shoutdb.txt";
[color=green]// use mask for link and email (yes/no). If yes, every link and email in your shoutbox will be displayed as [link] or [email] respectively (defined as below).[/color]
$usemask = "yes";
$link_mask = "[link]";
$email_mask = "[email]";
[color=green]// the smiley directory. This is where you place all images for smilies.[/color]
$smileydir = './images/';
[color=green]// define your own smilies
// the shout containing characters like they are defined on the left hand side will be replaced by an image on the right.
// you could add more or change them to whatever you'd like[/color]
$smileys = array (
"[:)]" => "smile.gif",
"[:))]" => "lol.gif",
"[:(]" => "sad.gif",
);
[color=green]/************* FUNCTIONS *****************/
// this will prepare all smilies[/color]
function alter_smiley(&$item1, $key, $prefix) {
$item1 = " ";
}
[color=green]// bad words filter, you should add your own ones here[/color]
function removeBadWords(&$text) {
$badwords = array(
"/fu[color=gray].[/color]ck/",
"/sh[color=gray].[/color]it/"
);
for ($i=0;$i";
elseif(!$shout) $errorMsg.="You need to make a shout! ";
elseif(($name=="Name") || ($shout=="Message")) $errorMsg.="Slacker! Say something mate. ";
[color=green]// Good, now the essentials are taken care of! "
// Let's make the name display a link if there is a site specified.[/color]
else {
if($site) $author = "$name";
else $author = $name;
[color=green]// Now we should open the file, or make it if it's not there![/color]
$handle = fopen($filename,"a");
[color=green]// Date...[/color]
$date = strftime("%D");
$time = strftime("%T");
$ipaddr = $REMOTE_ADDR;
removeBadWords($shout);
[color=green]// this is how a shout will be stored in your database file[/color]
[color=green]// you can change this to your taste but do remember to change the code reading the file[/color]
$data = "$author | $date | $time | $ipaddr | $shout\n";
fwrite($handle,"$data");
fclose($handle);
}
}
echo $errorMsg;
[color=green]/************* SHOW FORM *****************/[/color]
echo "
\n";
echo "
\n";
echo "
\n";
[color=green]/************* DISPLAY SHOUT *****************/
// This makes an array with each line in the file [/color]
$shouts = file($filename);
$rowColor = 0;
$count = 0;
array_walk ($smileys, 'alter_smiley', $smileydir);
[color=green]// We'll add krsort right here! [/color]
krsort($shouts);
[color=green]// This does the same thing to each part...[/color]
$link_search = array("/\",
"/\>/",
"/\]/",
"/\[/",
"#([\n ])([a-z0-9\-_.]+?)@([^, \n\r]+)#i",
"#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \n\r]*)?)#i",
"/(?\s]+)/i");
if ($usemask=='yes')
$link_replace = array("<",
">",
">",
"<",
"\\1".$email_mask."",
"\\1".$link_mask."",
"".$link_mask."");
else
$link_replace = array("<",
">",
">",
"<",
"\\1\\2@\\3",
"\\1www.\\2.\\3\\4",
"\\0");
foreach($shouts as $sbox) {
$count++;
[color=green]// We'll split it into another array with list and explode.[/color]
[color=green]// If you have changed the way data stored, please modify the following line too[/color]
list($auth,$date,$time,$ipaddr,$shout) = explode(" | ", $sbox);
$shout = " ".$shout;
$shout = preg_replace($link_search, $link_replace, $shout);
$shout = strtr($shout, $smileys);
$shout = chop($shout);
[color=green]// Now, we have to output it![/color]
echo "