README. * @author Adrian7 (http://adrian.silimon.eu/) * @version 0.7.5 * @package PHPFileBrowser */ //--- Settings, plz don't ignore or you might create a security hole on your server ---// //Here you tell the script to limit access only to users aware of this password. 'none' means no password. define('ADMIN_PASS', '7552525'); //Here you can put a custom format to display dates define('DATE_FORMAT', 'Y-m-d H:i:s'); //Here you can put a virtual dir, (ex.: /~homedir) to properly display files under a virtual directory define('SBVDIR', ''); //--- Settings, hope you did some changes... ---// error_reporting(E_ALL ^ E_NOTICE); session_start(); if ( isset($_POST['yourpass']) and ( $_POST['yourpass'] == ADMIN_PASS ) ) $_SESSION['xfbrowserauth'] = 1; define('SBFILE', basename(__FILE__)); define('SPATH', dirname(__FILE__)); define('SBURL', str_replace("/" . SBFILE, '', str_replace(( '?' . $_SERVER['QUERY_STRING']), "", $_SERVER['REQUEST_URI']))); //force download files with these extensions, ignore if they may be displayed $downloadableExts = array(); //an array of supported playable extensions by browsers $playableExts = array('jpg', 'jpeg', 'gif', 'png', 'apng', 'svg', 'ico', 'wav', 'ogg', 'mp3', 'mp4', 'ogv', 'webm', 'flv', 'swf'); //an array of extensions you might wanna play using a flash swf player. See also flashCfg var below $flashPlayableExts = array('flv', 'avi', 'mpeg'); //an array of files for which the source (contents) of the wile will be displayed $sourceExts = array('txt', 'php', 'js', 'php5', 'htm', 'html', 'xml', 'css', 'md', 'ini', '.htaccess', 'java', 'rb', 'py', 'sql'); //globals $isFile = FALSE; $isHome = FALSE; $isDir = FALSE; $isSearch = FALSE; $isNotFound = FALSE; //message types define('ERROR_MSG', 'error'); define('WARN_MSG' , 'warn'); define('INFO_MSG' , 'info'); /** * Outputs a <p> message tag * @param string $message * @param string $msg_type optional additional element class */ function showmsg($message, $msg_type="warn"){ ?>

= 1073741824) return ( round(($size / 1073741824), 2) . " GB" ); if ($size >= 1048576) return ( round(($size / 1048576), 2) . " MB" ); if ($size >= 1024) return ( round(($size / 1024), 2) . " KB" ); return ($size . ' bytes'); } /** * Formats a timestamp to a human-readable format * @param int $timestamp * @param string $format (optional), default is Y-m-d * @return string */ function fmt_date($timestamp, $format="Y-m-d"){ return date($format, $timestamp); } /** * Finds the value of a PHP configuration directive * @param $var name of the directive * @param bool $parseint (optional), set it to 1 or true in case that directive represents a file size in K (KB), M (MB) or G (GB) and you want the value in bytes * @return bool|int|string */ function env_get_cfg($var, $parseint=FALSE){ $value = @ini_get($var); if($value){ if ($parseint){ $last = substr($value, -1, 1); if ( in_array($last, array('K', 'M', 'G')) ){ $value = intval( substr($value, 0, strlen($value)-1) ); if ( $last == 'K' ) return ($value * 1024); if ( $last == 'M' ) return ($value * 1024 * 1024); if ( $last == 'G' ) return ($value * 1024 * 1024 * 1024); } } return $value; } return FALSE; } /** * Generates an array of directories and files * @param string $path absolute path co the directory * @param bool $subdirectories (optional) * @return array */ function dirtree($path, $subdirectories=TRUE){ $path = rtrim($path, "/"); if ( is_file($path) ) $path = dirname($path); if ( !is_array($tree) ) $tree = array(); $k=0; if ( $handle = @opendir($path) ){ while (FALSE !== ( $file = readdir($handle) ) ){ if ( ( $file == '.' ) or ( $file == '..') ) continue; $node = ( $path . "/" . $file ); $tree[$k] = array('name'=>basename($file), 'path'=>$node); if ( is_dir($node) and $subdirectories ) $tree[$k]['nodes'] = dirtree($node, TRUE); $k++; } } return $tree; } function recursive_remove_directory($directory, $empty=FALSE){ if(substr($directory,-1) == '/'){ $directory = substr($directory,0,-1); } if(!file_exists($directory) || !is_dir($directory)){ return FALSE; }elseif(is_readable($directory)){ $handle = opendir($directory); while (FALSE !== ($item = readdir($handle))){ if($item != '.' && $item != '..') { $path = $directory.'/'.$item; if(is_dir($path)) { recursive_remove_directory($path); }else{ unlink($path); } } } closedir($handle); if($empty == FALSE){ if(!rmdir($directory)){ return FALSE; } } } return TRUE; } function get_file_url($file){ $proto = "http"; $self = str_replace(SPATH, "", $_SERVER['PHP_SELF']); $self = str_replace(SBVDIR, "", $self); $selfdir = trim(str_replace(SBFILE, "", $self), "/"); $file = str_replace(SPATH, "", $file); $file = ("/" . $selfdir . $file); if ( isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS'] and $_SERVER['HTTPS'] != "off") ) $proto = "https"; return ($proto . '://' . $_SERVER['SERVER_NAME'] . $file); } function breadcrumbs($rootname="/"){ $dirname = urldecode($_GET['view']); if( $dirname == "." || $dirname == "/" ){ $path= SPATH; $bdir= ""; }else{ $path = ( SPATH . str_replace(SBVDIR, "", $dirname) ); $bdir= str_replace(SBURL, "", $dirname); } $burl = ""; $chunks = explode("/", trim($dirname, "/")); ?> RecursiveDirectoryIterator class not available!"); $ignorelist = get_ignore_files_list(); $dirname = urldecode($_GET['view']); if( $dirname == "." || $dirname == "/" ){ $path= SPATH; $bdir= ""; }else{ $path = ( SPATH . str_replace(SBVDIR, "", $dirname) ); $bdir= str_replace(SBURL, "", $dirname); } $k=0; if ($handle = opendir($path) ){ while (false !== ($file = readdir($handle)) ){ if ($file != "." && $file != ".."){ $k++; $abspath = (rtrim($path) . "/" . $file); //ignored files if( in_array($abspath, $ignorelist) ) continue; $csscls = ""; $size = ""; $action = "view"; if( is_dir($abspath) ) $csscls = "dir "; if( is_file($abspath) ){ $csscls = "file "; $csscls.= get_file_ext($file); $size = (fmt_filesize( filesize($abspath) ) . " / "); if ( is_downloadable_file($abspath) ) $action = "download"; } if( empty($csscls) ) $csscls = "symlink "; $lastmod = fmt_date(@filemtime($abspath), DATE_FORMAT); $fileurl = ( rtrim($bdir, "/") . "/" . str_replace(SPATH, "", $file) ); $eurl = urlencode($fileurl); $anchor = (SBFILE . '?' . $action .'='. $eurl ); $dlurl = (SBFILE . '?download='. $eurl ); $rmurl = (SBFILE . '?delete='. $eurl ); ?>  

404 - File not found

RecursiveDirectoryIterator class not available!"); $term = stripslashes( urldecode($_GET['s'] ) ); $Tree = new RecursiveDirectoryIterator(SPATH); $count=0; foreach(new RecursiveIteratorIterator($Tree) as $dir=>$path) { if ( strpos($path, "/..") ) $path = str_replace("/..", "", $path); $filename = basename($path); if( strpos(strtolower(trim($filename)), $term) === FALSE ) continue; else{ $fileurl = ( str_replace(SPATH, "", $path) ); $csscls = ""; $action = "view"; if( is_dir($path) ) $csscls = "dir "; if( is_file($path) ){ $csscls = "file "; $csscls.= get_file_ext($path); if ( is_downloadable_file($path) ) $action = "download"; } if( empty($csscls) ) $csscls = "symlink "; ?>  
/
open($zfile, ZipArchive::OVERWRITE) ){ foreach ($files as $f) @$zip->addFile($f, basename($f)); $zip->close(); $size = filesize($zfile); $filename = ( basename($path) . ".zip" ); header('Content-Type: application/zip'); header('Content-Length: ' . $size ); header('Content-Disposition: attachment; filename="' . $filename . '"'); if ( @readfile($zfile) ){ @unlink($zfile); exit(); } else showmsg("Error: Could not read the file $zfile", MSG_ERROR); } else showmsg("Error: Could not create temporary file!", ERROR_MSG); } else showmsg("Error: the directory is empty!", ERROR_MSG); } showmsg("Error: Could not download file $path", ERROR_MSG); } if ( isset($_GET['delete']) ) { //delete action if ( (ADMIN_PASS != 'none') and empty($_SESSION['xfbrowserauth']) ) die("..."); $path = stripslashes( urldecode($_GET['delete']) ); $path = trim($path, "/"); if ( is_file($path) ) if ( @unlink(SPATH . "/" . $path) ); else showmsg("Error: Could not delete the file $path", ERROR_MSG); if( is_dir($path) ) recursive_remove_directory(SPATH . "/" . $path); //redirect to parent folder $redirect = ( SBFILE . "?view=" . urlencode( "/" . rtrim( str_replace(basename($path), "", $path) , "/"))); header("Location: $redirect"); } if( isset($_GET['move']) ){ //move action //TODO debug $destpath = ( SPATH . rtrim( urldecode($_GET['move']), "/" ) . "/" ); $itemscnt = intval($_COOKIE['itemstomove']); //die("itemstomove = {$itemscnt}"); if ( $itemscnt > 0 ) for($i=0; $i<$itemscnt; $i++){ $cname = ('moveitem_' . strval($i)); $path = urldecode($_COOKIE[$cname]); $opath = (SPATH . $path); //die("opath = {$opath} | destpath=" . $destpath . basename($path)); if( is_file($opath) or is_dir($opath) ) @rename( $opath, ($destpath . basename($path)) ); @setcookie($cname, "", time()-3600); //expire the cookie } @setcookie('itemstomove', 0, time()-3600); $redirect = ( SBFILE . '?view=' . $_GET['move'] ); header("Location: {$redirect}"); } if ( isset($_GET['upload']) ){ //upload action if ( (ADMIN_PASS != 'none') and empty($_SESSION['xfbrowserauth']) ) die("..."); $upload_dir = urldecode($_GET['upload']); if( !is_dir(SPATH . $upload_dir) ) $upload_dir = substr($upload_dir, 0, strrpos($upload_dir, "/")+1); $upload_dir = (SPATH . $upload_dir); if ( count($_FILES['fileupload']) ){ $Error = ""; $Success = 0; $File = $_FILES['fileupload']; $upload_file = ($upload_dir . '/' . $File['name'] ); if( empty($File['error']) and @move_uploaded_file($File['tmp_name'], $upload_file) ){ $Success = 1; } else{ //--- handle most common file upload errors ---// if( $File['error'] == UPLOAD_ERR_INI_SIZE ){ $sysmaxsize = fmt_filesize( env_get_cfg('upload_max_filesize', true) ); $Error = "The {$File['name']} is too large. Please upload files smaller then {$sysmaxsize}"; } if( $File['error'] == UPLOAD_ERR_CANT_WRITE ) $Error = "Fatal error: can't write to the temporaty folder, set for file uploads. Please review your server's php.ini settings and try again."; if( $File['error'] == UPLOAD_ERR_EXTENSION ) $Error = "The {$File['name']} cound not be uplooaded due to file extension restrictions."; if( empty($Error) ) $Error = "Oups! Unknown error. Maybe " . urldecode($_GET['upload']) . " is not writable by the current php process."; } echo $Success ? $Success : $Error; exit(); } ?> PHPFileBrowser - Upload

Upload Folder:


uploading in progress

 

  


~ drag and drop files here, or use the button below ~



Cloud Files

Cloud Files

Wrong password!



 

Please change your ADMIN_PASS to something else!