Thread: [Phpcms-plugins-cvs] admin4phpCMS/modules/filemanager class.file_util.php,1.2,1.3 class.module_filem
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-08-25 21:17:28
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2565/modules/filemanager Modified Files: class.file_util.php class.module_filemanager.php Log Message: step 1 is taken Index: class.module_filemanager.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager/class.module_filemanager.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- class.module_filemanager.php 5 Aug 2004 16:38:41 -0000 1.5 +++ class.module_filemanager.php 25 Aug 2004 21:16:48 -0000 1.6 @@ -28,6 +28,9 @@ /* * $Log$ +* Revision 1.6 2004/08/25 21:16:48 mjahn +* step 1 is taken +* * Revision 1.5 2004/08/05 16:38:41 mjahn * tweaked phpcms::cache-module output * @@ -52,22 +55,26 @@ /** * Filemanager-class for administrative work in the filesystem * +* @todo include code for virtual filesystem (i.e. to browe compressed archives like a directory). +* @todo the vfs-plugins-api with methods for reading, writing, creating and deleting files and directories +* @todo the vfs-plugin must register a handler for each single action, so that the filemanager could retrieve the correct information * @package admin4phpCMS * @subpackage module_filemanager * @uses file_editor **/ - class module_filemanager extends module { - function init () { // connect to actions $this->_registerAction ('doParseParam', 'parseParam'); $this->_registerAction ('doProcess', 'process'); $this->docroot = realpath ($_SERVER['DOCUMENT_ROOT']); - $actiondata = array ('module'=>'filemanager'); - $this->_callEvent ('CONFIG_GET', $actiondata); - $this->CONF =& $actiondata ['config']; + $actiondata1 = array ('module'=>'filemanager'); + $this->_callEvent ('CONFIG_GET', $actiondata1); + $this->CONF =& $actiondata1 ['config']; include_once (dirname (__FILE__).'/config.filemanager.php'); + + $actiondata1 = array ('filename'=>dirname (__FILE__).'/layout.xml'); + $this->_callEvent ('LAYOUT_ADD_TEMPLATE', $actiondata1); } /** @@ -103,8 +110,8 @@ $this->basedir = realpath ($this->docroot.'/'.$this->basedir.'/'.$this->viewdir).'/'; if (strpos ($this->basedir, $this->docroot) === false) { $this->basedir = '/'; - $actiondata = array ('errortext'=>'Das Verzeichnis liegt außerhalb des zugelassenen Bereiches!'); - $this->_callEvent ('ERROR_NOTICE', $actiondata); + $actiondata1 = array ('errortext'=>'Das Verzeichnis liegt außerhalb des zugelassenen Bereiches!'); + $this->_callEvent ('ERROR_NOTICE', $actiondata1); } else { $this->basedir = str_replace ($this->docroot, '', $this->basedir); } @@ -116,9 +123,9 @@ * @param array $actiondata **/ function process (&$actiondata) { - $actiondata = array(); - $this->_callEvent ('USER_GET_STATUS', $actiondata); - $this->_USER = $actiondata; + $actiondata1 = array(); + $this->_callEvent ('USER_GET_STATUS', $actiondata1); + $this->_USER = $actiondata1; if (!$this->_USER['isLoggedIn']) { return true; @@ -149,11 +156,11 @@ **/ function getMenuMain (&$actiondata) { $root = $actiondata['_root']; - $actiondata = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Dateimanager', 'module'=>'filemanager', '_id'=>'filemanager', '_root'=>'mainmenu'); + $actiondata1 = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Dateimanager', 'module'=>'filemanager', '_id'=>'filemanager', '_root'=>'mainmenu'); if ($this->display) { - $actiondata ['extra'] = 'class="active"'; + $actiondata1 ['extra'] = 'class="active"'; } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); } /** @@ -164,29 +171,29 @@ $root = $actiondata['_root']; - $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Dateimanager', 'module'=>'filemanager', '_id'=>'files'); + $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Dateimanager', 'module'=>'filemanager', '_id'=>'files'); if ($this->action == '') { - $actiondata['id'] = 'current'; + $actiondata1['id'] = 'current'; } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Hochladen', 'module'=>'filemanager', '_id'=>'uploads', 'action'=>'upload'); + $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Hochladen', 'module'=>'filemanager', '_id'=>'uploads', 'action'=>'upload'); if ($this->action == 'upload') { - $actiondata['id'] = 'current'; + $actiondata1['id'] = 'current'; } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Backups', 'module'=>'filemanager', '_id'=>'backups', 'action'=>'backup'); + $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Backups', 'module'=>'filemanager', '_id'=>'backups', 'action'=>'backup'); if ($this->action == 'backup') { - $actiondata['id'] = 'current'; + $actiondata1['id'] = 'current'; } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Editor', 'module'=>'filemanager', '_id'=>'editor', 'action'=>'editor'); + $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Editor', 'module'=>'filemanager', '_id'=>'editor', 'action'=>'editor'); if ($this->action == 'editor') { - $actiondata['id'] = 'current'; + $actiondata1['id'] = 'current'; } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); } @@ -222,7 +229,7 @@ } // skip hidden files - if ($entry{0} == '.' && $entry{1} != '.') { + if ($entry{0} == '.' && (strlen ($entry) > 1 && $entry{1} != '.')) { continue; } @@ -238,38 +245,15 @@ } } closedir ($dh); - sort ($dirs); - sort ($files); + + $this->_userSort ($dirs, $files); $entries = array_merge ($dirs, $files); unset ($files, $dirs); $num = count ($entries); - $actiondata = array ('_type'=>'headline', '_id'=>'headline', '_root'=>$root, - 'content'=>'Verzeichnis: '.htmlentities ($this->basedir)); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $actiondata = array ('_type'=>'ulist', '_id'=>'filelist', '_root'=>$root, 'extra'=>'id="filelist"',); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $actiondata = array ('_type'=>'filelist_entry', '_id'=>'list-0', '_root'=>'filelist', - 'extra'=>'class="header"', 'filesize'=>'Größe', 'filemtime'=>'Letzte Änderung', 'chmod'=>'CHMOD', 'gid'=>'GID', 'uid'=>'UID'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $actiondata = array ('_root'=>'list-0', '_id'=>'list-img-0', '_type'=>'image', - 'src'=>'modules/layout/img/empty.gif', 'width'=>'16', 'height'=>'16', 'title'=>'', 'alt'=>'', 'extra'=>'class="input"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $actiondata = array ('_root'=>'list-0', '_id'=>'list-img-1', '_type'=>'image', 'src'=>'modules/layout/img/empty.gif', - 'width'=>'16', 'height'=>'16', 'title'=>'', 'alt'=>'', 'extra'=>'class="icon"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $actiondata = array ('_root'=>'list-0', '_id'=>'list-img-2', '_type'=>'image', 'src'=>'modules/layout/img/empty.gif', - 'width'=>'16', 'height'=>'16', 'title'=>'', 'alt'=>'', 'extra'=>'class="icon"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - // set filename - $actiondata = array ('_root'=>'list-0', '_id'=>'file0', '_type'=>'inline', 'extra'=>'class="filename""', 'content'=>'Name'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + $actiondata1 = array ('_type'=>'fm_list', '_id'=>'filelist', '_root'=>$root, + 'basedir'=>htmlentities ($this->basedir)); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); $alternate = 1; $sum_size = 0; @@ -294,15 +278,7 @@ $file['filectime'] = strftime ('%d.%m.%Y %H:%M:%S', $data[8]); $file['fileatime'] = strftime ('%d.%m.%Y %H:%M:%S', $data[10]); $file['filesize'] = file_util::filesize ($dir.'/'.$entry); - $file['chmod'] = array ('oct'=>file_util::fileperms($dir.'/'.$entry)); - // set file-list-item - $actiondata = array ( - '_type'=>'filelist_entry', '_id'=>'list-'.$entry, '_root'=>'filelist', 'filename'=>htmlentities ($entry), - 'filesize'=>$file['filesize'], 'fileatime'=>$file['fileatime'], 'filectime'=>$file['filectime'], - 'filemtime'=>$file['filemtime'], 'gid'=>$file['gid']['str'], 'uid'=>$file['uid']['str'], 'chmod'=>$file['chmod']['oct'], - 'extra'=>'class="line'.$alternate++.'"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - + $file['chmod'] = array ('oct'=>file_util::fileperms($dir.'/'.$entry), 'str'=>file_util::fileperms ($dir.'/'.$entry, true)); $entrypath = realpath ($dir.'/'.$entry); // entry is directory @@ -310,67 +286,52 @@ $nolink = false; - // entry is parent directory + // check if entry is parent directory if ($entry == '..') { $type = 'parent'; - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'img-empty-'.$entry, '_type'=>'image', 'src'=>'modules/layout/img/empty.gif', 'width'=>'16', 'height'=>'16', 'alt'=>'', 'title'=>'', 'extra'=>'class="input" id="input""'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + } elseif ($entry == '.') { + $type = 'empty'; + $nolink = true; } else { $num_dirs++; $type = 'folder'; - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'select-'.$entry, '_type'=>'form_checkbox_simple', 'id'=>'select['.$entry.']', 'name'=>'select['.$entry.']', 'value'=>'selected', 'title'=>'Auswählen', 'extra'=>'class="input"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - + // check if entry has executive permission if (!@file_exists($entrypath.'/.')) { $type = 'folder_inactive'; $nolink = true; } + // check if entry has reading permission if (!is_readable ($entrypath)) { $type = 'folder_inactive'; $nolink = true; } - if (is_link ($entrypath)) { + // check if entry is a symlink + if (is_link ($dir.$entry)) { $type = 'symlink'; } } + // check if destination-path of entry is within the allowed path + if (!file_util::checkpath ($this->docroot, $entrypath)) { + $nolink = true; + } + + $actiondata1 = array ('_root'=>'filelist', '_id'=>'dir-'.$entry, 'basedir'=>$this->basedir, 'filename'=>htmlentities ($entry), 'filesize'=>$file ['filesize'], 'fileatime'=>$file ['fileatime'], 'filectime'=>$file ['filectime'], 'filemtime'=>$file ['filemtime'], 'gid'=>$file ['gid'] ['str'], 'uid'=>$file ['uid'] ['str'], 'chmod'=>$file ['chmod'] ['str'], 'extra'=>'class="line'.$alternate++.'"', 'filetype'=>$type); if ($nolink) { // set no link for open directory - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'view-'.$entry, '_type'=>'empty', 'href'=>'?moduleid=filemanager&basedir='.$this->basedir.'&file='.$entry.'&action=viewdir'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + $actiondata1 ['_type'] = 'fm_dir_inactive'; + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); } else { // set link for open directory - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'view-'.$entry, '_type'=>'link', 'href'=>'?moduleid=filemanager&basedir='.$this->basedir.'&file='.$entry.'&action=viewdir', 'title'=>'Verzeichnis öffnen'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - } - // set image for link - $actiondata = array ('_root'=>'view-'.$entry, '_id'=>'img-view-'.$entry, '_type'=>'image', 'src'=>'modules/layout/img/filetypes/'.$type.'.gif', 'width'=>'16', 'height'=>'16', 'alt'=>'edit', 'extra'=>'class="icon"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - // set distance image - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'img-empty-'.$entry, '_type'=>'image', 'src'=>'modules/layout/img/empty.gif', 'width'=>'16', 'height'=>'16', 'alt'=>'', 'title'=>'', 'extra'=>'class="icon"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - // set filename - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'file-'.$entry, '_type'=>'inline', 'extra'=>'class="filename"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - if ($nolink) { - // set no link to filename - $actiondata = array ('_root'=>'file-'.$entry, '_id'=>'file-link-'.$entry, '_type'=>'empty', 'content'=>$entry); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - } else { - // set link to filename - $actiondata = array ('_root'=>'file-'.$entry, '_id'=>'file-link-'.$entry, '_type'=>'link', 'href'=>'?moduleid=filemanager&basedir='.$this->basedir.'&file='.$entry.'&action=viewdir', 'title'=>'Verzeichnis öffnen', 'content'=>$entry); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + $actiondata1 ['_type'] = 'fm_dir'; + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); } } - if (is_file ($dir.'/'.$entry)) { $num_files++; @@ -383,58 +344,90 @@ break; } } + + // check if file is a symlink if (is_link ($dir.'/'.$entry)) { - $type = 'symlink'; + $type = 'symlink.gif'; } - $editor = 'edit'; - - // insert checkbox for selecting files - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'select-'.$entry, '_type'=>'form_checkbox_simple', 'extra'=>'id="select['.$entry.']"', 'class'=>'input', 'name'=>'select['.$entry.']', 'value'=>'selected', 'title'=>'Auswählen'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - // insert view-link - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'view-'.$entry, '_type'=>'link', 'href'=>'?moduleid=filemanager&file='.$this->basedir.$entry.'&action=viewfile', 'title'=>'Datei anzeigen'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - // insert image for view-link - $actiondata = array ('_root'=>'view-'.$entry, '_id'=>'img-view-'.$entry, '_type'=>'image', 'src'=>'modules/layout/img/filetypes/'.$type, 'width'=>'16', 'height'=>'16', 'alt'=>'view', 'title'=>'', 'extra'=>'class="icon"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + $actiondata1 = array ('_root'=>'filelist', '_id'=>'file-'.$entry, 'filename'=>$entry, 'basedir'=>$this->basedir, 'filename'=>htmlentities ($entry), 'filesize'=>$file ['filesize'], 'fileatime'=>$file ['fileatime'], 'filectime'=>$file ['filectime'], 'filemtime'=>$file ['filemtime'], 'gid'=>$file ['gid'] ['str'], 'uid'=>$file ['uid'] ['str'], 'chmod'=>$file ['chmod'] ['str'], 'extra'=>'class="line'.$alternate++.'"', 'filetype'=>$type); - // insert edit-link - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'edit-'.$entry, '_type'=>'link', 'href'=>'?moduleid=filemanager&file='.$this->basedir.$entry.'&action=editfile', 'title'=>'Datei editieren'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - // insert image for edit-link - $actiondata = array ('_root'=>'edit-'.$entry, '_id'=>'img-edit-'.$entry, '_type'=>'image', 'src'=>'modules/layout/img/'.$editor.'.gif', 'width'=>'16', 'height'=>'16', 'alt'=>'edit', 'title'=>'', 'extra'=>'class="icon"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + // check if file is writeable + if (!is_writeable ($dir.'/'.$entry)) { + $actiondata1 ['_type'] = 'fm_file_inactive'; + } else { + $actiondata1 ['_type'] = 'fm_file'; + } - // set filename - $actiondata = array ('_root'=>'list-'.$entry, '_id'=>'file-'.$entry, '_type'=>'inline', 'extra'=>'class="filename"', 'content'=>$entry); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + // insert fileentry + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); } } - $actiondata = array ('_type'=>'filelist_entry', '_id'=>'list1', '_root'=>'filelist', - 'extra'=>'class="header"', 'filename'=>$num_dirs.' Verzeichnisse', 'filesize'=>file_util::filesize ($sum_size), 'filemtime'=>$num_files.' Dateien', - 'chmod'=>'', 'gid'=>'', ''=>'UID'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $actiondata = array ('_root'=>'list1', '_id'=>'list-img0', '_type'=>'image', - 'src'=>'modules/layout/img/empty.gif', 'width'=>'16', 'height'=>'16', 'title'=>'', 'alt'=>'', 'extra'=>'class="input"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + $actiondata1 = array ('_root'=>'filelist', '_id'=>'filelist-summary', '_type'=>'fm_sum', 'dirs'=>$num_dirs, 'files'=>$num_files, 'sumsize'=>file_util::filesize ($sum_size)); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - $actiondata = array ('_root'=>'list1', '_id'=>'list-img1', '_type'=>'image', - 'src'=>'modules/layout/img/empty.gif', 'width'=>'16', 'height'=>'16', 'title'=>'', 'alt'=>'', 'extra'=>'class="icon"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + // set options-box + $actiondata1 = array ('_root'=>$root, '_id'=>'fm-options', '_type'=>'block', 'extra'=>'id="fm-options"'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + // set tablist + $actiondata1 = array ('_root'=>'fm-options', '_id'=>'tablist', '_type'=>'ulist', 'extra'=>'class="tabbed"'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + // set tabbox + $actiondata1 = array ('_root'=>'fm-options', '_id'=>'tabbox', '_type'=>'block', 'extra'=>'class="tabbox"'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + $tabs = array ( + array ('name'=>'Neu', 'id'=>'new'), + array ('name'=>'Hochladen', 'id'=>'upload'), + array ('name'=>'Archivieren', 'id'=>'backup'), + array ('name'=>'Zwischenablage', 'id'=>'clipboard') + ); - $actiondata = array ('_root'=>'list1', '_id'=>'list-img2', '_type'=>'image', - 'src'=>'modules/layout/img/empty.gif', 'width'=>'16', 'height'=>'16', 'title'=>'', 'alt'=>'', 'extra'=>'class="icon""'); + $num = count ($tabs); + for ($i = 0; $i < $num; $i++) { + + // set tab-list + $actiondata1 = array ('_root'=>'tablist', '_id'=>'tablistitem-'.$tabs [$i] ['id'], '_type'=>'list_entry'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + // set tab-script + $actiondata1 = array ('_root'=>'tablist', '_id'=>'tablistscript-'.$tabs [$i] ['id'], '_type'=>'script', 'content'=>'registerTab (\'tabbox-'.$tabs [$i] ['id'].'\');'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + // set the tab-link + $actiondata1 = array ('_root'=>'tablistitem-'.$tabs [$i] ['id'], '_id'=>'tablink-'.$tabs [$i] ['id'], '_type'=>'link', 'href'=>'#tabbox-'.$tabs [$i] ['id'], 'content'=>$tabs [$i] ['name'], 'extra'=>'class="" id="tabbox-'.$tabs [$i] ['id'].'-nav" onclick="displayTab (\'tabbox-'.$tabs [$i] ['id'].'\')" onkeypress="displayTab (\'tabbox-'.$tabs [$i] ['id'].'\')"'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - // set filename - $actiondata = array ('_root'=>'list1', '_id'=>'file1', '_type'=>'inline', 'extra'=>'class="filename""', 'content'=>$num_dirs.' Verzeichnisse'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); + // set the tab-box container + $actiondata1 = array ('_root'=>'tabbox', '_id'=>'tabbox-'.$tabs [$i] ['id'], '_type'=>'block', 'extra'=>'id="tabbox-'.$tabs [$i] ['id'].'"'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + } + + // set the tab-box (new) + $actiondata1 = array ('_root'=>'tabbox-new', '_id'=>'tabbox-new-content', '_type'=>'fm_new'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + // set the tab-box (upload) + $actiondata1 = array ('_root'=>'tabbox-upload', '_id'=>'tabbox-upload-content', '_type'=>'fm_upload'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + // set the tab-box (backup) + $actiondata1 = array ('_root'=>'tabbox-backup', '_id'=>'tabbox-backup-content', '_type'=>'fm_backup'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + // set the tab-box (clipboard) + $actiondata1 = array ('_root'=>'tabbox-clipboard', '_id'=>'tabbox-clipboard-content', '_type'=>'fm_clipboard'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + + } + + function _userSort (&$dirs, &$files) { + sort ($dirs); + sort ($files); } } + ?> \ No newline at end of file Index: class.file_util.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager/class.file_util.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- class.file_util.php 24 Jul 2004 08:58:25 -0000 1.2 +++ class.file_util.php 25 Aug 2004 21:16:48 -0000 1.3 @@ -28,6 +28,9 @@ /* * $Log$ +* Revision 1.3 2004/08/25 21:16:48 mjahn +* step 1 is taken +* * Revision 1.2 2004/07/24 08:58:25 mjahn * changed some things * @@ -40,12 +43,64 @@ **/ class file_util { - function fileperms($filepath) { - $decperms = fileperms($filepath); - $octalperms = sprintf("%o",$decperms); - // -4 value should include ugo and strange bits for files and folders - return substr($octalperms,-4); + function chmodstr($in_Perms) { + $sP = ''; +/* + if(($in_Perms & 0xC000) == 0xC000) // Socket + $sP = 's'; + elseif(($in_Perms & 0xA000) == 0xA000) // Symbolic Link + $sP = 'l'; + elseif(($in_Perms & 0x8000) == 0x8000) // Regular + $sP = '−'; + elseif(($in_Perms & 0x6000) == 0x6000) // Block special + $sP = 'b'; + elseif(($in_Perms & 0x4000) == 0x4000) // Directory + $sP = 'd'; + elseif(($in_Perms & 0x2000) == 0x2000) // Character special + $sP = 'c'; + elseif(($in_Perms & 0x1000) == 0x1000) // FIFO pipe + $sP = 'p'; + else // UNKNOWN + $sP = 'u'; +*/ + // owner + $sP .= (($in_Perms & 0x0100) ? 'r' : '−') . + (($in_Perms & 0x0080) ? 'w' : '−') . + (($in_Perms & 0x0040) ? (($in_Perms & 0x0800) ? 's' : 'x' ) : + (($in_Perms & 0x0800) ? 'S' : '−')); + + // group + $sP .= (($in_Perms & 0x0020) ? 'r' : '−') . + (($in_Perms & 0x0010) ? 'w' : '−') . + (($in_Perms & 0x0008) ? (($in_Perms & 0x0400) ? 's' : 'x' ) : + (($in_Perms & 0x0400) ? 'S' : '−')); + + // world + $sP .= '<em>'; + $sP .= (($in_Perms & 0x0004) ? 'r' : '−') . + (($in_Perms & 0x0002) ? 'w' : '−') . + (($in_Perms & 0x0001) ? (($in_Perms & 0x0200) ? 't' : 'x' ) : + (($in_Perms & 0x0200) ? 'T' : '−')); + $sP .= '</em>'; + return $sP; + } + + function fileperms($filepath, $rwx = false) { + $decperms = fileperms($filepath); + $octalperms = sprintf("%o",$decperms); + if ($rwx) { + return file_util::chmodstr ($decperms); + } + // -4 value should include ugo and strange bits for files and folders + return substr($octalperms,-4); } + + function checkpath ($ref, $check) { + if (strpos ($check, $ref) === false) { + return false; + } + return true; + } function filesize($file) { if (is_int ($file)) { @@ -72,6 +127,19 @@ return round ($size / $factor); } + function filetime($file) { + if (is_int ($file)) { + $time = $file; + } elseif (is_dir ($file) || is_file ($file)) { + if (!file_exists ($file)) { + return '00.00.0000 00:00:00'; + } + $time = filemtime ($file); + } + + return strftime ($time, '%d.%m.%Y %H:%M%S'); + } + function gid ($gid) { $data = posix_getgrgid ($gid); return array ('int'=>$gid, 'str'=>$data['name']); |