forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.php
83 lines (66 loc) · 2.03 KB
/
list.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
<?php
// Global
$files = dirToArray(dirname(__FILE__) . '/code');
$files = array_reverse($files);
$total = 0;
$demo = '';
foreach ($files as $key => $value)
{
if (is_array($value) && count($value) > 0)
{
$total += count($value);
}
}
function getFile() {
global $files, $dir, $filename, $title, $code;
if (isset($_GET['d']) && isset($_GET['f']))
{
$dir = urldecode($_GET['d']);
$filename = urldecode($_GET['d']) . '/' . urldecode($_GET['f']);
$title = urldecode($_GET['t']);
if (file_exists($filename))
{
$code = file_get_contents($filename);
$files = dirToArray($dir);
}
}
}
function dirToArray($dir) {
$ignore = array('.', '..', 'js', 'src', 'css', 'fonts', 'build', 'examples', 'assets');
$result = array();
$root = scandir($dir);
$dirs = array_diff($root, $ignore);
foreach ($dirs as $key => $value)
{
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
{
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
}
else
{
if (substr($value, -3) == '.js')
{
$result[] = $value;
}
}
}
return $result;
}
function printJSLinks($files) {
$output = "";
foreach ($files as $key => $value)
{
$value2 = substr($value, 0, -3);
$file = urlencode($value);
if ($_SERVER['SERVER_NAME'] == '192.168.0.100')
{
$output .= "<a href=\"../labs/view.php?f=$file\"><span data-hover=\"$value2\">$value2</span></a>";
}
else
{
$output .= "<a href=\"view.php?f=$file\"><span data-hover=\"$value2\">$value2</span></a>";
}
}
return $output;
}
?>