diff options
author | deva <deva> | 2008-10-11 13:57:06 +0000 |
---|---|---|
committer | deva <deva> | 2008-10-11 13:57:06 +0000 |
commit | 534c0058a2e04fc9e9588189a7c9b87756c3df61 (patch) | |
tree | 5bd3bb0928797bfc2f51ddb2616dba7908ebd948 /forum | |
parent | b3ad20b02998a5d12819a1530d6a14a20751eb05 (diff) |
Added basis admin diagnostics page... to be expanded later.
Diffstat (limited to 'forum')
-rw-r--r-- | forum/htdocs/index.php | 13 | ||||
-rw-r--r-- | forum/utils/diagnostics.php | 64 |
2 files changed, 74 insertions, 3 deletions
diff --git a/forum/htdocs/index.php b/forum/htdocs/index.php index d4547e9..99169ab 100644 --- a/forum/htdocs/index.php +++ b/forum/htdocs/index.php @@ -38,10 +38,13 @@ include_once($UTIL_DIR . "/clientinfo.php"); <body> <div class="menu"> <a href="?mode=forum">Forum</a> -<?php /* <a href="?mode=filehandler">Filehandler</a> */ ?> + <a href="?mode=filehandler">Filehandler</a> <a href="?mode=calendar">Calendar</a> - <a href="?mode=profile">Profile</a> -</div> + <a href="?mode=profile">Profile</a><?php + if($current_user->uid == 0) { +?> <a href="?mode=diagnostics">Diagnostics</a><?php + } +?></div> <?php @@ -75,6 +78,10 @@ if($current_user) { include_once($UTIL_DIR. "/filehandler.php"); break; + case "diagnostics": + include_once($UTIL_DIR. "/diagnostics.php"); + break; + case "view": default: include_once($UTIL_DIR. "/view.php"); 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 |