Menu

[r5]: / response.php  Maximize  Restore  History

Download this file

95 lines (78 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?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 */
}
?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.