Exemplo n.º 1
0
<?php

include dirname(__FILE__) . '/../inc/common.php';
// Get parameters
if (empty($_GET['term'])) {
    die('false');
}
$term = $_GET['term'];
if (get_magic_quotes_gpc()) {
    $term = stripslashes($term);
}
$search = new Wiki_Search();
$filePaths = $search->find($term);
$urls = array();
foreach ($filePaths as $filePath) {
    if (!isOutsideWiki($filePath)) {
        $urls[] = '"' . getFileUrl($filePath) . '"';
    }
}
// Print the file urls
echo '[';
echo implode(', ', $urls);
echo ']';
Exemplo n.º 2
0
<?php

include dirname(__FILE__) . '/../inc/common.php';
// Get the raw content
$path = $_GET['path'];
$directoryPath = BASE_PATH . '/' . $path;
// Check invalid directory
if (isOutsideWiki($directoryPath)) {
    header('HTTP/1.1 404 Not Found');
    exit;
}
// Page title
$directoryPath = realpath($directoryPath);
$pathInfo = explode('/', $directoryPath);
$title = $pathInfo[count($pathInfo) - 1];
// Browse
$folders = array();
$files = array();
if ($handle = opendir($directoryPath)) {
    while (false !== ($name = readdir($handle))) {
        if (!in_array($name, array('.', '..', '.htaccess', '.wiki'))) {
            if (is_dir($directoryPath . '/' . $name)) {
                $folders[$name] = '<li><a class="folder" href="' . $name . '/">' . $name . '</a></li>';
            } else {
                $files[$name] = '<li><a class="file" href="' . $name . '">' . $name . '</a></li>';
            }
        }
    }
    closedir($handle);
}
ksort($folders);