<?php
// ASP response Object Implementation (PHP)
class response {
private $content;
private $bufferContent;
// TODO: response.Cookies
//--------------------
// Properties
//--------------------
public $Buffer = FALSE;
public $CacheControl; // TODO
public $Charset; // TODO
public $ContentType; // TODO
public $Expires; // TODO
public $ExpiresAbsolute; // TODO
public $IsClientConnected; // TODO
public $Pics; // TODO
public $Status; // TODO
//--------------------
// Methods
//--------------------
function AddHeader($name, $value) {
header("HTTP_{$name}: {$value}");
}
function AppendToLog($logText) {
$fp = fopen("_serverLog.log", "a");
fwrite($fp, "\n{$logText}");
fclose($fp);
}
// TODO
function BinaryWrite($array) { // This will probably never work :(
foreach($array as $byte) { // UNTESTED:
// print decbin($byte);
// print chr($byte);
} // /END
}
function Clear() {
if($this->Buffer === FALSE) return -1;
$this->bufferContent = "";
}
function End() {
if($this->Buffer === TRUE) echo $this->bufferContent;
die();
}
function Flush() {
if($this->Buffer === TRUE) echo $this->bufferContent;
}
function Redirect($uri) {
if (!preg_match('/(http:\/\//i', $str)) {
$uri = 'http://' . $uri;
}
@header("Location: {$uri}");
// If we haven't already been redirected for
// some strange reason, echo a meta tag.
echo "<meta http-equiv=\"REFRESH\" content=\"0;url={$uri}\">";
sleep(1);
// Still not redirected?
echo "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\nwindow.location=\"{$uri}\";\n//-->\n</script>";
sleep(3); // JS takes time to be parsed
// If we are STILL not redirected, the current webpage is weird
return 0;
}
function Write() {
$args = func_num_args();
if(!$args) return -1; // No arguments?
for($i=0; $i<$args; $i++) {
if($this->Buffer === TRUE) {
$this->bufferContent = func_get_arg($i);
} else {
echo func_get_arg($i);
}
}
}
}
class ___Cookies {
/* TODO */
}
?>