Basic File Manager (Backend)
More...
|
| __construct () |
| filemanager constructor. check if all media subfolder exists, if not, try to create them More...
|
|
Basic File Manager (Backend)
Basic File Manager (Backend)
This basic file manager class provides simple view, delete and upload methods.
Class covers backend functionality. See Methods Summary for details!
- Author
- Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
- Copyright
- 2009-2015 Daniel Retzl yawk.goodconnect.net @license https://opensource.org/licenses/MIT
- Since
- File available since Release 1.0.0
Definition at line 16 of file filemanager.php.
◆ __construct()
YAWK\filemanager::__construct |
( |
| ) |
|
filemanager constructor. check if all media subfolder exists, if not, try to create them
Definition at line 23 of file filemanager.php.
25 $folders = array(
'../media/images',
References $folder.
◆ countFilesFromFolder()
static YAWK\filemanager::countFilesFromFolder |
( |
|
$folder | ) |
|
|
static |
◆ deleteItem()
static YAWK\filemanager::deleteItem |
( |
|
$file | ) |
|
|
static |
◆ drawTableFooter()
static YAWK\filemanager::drawTableFooter |
( |
| ) |
|
|
static |
draw: output html end table body, end table
Definition at line 81 of file filemanager.php.
83 print
"</tbody></table><br><br>";
◆ drawTableHeader()
static YAWK\filemanager::drawTableHeader |
( |
|
$lang, |
|
|
|
$i |
|
) |
| |
|
static |
draw the table header with labeling
- Parameters
-
array | $lang | language array |
integer | $i | |
Definition at line 53 of file filemanager.php.
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>
References $_GET.
◆ getCurrentMimeTypes()
static YAWK\filemanager::getCurrentMimeTypes |
( |
| ) |
|
|
static |
Fast generation of a complete uptodate mime types list.
- Returns
- bool|string
Definition at line 609 of file filemanager.php.
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;
References $i, and $url.
◆ getFilesFromFolder()
static YAWK\filemanager::getFilesFromFolder |
( |
|
$folder, |
|
|
|
$lang |
|
) |
| |
|
static |
returns a list of all files in given folder. expect $folder as string
- Author
- Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
- Copyright
- 2009-2015 Daniel Retzl yawk.goodconnect.net @license https://opensource.org/licenses/MIT
- Parameters
-
string | $folder | folder to look for files |
string | $path | path to workout |
array | $lang | current language array |
Definition at line 157 of file filemanager.php.
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>
static sizeFilter($bytes, $precision)
calculate filesize from bytes
References $_GET, $errorMsg, $folder, $i, die, and YAWK\filemanager\sizeFilter().
◆ getFilesFromFolderToArray()
static YAWK\filemanager::getFilesFromFolderToArray |
( |
|
$folder | ) |
|
|
static |
◆ getFilesOnlyFromFolder()
static YAWK\filemanager::getFilesOnlyFromFolder |
( |
|
$folder | ) |
|
|
static |
◆ getPhpMaxUploadSize()
static YAWK\filemanager::getPhpMaxUploadSize |
( |
| ) |
|
|
static |
get and return PHP max file size setting
- Author
- Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
- Copyright
- 2009-2016 Daniel Retzl @license https://opensource.org/licenses/MIT
- Returns
- bool|string
Definition at line 417 of file filemanager.php.
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);
References $db.
◆ getPostMaxSize()
static YAWK\filemanager::getPostMaxSize |
( |
| ) |
|
|
static |
◆ getSubfoldersToArray()
static YAWK\filemanager::getSubfoldersToArray |
( |
|
$folder | ) |
|
|
static |
◆ getUploadMaxFilesize()
static YAWK\filemanager::getUploadMaxFilesize |
( |
| ) |
|
|
static |
◆ recursiveRemoveDirectory()
static YAWK\filemanager::recursiveRemoveDirectory |
( |
|
$directory | ) |
|
|
static |
◆ removeSpecialChars()
static YAWK\filemanager::removeSpecialChars |
( |
|
$string | ) |
|
|
static |
remove special chars as well as leading and trailing slashes from string
- Author
- Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
- Copyright
- 2017 Daniel Retzl @license https://opensource.org/licenses/MIT
- Parameters
-
string | $string | the affected string |
Definition at line 482 of file filemanager.php.
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,
"/");
◆ ritit()
static YAWK\filemanager::ritit |
( |
|
$folder | ) |
|
|
static |
returns an multidimensional array containing subfolders + files of given folder
- Parameters
-
string | $folder | to get files from |
- Returns
- array|null
Definition at line 547 of file filemanager.php.
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);
References $folder.
◆ sizeFilter()
static YAWK\filemanager::sizeFilter |
( |
|
$bytes, |
|
|
|
$precision |
|
) |
| |
|
static |
◆ subdirToOptions()
static YAWK\filemanager::subdirToOptions |
( |
|
$path | ) |
|
|
static |
all folders in $path as select <option>...</option>
- Parameters
-
string | $path | rootpath that should be scanned and returned |
Definition at line 91 of file filemanager.php.
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>";
The documentation for this class was generated from the following file: