-
Notifications
You must be signed in to change notification settings - Fork 2
/
filesystem.class.php
executable file
·60 lines (52 loc) · 1.65 KB
/
filesystem.class.php
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
<?php
function mopen($myFile, $mode) {
for ($i = 1; $i <= 10; $i++) {
try {
$fh = fopen($myFile, $mode);
if (is_resource($fh)) return $fh;
} catch (Exception $e) {}
}
return null;
}
function read($myFile) {
$theData = "";
if (file_exists($myFile) && filesize($myFile) > 0) {
$fh = mopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
}
return $theData;
}
function write($myFile, $data) {
$fh = mopen($myFile, 'w+') or die("can't open file");
$stringData = $data;
fwrite($fh, $stringData);
fclose($fh);
}
function fappend($myFile, $data) {
$fh = mopen($myFile, 'a+') or die("can't open file");
$stringData = $data . "\n";
fwrite($fh, $stringData);
fclose($fh);
}
function mtime($myFile) {
$LastModified = 0;
if (file_exists($myFile)) {
$LastModified = filemtime($myFile);
}
return $LastModified;
}
function emu_getallheaders() {
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
$headers[$name] = $value;
} else if ($name == "CONTENT_TYPE") {
$headers["Content-Type"] = $value;
} else if ($name == "CONTENT_LENGTH") {
$headers["Content-Length"] = $value;
}
}
return $headers;
}
?>