summaryrefslogtreecommitdiff
path: root/forum/utils/diagnostics.php
diff options
context:
space:
mode:
Diffstat (limited to 'forum/utils/diagnostics.php')
-rw-r--r--forum/utils/diagnostics.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/forum/utils/diagnostics.php b/forum/utils/diagnostics.php
new file mode 100644
index 0000000..3bef120
--- /dev/null
+++ b/forum/utils/diagnostics.php
@@ -0,0 +1,64 @@
+<?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);
+testFile($DATA_DIR . "/forum.log", true, true, false);
+
+testFile("NOfile", true, true, true);
+testFile("/etc/passwd", true, true, true);
+?>
+</table> \ No newline at end of file