slitaz-forge annotate mirror/root/dir-generator.php @ rev 602

New style on mirror1
mirror1.slitaz.org/ : mirror1.slitaz.org/info/ : mirror1.slitaz.org/webboot/ : dvd.slitaz.org
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Oct 16 02:08:09 2015 +0300 (2015-10-16)
parents dd8c986dfebf
children 17ab49508a9f
rev   line source
pankso@166 1 <?php
al@600 2 if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
al@600 3 ob_start('ob_gzhandler');
al@600 4 else
al@600 5 ob_start();
al@600 6
al@600 7 function redirect() {
pankso@166 8 ?>
al@600 9 <!DOCTYPE html>
al@600 10 <html lang="en">
pankso@166 11 <head>
pankso@166 12 <title>SliTaz mirror redirection</title>
al@600 13 <meta charset="UTF-8">
al@600 14 <meta name="description" content="slitaz mirror redirection">
al@600 15 <meta name="robots" content="index, nofollow">
al@600 16 <meta name="author" content="SliTaz Contributors">
pascal@577 17 <meta http-equiv="Refresh" content="0;url=http://mirror1.slitaz.org/">
pankso@166 18 </head>
al@600 19 <body>
al@600 20 <script>window.location.replace('http://mirror1.slitaz.org/')</script>
al@600 21 <noscript>
al@600 22 <frameset rows="100%">
al@600 23 <frame src="http://mirror1.slitaz.org/">
al@600 24 <noframes>
al@600 25 <body>Please follow <a href="http://mirror1.slitaz.org/">this link</a>.</body>
al@600 26 </noframes>
al@600 27 </frameset>
al@600 28 </noscript>
al@600 29 </body>
al@600 30 </html>
pankso@166 31 <?php
pankso@166 32 }
pankso@166 33
al@600 34 $VERSION = "0.4-slitaz";
pankso@166 35
pankso@166 36 /* Lighttpd Enhanced Directory Listing Script
pankso@166 37 * ------------------------------------------
pankso@166 38 * Authors: Evan Fosmark <me@evanfosmark.com>,
pankso@166 39 * Pascal Bellard <pascal.bellard@slitaz.org>
pankso@166 40 * Christophe Lincoln <pankso@slitaz.org>
pankso@166 41 *
pankso@166 42 *
pankso@166 43 * GNU License Agreement
pankso@166 44 * ---------------------
pankso@166 45 * This program is free software; you can redistribute it and/or modify
pankso@166 46 * it under the terms of the GNU General Public License as published by
pankso@166 47 * the Free Software Foundation; either version 2 of the License, or
pankso@166 48 * (at your option) any later version.
pankso@166 49 *
pankso@166 50 * This program is distributed in the hope that it will be useful,
pankso@166 51 * but WITHOUT ANY WARRANTY; without even the implied warranty of
pankso@166 52 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pankso@166 53 * GNU General Public License for more details.
pankso@166 54 *
pankso@166 55 * You should have received a copy of the GNU General Public License
pankso@166 56 * along with this program; if not, write to the Free Software
pankso@166 57 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
pankso@166 58 *
pankso@166 59 * http://www.gnu.org/licenses/gpl.txt
pankso@166 60 */
al@600 61
al@600 62
pankso@166 63 // Get the path (cut out the query string from the request_uri)
pankso@166 64 list($path) = explode('?', $_SERVER['REQUEST_URI']);
pankso@166 65
pankso@166 66
pankso@166 67 // Get the path that we're supposed to show.
pankso@166 68 $path = ltrim(rawurldecode($path), '/');
pankso@166 69
pankso@166 70
al@600 71 if(strlen($path) == 0)
pankso@166 72 $path = "./";
pankso@166 73
pankso@166 74
pankso@166 75 // Can't call the script directly since REQUEST_URI won't be a directory
al@600 76 if($_SERVER['PHP_SELF'] == '/' . $path) {
pankso@166 77 redirect();
pankso@166 78 // die("Unable to call " . $path . " directly.");
pankso@166 79 }
pankso@166 80
pankso@166 81
al@600 82 $vpath = ($path != "./") ? $path : "";
pankso@166 83 // Make sure it is valid.
al@600 84 if (!is_dir($path)) {
pankso@166 85 // die("<b>" . $path . "</b> is not a valid path.");
pankso@166 86 $path = dirname($_SERVER["SCRIPT_FILENAME"]);
pankso@166 87 list($vpath) = explode('?', $_SERVER['REQUEST_URI']);
pankso@166 88 $vpath = ltrim(rawurldecode($vpath), '/');
pankso@166 89 }
pankso@166 90
pankso@166 91
pankso@166 92 //
pankso@166 93 // This function returns the file size of a specified $file.
pankso@166 94 //
pankso@166 95 function format_bytes($size, $precision=1) {
al@600 96 $sizes = array('Y', 'Z', 'E', 'P', 'T', 'G', 'M', 'K', '');
al@600 97 $total = count($sizes);
pankso@166 98
al@600 99 while ($total-- && $size > 1024)
al@600 100 $size /= 1024;
al@600 101 if ($sizes[$total] == '') {
al@600 102 $size /= 1024;
al@600 103 $total--;
al@600 104 }
al@600 105 return sprintf('%.' . $precision . 'f', $size) . $sizes[$total];
pankso@166 106 }
pankso@166 107
al@600 108
pankso@166 109 //
pankso@166 110 // Get some variables from /etc/lighttpd/lighttpd.conf
pankso@166 111 //
pankso@166 112 $conf_lightty = file_get_contents("/etc/lighttpd/lighttpd.conf");
pankso@166 113
al@600 114 function get_conf($var, $start, $stop, $default='') {
al@600 115 global $conf_lightty;
pankso@166 116
al@600 117 if (!preg_match('/' . $var . '/', $conf_lightty))
al@600 118 return $default;
al@600 119 $filter = '/(.*\n)*' . $var . '\s*=\s*' . $start . '(([^' . $stop . ']*\n*)*)' . $stop . '(.*\n)*/';
al@600 120 return preg_replace($filter, '$2', $conf_lightty);
pankso@166 121 }
pankso@166 122
al@600 123 $encoding = get_conf('dir-listing.encoding', '"', '"', 'ascii');
al@600 124 $external_css = get_conf('dir-listing.external-css', '"', '"');
pankso@166 125
pankso@166 126 $show_hidden_files = false;
al@600 127 if (get_conf('dir-listing.hide-dotfile', '"', '"', 'disable') == "disable")
pankso@166 128 $show_hidden_files = true;
pankso@166 129 // get_conf('dir-listing.exclude','\(','\)');
pankso@166 130 // get_conf('dir-listing.set-footer','"','"');
pankso@166 131
pankso@166 132 $mime_types = array();
al@600 133 foreach (explode(',', get_conf('mimetype.assign','\(','\)')) as $item) {
pankso@166 134 $filter = '/\s*"(.*)"\s*=>\s*"(.*)".*/';
al@600 135 $val = explode(',', preg_replace($filter, '$1,$2', $item));
al@600 136 if (isset($val[1]))
al@600 137 $mime_types[$val[0]] = $val[1];
pankso@166 138 }
pankso@166 139
al@600 140
pankso@166 141 //
pankso@166 142 // This function returns the mime type of $file.
pankso@166 143 //
pankso@166 144 function get_file_type($file) {
pankso@166 145 global $mime_types;
al@600 146
pankso@166 147 $file = basename($file);
pankso@166 148 $default_type = "application/octet-stream";
al@600 149 if (isset($mime_types[$file]))
pankso@166 150 return $mime_types[$file];
pankso@166 151 $pos = strrpos($file, ".");
al@600 152 if ($pos === false)
pankso@166 153 return $default_type;
pankso@166 154 //FIXME .tar.gz
al@600 155 $ext = '.' . rtrim(substr($file, $pos+1), "~");
al@600 156 if (isset($mime_types[$ext]))
pankso@166 157 return $mime_types[$ext];
pankso@166 158 return $default_type;
pankso@166 159 }
pankso@166 160
al@600 161
al@600 162
al@600 163
pankso@166 164 //$slitaz_style = (dirname($_SERVER["PHP_SELF"]) == '/');
pascal@577 165 //$slitaz_style = ($_SERVER["SERVER_NAME"] == "mirror1.slitaz.org");
al@600 166 $slitaz_style = preg_match("/mirror1\.slitaz\./", $_SERVER["SERVER_NAME"]);
al@600 167
pankso@166 168 if ($slitaz_style) {
al@600 169 // SliTaz Style
pascal@379 170 $modified = gmdate("D, d M Y H:i:s e", strtotime("-1 hour"));
al@600 171 $expires = gmdate("D, d M Y H:i:s e", strtotime("+1 hour"));
pankso@166 172 $fvalue = "";
al@600 173 if (isset($_GET['f']))
al@600 174 $fvalue = 'value="' . $_GET['f'] . '"';
al@600 175 header("Expires: " . $expires);
pascal@379 176 header("Last-Modified: " . $modified);
pascal@379 177 header("Pragma: cache");
al@600 178 // header("Cache-Control: public");
al@600 179 // <meta http-equiv="cache-control" content="public" />
al@600 180 // <meta http-equiv="last-modified" content="$modified" />
al@600 181 // <meta http-equiv="expires" content="$expires" />
al@601 182 print "
al@600 183 <!DOCTYPE html>
al@601 184 <html lang=\"en\">
pankso@166 185 <head>
pankso@166 186 <title>Index of /$vpath</title>
al@601 187 <meta charset=\"UTF-8\">
al@602 188 <meta name=\"description\" content=\"Index of /$vpath\">
al@602 189 ";
al@601 190 ?>
al@600 191 <meta name="robots" content="index, nofollow">
al@600 192 <meta name="author" content="SliTaz Contributors">
al@600 193 <meta name="viewport" content="width=device-width, initial-scale=1.0">
al@600 194 <link rel="shortcut icon" href="/static/favicon.ico">
al@600 195 <link rel="stylesheet" type="text/css" href="/static/slitaz.min.css">
pankso@166 196 </head>
pankso@166 197 <body>
pankso@166 198
al@602 199 <script>de=document.documentElement;de.className+=(("ontouchstart" in de)?' touch':' no-touch');</script>
al@602 200
al@600 201 <header>
al@600 202 <h1><a href="http://mirror1.slitaz.org/">SliTaz Mirror</a></h1>
al@602 203 <div class="network">
al@600 204 <a class="home" href="http://www.slitaz.org/"></a>
pankso@166 205 <a href="http://scn.slitaz.org/">Community</a>
pankso@166 206 <a href="http://doc.slitaz.org/">Doc</a>
pankso@166 207 <a href="http://forum.slitaz.org/">Forum</a>
pankso@166 208 <a href="http://pro.slitaz.org/">Pro</a>
pankso@166 209 <a href="https://slitaz.spreadshirt.net/">Shop</a>
pankso@166 210 <a href="http://bugs.slitaz.org">Bugs</a>
pascal@343 211 <a href="http://hg.slitaz.org/?sort=lastchange">Hg</a>
pankso@173 212 <a href="http://cook.slitaz.org/">Cook</a>
pankso@166 213 </div>
al@600 214 </header>
pankso@166 215
al@602 216 <div class="block"><div>
al@600 217 <!-- Information/image -->
al@602 218 <div class="block_info">
al@600 219 <header>Welcome to Open Source!</header>
al@600 220 <?php
al@600 221
al@600 222 if (preg_match("/mirror1\.slitaz\./", $_SERVER["SERVER_NAME"]))
al@600 223 { ?>
al@600 224 <p>This is the SliTaz GNU/Linux main mirror. The server runs naturally
al@600 225 SliTaz (stable) in an uml virtual machine provided by
al@600 226 <a href="http://www.ads-lu.com/">ADS</a> and is located in France.</p>
al@600 227 <p><a href="/info/">Mirror info...</a></p>
al@600 228 <?php
al@600 229 }
al@600 230
al@600 231 ?>
al@600 232 <form action="/" method="get">
al@600 233 <input type="search" name="f"/>
al@600 234 </form>
al@600 235 </div>
pankso@166 236 <!-- Navigation -->
al@600 237 <nav>
al@600 238 <header>Online Tools</header>
pankso@166 239 <ul>
pascal@378 240 <li><a href="http://pizza.slitaz.me/">Live ISO Builder</a></li>
pascal@378 241 <li><a href="http://pizza.slitaz.org/">Live flavor Builder</a></li>
pascal@378 242 <li><a href="http://tiny.slitaz.org/">Tiny SliTaz Builder</a></li>
pankso@166 243 <li><a href="http://boot.slitaz.org/">Web Boot</a></li>
al@600 244 <li><a href="http://web.archive.org/web/*/http://mirror.slitaz.org">WebArchive</a></li>
pankso@166 245 </ul>
al@600 246 </nav>
al@600 247 </div></div>
pankso@166 248
al@600 249 <script>
pascal@379 250 function QRCodePNG(str, obj) {
pascal@379 251 try {
pascal@587 252 obj.height = obj.width += 200;
pascal@379 253 return QRCode.generatePNG(str, {ecclevel: 'H'});
pascal@379 254 }
pascal@379 255 catch (any) {
pascal@379 256 var element = document.createElement("script");
al@600 257 element.src = "/static/qrcode.min.js";
pascal@379 258 element.type ="text/javascript";
pascal@379 259 element.onload = function() {
pascal@379 260 obj.src = QRCode.generatePNG(str, {ecclevel: 'H'});
pascal@379 261 };
pascal@379 262 document.body.appendChild(element);
pascal@379 263 }
pascal@379 264 }
pascal@379 265 </script>
pankso@167 266
al@602 267 <div class="mirrors">
al@600 268 <?php
pankso@169 269
al@600 270 // Mirror list
al@600 271 $mirrors = array();
al@600 272 $fp = @fopen(dirname($_SERVER["SCRIPT_FILENAME"]) . "/mirrors.html", "r");
al@600 273 if ($fp) {
al@600 274 // Parse mirrors.html
al@600 275 while (($line = fgets($fp)) !== false) {
al@600 276 // string /" is the end of mirrors url
al@600 277 $fullline = str_replace('/"', "/" . $vpath . '"', $line);
al@600 278 print $fullline;
al@600 279 }
al@600 280 fclose($fp);
al@600 281 } else {
al@600 282 $fp = @fopen(dirname($_SERVER["SCRIPT_FILENAME"]) . "/mirrors", "r");
al@600 283 if ($fp) {
al@600 284 while (($line = fgets($fp)) !== false) {
al@600 285 $line = chop($line);
al@600 286 $url = parse_url($line);
al@600 287 if ($_SERVER["SERVER_NAME"] == $url['host'])
al@600 288 continue;
al@600 289 $host = explode('.', $url['host']);
al@600 290 $mirrors[$host[count($host)-2] . "." .
al@600 291 $host[count($host)-1]] = $line;
al@600 292 }
al@600 293 }
al@600 294 fclose($fp);
al@600 295 foreach($mirrors as $name => $url) {
al@600 296 print "<a href=\"$url$vpath\" title=\"$name mirror\">$name</a>\n";
al@600 297 }
al@600 298 }
pankso@166 299
al@600 300 print "</div>";
al@600 301 // end SliTaz Style
al@600 302 } else {
al@600 303 // not SliTaz Style
pankso@166 304
al@600 305 // Print the heading stuff
al@600 306 print "<?xml version='1.0' encoding='$encoding'?>
pankso@166 307 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
pankso@166 308 <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
pankso@166 309 <head>
al@600 310 <title>Index of /$vpath</title>
pankso@166 311 ";
al@600 312 if ($external_css != '') {
al@600 313 print " <link rel='stylesheet' type='text/css' href='$external_css' />";
al@600 314 } else {
al@600 315 print "<style type='text/css'>
al@600 316 a, a:active {text-decoration: none; color: blue;}
al@600 317 a:visited {color: #48468F;}
al@600 318 a:hover, a:focus {text-decoration: underline; color: red;}
al@600 319 body {background-color: #F5F5F5;}
al@600 320 h2 {margin-bottom: 12px;}
al@600 321 table {margin-left: 12px;}
al@600 322 th, td {font: 90% monospace; text-align: left;}
al@600 323 th {font-weight: bold; padding-right: 14px; padding-bottom: 3px;}
al@600 324 td {padding-right: 14px;}
al@600 325 td.s, th.s {text-align: right;}
al@600 326 div.list {background-color: white; border-top: 1px solid #646464; border-bottom: 1px solid #646464; padding-top: 10px; padding-bottom: 14px;}
al@600 327 div.foot { font: 90% monospace; color: #787878; padding-top: 4px;}
al@600 328 </style>
pankso@166 329 ";
al@600 330 }
al@600 331
al@600 332 print " </head>
al@600 333 <body>
al@600 334 <h2>Index of /$vpath</h2>
pankso@166 335 ";
al@600 336 // end not SliTaz Style
pankso@166 337 }
pankso@166 338
al@600 339
al@600 340
al@600 341
al@602 342 print "<!-- Content -->
al@602 343 <main>
al@602 344 <div class='list'>
al@602 345 <div class='lang'>Path: /$vpath</div>
al@600 346 <table>";
pankso@166 347
al@600 348
al@600 349 function my_is_file($path) {
al@600 350 // 2G+ file support
al@600 351 exec("[ -f '" . $path . "' ]", $tmp, $ret);
pankso@166 352 return $ret == 0;
al@600 353 //return is_file($path);
pankso@166 354 }
pankso@166 355
al@600 356
al@600 357 function my_filesize($path) {
al@600 358 // 2G+ file support
al@600 359 return rtrim(shell_exec("stat -Lc %s '" . $path . "'"));
al@600 360 //return filesize($path);
pankso@166 361 }
pankso@166 362
al@600 363
al@600 364 function my_filemtime($path) {
al@600 365 // 2G+ file support
al@600 366 return rtrim(shell_exec("stat -Lc %Y '" . $path . "'"));
al@600 367 //return filemtime($path);
pankso@166 368 }
pankso@166 369
al@600 370
al@600 371 function my_filemtimeasc($path) {
al@600 372 // 2G+ file support
al@600 373 return rtrim(shell_exec("LC_ALL=C date -r '" . $path . "' '+%Y-%b-%d %H:%M:%S'"));
al@600 374 //return date('Y-M-d H:m:s', filemtime($path));
pankso@166 375 }
pankso@166 376
pascal@280 377
al@600 378 if (filesize($path . "/.folderlist") > 0 &&
al@600 379 filesize($path . "/.filelist") > 0 &&
al@600 380 filemtime($path . "/.filelist") > filemtime($path)) {
al@600 381 $folderlist = unserialize(file_get_contents($path . "/.folderlist"));
al@600 382 $filelist = unserialize(file_get_contents($path . "/.filelist"));
al@600 383 } else {
al@600 384
al@600 385 proc_nice(10);
al@600 386 // Get all of the folders and files.
al@600 387 $folderlist = array();
al@600 388 $filelist = array();
al@600 389 if($handle = @opendir($path)) {
al@600 390 while(($item = readdir($handle)) !== false) {
al@600 391 if ($item == "index.php") continue;
al@600 392 if ($item == ".folderlist") continue;
al@600 393 if ($item == ".filelist") continue;
al@600 394 if ($item == "dir-generator.php") continue;
al@600 395 if ($item == "robots.txt") continue;
al@600 396 if ($item == "humans.txt") continue;
al@600 397 if ($item == "mirrors.html") continue;
al@600 398 if (is_dir($path.'/'.$item) and $item != '.' and $item != '..') {
al@600 399 $folderlist[] = array(
al@600 400 'name' => $item,
al@600 401 'size' => 0,
al@600 402 'modtime'=> filemtime($path . '/' . $item),
al@600 403 'modtimeasc'=> my_filemtimeasc($path . '/' . $item),
al@600 404 'file_type' => "Directory"
al@600 405 );
al@600 406 } elseif (my_is_file($path . '/' . $item)) {
al@600 407 if (!$show_hidden_files) {
al@600 408 if (substr($item, 0, 1) == "." or substr($item, -1) == "~")
al@600 409 continue;
al@600 410 }
al@600 411 $filelist[] = array(
al@600 412 'name'=> $item,
al@600 413 'size'=> my_filesize($path . '/' . $item),
al@600 414 'modtime'=> my_filemtime($path . '/' . $item),
al@600 415 'modtimeasc'=> my_filemtimeasc($path . '/' . $item),
al@600 416 'file_type' => get_file_type($path . '/' . $item)
al@600 417 );
al@600 418 }
pankso@166 419 }
al@600 420 closedir($handle);
al@600 421 file_put_contents($path . "/.folderlist", serialize($folderlist), LOCK_EX);
al@600 422 file_put_contents($path . "/.filelist", serialize($filelist), LOCK_EX);
pankso@166 423 }
pankso@166 424 }
pankso@166 425
pascal@282 426 if (isset($_GET['f'])) {
pascal@282 427 $filter = $_GET['f'];
al@600 428 if (substr($filter, 0, 1) != '/')
al@600 429 $filter = '/' . $filter . '/i';
pascal@282 430 foreach ($filelist as $key => $value)
al@600 431 if (!preg_match($filter, $value['name']))
pascal@282 432 unset($filelist[$key]);
pascal@282 433 foreach ($folderlist as $key => $value)
al@600 434 if (!preg_match($filter, $value['name']))
pascal@282 435 unset($folderlist[$key]);
pascal@282 436 }
pankso@166 437
al@600 438 if (!isset($_GET['s']))
pankso@166 439 $_GET['s'] = 'name';
al@600 440
pankso@166 441
pankso@166 442 // Figure out what to sort files by
pankso@166 443 $file_order_by = array();
al@600 444 foreach ($filelist as $key => $row)
al@600 445 $file_order_by[$key] = $row[$_GET['s']];
al@600 446
pankso@166 447
pankso@166 448 // Figure out what to sort folders by
pankso@166 449 $folder_order_by = array();
al@600 450 foreach ($folderlist as $key => $row)
al@600 451 $folder_order_by[$key] = $row[$_GET['s']];
al@600 452
pankso@166 453
pankso@166 454 // Order the files and folders
pankso@166 455 $sort_type = SORT_ASC;
pankso@166 456 $order = "&amp;o=d";
al@600 457 if (isset($_GET['o'])) {
pankso@166 458 $sort_type = SORT_DESC;
pankso@166 459 $order = "";
pankso@166 460 }
pankso@166 461 array_multisort($folder_order_by, $sort_type, $folderlist);
al@600 462 array_multisort($file_order_by, $sort_type, $filelist);
al@600 463
al@600 464
al@600 465 // Table caption: number of folders and files
al@600 466 print "<caption>" . count($folderlist) . " folders and " . count($filelist) . " files.</caption>";
pankso@166 467
pankso@166 468
pankso@166 469 // Show sort methods
pankso@166 470 print "<thead><tr>";
pankso@166 471
pankso@166 472 $sort_methods = array();
pankso@166 473 $sort_methods['name'] = "Name";
pankso@166 474 $sort_methods['modtime'] = "Last Modified";
pankso@166 475 $sort_methods['size'] = "Size";
pankso@166 476
al@600 477 foreach($sort_methods as $key => $item) {
al@600 478 if ($_GET['s'] == $key)
al@600 479 $key = "$key$order";
al@600 480 print "<th><a href='?s=$key'>$item</a></th>";
pankso@166 481 }
pankso@166 482 print "</tr></thead>\n<tbody>\n";
pankso@166 483
pankso@166 484
pankso@166 485
al@600 486
pankso@166 487 // Parent directory link
al@600 488 if ($path != "./")
al@600 489 print "<tr><td class='up'><a href='..'>Parent Directory</a>/</td>" .
al@600 490 "<td>&nbsp;</td>" .
al@600 491 "<td>- &nbsp;</td></tr>\n";
al@600 492
pankso@166 493
pankso@166 494
pankso@166 495
pankso@166 496 // Print folder information
al@600 497 foreach($folderlist as $folder)
al@600 498 print "<tr><td class='dir'><a href='" . addslashes($folder['name']). "'>" .
al@600 499 htmlentities($folder['name']) . "</a>/</td>" .
al@601 500 "<td>" . $folder['modtimeasc'] . "</td>" .
al@600 501 "<td>- &nbsp;</td></tr>\n";
al@600 502
pankso@166 503
pankso@166 504
pankso@166 505 // Print file information
pankso@166 506 foreach($filelist as $file) {
al@601 507 $filename = $file['name'];
al@602 508 $url = addslashes($filename);
al@600 509
al@602 510 if (preg_match('/\.(tazpkg|deb)$/', $filename))
al@600 511 $class = "pkg";
al@601 512 elseif (preg_match('/\.iso$/', $filename))
al@600 513 $class = "iso";
al@601 514 elseif (preg_match('/\.(exe|com)$/', $filename))
al@600 515 $class = "exe";
al@601 516 elseif (preg_match('/^README$/', $filename))
al@600 517 $class = "rme";
al@601 518 elseif (preg_match('/^bzImage$/', $filename))
al@600 519 $class = "krn";
al@601 520 elseif (preg_match('/\.zip$/', $filename))
al@600 521 $class = "zip";
al@601 522 elseif (preg_match('/\.log$/', $filename))
al@600 523 $class = "log";
al@600 524 else {
al@600 525 $classes = explode('/', $file['file_type']);
al@600 526 $class = $classes[1];
al@600 527 }
al@600 528
al@600 529
al@601 530 print "<tr><td class='$class'><a href='$url'>" . htmlentities($filename) . "</a></td>" .
al@600 531 "<td>" . $file['modtimeasc'] .
al@600 532 " <img src='/static/qr.png' alt='#' " .
al@600 533 "onmouseover=\"this.title = location.href+'$url'\" " .
al@600 534 "onclick=\"this.src = QRCodePNG(location.href+'$url', this)\"/></td>" .
al@600 535 "<td>" . format_bytes($file['size']) . "</td></tr>\n";
pankso@166 536 }
pankso@166 537
pankso@166 538 // Print ending stuff
al@600 539 print " </tbody>
pankso@166 540 </table>
al@600 541 </div>";
pascal@587 542
al@600 543 $soft = explode('/', $_SERVER["SERVER_SOFTWARE"]);
al@600 544 $tag = get_conf('server.tag', '"', '"', $soft[0] . ' &lt;' . $soft[1] . '&gt;');
al@600 545
al@600 546
al@600 547 if (filesize($path . "/README"))
al@600 548 print "<pre>" .
al@600 549 preg_replace('!(((f|ht)tp(s)?://)[-a-zA-Z()0-9@:%_+.~#?&;//=]+)!i',
al@600 550 '<a href="$1">$1</a>', file_get_contents($path . "/README")) .
al@600 551 "</pre>\n";
al@600 552
al@600 553
al@600 554
al@600 555 if ($slitaz_style) {
al@600 556 // SliTaz Style
al@600 557 ?>
pankso@166 558
pankso@166 559 <!-- End of content -->
al@602 560 </main>
pankso@166 561
al@600 562 <footer>
al@602 563 <div>
al@602 564 Copyright &copy; <span class="year"></span>
al@602 565 <a href="http://www.slitaz.org/">SliTaz</a>
al@602 566 </div>
al@602 567 <div>
al@602 568 Network:
al@602 569 <a href="http://scn.slitaz.org/">Community</a> ·
al@602 570 <a href="http://doc.slitaz.org/">Doc</a> ·
al@602 571 <a href="http://forum.slitaz.org/">Forum</a> ·
al@602 572 <a href="http://pkgs.slitaz.org/">Packages</a> ·
al@602 573 <a href="http://bugs.slitaz.org">Bugs</a> ·
al@600 574 <a href="http://hg.slitaz.org/?sort=lastchange">Hg</a>
al@602 575 </div>
al@602 576 <div>
al@602 577 SliTaz @
al@602 578 <a href="http://twitter.com/slitaz">Twitter</a> ·
al@602 579 <a href="http://www.facebook.com/slitaz">Facebook</a> ·
al@602 580 <a href="http://distrowatch.com/slitaz">Distrowatch</a> ·
al@602 581 <a href="http://en.wikipedia.org/wiki/SliTaz">Wikipedia</a> ·
pankso@166 582 <a href="http://flattr.com/profile/slitaz">Flattr</a>
al@602 583 </div>
al@600 584 <img src="static/qr.png" alt="#" onmouseover="this.title = location.href"
al@602 585 onclick="this.src = QRCodePNG(location.href, this)"/>
al@600 586 </footer>
pankso@166 587
al@600 588 <?php
al@600 589 // end SliTaz Style
al@600 590 } else {
al@600 591 // not SliTaz Style
al@600 592 print "
al@600 593 <form action='" . $_SERVER["REQUEST_URI"] . "' method='get'>
al@600 594 <div class='foot'>" . $tag . "
al@600 595 <input type='text' name='f'/>
al@600 596 <!-- <input type='submit' value='Filter' /> -->
al@600 597 </div>
pankso@166 598 </form>
pankso@166 599 ";
al@600 600 // end not SliTaz Style
al@600 601 }
al@600 602
pankso@166 603 print "</body>
pankso@166 604 </html>";
pankso@166 605 ?>