-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfiles.php
46 lines (37 loc) · 1.08 KB
/
files.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
<?php
// files.php -- Utility functions for files
// get_file_list
function get_file_list($path) {
$files = array();
if (!is_dir($path)) { return $files; }
$items = scandir($path);
foreach ($items as $item) {
$item_path = $path . DIRECTORY_SEPARATOR . $item;
if (is_dir($item_path)) {
$files[] = $item;
}
}
return $files;
}
// get_dir_list
function get_dir_list($path) {
$files = array();
if (!is_dir($path)) { return $files; }
$items = scandir($path);
foreach ($items as $item) {
$item_path = $path . DIRECTORY_SEPARATOR . $item;
if (is_dir($item_path)) {
$files[] = $item;
}
}
return $files;
}
// read_file
// $text = readfile('index.php');
// file_put_contents('/ex04.php', read_file('index.php'));
function read_file($path) {
$text = file_get_contents($path);
$text = htmlspecialchars($text);
return $text;
}
?>