summaryrefslogtreecommitdiffstats
path: root/usr/local/www/filebrowser
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-04-14 14:10:58 +0545
committerPhil Davis <phil.davis@inf.org>2015-04-14 14:10:58 +0545
commitf3ec04877ba7ef9aa4e0c43d34cec0f58a53891f (patch)
tree05bf5b60f03bcba80cdfbe6de0394b09fab8e14e /usr/local/www/filebrowser
parent460610b2076ed39fd3f0d36a5c758c2bc9afefb0 (diff)
downloadpfsense-f3ec04877ba7ef9aa4e0c43d34cec0f58a53891f.zip
pfsense-f3ec04877ba7ef9aa4e0c43d34cec0f58a53891f.tar.gz
Code style for small things in usr-local-www
Diffstat (limited to 'usr/local/www/filebrowser')
-rw-r--r--usr/local/www/filebrowser/browser.js7
-rw-r--r--usr/local/www/filebrowser/browser.php108
2 files changed, 60 insertions, 55 deletions
diff --git a/usr/local/www/filebrowser/browser.js b/usr/local/www/filebrowser/browser.js
index c9788c4..2769db3 100644
--- a/usr/local/www/filebrowser/browser.js
+++ b/usr/local/www/filebrowser/browser.js
@@ -16,14 +16,15 @@ jQuery(document).ready(
function fbBrowse(path) {
jQuery("#fileContent").fadeOut();
- if(jQuery("#fbCurrentDir"))
+ if (jQuery("#fbCurrentDir")) {
jQuery("#fbCurrentDir").html("Loading ...");
+ }
jQuery.ajax(
"/filebrowser/browser.php?path=" + encodeURI(path ? path : "/"),
{ type: "get", complete: fbComplete }
);
-
+
}
function fbComplete(req) {
@@ -36,7 +37,7 @@ function fbComplete(req) {
fbFile: function() { jQuery("#fbTarget").val(this.id); }
}
- for(var type in actions) {
+ for (var type in actions) {
jQuery("#fbBrowser ." + type).each(
function() {
jQuery(this).click(actions[type]);
diff --git a/usr/local/www/filebrowser/browser.php b/usr/local/www/filebrowser/browser.php
index dea747e..8ab05db 100644
--- a/usr/local/www/filebrowser/browser.php
+++ b/usr/local/www/filebrowser/browser.php
@@ -15,14 +15,18 @@ function get_content($dir) {
clearstatcache();
$fd = @opendir($dir);
- while($entry = @readdir($fd)) {
- if($entry == ".") continue;
- if($entry == ".." && $dir == "/") continue;
-
- if(is_dir("{$dir}/{$entry}"))
+ while ($entry = @readdir($fd)) {
+ if ($entry == ".") {
+ continue;
+ }
+ if ($entry == ".." && $dir == "/") {
+ continue;
+ }
+ if (is_dir("{$dir}/{$entry}")) {
array_push($dirs, $entry);
- else
+ } else {
array_push($files, $entry);
+ }
}
@closedir($fd);
@@ -34,8 +38,9 @@ function get_content($dir) {
}
$path = realpath(strlen($_GET['path']) > 0 ? $_GET['path'] : "/");
-if(is_file($path))
+if (is_file($path)) {
$path = dirname($path);
+}
// ----- header -----
?>
@@ -54,15 +59,14 @@ if(is_file($path))
<?php
// ----- read contents -----
-if(is_dir($path)) {
+if (is_dir($path)) {
list($dirs, $files) = get_content($path);
?>
-
+
</td>
</tr>
<?php
-}
-else {
+} else {
?>
Directory does not exist.
</td>
@@ -73,7 +77,7 @@ else {
}
// ----- directories -----
-foreach($dirs as $dir):
+foreach ($dirs as $dir):
$realDir = realpath("{$path}/{$dir}");
?>
<tr>
@@ -90,56 +94,56 @@ foreach($dirs as $dir):
endforeach;
// ----- files -----
-foreach($files as $file):
+foreach ($files as $file):
$ext = strrchr($file, ".");
switch ($ext) {
- case ".css":
- case ".html":
- case ".xml":
- $type = "code";
- break;
- case ".rrd":
- $type = "database";
- break;
- case ".gif":
- case ".jpg":
- case ".png":
- $type = "image";
- break;
- case ".js":
- $type = "js";
- break;
- case ".pdf":
- $type = "pdf";
- break;
- case ".inc":
- case ".php":
- $type = "php";
- break;
- case ".conf":
- case ".pid":
- case ".sh":
- $type = "system";
- break;
- case ".bz2":
- case ".gz":
- case ".tgz":
- case ".zip":
- $type = "zip";
- break;
- default:
- $type = "generic";
+ case ".css":
+ case ".html":
+ case ".xml":
+ $type = "code";
+ break;
+ case ".rrd":
+ $type = "database";
+ break;
+ case ".gif":
+ case ".jpg":
+ case ".png":
+ $type = "image";
+ break;
+ case ".js":
+ $type = "js";
+ break;
+ case ".pdf":
+ $type = "pdf";
+ break;
+ case ".inc":
+ case ".php":
+ $type = "php";
+ break;
+ case ".conf":
+ case ".pid":
+ case ".sh":
+ $type = "system";
+ break;
+ case ".bz2":
+ case ".gz":
+ case ".tgz":
+ case ".zip":
+ $type = "zip";
+ break;
+ default:
+ $type = "generic";
}
$fqpn = "{$path}/{$file}";
- if(is_file($fqpn)) {
+ if (is_file($fqpn)) {
$fqpn = realpath($fqpn);
$size = sprintf("%.2f KiB", filesize($fqpn) / 1024);
- }
- else
+ } else {
$size = "";
+ }
?>
<tr>
OpenPOWER on IntegriCloud