summaryrefslogtreecommitdiff
path: root/forum/utils/diagnostics.php
blob: 14e58bdef24d416c9234da9822a6f6f58a469e5a (plain)
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
<?php

function testResult($result, $reference, $yes = "yes", $no = "no")
{
	$str = "<div style=\"display: inline; color: ";
	if($result == $reference) $str .= "#090";
	else $str .= "#900; font-weight: bold";
	$str .= ";\">";
	if($result) $str .= $yes;
	else $str .= $no;
	$str .= "</div>";
	return $str;
}

function testFile($file, $readable, $writeable, $executable)
{
	echo "<tr>";
	echo "<td>" . $file . "</td>";
	echo "<td>" . testResult(file_exists($file), true) . "</td>";
	echo "<td>" . testResult(is_file($file), true, "file", "not file") . "</td>";
	echo "<td>" . testResult(is_readable($file), $readable) . "</td>";
	echo "<td>" . testResult(is_writeable($file), $writeable) . "</td>";
	echo "<td>" . testResult(is_executable($file), $executable) . "</td>";
	echo "</tr>\n";
}

function testLink($link, $readable, $writeable, $executable)
{
	echo "<tr>";
	echo "<td>" . $link . "</td>";
	echo "<td>" . testResult(file_exists($link), true) . "</td>";
	echo "<td>" . testResult(is_link($link), true, "link", "not link") . "</td>";
	echo "<td>" . testResult(is_readable($link), $readable) . "</td>";
	echo "<td>" . testResult(is_writeable($link), $writeable) . "</td>";
	echo "<td>" . testResult(is_executable($link), $executable) . "</td>";
	echo "</tr>\n";
}

function testDir($dir, $readable, $writeable, $executable)
{
	echo "<tr>";
	echo "<td>" . $dir . "</td>";
	echo "<td>" . testResult(file_exists($dir), true) . "</td>";
	echo "<td>" . testResult(is_dir($dir), true, "dir", "not dir") . "</td>";
	echo "<td>" . testResult(is_readable($dir), $readable) . "</td>";
	echo "<td>" . testResult(is_writeable($dir), $writeable) . "</td>";
	echo "<td>" . testResult(is_executable($dir), $executable) . "</td>";
	echo "</tr>\n";
}

?>
<table border="1px">
<tr><td width="30%">Name</td><td width="10%">Exists</td><td width="10%">Type</td><td width="10%">Readable</td><td width="10%">Writeable</td><td width="10%">Executable</td></tr>
<?php

//testLink("../forum", true, false, false);
testDir($UTIL_DIR, true, false, true);
testDir($DATA_DIR, true, true, true);
testDir("gfx/avatars", true, true, true);
testFile($DATA_DIR . "/forum.log", true, true, false);

#testFile("NOfile", true, true, true);
#testFile("/etc/passwd", true, true, true);
?>
</table>