-
Notifications
You must be signed in to change notification settings - Fork 0
/
dir.php
106 lines (91 loc) · 3.94 KB
/
dir.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
include_once dirname(__FILE__) . '/commons.php';
use \Michelf\Markdown; // dependencies Markdown
if( !defined('DISPLAY_HTML') )
define('DISPLAY_HTML', true);
if( !defined('DISPLAY_UP') )
define('DISPLAY_UP', true);
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
$displayDir = preg_replace('`^(' . BASEDIR . ')`sUi', DIRECTORY_SEPARATOR, $baseDir);
$displayDir = preg_replace('`/{1,}`', DIRECTORY_SEPARATOR, $displayDir);
$dirToExplore = trim($_SERVER['REQUEST_URI'], '/');
$tabIndex = 1;
$ariane = explode(DIRECTORY_SEPARATOR, trim($dirToExplore, DIRECTORY_SEPARATOR));
$ariane = array_merge(array('/' => 'rb(π)'), array_combine($ariane, $ariane));
$optionDirectory = RBPiFiles::getOptions(ROOT_RBPI . $dirToExplore);
if( DISPLAY_HTML ): ?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>rb(π) - <?php echo ucfirst($dirToExplore); ?></title>
<meta name="author" content="Olivarès Georges" />
<link rel="stylesheet" href="<?php echo BASEDIR_RBPI; ?>/web/style.css">
</head>
<body class="directory">
<div>
<div class="content">
<div id="background"></div>
<?php endif; ?>
<h1>
<span class="pi">Index of</span>
<ul class="ariane">
<?php $dirs = array(); $i = 0; foreach( $ariane as $path => $dir ): if( empty($dir) ) continue; $dirs[] = $path; $i++; ?>
<li><a data-id="<?php echo $i > 1 ? $dir : null; ?>" href="<?php echo DIRECTORY_SEPARATOR . trim(implode(DIRECTORY_SEPARATOR, $dirs), DIRECTORY_SEPARATOR); ?>" class="<?php echo $i == 1 ? 'pi' : 'ppi'; ?><?php echo $i == count($ariane) - 1 ? ' prev' : null; ?>"><?php echo $dir; ?></a></li>
<?php endforeach; ?>
</ul>
</h1>
<?php if( $optionDirectory['description'] ): ?>
<p class="description"><?php echo $optionDirectory['description']; ?></p>
<?php endif; ?>
<table class="files">
<thead>
<tr>
<th> </th>
<th>Name</th>
<th>Last modified</th>
<th>Size</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php foreach( RBPiFiles::getList(ROOT_RBPI . $dirToExplore) as $href => $dir ):
if( !DISPLAY_UP && in_array($href, array('/.', '/..'))) continue;
?>
<tr tabindex="<?php echo $tabIndex++; ?>">
<td class="icon">
<img src="<?php echo $dir['icon']; ?>" alt="[DIR] <?php echo $dir['icon']; ?>" />
</td>
<td>
<a tabindex="-1" id="<?php echo urlencode($dir['name']); ?>" href="<?php echo trim($href, DIRECTORY_SEPARATOR); ?>" class="link"><?php echo $dir['name']; ?></a>
</td>
<td>
<?php echo date(trim(DATE_RFC1036, ' O'), $dir['modified']); ?>
</td>
<td>
<?php if( $dir['size'] ): ?>
<?php echo preg_replace('`([a-zA-Z]+)`', '<span class="ppi">$1</span>', size2String($dir['size'])); ?>
<?php else: ?>
<span class="pi">-</span>
<?php endif; ?>
</td>
<td>
<?php echo $dir['description']; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if( file_exists($f = ROOT_RBPI . $dirToExplore . DIRECTORY_SEPARATOR . 'readme.md') OR file_exists($f = ROOT_RBPI . $dirToExplore . DIRECTORY_SEPARATOR . 'README.md') ): ?>
<div class="md">
<?php echo preg_replace('`href="(.[^"]+)"`sUi', 'href="$1" tabindex="-1"', Markdown::defaultTransform(file_get_contents($f))); ?>
</div>
<?php endif; ?>
<?php echo $_SERVER['SERVER_SIGNATURE']; ?>
<?php if( DISPLAY_HTML ): ?>
</div>
</div>
<script src="<?php echo BASEDIR_RBPI; ?>/web/jquery.min.js"></script>
<script src="<?php echo BASEDIR_RBPI; ?>/web/jquery.scrollTo.min.js"></script>
<script src="<?php echo BASEDIR_RBPI; ?>/web/scripts.js"></script>
</body>
</html><?php endif; ?>