header("Location: http://www.modernmethod.com/sajax/sajax-0.11/php/example_wall.php");
exit;
require("Sajax.php");
//
// The world's least efficient wall implementation
//
function colorify_ip($ip)
{
$parts = explode(".", $ip);
$color = sprintf("%02s", dechex($parts[1])) .
sprintf("%02s", dechex($parts[2])) .
sprintf("%02s", dechex($parts[3]));
return $color;
}
function add_line($msg) {
$f = fopen("/tmp/wall.html", "a");
$dt = date("Y-m-d h:i:s");
$msg = strip_tags(stripslashes($msg));
$remote = $_SERVER["REMOTE_ADDR"];
// generate unique-ish color for IP
$color = colorify_ip($remote);
fwrite($f, "$dt $msg
\n");
fclose($f);
}
function refresh() {
$lines = file("/tmp/wall.html");
// return the last 25 lines
return join("\n", array_slice($lines, -25));
}
$sajax_request_type = "GET";
sajax_init();
sajax_export("add_line", "refresh");
sajax_handle_client_request();
?>