Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<html>
2
<!-- Whizzylink.php
3
Copyright © 2005, John Goodman - john.goodman(at)unverse.net  *date 051115
4
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
5
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6
A copy of the GNU General Public License can be obtained at: http://www.gnu.org/licenses/gpl.html
7
-->
8
<head>
9
<title>Whizzylink link browse v2</title>
10
<style>
11
body {font:85% sans-serif;}
12
</style>
13
<script type="text/javascript">
14
function WantThis(url) {
15
 window.opener.document.getElementById('lf_url').value = url;
16
 window.close();
17
}
18
</script>
19
<meta name="robots" content="noindex,nofollow">
20
</head>
21
<body>
22
<div id="files" >
23
Click a name below to select.<br>
24
<?php
25
$docpath = $_REQUEST['d'];
26
$extensions = $_REQUEST['x'] ? '/(' . $_REQUEST['x'] .')$/i' : '/\.(html|pdf|txt)$/i';
27
$d = $_SERVER['DOCUMENT_ROOT'] . '/' . $docpath;
28
$d = str_replace('//','/',$d);
29
$dir = opendir($d);
30
while ($file = readdir($dir)){
31
  $files[] = $file;
32
}
33
closedir($dir);
34
usort($files, "insensitive"); //see function insensitive($a, $b)
35
foreach ($files as $filename) {
36
  $filepath = "$d/$filename";
37
  $fsize = sprintf("%u", filesize($filepath)); //filesizes over 2Mb won't fit in an int so we unsign it
38
  $modtime = date ("d F Y H:i:s", filemtime($filepath)); //mtime is unix timestamp
39
  $tip = " Size: $fsize <br>Updated: $modtime ";
40
  if (is_dir($filepath) && $docpath) { //it's a directory
41
    if ($filename == '.'){ //current directory
42
      $dlist .= "<img src='/btn/dir.png'> $docpath ";
43
    } else if ($filename == '..') { //parent directory
44
      if($docpath) { //we're in a sub directory - no Up from root
45
        $updir = substr($docpath,0,strrpos($docpath,'/'));
46
        $dlist .= "<img src='/btn/back.png'><a href='$self?d=$updir'>Up</a>/<br>";
47
       }
48
    } else {
49
      $docpath = str_replace($_SERVER['DOCUMENT_ROOT'], "", $d);
50
      $dlist .= "<div style='float:left;width:20em'><img src='/btn/dir.png'><a href='$self?d=$docpath/$filename'>$filename</a></div>";
51
    }
52
  } else if (preg_match($extensions,$filename) ) {
53
      $flist .= "<div style='float:left;width:20em'><a href='#' onclick='WantThis(\"$docpath/$filename\")'>$filename</a></div>"; //it's a potential link
54
  }
55
}
56
echo $dlist . $flist;
57
 
58
function insensitive($a, $b) { //used by usort to sort file list case insensitive -------------------------
59
   return strcmp(strtolower($a), strtolower($b));
60
}
61
?>
62
</div>
63
</body>
64
</html>