(root)/wiki/index.php - Rev 387
Rev 367 |
Rev 486 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
<?php
function endswith
($string, $test) {
$strlen = strlen($string);
$testlen = strlen($test);
if ($testlen > $strlen) return false;
return substr_compare($string, $test, -$testlen) === 0;
}
require '../_taios.php';
$pageName = $_GET['page'];
if (empty($pageName))
{
$pageName = 'Index';
}
$page = new Taios_Page
('Wiki - ' . $pageName, '../');
if (isset($_GET['random']))
{
$results = array();
$handler = opendir('pages/');
while ($file = readdir($handler))
{
if ($file != '.' && $file != '..' && endswith
($file, ".txt"))
{
$results[] = substr($file, 0, count($file) - 5);
}
}
$index = rand() % count($results);
$result = $results[$index];
$page->redirect('index.php?page=' . $result);
}
$page->drawHeader();
write
('<h3>Wiki</h3>');
$page->drawMenuItem('Index', 'wiki/index.php');
$page->drawMenuItem('Random Page', 'wiki/index.php?random');
$page->drawMiddle();
if ($page->isUserGM($page->getLoggedInUser()))
{
write
('<p><a href="edit.php?page=' . $pageName . '">Edit Page</a></p><br />');
}
$filename = 'pages/' . $pageName . '.txt';
$fp = @fopen($filename, 'r');
if ($fp)
{
write
('<p>' . $page->replaceBBCode(fread($fp, filesize($filename))) . '</p>');
fclose($fp);
}
else
{
write
('<p>This page is empty.</p>');
}
$page->drawFooter();
?>