25 $folders = array(
'../media/images',
56 if (isset(
$_GET[
'path']) && (!empty(
$_GET[
'path'])))
58 $backBtn =
"<a class=\"btn btn-success pull-right\" href=\"index.php?page=filemanager\" onclick=\"window.history.back();\"><i class=\"fa fa-level-up\"></i> $lang[BACK]</a>";
66 print
"<table style=\"width:100%;\" class=\"table table-responsive table-hover\" id=\"table-sort$i\">
69 <td style=\"width:10%;\" class=\"text-right\"><b>$lang[FILEMAN_SIZE]</b></td>
70 <td style=\"width:70%;\" class=\"text-left\"><b>$lang[FILEMAN_FILENAME]</b></td>
71 <td style=\"width:10%;\" class=\"text-center\"><b>$lang[FILEMAN_RIGHTS]</b></td>
72 <td style=\"width:10%;\" class=\"text-center\"><b>$lang[ACTIONS]</b></td>
83 print
"</tbody></table><br><br>";
93 if (isset($path) && (!empty($path) && (is_dir($path))))
96 $iter = new \RecursiveIteratorIterator(
97 new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS),
98 \RecursiveIteratorIterator::SELF_FIRST,
99 \RecursiveIteratorIterator::CATCH_GET_CHILD
104 echo
"<optgroup label=\"Subfolder\">";
105 foreach ($iter as $path => $dir)
107 if($dir->getFilename() ===
"audio")
continue;
108 if($dir->getFilename() ===
"backup")
continue;
109 if($dir->getFilename() ===
"documents")
continue;
110 if($dir->getFilename() ===
"downloads")
continue;
111 if($dir->getFilename() ===
"images")
continue;
112 if($dir->getFilename() ===
"mailbox")
continue;
113 if($dir->getFilename() ===
"uploads")
continue;
114 if($dir->getFilename() ===
"video")
continue;
123 $subpath = ltrim($path,
"..");
124 $subpath = ltrim($subpath,
"/");
125 $subpath = ltrim($subpath,
"media");
126 $subpath = ltrim($subpath,
"/");
127 $subpath = strtr($subpath,
"\\",
"/");
128 $label = ltrim($subpath,
"/");
129 $label = ucfirst($label);
130 echo
"<option value=\"$subpath\"> $label</option>";
162 if (isset(
$_GET[
'path']) && (!empty(
$_GET[
'path'])))
179 die (
"$lang[FILEMAN_FOLDER_MISSING]");
186 foreach (
new \DirectoryIterator($path) as $file) {
188 if ($file->isFile()) {
190 $files[] = htmlentities($file);
192 $file_perms[] = substr(sprintf(
'%o', fileperms($path .
"/" . $file)), -4);
194 $file_size[] = filesize($path .
"/" . $file);
197 if ($file->isDir() AND (!$file->isDot())) {
198 $folders[] = htmlentities($file);
199 $dir_perms[] = substr(sprintf(
'%o', fileperms($path .
"/" . $file)), -4);
203 if (!empty($files)) {
207 if (!empty($folders)) {
212 if (empty($files) && (empty($folders)))
214 $errorMsg =
"$lang[FILEMAN_THIS_EMPTY_DIR]<br>
215 <a href=\"index.php?page=filemanager\" onclick=\"window.history.back();\"> $lang[BACK]</a>";
229 $deleteIcon =
"<i class=\"fa fa-trash-o\"></i>";
230 foreach ($folders as $dir_value)
233 if (!isset($file_perms[
$i])){ $file_perms[
$i] =
''; }
234 if (!isset($dir_perms[
$i])){ $dir_perms[
$i] =
''; }
239 <td class=\"text-right\"><a href=\"?page=filemanager&path=$path" .
"/$dir_value\"><div style=\"width:100%\"><i class=\"fa fa-folder\"></i></div></a></td>
240 <td class=\"text-left\"><a href=\"?page=filemanager&path=$path" .
"/$dir_value\"><div style=\"width:100%\">$dir_value</div></a></td>
241 <td class=\"text-center\">$dir_perms[$i] <small><a class=\"fa fa-edit\" onclick=\"setChmodCode('$path/$file_value', '$file_perms[$i]');\" data-toggle=\"modal\" data-target=\"#chmodModal\" data-foldername=\"$file_perms[$i]\" title=\"$lang[FILEMAN_CHMOD]\" href=\"#myModal\"></a></small> </td>
242 <td class=\"text-center\">
243 <a class=\"fa fa-trash-o\" data-title=\"$lang[FILEMAN_REMOVE_FOLDER]\" data-itemtype=\"$lang[FOLDER]\" role=\"dialog\" data-confirm=\"$lang[FILEMAN_DELETE] «$dir_value»\"
244 title=\"$lang[FILEMAN_REMOVE_FOLDER]\" data-target=\"#deleteModal\" data-toggle=\"modal\" href=\"index.php?page=filemanager&delete=1&path=$path&item=$dir_value&folder=$folder\"></a>
246 <a class=\"fa fa-pencil\" id=\"renameToggle\" onclick=\"setRenameFieldState('$path', '$dir_value', '$lang[FILEMAN_RENAME_FOLDER]');\" data-toggle=\"modal\" data-target=\"#renameModal\" data-foldername=\"$dir_value\" title=\"$lang[RENAME]\" href=\"#myModal\"></a>
266 foreach ($files as $file_value) {
270 <td class=\"text-right\">$fsize</td>
271 <td class=\"text-left\"><a href='$path" .
"/$file_value'><div style=\"width:100%\">$file_value</div></a></td>
272 <td class=\"text-center\">$file_perms[$i] <small><a class=\"fa fa-edit\" onclick=\"setChmodCode('$path/$file_value', '$file_perms[$i]');\" data-toggle=\"modal\" data-target=\"#chmodModal\" data-foldername=\"$file_perms[$i]\" title=\"$lang[FILEMAN_CHMOD]\" href=\"#myModal\"></a></small></td>
273 <td class=\"text-center\">
275 <a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"$lang[FILEMAN_DELETE] «$file_value»\"
276 title=\"$lang[FILEMAN_REMOVE_FILE]\" data-target=\"#moveModal\" data-toggle=\"modal\" href='index.php?page=filemanager&delete=1&path=$path&item=$file_value&folder=$folder'></a>
278 <a class=\"fa fa-pencil\" onclick=\"setRenameFieldState('$path', '$file_value', '$lang[FILEMAN_RENAME_FILE]');\" data-toggle=\"modal\" data-target=\"#renameModal\" data-foldername=\"$file_value\" title=\"$lang[RENAME]\" href=\"#myModal\"></a>
298 foreach(glob(
"{$directory}/*") as $file)
310 if (rmdir($directory))
335 if (self::recursiveRemoveDirectory($file))
347 else if (is_file($file))
375 if ($postMaxSize = ini_get(
'post_max_size'))
381 if (!isset(
$db)) {
$db = new \YAWK\db(); }
382 \YAWK\sys::setSyslog(
$db, 27, 1,
"failed to ini_get post_max_size", 0, 0, 0, 0);
383 echo
"Unable to get post_max_size";
398 if ($upload_max_filesize = ini_get(
'upload_max_filesize'))
400 return $upload_max_filesize;
404 if (!isset(
$db)) {
$db = new \YAWK\db(); }
405 \YAWK\sys::setSyslog(
$db, 27, 1,
"failed to ini_get upload_max_filesize", 0, 0, 0, 0);
421 if ($postMaxSize = ini_get(
'post_max_size'))
423 $returnValue = $postMaxSize;
425 if ($upload_max_filesize = ini_get(
'upload_max_filesize'))
427 $returnValue .=
" (".$upload_max_filesize.
")";
431 if (!isset(
$db)) {
$db = new \YAWK\db(); }
432 \YAWK\sys::setSyslog(
$db, 27, 1,
"failed to ini_get post_max_size", 0, 0, 0, 0);
451 foreach (
new \DirectoryIterator(
$folder) as $fileInfo) {
452 if($fileInfo->isDot())
continue;
453 if($fileInfo->isDir())
continue;
468 foreach (
new \DirectoryIterator(
$folder) as $fileInfo) {
469 if($fileInfo->isDot())
continue;
470 if($fileInfo->isDir())
continue;
471 echo $fileInfo->getFilename() .
"<br>\n";
484 if (isset($string) && (!empty($string)))
488 $string = preg_replace (
'/[^a-z0-9-. ]/i',
'', $string);
490 $string = trim($string);
492 $string = strtr($string,
"\\",
"/");
494 $string = ltrim($string,
"/");
496 $string = rtrim($string,
"/");
515 foreach (
new \DirectoryIterator(
$folder) as $fileInfo) {
516 if($fileInfo->isDot())
continue;
517 if($fileInfo->isDir())
continue;
518 $files[] = $fileInfo->getFilename();
532 $subFolders = array();
533 foreach (
new \DirectoryIterator(
$folder) as $fileInfo) {
534 if($fileInfo->isDot())
continue;
535 if($fileInfo->isFile())
continue;
536 if($fileInfo->isDir())
537 $subFolders[] = $fileInfo->getFilename();
551 $ritit = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$folder, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
553 foreach ($ritit as $splFileInfo) {
555 $path = $splFileInfo->isDir()
556 ? array($splFileInfo->getFilename() => array())
557 : array($splFileInfo->getFilename());
559 for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth--) {
560 $path = array($ritit->getSubIterator($depth)->current()->getFilename() => $path);
563 $r = array_merge_recursive($r, $path);
592 if (!isset($precision) || (empty($precision)))
597 $label = array(
'B',
'KB',
'MB',
'GB',
'TB',
'PB');
599 for (
$i = 0; $bytes >= 1024 &&
$i < (count($label) - 1); $bytes /= 1024,
$i++) ;
601 return (round($bytes, $precision) .
" " . $label[
$i]);
611 $url =
"http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types";
613 foreach(@explode(
"\n",@file_get_contents(
$url))as $x)
614 if(isset($x[0])&&$x[0]!==
'#'&&preg_match_all(
'#([^\s]+)#',$x,$out)&&isset($out[1])&&($c=count($out[1]))>1)
616 $s[]=
' \''.$out[1][
$i].
'\' => \
''.$out[1][0].
'\'';
617 return @sort($s)?
'$mime_types = array(<br />'.implode($s,
',<br />').
'<br />);':
false;
print $lang['FILEMAN_UPLOAD']
Basic File Manager (Backend)
static subdirToOptions($path)
all folders in $path as select <option>...</option>
static countFilesFromFolder($folder)
count files from folder
static getUploadMaxFilesize()
get and return upload max filesize value from phpinfo()
static getFilesFromFolderToArray($folder)
returns an array containing only files from folder (no subfolders)
static ritit($folder)
returns an multidimensional array containing subfolders + files of given folder
__construct()
filemanager constructor. check if all media subfolder exists, if not, try to create them
static recursiveRemoveDirectory($directory)
Delete a directory recursive.
static getPhpMaxUploadSize()
get and return PHP max file size setting
static deleteItem($file)
delete file from folder
static getFilesFromFolder($folder, $lang)
returns a list of all files in given folder. expect $folder as string
static removeSpecialChars($string)
remove special chars as well as leading and trailing slashes from string
static getPostMaxSize()
get and return post_max_size value from phpinfo()
static getFilesOnlyFromFolder($folder)
output a list showing only files from folder (no subfolders)
static drawTableFooter()
draw: output html end table body, end table
static sizeFilter($bytes, $precision)
calculate filesize from bytes
static getSubfoldersToArray($folder)
returns an array containing only files from folder (no subfolders)
static getCurrentMimeTypes()
Fast generation of a complete uptodate mime types list.
static drawTableHeader($lang, $i)
draw the table header with labeling
This class serves methods to create backup from files.