Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<html>
2
<!-- Whizzypic.php v2 - resistant to no /images directory
3
Copyright � 2005, John Goodman - john.goodman(at)unverse.net  *date 051215
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>Whizzypic image browse v2</title>
10
<style>
11
body {font:85% sans-serif;}
12
#picture {width:55%;height:100%;float:left;}
13
#files {height:100%;overflow:auto;margin-left:4em;font-size:90%;}
14
#caption{font-size:1.2em}
15
#preview {height:80%;width:100%}
16
</style>
17
<script type="text/javascript">
18
function WantThis(url) {
19
 window.opener.document.getElementById('if_url').value = url;
20
 window.close();
21
}
22
</script>
23
</head>
24
<body>
25
<div id="picture">
26
 <span id='caption'>Image preview</span><br><br>
27
 <iframe id='preview' src='/btn/image.gif'>
28
 </iframe>
29
</div>
30
<div id="files" >
31
Hover over a name below to preview, click it to select.<br>
32
<?php
33
$self = $_SERVER['SCRIPT_NAME'];
34
$docpath = $_REQUEST['d'] ? $_REQUEST['d'] : '/images';
35
$d = $_SERVER['DOCUMENT_ROOT'] . '/' . $docpath;
36
$d = str_replace('//','/',$d);
37
if (!is_dir($d)) $d = $_SERVER['DOCUMENT_ROOT'];
38
$dir = opendir($d);
39
while ($file = readdir($dir)){
40
  $files[] = $file;
41
}
42
closedir($dir);
43
usort($files, "insensitive"); //see function insensitive($a, $b)
44
foreach ($files as $filename) {
45
  $filepath = "$d/$filename";
46
  $fsize = sprintf("%u", filesize($filepath)); //filesizes over 2Mb won't fit in an int so we unsign it
47
  $modtime = date ("d F Y H:i:s", filemtime($filepath)); //mtime is unix timestamp
48
  $tip = " Size: $fsize <br>Updated: $modtime ";
49
  if (is_dir($filepath)) { //it's a directory
50
    if ($filename == '.'){ //current directory
51
      $dlist .= "<img src='btn/dir.png'> $docpath ";
52
    } else if ($filename == '..') { //parent directory
53
      if($docpath) { //we're in a sub directory - no Up from root
54
        $updir = substr($docpath,0,strrpos($docpath,'/'));
55
        $dlist .= "<img src='btn/back.png'><a href='$self?d=$updir'>Up</a>/<br>";
56
       }
57
    } else if ($filename != 'bak') {
58
      $docpath = str_replace($_SERVER['DOCUMENT_ROOT'], "", $d);
59
      $dlist .= "<img src='btn/dir.png'><a href='$self?d=$docpath/$filename'>$filename</a>/<br>";
60
    }
61
  } else if (strpos($filename, '.jpg') || strpos($filename, '.gif') || strpos($filename, '.png') || strpos($filename, '.ico') ) {
62
      $flist .= "<img src='btn/image.png'><a href='#' onclick='WantThis(\"$docpath/$filename\")' onmouseover='document.getElementById(\"preview\").src=\"$docpath/$filename\";document.getElementById(\"caption\").innerHTML=\"<b>$filename</b><br>$tip\"'>$filename</a></br>"; //it's a picture
63
  }
64
}
65
echo $dlist . $flist;
66
 
67
function insensitive($a, $b) { //used by usort to sort file list case insensitive -------------------------
68
   return strcmp(strtolower($a), strtolower($b));
69
}
70
?>
71
</div>
72
</body>
73
</html>