| 1 |
lars |
1 |
<!-- Whizzylink.php
|
|
|
2 |
Copyright © 2006, John Goodman - john.goodman(at)unverse.net *date 060307
|
|
|
3 |
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.
|
|
|
4 |
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.
|
|
|
5 |
A copy of the GNU General Public License can be obtained at: http://www.gnu.org/licenses/gpl.html
|
|
|
6 |
|
|
|
7 |
PARAMETERS are optional:
|
|
|
8 |
d=start directory
|
|
|
9 |
default is the root directory
|
|
|
10 |
x=list of file extensions to consider, separated by '|'
|
|
|
11 |
default is htm|html|txt|doc|xls|ppt|pdf|cfm (NB asp|php|shtml Not included in default)
|
|
|
12 |
b=path to button images
|
|
|
13 |
default is /btn
|
|
|
14 |
e.g. whizzylink.php?d=publicpages&x=html|pdf|php
|
|
|
15 |
-->
|
|
|
16 |
<html>
|
|
|
17 |
<head>
|
|
|
18 |
<title>Whizzylink link browse v4</title>
|
|
|
19 |
<style>
|
|
|
20 |
body {font:85% sans-serif;}
|
|
|
21 |
</style>
|
|
|
22 |
<script type="text/javascript">
|
|
|
23 |
function WantThis(url) {
|
|
|
24 |
window.opener.document.getElementById('lf_url').value = url;
|
|
|
25 |
window.close();
|
|
|
26 |
}
|
|
|
27 |
</script>
|
|
|
28 |
<META NAME="ROBOTS" CONTENT="NOINDEX,NOFOLLOW">
|
|
|
29 |
</head>
|
|
|
30 |
<body>
|
|
|
31 |
<div id="files" >
|
|
|
32 |
Click a name below to select.<br>
|
|
|
33 |
<?php
|
|
|
34 |
$butpath = $_REQUEST['b'] ? $_REQUEST['b'] : '/btn';
|
|
|
35 |
$extensions = $_REQUEST['x'] ? '/\.(' . $_REQUEST['x'] .')$/i' : '/\.(htm|html|txt|doc|xls|ppt|pdf|cfm)$/i';
|
|
|
36 |
$docpath = trim($_REQUEST['d'],"/");
|
|
|
37 |
$d = $_SERVER['DOCUMENT_ROOT'] . '/' . $docpath;
|
|
|
38 |
$dir = opendir($d);
|
|
|
39 |
while ($file = readdir($dir)){
|
|
|
40 |
$files[] = $file;
|
|
|
41 |
}
|
|
|
42 |
closedir($dir);
|
|
|
43 |
natcasesort($files); //see function insensitive($a, $b)
|
|
|
44 |
foreach ($files as $filename) {
|
|
|
45 |
$filepath = "$d/$filename";
|
|
|
46 |
if (@is_dir($filepath)) { //it's a directory
|
|
|
47 |
if ($filename == '.'){ //current directory
|
|
|
48 |
$dlist .= "<img src='".$butpath."/dir.gif'> $docpath ";
|
|
|
49 |
} else if ($filename == '..') { //parent directory
|
|
|
50 |
if($docpath) { //we're in a sub directory - no Up from root
|
|
|
51 |
$updir = substr($docpath,0,strrpos($docpath,'/'));
|
|
|
52 |
$dlist .= "<img src='".$butpath."/back.gif'><a href='$self?d=$updir'>Up</a>/<br>";
|
|
|
53 |
}
|
|
|
54 |
} else {
|
|
|
55 |
//$docpath = str_replace($_SERVER['DOCUMENT_ROOT'], "", $d);//NEEDED?
|
|
|
56 |
$dlist .= "<div style='float:left;width:20em'><img src='".$butpath."/dir.gif'><a href='$self?d=$docpath/$filename'>$filename</a></div>";
|
|
|
57 |
}
|
|
|
58 |
} else if (preg_match($extensions,$filename) || strpos($filename,'.') === false) { //hide forbidden extensions
|
|
|
59 |
$flist .= "<div style='float:left;width:20em'><a href='#' onclick='WantThis(\"$docpath/$filename\")'>$filename</a></div>"; //it's a potential link
|
|
|
60 |
}
|
|
|
61 |
}
|
|
|
62 |
echo $dlist . $flist;
|
|
|
63 |
|
|
|
64 |
?>
|
|
|
65 |
</div>
|
|
|
66 |
</body>
|
|
|
67 |
</html>
|