Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (40 sloc) 1.387 kb
<?php
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docs';
if (isset($_REQUEST['doc']) && !empty($_REQUEST['doc'])) {
$doc = $dir . '/' . $_REQUEST['doc'];
if (($fullpath = realpath($doc)) && file_exists($fullpath) && stripos($fullpath, $dir, 0) === 0) {
echo '<link rel="stylesheet" href="assets/css/styles.css">';
echo '<div class="box box-text documentation">';
$output = file_get_contents($fullpath);
$output = preg_replace('#src="\.\.\/\.\.\/\.\.\/#', 'src="', $output);
echo $output;
echo '</div>';
}
} else {
$iterator = new RecursiveDirectoryIterator($dir);
$renderer = function ($iterator) use (&$renderer, $dir) {
$html = array();
foreach ($iterator as $path) {
if ($path->isDir()) {
$html[] = "\n<li>";
$html[] = $path->getBaseName();
$html[] = '<ul>';
$html[] = $renderer(new RecursiveDirectoryIterator($path));
$html[] = '</ul>';
$html[] = '</li>';
} else {
$link = ltrim(preg_replace('/^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $dir), '/').'/i', '', str_replace(DIRECTORY_SEPARATOR, '/', $path)), '/');
$html[] = "\n<li>";
$html[] = '<a href="index.php?doc='.urlencode($link).'">'.$path->getBaseName().'</a>';
$html[] = '</li>';
}
}
return implode("\n", $html);
}
?>
<h1>Documentation</h1>
<ul class="sections">
<?php echo $renderer($iterator); ?>
</ul>
<?php
}
Jump to Line
Something went wrong with that request. Please try again.