diff options
author | Renato Botelho <renato@netgate.com> | 2015-08-25 08:08:24 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-08-25 14:49:54 -0300 |
commit | 46bc6e545a17e77202aaf01ec0cd8d5a46567525 (patch) | |
tree | 32d18dda436ec739c67c489ceb771e8629cd926f /src/usr/local/www/filebrowser | |
parent | 4d9801c2dbd2b3e54a39578ee62b93af66607227 (diff) | |
download | pfsense-46bc6e545a17e77202aaf01ec0cd8d5a46567525.zip pfsense-46bc6e545a17e77202aaf01ec0cd8d5a46567525.tar.gz |
Move main pfSense content to src/
Diffstat (limited to 'src/usr/local/www/filebrowser')
22 files changed, 213 insertions, 0 deletions
diff --git a/src/usr/local/www/filebrowser/browser.js b/src/usr/local/www/filebrowser/browser.js new file mode 100644 index 0000000..2769db3 --- /dev/null +++ b/src/usr/local/www/filebrowser/browser.js @@ -0,0 +1,48 @@ +/* + pfSense_MODULE: shell +*/ + +jQuery(document).ready( + function() { + jQuery("#fbOpen").click( + function() { + jQuery("#fbBrowser").fadeIn(750); + fbBrowse(jQuery("#fbTarget").val()); + } + ); + } +); + +function fbBrowse(path) { + jQuery("#fileContent").fadeOut(); + + if (jQuery("#fbCurrentDir")) { + jQuery("#fbCurrentDir").html("Loading ..."); + } + + jQuery.ajax( + "/filebrowser/browser.php?path=" + encodeURI(path ? path : "/"), + { type: "get", complete: fbComplete } + ); + +} + +function fbComplete(req) { + jQuery("#fbBrowser").html(req.responseText); + + var actions = { + fbHome: function() { fbBrowse("/"); }, + fbClose: function() { jQuery("#fbBrowser").fadeOut(750); }, + fbDir: function() { fbBrowse(this.id); }, + fbFile: function() { jQuery("#fbTarget").val(this.id); } + } + + for (var type in actions) { + jQuery("#fbBrowser ." + type).each( + function() { + jQuery(this).click(actions[type]); + jQuery(this).css("cursor","pointer"); + } + ); + } +} diff --git a/src/usr/local/www/filebrowser/browser.php b/src/usr/local/www/filebrowser/browser.php new file mode 100644 index 0000000..8ab05db --- /dev/null +++ b/src/usr/local/www/filebrowser/browser.php @@ -0,0 +1,165 @@ +<?php + +require_once("guiconfig.inc"); + +/* + pfSense_MODULE: shell + Copyright (C) 2013-2015 Electric Sheep Fencing, LP + +*/ +// Fetch a list of directories and files inside a given directory +function get_content($dir) { + $dirs = array(); + $files = array(); + + clearstatcache(); + $fd = @opendir($dir); + + while ($entry = @readdir($fd)) { + if ($entry == ".") { + continue; + } + if ($entry == ".." && $dir == "/") { + continue; + } + if (is_dir("{$dir}/{$entry}")) { + array_push($dirs, $entry); + } else { + array_push($files, $entry); + } + } + + @closedir($fd); + + natsort($dirs); + natsort($files); + + return array($dirs, $files); +} + +$path = realpath(strlen($_GET['path']) > 0 ? $_GET['path'] : "/"); +if (is_file($path)) { + $path = dirname($path); +} + +// ----- header ----- +?> +<table width="100%"> + <tr> + <td class="fbHome" width="25px" align="left"> + <img onClick="jQuery('#fbTarget').val('<?=$realDir?>'); fbBrowse('/');" src="/filebrowser/images/icon_home.gif" alt="Home" title="Home" /> + </td> + <td><b><?=$path;?></b></td> + <td class="fbClose" align="right"> + <img onClick="jQuery('#fbBrowser').fadeOut();" border="0" src="/filebrowser/images/icon_cancel.gif" alt="Close" title="Close" /> + </td> + </tr> + <tr> + <td id="fbCurrentDir" colspan="3" class="vexpl" align="left"> +<?php + +// ----- read contents ----- +if (is_dir($path)) { + list($dirs, $files) = get_content($path); +?> + + </td> + </tr> +<?php +} else { +?> + Directory does not exist. + </td> + </tr> +</table> +<?php + exit; +} + +// ----- directories ----- +foreach ($dirs as $dir): + $realDir = realpath("{$path}/{$dir}"); +?> + <tr> + <td></td> + <td class="fbDir vexpl" id="<?=$realDir;?>" align="left"> + <div onClick="jQuery('#fbTarget').val('<?=$realDir?>'); fbBrowse('<?=$realDir?>');"> + <img src="/filebrowser/images/folder_generic.gif" /> + <?=$dir;?> + </div> + </td> + <td></td> + </tr> +<?php +endforeach; + +// ----- files ----- +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"; + } + + $fqpn = "{$path}/{$file}"; + + if (is_file($fqpn)) { + $fqpn = realpath($fqpn); + $size = sprintf("%.2f KiB", filesize($fqpn) / 1024); + } else { + $size = ""; + } + +?> + <tr> + <td></td> + <td class="fbFile vexpl" id="<?=$fqpn;?>" align="left"> + <?php $filename = str_replace("//","/", "{$path}/{$file}"); ?> + <div onClick="jQuery('#fbTarget').val('<?=$filename?>'); loadFile(); jQuery('#fbBrowser').fadeOut();"> + <img src="/filebrowser/images/file_<?=$type;?>.gif" alt="" title=""> + <?=$file;?> + </div> + </td> + <td align="right" class="vexpl"> + <?=$size;?> + </td> + </tr> +<?php +endforeach; +?> +</table> diff --git a/src/usr/local/www/filebrowser/images/file_code.gif b/src/usr/local/www/filebrowser/images/file_code.gif Binary files differnew file mode 100755 index 0000000..f06a205 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_code.gif diff --git a/src/usr/local/www/filebrowser/images/file_database.gif b/src/usr/local/www/filebrowser/images/file_database.gif Binary files differnew file mode 100755 index 0000000..d479c91 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_database.gif diff --git a/src/usr/local/www/filebrowser/images/file_doc.gif b/src/usr/local/www/filebrowser/images/file_doc.gif Binary files differnew file mode 100755 index 0000000..222c31b --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_doc.gif diff --git a/src/usr/local/www/filebrowser/images/file_flash.gif b/src/usr/local/www/filebrowser/images/file_flash.gif Binary files differnew file mode 100755 index 0000000..e565c37 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_flash.gif diff --git a/src/usr/local/www/filebrowser/images/file_generic.gif b/src/usr/local/www/filebrowser/images/file_generic.gif Binary files differnew file mode 100755 index 0000000..5f39482 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_generic.gif diff --git a/src/usr/local/www/filebrowser/images/file_image.gif b/src/usr/local/www/filebrowser/images/file_image.gif Binary files differnew file mode 100755 index 0000000..4960683 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_image.gif diff --git a/src/usr/local/www/filebrowser/images/file_js.gif b/src/usr/local/www/filebrowser/images/file_js.gif Binary files differnew file mode 100755 index 0000000..9b6601f --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_js.gif diff --git a/src/usr/local/www/filebrowser/images/file_pdf.gif b/src/usr/local/www/filebrowser/images/file_pdf.gif Binary files differnew file mode 100755 index 0000000..b01bb23 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_pdf.gif diff --git a/src/usr/local/www/filebrowser/images/file_php.gif b/src/usr/local/www/filebrowser/images/file_php.gif Binary files differnew file mode 100755 index 0000000..ab7f459 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_php.gif diff --git a/src/usr/local/www/filebrowser/images/file_ppt.gif b/src/usr/local/www/filebrowser/images/file_ppt.gif Binary files differnew file mode 100755 index 0000000..0383c98 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_ppt.gif diff --git a/src/usr/local/www/filebrowser/images/file_system.gif b/src/usr/local/www/filebrowser/images/file_system.gif Binary files differnew file mode 100755 index 0000000..f1997c7 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_system.gif diff --git a/src/usr/local/www/filebrowser/images/file_xls.gif b/src/usr/local/www/filebrowser/images/file_xls.gif Binary files differnew file mode 100755 index 0000000..d004013 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_xls.gif diff --git a/src/usr/local/www/filebrowser/images/file_zip.gif b/src/usr/local/www/filebrowser/images/file_zip.gif Binary files differnew file mode 100755 index 0000000..ec98255 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/file_zip.gif diff --git a/src/usr/local/www/filebrowser/images/folder_generic.gif b/src/usr/local/www/filebrowser/images/folder_generic.gif Binary files differnew file mode 100755 index 0000000..45b191d --- /dev/null +++ b/src/usr/local/www/filebrowser/images/folder_generic.gif diff --git a/src/usr/local/www/filebrowser/images/icon_cancel.gif b/src/usr/local/www/filebrowser/images/icon_cancel.gif Binary files differnew file mode 100755 index 0000000..246a819 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/icon_cancel.gif diff --git a/src/usr/local/www/filebrowser/images/icon_contract.gif b/src/usr/local/www/filebrowser/images/icon_contract.gif Binary files differnew file mode 100755 index 0000000..cf82159 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/icon_contract.gif diff --git a/src/usr/local/www/filebrowser/images/icon_expand.gif b/src/usr/local/www/filebrowser/images/icon_expand.gif Binary files differnew file mode 100755 index 0000000..06c0c68 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/icon_expand.gif diff --git a/src/usr/local/www/filebrowser/images/icon_home.gif b/src/usr/local/www/filebrowser/images/icon_home.gif Binary files differnew file mode 100755 index 0000000..f888434 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/icon_home.gif diff --git a/src/usr/local/www/filebrowser/images/icon_left.gif b/src/usr/local/www/filebrowser/images/icon_left.gif Binary files differnew file mode 100755 index 0000000..0d1137c --- /dev/null +++ b/src/usr/local/www/filebrowser/images/icon_left.gif diff --git a/src/usr/local/www/filebrowser/images/icon_magnifier.gif b/src/usr/local/www/filebrowser/images/icon_magnifier.gif Binary files differnew file mode 100755 index 0000000..e96e548 --- /dev/null +++ b/src/usr/local/www/filebrowser/images/icon_magnifier.gif |