File: dirbrowser.php

package info (click to toggle)
rtgui 0.2.81-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 576 kB
  • sloc: php: 1,194; sh: 14; makefile: 10
file content (64 lines) | stat: -rwxr-xr-x 2,550 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
//
//  This file is part of rtGui.  http://rtgui.googlecode.com/
//  Copyright (C) 2007-2011 Simon Hall.
//
//  rtGui 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 3 of the License, or
//  (at your option) any later version.
//
//  rtGui 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.
//
//  You should have received a copy of the GNU General Public License
//  along with rtGui.  If not, see <http://www.gnu.org/licenses/>.

foreach ($_POST as $key => $val) { $v = "r_$key"; $$v = $val; }
foreach ($_GET  as $key => $val) { $v = "r_$key"; $$v = $val; }
foreach ($_FILES as $key => $val) { $v = "r_$key"; $$v = $val; }

if ($r_dir=="" || !isset($r_dir)) $r_dir="/";
if (!isset($r_hilitedir)) $r_hilitedir="";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<?php
echo "<body class='dirbrowse'  onLoad=\"window.parent.document.getElementById('seldir').innerHTML='".htmlentities($r_dir,ENT_QUOTES,"UTF-8")."';\" >\n";
echo "<div align='left'>\n";
if ($r_dir!="/" ) echo "<a href='dirbrowser.php?dir=".urlencode(substr($r_dir,0,strrpos($r_dir,"/")))."&amp;hilitedir=".urlencode($r_hilitedir)."'>[..]</a><br>";

$files=array();
if ($dirarray=@scandir($r_dir)) {
   foreach($dirarray as $file) {
      if ($r_dir=="/") {
         $truedir=$r_dir.$file;
      } else {
         $truedir=$r_dir."/".$file;
      }
      if ($file!="." && $file!="..") {
         if (is_dir($truedir)) {
            if (substr($r_hilitedir,1)==$file) echo "<b>";
            echo "<img src='images/folder.gif'> <a href='dirbrowser.php?dir=".urlencode($truedir)."&amp;hilitedir=".urlencode($r_hilitedir)."'>".htmlentities($file,ENT_QUOTES,"UTF-8")."</a><br>";
            if (substr($r_hilitedir,1)==$file) echo "</b>";
         } else {
            $files[]=$file;
         }
      }
   }
   foreach($files as $file) {
      echo "<img src='images/file.gif'> ".htmlentities($file,ENT_QUOTES,"UTF-8")."<br>\n";
   }
} else {
   echo "!Invalid directory!";
}
   ?>
</div>
</body>
</html>