Subversion Repositories taios

Rev

Rev 366 | Rev 368 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
169 tom 1
<?php
2
 
365 tom 3
function endswith($string, $test) {
4
    $strlen = strlen($string);
5
    $testlen = strlen($test);
6
    if ($testlen > $strlen) return false;
7
    return substr_compare($string, $test, -$testlen) === 0;
8
}
9
 
169 tom 10
require '../_taios.php';
11
 
224 tom 12
$pageName = $_GET['page'];
225 tom 13
if (empty($pageName))
221 tom 14
{
224 tom 15
    $pageName = 'Index';
221 tom 16
}
169 tom 17
 
227 tom 18
$page = new Taios_Page('Wiki - ' . $pageName, '../');
365 tom 19
 
20
if (isset($_GET['random']))
21
{
22
    $results = array();
366 tom 23
    $handler = opendir('pages/');
365 tom 24
    while ($file = readdir($handler))
25
    {
26
        if ($file != '.' && $file != '..' && endswith($file, ".txt"))
27
        {
367 tom 28
            $results[] = substr($file, 0, count($file) - 5);
365 tom 29
        }
30
    }
31
 
32
    $index = rand() % count($results);
33
    $result = $results[$index];
34
    $page->redirect('index.php?page=' . $result);    
35
}
36
 
227 tom 37
$page->drawHeader();
361 tom 38
write('<h3>Wiki</h3>');
364 tom 39
$page->drawMenuItem('Index', 'wiki/index.php');
40
$page->drawMenuItem('Random Page', 'wiki/index.php?random');
227 tom 41
$page->drawMiddle();
42
 
305 tom 43
write('<p><i>The wiki is still under construction.</i></p>');
44
 
228 tom 45
if ($page->isUserGM($page->getLoggedInUser()))
46
{
47
    write('<p><a href="edit.php?page=' . $pageName . '">Edit Page</a></p><br />');
48
}
49
 
225 tom 50
$filename = 'pages/' . $pageName . '.txt';
51
 
230 tom 52
$fp = @fopen($filename, 'r');
221 tom 53
if ($fp)
54
{
226 tom 55
    write('<p>' . $page->replaceBBCode(fread($fp, filesize($filename))) . '</p>');
221 tom 56
    fclose($fp);
57
}
58
else
59
{
60
    write('<p>This page is empty.</p>');
61
}
62
 
169 tom 63
$page->drawFooter();
64
 
65
?>
66