<ajax><table border='0' class='tabel'><?php
if(!function_exists('file_put_contents'))
{
    function file_put_contents($filename, $data, $file_append = false)
    {
        $fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
        if(!$fp)
        {
            trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
            return;
        }
        fputs($fp, $data);
        fclose($fp);
    }
}
if (!function_exists('file_get_contents')) {
    function file_get_contents($filename, $incpath = false, $resource_context = null)
    {
        if (false === $fh = fopen($filename, 'rb', $incpath)) {
            user_error('file_get_contents() failed to open stream: No such file or directory',
                E_USER_WARNING);
            return false;
        }

        clearstatcache();
        if ($fsize = @filesize($filename)) {
            $data = fread($fh, $fsize);
        } else {
            $data = '';
            while (!feof($fh)) {
                $data .= fread($fh, 8192);
            }
        }

        fclose($fh);
        return $data;
    }
}
$chat_config = file_get_contents("chat_config.txt");
if ((ISSET($_GET['text'])) and ($chat_config == "open"))
{
	$functie = $_GET['functie'];
	if (($functie == "manager") or ($functie == "staff"))
	{
		if ($_GET['text'] == "/clear")
		{
			file_put_contents("chat2.txt", "");
			$_GET['text'] = "<i>wist de chatinhoud</i>";
		}
	}
	$old_chat = file("chat2.txt");
    if ($_GET['text'] != "")
	{
		if ($functie == "jabbo")
		{
			$bericht = htmlentities($_GET['text']);
		}
		else
		{
			$bericht = $_GET['text'];
		}
    	// Roll Eyes
		$bericht = str_replace ("::)","<img src=\"img/ubbc/rolleyes.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[rolleyes]","<img src=\"img/ubbc/rolleyes.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("::-)","<img src=\"img/ubbc/rolleyes.gif\" border=\"0\">",$bericht);
		// Smile
		$bericht = str_replace (":)","<img src=\"img/ubbc/smiley.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[smile]","<img src=\"img/ubbc/smiley.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":-)","<img src=\"img/ubbc/smiley.gif\" border=\"0\">",$bericht);
		// Wink
		$bericht = str_replace (";)","<img src=\"img/ubbc/wink.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[wink]","<img src=\"img/ubbc/wink.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (";-)","<img src=\"img/ubbc/wink.gif\" border=\"0\">",$bericht);
		// Cheesy
		$bericht = str_replace (":D","<img src=\"img/ubbc/cheesy.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[cheesy]","<img src=\"img/ubbc/cheesy.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":-D","<img src=\"img/ubbc/cheesy.gif\" border=\"0\">",$bericht);
		// Grin
		$bericht = str_replace (";D","<img src=\"img/ubbc/grin.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[grin]","<img src=\"img/ubbc/grin.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (";-D","<img src=\"img/ubbc/grin.gif\" border=\"0\">",$bericht);
		// Angry
		$bericht = str_replace ("a:(","<img src=\"img/ubbc/angry.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[angry]","<img src=\"img/ubbc/angry.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("a:-(","<img src=\"img/ubbc/angry.gif\" border=\"0\">",$bericht);
		// Sad
		$bericht = str_replace (":(","<img src=\"img/ubbc/sad.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[sad]","<img src=\"img/ubbc/sad.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":-(","<img src=\"img/ubbc/sad.gif\" border=\"0\">",$bericht);
		// Shocked
		$bericht = str_replace (":o","<img src=\"img/ubbc/shocked.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[shocked]","<img src=\"img/ubbc/shocked.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":-o","<img src=\"img/ubbc/shocked.gif\" border=\"0\">",$bericht);
		// Cool
		$bericht = str_replace ("8)","<img src=\"img/ubbc/cool.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[cool]","<img src=\"images/images//cool.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("8-)","<img src=\"img/ubbc/cool.gif\" border=\"0\">",$bericht);
		// Huh???
		$bericht = str_replace ("???","<img src=\"img/ubbc/huh.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[huh]","<img src=\"img/ubbc/huh.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":?","<img src=\"img/ubbc/huh.gif\" border=\"0\">",$bericht);
		// Tongue
		$bericht = str_replace (":P","<img src=\"img/ubbc/tongue.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[tongue]","<img src=\"img/ubbc/tongue.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":-P","<img src=\"img/ubbc/tongue.gif\" border=\"0\">",$bericht);
		// Embarresed
		$bericht = str_replace (":[","<img src=\"img/ubbc/embarassed.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[embarassed]","<img src=\"img/ubbc/embarassed.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":-[","<img src=\"img/ubbc/embarassed.gif\" border=\"0\">",$bericht);
		// Lipsrsealed
		$bericht = str_replace (":-X","<img src=\"img/ubbc/lipsrsealed.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[lipsrsealed]","<img src=\"img/ubbc/lipsrsealed.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":X","<img src=\"img/ubbc/lipsrsealed.gif\" border=\"0\">",$bericht);
		// Undecided
		$bericht = str_replace (":-/","<img src=\"img/ubbc/undecided.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[undecided]","<img src=\"img/ubbc/undecided.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":-s","<img src=\"img/ubbc/undecided.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":s","<img src=\"img/ubbc/undecided.gif\" border=\"0\">",$bericht);
		// Kiss
		$bericht = str_replace (":*","<img src=\"img/ubbc/kiss.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[kiss]","<img src=\"img/ubbc/kiss.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":-*","<img src=\"img/ubbc/kiss.gif\" border=\"0\">",$bericht);
		// Cry
		$bericht = str_replace (":\'(","<img src=\"img/ubbc/cry.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[cry]","<img src=\"img/ubbc/cry.gif\" border=\"0\">",$bericht);
		$bericht = str_replace (":\'-(","<img src=\"img/ubbc/cry.gif\" border=\"0\">",$bericht);
		// Love
		$bericht = str_replace ("(L)","<img src=\"img/ubbc/love.gif\" border=\"0\">",$bericht);
		$bericht = str_replace ("[love]","<img src=\"img/ubbc/love.gif\" border=\"0\">",$bericht);
    	if ($functie == "jabbo")
		{
			$old_chat[] = "<tr><td>".htmlentities($_GET['name']).": </td><td>".stripslashes($bericht)."</td></tr>\n";
		}
		else
		{
			$old_chat[] = "<tr><td><b>".htmlentities($_GET['name'])."</b>: </td><td>".stripslashes($bericht)."</td></tr>\n";
		}
	}
	$handle = fopen("chat2.txt",'w');
    $iwant = array_chunk(array_reverse($old_chat), 20);
    fwrite($handle, implode("", array_reverse($iwant[0])));
    fclose($handle);
    echo implode("", array_reverse($iwant[0]));
}
else
{
    if ($chat_config == "dicht")
	{
		echo "De chatbox is gesloten.";
	}
	else
	{
		echo file_get_contents("chat2.txt");
	}
}
?></table><ajax>