-
Notifications
You must be signed in to change notification settings - Fork 0
/
gantry.functions.php
72 lines (63 loc) · 1.91 KB
/
gantry.functions.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
<?php
function maker($destination)
{
if (!is_dir($destination) && !@mkdir($destination)) {
$parent = pathinfo($destination,PATHINFO_DIRNAME);
maker($parent);
return maker($destination);
}
return false;
}
function old($var){
return (isset($_SESSION['post']) && isset($_SESSION['post'][$var]))?$_SESSION['post'][$var]:false;
}
function runner($listing,$fpath,$lmod,$exception_patterns)
{
if (in_array($fpath, $exception_patterns)) return $listing;
$dir = pathinfo($fpath, PATHINFO_DIRNAME);
$listing = saveDir($listing, $dir);
if (!is_dir($fpath) && filemtime($fpath) >= $lmod) {
// echo $fpath.'::::::::::::'.date('d-m-Y H:i:s',filemtime($fpath)).'<br>';
return saver($listing, $fpath);
}
$set = glob(rtrim($fpath,'/').'/*');
foreach ($set as $key => $value) {
$listing = runner($listing, $value, $lmod, $exception_patterns);
}
return $listing;
}
function saver($listing,$fpath)
{
$dir = pathinfo($fpath, PATHINFO_DIRNAME);
$fn = pathinfo($fpath,PATHINFO_BASENAME);
if (!isset($listing['files']) || !is_array($listing['files'])) {
$listing['files'] = [];
}
if (!isset($listing['files'][$dir]) || !is_array($listing['files'][$dir])) {
$listing['files'][$dir] = [];
}
if (!in_array($fn, $listing['files'][$dir])) {
$listing['files'][$dir][] = $fn;
}
return $listing;
}
function saveDir($listing, $fpath)
{
$dir = pathinfo($fpath, PATHINFO_DIRNAME);
$fn = pathinfo($fpath,PATHINFO_BASENAME);
// print_r(pathinfo($fpath));
if (!isset($listing['dir']) || !is_array($listing['dir'])) {
$listing['dir'] = [];
}
if (!isset($listing['dir'][$dir]) || !is_array($listing['dir'][$dir])) {
$listing['dir'][$dir] = [];
}
if (!in_array($fn, $listing['dir'][$dir])) {
$listing['dir'][$dir][] = $fn;
}
if (!isset($listing['dir'][$fpath]) || !is_array($listing['dir'][$fpath])) {
$listing['dir'][$fpath] = [];
}
return $listing;
}
?>