summaryrefslogtreecommitdiffstats
path: root/log_files.php
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-09-10 08:07:12 +0000
committerRomain d'Alverny <rda@mageia.org>2012-09-10 08:07:12 +0000
commit8e44f84b9d02dd5b9c8458f439dc3e89679aa25c (patch)
tree7578fd0bd78c2c7b88b0a1fec41d70a8c93937c5 /log_files.php
parentcf16eec875de2a1dc13d569729c8565e9ade9fa5 (diff)
downloadpkgsubmit-8e44f84b9d02dd5b9c8458f439dc3e89679aa25c.tar
pkgsubmit-8e44f84b9d02dd5b9c8458f439dc3e89679aa25c.tar.gz
pkgsubmit-8e44f84b9d02dd5b9c8458f439dc3e89679aa25c.tar.bz2
pkgsubmit-8e44f84b9d02dd5b9c8458f439dc3e89679aa25c.tar.xz
pkgsubmit-8e44f84b9d02dd5b9c8458f439dc3e89679aa25c.zip
show files tree structure
Diffstat (limited to 'log_files.php')
-rw-r--r--log_files.php66
1 files changed, 40 insertions, 26 deletions
diff --git a/log_files.php b/log_files.php
index 7c365b9..4648a6f 100644
--- a/log_files.php
+++ b/log_files.php
@@ -34,44 +34,23 @@ if (!is_dir($path)) {
die('Sorry, not found');
}
-$glob = $path . '/*';
-$s = sprintf('<h4>%s</h4>', $job);
-$s .= '<ul>';
-
-foreach (glob_recursive($glob) as $f) {
- if (is_dir($f))
- continue;
-
- $link = 'uploads' . str_replace($upload_dir, '', $f);
- $show = str_replace(array($path . '/', '/'), array('', ' / '), $f);
- $s .= sprintf('<li><a href="%s" rel="nofollow" class="view-inline">%s</a> (%s)</li>',
- $link, $show,
- _format_bytes(filesize($f))
- );
-}
+$list = glob_recursive_tree($path . '/*');
$others = array(
'.youri',
'_i586.done',
'_x86_64.done'
);
+
foreach ($others as $suffix) {
$f = $path . $suffix;
if (file_exists($f)) {
- $link = 'uploads' . str_replace($upload_dir, '', $f);
- $show = explode($path, $f);
- $show = $job . $suffix;
- $s .= sprintf('<li><a href="%s" rel="nofollow" class="view-inline">%s</a> (%s)</li>',
- $link, $show,
- _format_bytes(filesize($f))
- );
+ $list[] = $f;
}
}
-$s .= '</ul>';
-
-echo $s;
-
+echo sprintf('<h4>%s</h4>', $job),
+ print_list($list);
// lib code below.
@@ -129,3 +108,38 @@ function glob_recursive($pattern, $flags = 0)
return $files;
}
+
+function glob_recursive_tree($pattern, $flags = 0)
+{
+ $files = glob($pattern, $flags);
+ foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
+ $dirtop = explode('/', $dir);
+ $files[end($dirtop)] = glob_recursive_tree($dir . '/' . basename($pattern), $flags);
+ }
+
+ return $files;
+}
+
+function print_list($list)
+{
+ global $upload_dir, $path;
+
+ $l = array();
+ foreach ($list as $f) {
+ if (!is_string($f)) {
+ continue;
+ }
+
+ if (is_dir($f)) {
+ $top = basename($f);
+ $l[] = sprintf('<li><span class="dir">%s</span>%s</li>', $top, print_list($list[$top]));
+ } elseif (file_exists($f)) {
+ $l[] = sprintf('<li><a href="%s" rel="nofollow" class="view-inline">%s</a> (%s)</li>',
+ 'uploads' . str_replace($upload_dir, '', $f),
+ basename($f),
+ _format_bytes(filesize($f))
+ );
+ }
+ }
+ return sprintf('<ul>%s</ul>', implode($l));
+}