I have a shoutbox on my site called Ajap ahout, it's okay but it would be better if it autoformatted emoticons.
For example, when a user types ': )' it is translated into 🙂.
Would this be possible?
The code below is the function that sends the shout:
<?php
session_start();
?><br />
<?php
include $_SERVER['DOCUMENT_ROOT']."/arcade/bannedusers.php";
?>
<?php
/***************************************************************************
* sendshout_xml.php
* ---------------------------
* Shouts =)
*
* Customizations: If you change the structure, change the last write.
* You can also change all of the on die messages without
* worrying about screwing anything up =)
*
***************************************************************************/
/***************************************************************************
*
* AJAP Shout is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
function words($w)
{
$w=explode(" ",$w);
foreach($w AS $ww)
{
$new[]=badw($ww);
}
return implode(" ",$new);
}
$restricted=array("-","+"," ","'",',',"/","%","&",".","-","<",">","{","}","[","]","\\","=",":","#","&","@","_","!","(",")","*"," ");
function badw($data)
{
global $restricted;
$line = file('badwords.txt');
$line=explode(",",$line[0]);
// Count this array
foreach($line AS $k)
{
$data2=str_replace($restricted,"",$data);
if(strstr(strtolower($data2),strtolower($k)))
{
return '';
exit();
}
}
return htmlspecialchars($data);
}
function sendshout() {
//define shout varibles and st00f
$ip = $_SERVER['REMOTE_ADDR'];
$name = words($_GET['name']);
$m = strip_tags(words($_GET['message']));
if(!$name | !$m)
{
$message = "Removed, Please Input A Proper Name/Message.";
return $message;
die;
}
//define te xml file
$file = $_SERVER['DOCUMENT_ROOT']."/shoutbox/shouts.txt";
//cut lines, so we don't have so much data in our file
function cutline($filename,$line_no=-1) {
$strip_return=FALSE;
$data=file($filename);
$pipe=fopen($filename,'w');
$size=count($data);
if($line_no==-1) $skip=$size-1;
else $skip=$line_no-1;
for($line=0;$line<$size;$line++)
if($line!=$skip)
fputs($pipe,$data[$line]);
else
$strip_return=TRUE;
return $strip_return;
}
//strip the last result, don't mess with this, unless you know what you're doing, or course =)
//if the shoutbox is showing "Error on line x", and you recently changed this, check this and fix your file
$i = 1;
while($i<5)
{
cutline($file,1);
$i++;
}
//write the new shout
$fh = fopen($file, 'a') or die("Could not write to file.");
$shout = '
<tr>
<td align="right" width="18%"><!--'.$ip.'-->'.$name.' : </td>
<td align="left" width="81%">'.$m.'</td>
</tr>';
fwrite($fh, $shout);
fclose($fh);
//message on success
$message = "<input type=\"submit\" id=\"submit\" value=\"Send\"/>";
return $message;
}
//perform the function =)
echo(sendshout());
?>
(Please could you show me exactly where to put it as I'm a n00b 🙂
Any help is greatly appreciated,
w3rra.