diff options
author | Parabola <dev@list.parabolagnulinux.org> | 2014-07-24 00:26:38 +0000 |
---|---|---|
committer | Parabola <dev@list.parabolagnulinux.org> | 2014-07-24 00:26:38 +0000 |
commit | 9a26239bb835d2d9687c04ad307901a40ddf45e1 (patch) | |
tree | 7232afe4ae2abed0d8f67f3361da471fa446a9cd /index.php |
initial commit
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/index.php b/index.php new file mode 100644 index 0000000..95a8af1 --- /dev/null +++ b/index.php @@ -0,0 +1,123 @@ +<?php +$repos_arch_project = [ 'core', 'extra', 'staging', 'testing', 'gnome-unstable', 'kde-unstable' ]; +$repos_arch_community = [ 'community', 'community-staging', 'community-testing', + 'multilib', 'multilib-staging', 'multilib-testing' ]; +$repos_para_project = [ 'libre', 'libre-testing', + 'libre-multilib', 'libre-multilib-testing' ]; +$repos_para_community = [ 'cross', 'java', 'kernels', 'nonprism', 'pcr' ]; + +$assetdir = dirname($_SERVER["SCRIPT_NAME"]); +$root = $_SERVER["DOCUMENT_ROOT"]; +//$root = "/srv/http/repo/public/main"; +$dirname = explode("?", $_SERVER["REQUEST_URI"], 2)[0]; + +function classify($root, $dirname, $filename) { + global $repos_arch_project, $repos_arch_community, $repos_para_project, $repos_para_community; + + if ($filename === '.') { return [ 'dir' ]; } + if ($filename === '..') { return [ 'dir', 'parent' ]; } + + $parts = preg_split("|/+|", $dirname, -1, PREG_SPLIT_NO_EMPTY); + $dirname = implode('/', $parts); + + $classes = array(); + if (count($parts) == 0) { + // in the top-level + if (in_array($filename, $repos_arch_project )) { array_push($classes, 'repo', 'arch'); } + if (in_array($filename, $repos_para_project )) { array_push($classes, 'repo', 'para'); } + if (in_array($filename, $repos_arch_community)) { array_push($classes, 'repo', 'arch', 'community'); } + if (in_array($filename, $repos_para_community)) { array_push($classes, 'repo', 'para', 'community'); } + if ($filename[0] === '~' ) { array_push($classes, 'repo', 'para', 'community'); } + } elseif ($dirname == "pool" || $dirname == "sources") { + switch($filename) { + case "packages": array_push($classes, 'pool', 'arch'); break; + case "community": array_push($classes, 'pool', 'arch', 'community'); break; + case "parabola": array_push($classes, 'pool', 'para'); break; + } + } + if ($filename[0] === '.' || substr($filename, -1) === '~') { $classes[] = 'hidden'; } + if (is_link($root.'/'.$dirname.'/'.$filename)) { $classes[] = 'link'; } + if (is_dir($root.'/'.$dirname.'/'.$filename)) { $classes[] = 'dir'; } + if (is_file($root.'/'.$dirname.'/'.$filename)) { $classes[] = 'file'; } + + if (preg_match("/\.pkg\.tar(\..z)?$/", $filename) == 1) { $classes[] = 'pkg'; } + if (preg_match("/\.tar(\..z|\.bz2)?$/", $filename) == 1) { $classes[] = 'tar'; } + $classes[] = pathinfo($filename, PATHINFO_EXTENSION); + + return $classes; +} +?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8" /> + <title>Parabola GNU/Linux-libre - Index of <?php echo htmlentities($dirname); ?></title> + <link rel="stylesheet" type="text/css" href="https://parabolagnulinux.org/static/archweb.3b36d2301f70.css" media="screen, projection" /> + <link rel="stylesheet" type="text/css" href="<?php echo $assetdir."/style.css"; ?>" /> + <link rel="icon" type="image/x-icon" href="https://parabolagnulinux.org/static/favicon.72ab042ac877.ico" /> + <link rel="shortcut icon" type="image/x-icon" href="https://parabolagnulinux.org/static/favicon.72ab042ac877.ico" /> + <link rel="apple-touch-icon" href="https://parabolagnulinux.org/static/logos/apple-touch-icon-57x57.6484c8e17e2f.png" /> + <link rel="apple-touch-icon" sizes="72x72" href="https://parabolagnulinux.org/static/logos/apple-touch-icon-72x72.f60f1458fe1c.png" /> + <link rel="apple-touch-icon" sizes="114x114" href="https://parabolagnulinux.org/static/logos/apple-touch-icon-114x114.e7845a2e4bab.png" /> + <link rel="apple-touch-icon" sizes="144x144" href="https://parabolagnulinux.org/static/logos/apple-touch-icon-144x144.97a164b5f85c.png" /> + <link rel="search" type="application/opensearchdescription+xml" href="https://parabolagnulinux.org/opensearch/packages/" title="Parabola GNU/Linux-libre Packages" /> +</head> +<body> + + <div id="archnavbar" class="anb-repo"> + <div id="archnavbarlogo"><h1><a href="/" title="Return to the main page">Parabola</a></h1></div> + <div id="archnavbarmenu"> + <ul id="archnavbarlist"> + <li id="anb-home"><a href="https://parabolagnulinux.org" title="Parabola news, packages, projects and more">Home</a></li> + <li id="anb-packages"><a href="https://parabolagnulinux.org/packages/" title="Parabola Package Database">Packages</a></li> + <li id="anb-wiki"><a href="https://wiki.parabolagnulinux.org" title="Community documentation">Wiki</a></li> + <li id="anb-bugs"><a href="https://labs.parabola.nu" title="Issue Tracker">Bugs</a></li> + <li id="anb-projects"><a href="https://projects.parabolagnulinux.org" title="Our Code">Projects</a></li> + <li id="anb-download"><a href="https://parabolagnulinux.org/download" title="Get Parabola">Download</a></li> + </ul> + </div> + </div><!-- #archnavbar --> + + <div id="content"> + + <div id="archdev-navbar"> </div> + + <div class="box"> + <h2>Index of <?php echo htmlentities($dirname); ?></h2> + <table><tbody> +<?php + if ($dh = opendir($root.'/'.$dirname)) { + $filenames = array(); + while (($filename = readdir($dh)) !== false) { $filenames[] = $filename; } + closedir($dh); + sort($filenames); + foreach ($filenames as $filename) { + if ($filename === '.') { continue; } + $classes = classify($root, $dirname, $filename); + echo "\t\t\t\t<tr class=\"".implode(' ', $classes)."\">"; + if (is_link($root.'/'.$dirname.'/'.$filename)) { + echo "<td><a href=\"".htmlentities($filename)."\">".htmlentities($filename)."</a> -> ".htmlentities(readlink($root.'/'.$dirname.'/'.$filename))."</td>"; + } else { + echo "<td><a href=\"".htmlentities($filename)."\">".htmlentities($filename)."</a></td>"; + } + + if ($filename == '..') { + echo '<td></td><td></td>'; + } else { + echo "<td>".date("Y-m-d H:i", filemtime($root.'/'.$dirname.'/'.$filename))."</td>"; + if (is_dir($root.'/'.$dirname.'/'.$filename)) { + echo "<td class=number>-</td>"; + } else { + echo "<td class=number>".filesize($root.'/'.$dirname.'/'.$filename)."</td>"; + } + echo "</tr>\n"; + } + } + } +?> + </tbody></table> + </div> + + </div> +</body> +</html> |