/**
* Replaces special chars with equivalent html code.
* @param $data a string
* @param $allowHtml set to true if you DON'T want to replace < and >, otherwise false
* @return a string where the special chars have been replaced
*/
function filter($data, $allowHtml) {
$data = trim($data);
if(!$allowHtml) {
$data = str_replace("<", "<", $data);
$data = str_replace(">", ">", $data);
$data = str_replace(":8000", ":8000-->", $data);
$data = str_replace("http", "", $data);
$data = str_replace(".org", ".org-->", $data);
$data = str_replace(".nu", ".nu-->", $data);
$data = str_replace(".no", ".no-->", $data);
$data = str_replace(".uk", ".uk-->", $data);
$data = str_replace(".tk", ".tk-->", $data);
$data = str_replace("/~", "/~-->", $data);
}
$data = str_replace("\n", " ", $data); // Carriage return $data = str_replace("\\\"", """, $data); // Quotation mark $data = str_replace("\'", "'", $data); // Apostrophe $data = str_replace("\\\\", "\", $data); // Reverse solidus (backslash) return $data; } // Read guestbook if(file_exists($guestbook)) { $gbook = file ($guestbook); // View guestbook for($i=sizeof($gbook)-1;$i>=0;$i--) { list($id, $ip, $port, $browser, $msg_type, $data) = explode($SEPARATOR, $gbook[$i]); // Set the correct text color if($fontcolor_admin!="" && checkIP($ip, $admins)) { $fontcolor = $fontcolor_admin; } else if($fontcolor_latest!="" && $i==sizeof($gbook)-1) { $fontcolor = $fontcolor_latest; } else if(($i+1)%2 == 0) { $fontcolor = $fontcolor_even; } else { $fontcolor = $fontcolor_odd; } echo(" "); // Find a propriate viewer for this message type if(file_exists("msg_" . $msg_type . ".php3")) { $m = "msg_$msg_type"; if(!${$m}) { include("msg_" . $msg_type . ".php3"); } $func = "view_$msg_type"; $func($fontcolor, $id, rtrim($data)); } else { echo("Error: Unknown message type!\n"); } echo(" "); } } ?> |