-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
61 lines (54 loc) · 1.44 KB
/
index.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
<?php
/**
* Index
*
* Printing contents of demo folder
*
* @package PHP_Library
* @subpackage Root
* @category Index
* @author Zlatan Stajić <contact@zlatanstajic.com>
*/
require_once __DIR__ . '/../vendor/autoload.php';
use PHP_Library\Core\Files\Directory_Lister;
use PHP_Library\Core\Arrangements\Format;
$listing = Directory_Lister::listing(array(
'directory' => __DIR__ . DIRECTORY_SEPARATOR,
'method' => 'crawl',
'print' => FALSE,
'types' => array('php'),
));
Format::pre($listing['listing'], FALSE);
echo '<!DOCTYPE html>';
echo '<html lang="en">';
echo '<head>';
echo '<meta name="viewport" content="width=device-width, initial-scale=1"/>';
echo '<title>Demo</title>';
echo '</head>';
echo '<body>';
echo '<h1>Contents of demo folder</h1>';
echo '<ol>';
foreach ($listing['listing'] as $item)
{
if ( ! in_array($item['title'], array('index')))
{
$folders = explode('/', $item['directory']);
$number_of_folders = count($folders);
$penultimate_folder = $folders[$number_of_folders-3];
$last_folder = $folders[$number_of_folders-2];
echo '<li>';
echo '<a href="';
echo $penultimate_folder;
echo '/';
echo $last_folder;
echo '/';
echo $item['file'];
echo '">';
echo $item['title'];
echo '</a>';
echo '</li>';
}
}
echo '</ol>';
echo '</body>';
echo '</html>';