Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ include("rbfminc/config.php"); //include("rbfminc/session.php"); require_once('config.inc'); require("guiconfig.inc"); $closehead = false; include("head.inc"); global $config; if ('ok' == 'ok') { set_time_limit(1800); //30 min include("rbfminc/functions.php"); clearstatcache(); $_GET['p'] = urldecode($_GET['p']); if ($_COOKIE['current_folder']) { $initial_folder_cookie = $_COOKIE['current_folder']; } if ($_GET['url_field']) { setcookie('url_field', $_GET['url_field']); $url_field = $_GET['url_field']; } else { $url_field = $_COOKIE['url_field']; } if ($_GET['p']) { if (substr($_GET['p'], -1) != "/") { $_GET['p'] = $_GET['p']."/"; } $current_folder = $_GET['p']; } elseif (($initial_folder_cookie) && (file_exists($initial_folder_cookie))) { if (substr($initial_folder_cookie, -1) != "/") { $initial_folder_cookie = $initial_folder_cookie."/"; } $current_folder = $initial_folder_cookie; } elseif (($initial_folder) && (file_exists($initial_folder))) { if (substr($initial_folder, -1) != "/") { $initial_folder = $initial_folder."/"; } $current_folder = $initial_folder; } else { $current_folder = $_SERVER['DOCUMENT_ROOT']."/"; } if (($only_below) && (strlen($current_folder) < strlen($initial_folder))) { setcookie('current_folder', '', time()-3600); header("Location: file_manager.php"); exit(); } //setcookie('current_folder', $current_folder); if (substr($current_folder, 0, strlen($_SERVER['DOCUMENT_ROOT'])) == $_SERVER['DOCUMENT_ROOT']) { $url_path = "http://" . $_SERVER['HTTP_HOST'] . "/" . substr($current_folder, strlen($_SERVER['DOCUMENT_ROOT'])); } if (($_POST['save_file'] == 'save_file') && ($_GET['f'])) { if ($handle = fopen($current_folder.$_GET['f'] , 'w')) { if (fwrite($handle, stripslashes($_POST['file_content'])) === FALSE) { $alert_info .= "Cannot write to file ({$current_folder}{$_GET['f']})"; } else { $alert_info .= "File ({$current_folder}{$_GET['f']}) successfully saved"; $redirect = "file_manager.php?p=".urlencode($current_folder); } } else { $alert_info .= "Invalid file!!!"; } } if ($_POST['upload_file'] == 'upload_file') { if ($_FILES['file']['error'] == 8) { $alert_info .= "File upload stopped by extension!!!"; } if ($_FILES['file']['error'] == 7) { $alert_info .= "Failed to write file to disk!!!"; } if ($_FILES['file']['error'] == 6) { $alert_info .= "Missing a temporary folder!!!"; } if ($_FILES['file']['error'] == 4) { $alert_info .= "No image was uploaded!!!"; } if ($_FILES['file']['error'] == 3) { $alert_info .= "The uploaded file was only partially uploaded!!!"; } if ($_FILES['file']['error'] == 2) { $alert_info .= "The uploaded file exceeds the MAX_FILE_SIZE!!!"; } if ($_FILES['file']['error'] == 1) { $alert_info .= "The uploaded file exceeds the upload_max_filesize!!!"; } if (!$alert_info) { if ((file_exists($current_folder.$_FILES['file']['name'])) && (!$_POST['replace_file'])) { $alert_info .= "A file with the same name already exist in this folder\\nTo replace this file check \"Replace existing file\" in upload form!"; $redirect = "file_manager.php?p=".urlencode($current_folder); } else { if (!@move_uploaded_file($_FILES["file"]["tmp_name"], $current_folder.$_FILES['file']['name'])) { $alert_info .= "Failed to upload file!!!"; } else { $alert_info .= "File successfully uploaded!"; $redirect = "file_manager.php?p=".urlencode($current_folder); } } } } if (($_GET['do'] == 'delete') && ($_GET['file']) && ($_GET['type'] == 'file')) { if (file_exists($current_folder.$_GET['file'])) { if (!@unlink($current_folder.$_GET['file'])) { $alert_info = "You cannot delete this file\\nThe relevant permissions must permit this."; } else { $alert_info = "File deleted"; $redirect = "file_manager.php?p=".urlencode($current_folder); } } else { $alert_info = "You cannot delete this file\\nInvalid file"; } } if (($_GET['do'] == 'delete') && ($_GET['file']) && ($_GET['type'] == 'directory')) { if (file_exists($current_folder.$_GET['file'])) { if (!RecursiveFolderDelete($current_folder.$_GET['file'])) { $alert_info = "You cannot delete this directory\\nThe relevant permissions must permit this."; } else { $alert_info = "Folder deleted"; $redirect = "file_manager.php?p=".urlencode($current_folder); } } else { $alert_info = "You cannot delete this directory\\nInvalid directory"; } } if ($_POST['create_folder'] == "Create folder") { if (@mkdir($current_folder.$_POST['folder_name'])) { $alert_info = "Folder created successfully!"; } else { $alert_info = "Invalid folder name!"; } } preg_match_all("/\//", $current_folder, $m); if (count($m[0]) > 1) { $up_one_level = " ondblclick=\"document.location='{$_SERVER['PHP_SELF']}?p=".urlencode(substr($current_folder, 0, strrpos(substr($current_folder, 0, -1), "/"))."/")."'\""; } if ($handle = @opendir($current_folder)) { while (false !== ($folder_content = readdir($handle))) { if ((is_dir($current_folder . '/' . $folder_content)) && ($folder_content != '.' && $folder_content != '..')) { $folders[] = $folder_content; } elseif ((!is_dir($current_folder . '/' . $folder_content)) && ($folder != '.') && ($folder_content != '..')) { $files[] = $folder_content; } } closedir($handle); } else { $error = "

Invalid directory

"; } $container .= <<   Name   Ext. Size Date Attributes F [..] EOF; $id = 1; if (is_array($folders)) { array_multisort($folders, SORT_ASC, SORT_REGULAR); foreach ($folders as $v) { if ($v) { $vf = $v.'/'; $last_updated_time = date("Y.m.d H:i:s", filemtime($current_folder.$v)); $fileperms = GetFilePerms($current_folder.$v); if ($url_path) { $browser = "\"W\""; if ($url_field) { $use_url = "\"U\""; } else { $use_url = "\"U\""; } } else { $browser = " "; $use_url = "\"U\""; } $cfe = urlencode($current_folder); $vfe = urlencode($v); $container .= << Folder
{$v}
{$browser}   Rename   D   <DIR> {$last_updated_time} {$fileperms} EOF; $id++; } } } if (is_array($files)) { array_multisort($files, SORT_ASC, SORT_REGULAR); foreach ($files as $v) { if ($v) { $extension = substr(strrchr($v, "."), 1); $file_image = "ico_file.png"; if (($extension == 'php') || ($extension == 'php3')) { $file_image = "ico_php.png"; } if (($extension == 'htm') || ($extension == 'HTM') || ($extension == 'html') || ($extension == 'HTML')) { $file_image = "ico_html.png"; } if (($extension == 'jpg') || ($extension == 'JPG') || ($extension == 'jpeg') || ($extension == 'JPEG') || ($extension == 'gif') || ($extension == 'GIF') || ($extension == 'png') || ($extension == 'PNG')) { $file_image = "ico_picture.png"; } $last_updated_time = date("Y.m.d H:i:s", filemtime($current_folder.$v)); $file_size = roundsize(filesize($current_folder.$v)); if (($extension == 'txt') || ($extension == 'inc') || ($extension == 'sh') || ($extension == 'js') || ($extension == 'xml') || ($extension == 'conf') || ($extension == 'config') || ($extension == 'ini') || ($extension == 'php') || ($extension == 'php3') || ($extension == 'htm') || ($extension == 'HTM') || ($extension == 'html') || ($extension == 'HTML') || ($extension == 'css') || ($extension == 'CSS')) { $edit_file_content = "\"Edit\""; } else { $edit_file_content = " "; } $fileperms = GetFilePerms($current_folder.$v); if ($url_path) { $browser = "\"W\""; if ($url_field) { $use_url = "\"U\""; } else { $use_url = "\"U\""; } } else { $browser = " "; $use_url = "\"U\""; } $cfe = urlencode($current_folder); $vfe = urlencode($v); $container .= << File
{$v}
{$browser} Download Rename {$edit_file_content} D {$extension} {$file_size} {$last_updated_time} {$fileperms} EOF; $id++; } } } $container .= ""; $container = preg_replace("/\s+/m", " ", $container); ?>

URL path:
Upload a file in current folder:    Replace existing file   
    Create new folder here; Folder name:
[ open OPEN IN BROWSER ]     [ download DOWNLOAD ]     [ rename RENAME ]     [ view VIEW/EDIT ]     [ delete DELETE ]
File: {$current_folder}{$_GET['f']}

EOD; } ?>
Created by TomSchaefer // EOD; } if ($redirect) { echo << // EOD; } ?> Login