Thread: [Phpcms-plugins-cvs] admin4phpCMS/modules/filemanager class.module_filemanager.php,1.7,1.8 class.fil
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-09-29 20:10:57
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19438/modules/filemanager Modified Files: class.module_filemanager.php class.file_util.php layout.filemanager.xml Log Message: completed phpCMS-config-part began the statistic part Index: layout.filemanager.xml =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager/layout.filemanager.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- layout.filemanager.xml 25 Aug 2004 21:21:01 -0000 1.1 +++ layout.filemanager.xml 29 Sep 2004 20:10:46 -0000 1.2 @@ -14,9 +14,9 @@ <ul id="filelist"> <li class="header"> - <img src="modules/layout/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> - <img src="modules/layout/img/empty.gif" width="16" height="16" title="" alt="" class="icon" /> - <img src="modules/layout/img/empty.gif" width="16" height="16" title="" alt="" class="icon" /> + <img src="modules/filemanager/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> + <img src="modules/filemanager/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> + <img src="modules/filemanager/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> <span class="chmod" title="Besitzer: UID\nGruppe: GID">Rechte</span> <span class="filesize" title="Dateigröße">Größe</span> <span class="filemtime" title="Last modified">Letzte Änderung</span> @@ -31,11 +31,11 @@ <layout:insert name="fm_dir"> <![CDATA[ <li <layout:replace name="extra" default="" />> - <input type="checkbox" name="select[<layout:replace name="filename" default="" />]" value="selected" id="select[<layout:replace name="filename" default="" />]" /> + <input type="checkbox" name="select[<layout:replace name="filename" default="" />]" value="selected" id="select[<layout:replace name="filename" default="" />]" class="input" /> <a href="?moduleid=filemanager&basedir=<layout:replace name="basedir" default="/" />&file=<layout:replace name="filename" default="" />&action=viewdir" title="Verzeichnis öffnen" > - <img src="modules/layout/img/filetypes/<layout:replace name="filetype" default="" />.gif" width="16" height="16" title="" alt="open" class="icon" /> + <img src="modules/filemanager/img/filetypes/<layout:replace name="filetype" default="" />.gif" width="16" height="16" title="" alt="open" class="input" /> </a> - <img src="modules/layout/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> + <img src="modules/filemanager/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> <span class="chmod" title="Besitzer: <layout:replace name="uid" default="" /> <> Gruppe: <layout:replace name="gid" default="" />"> <layout:replace name="chmod" default="0000" /></span> <span class="filesize" title="Dateigröße"><layout:replace name="filesize" default="1 kB" /></span> <span class="filemtime" title="Last modified"><layout:replace name="filemtime" default="" /></span> @@ -50,9 +50,9 @@ <layout:insert name="fm_dir_inactive"> <![CDATA[ <li <layout:replace name="extra" default="" />> - <img src="modules/layout/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> - <img src="modules/layout/img/filetypes/<layout:replace name="filetype" default="" />.gif" width="16" height="16" title="" alt="" class="icon" /> - <img src="modules/layout/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> + <img src="modules/filemanager/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> + <img src="modules/filemanager/img/filetypes/<layout:replace name="filetype" default="" />.gif" width="16" height="16" title="" alt="" class="input" /> + <img src="modules/filemanager/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> <span class="chmod" title="Besitzer: <layout:replace name="uid" default="" /> <> Gruppe: <layout:replace name="gid" default="" />"> <layout:replace name="chmod" default="0000" /></span> <span class="filesize" title="Dateigröße"><layout:replace name="filesize" default="1 kB" /></span> <span class="filemtime" title="Last modified"><layout:replace name="filemtime" default="" /></span> @@ -65,12 +65,12 @@ <layout:insert name="fm_file"> <![CDATA[ <li <layout:replace name="extra" default="" />> - <input type="checkbox" name="select[<layout:replace name="filename" default="" />]" value="selected" id="select[<layout:replace name="filename" default="" />]" /> - <a href="?moduleid=filemanager&basedir=<layout:replace name="basedir" default="/" />&file=<layout:replace name="basedir" default="/" /><layout:replace name="filename" default="" />&action=viewfile" title="Datei anzeigen" > - <img src="modules/layout/img/filetypes/<layout:replace name="filetype" default="" />" width="16" height="16" title="" alt="view" class="icon" /> + <input type="checkbox" name="select[<layout:replace name="filename" default="" />]" value="selected" id="select[<layout:replace name="filename" default="" />]" class="input" /> + <a href="?moduleid=editor&basedir=<layout:replace name="basedir" default="/" />&file=<layout:replace name="basedir" default="/" /><layout:replace name="filename" default="" />&action=viewfile" title="Datei anzeigen" > + <img src="modules/filemanager/img/filetypes/<layout:replace name="filetype" default="" />" width="16" height="16" title="" alt="view" class="input" /> </a> - <a href="?moduleid=filemanager&basedir=<layout:replace name="basedir" default="/" />&file=<layout:replace name="basedir" default="/" /><layout:replace name="filename" default="" />&action=editfile" title="Datei editieren" > - <img src="modules/layout/img/edit.gif" width="16" height="16" title="" alt="edit" class="icon" /> + <a href="?moduleid=editor&basedir=<layout:replace name="basedir" default="/" />&file=<layout:replace name="basedir" default="/" /><layout:replace name="filename" default="" />&action=editfile" title="Datei editieren" > + <img src="modules/filemanager/img/edit.gif" width="16" height="16" title="" alt="edit" class="input" /> </a> <span class="chmod" title="Besitzer: <layout:replace name="uid" default="" /> <> Gruppe: <layout:replace name="gid" default="" />"><layout:replace name="chmod" default="0000" /></span> <span class="filesize" title="Dateigröße"><layout:replace name="filesize" default="1 kB" /></span> @@ -84,11 +84,11 @@ <layout:insert name="fm_file_inactive"> <![CDATA[ <li <layout:replace name="extra" default="" />> - <img src="modules/layout/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> - <a href="?moduleid=filemanager&basedir=<layout:replace name="basedir" default="/" />&file=<layout:replace name="basedir" default="/" /><layout:replace name="filename" default="" />&action=viewfile" title="Datei anzeigen" > - <img src="modules/layout/img/filetypes/<layout:replace name="filetype" default="" />" width="16" height="16" title="" alt="view" class="icon" /> + <img src="modules/filemanager/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> + <a href="?moduleid=editor&basedir=<layout:replace name="basedir" default="/" />&file=<layout:replace name="basedir" default="/" /><layout:replace name="filename" default="" />&action=viewfile" title="Datei anzeigen" > + <img src="modules/filemanager/img/filetypes/<layout:replace name="filetype" default="" />" width="16" height="16" title="" alt="view" class="input" /> </a> - <img src="modules/layout/img/edit_inactive.gif" width="16" height="16" title="" alt="" class="icon" /> + <img src="modules/filemanager/img/edit_inactive.gif" width="16" height="16" title="" alt="" class="input" /> <span class="chmod" title="Besitzer: <layout:replace name="uid" default="" /> <> Gruppe: <layout:replace name="gid" default="" />"><layout:replace name="chmod" default="0000" /></span> <span class="filesize" title="Dateigröße"><layout:replace name="filesize" default="1 kB" /></span> <span class="filemtime" title="Last modified"><layout:replace name="filemtime" default="00.00.0000 00:00:00" /></span> @@ -101,9 +101,9 @@ <layout:insert name="fm_sum"> <![CDATA[ <li class="footer"> - <img src="modules/layout/img/arrow.gif" width="16" height="16" title="" alt="" class="input" /> - <input type="image" name="fm-delete-selection" src="modules/layout/img/delete.gif" alt="del" title="Lösche ausgwählte Einträge" /> - <img src="modules/layout/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> + <img src="modules/filemanager/img/arrow.gif" width="16" height="16" title="" alt="" class="input" /> + <input type="image" name="fm-delete-selection" src="modules/filemanager/img/delete.gif" alt="del" title="Lösche ausgwählte Einträge" /> + <img src="modules/filemanager/img/empty.gif" width="16" height="16" title="" alt="" class="input" /> <span class="chmod"> </span> <span class="filesize" title=""><layout:replace name="sumsize" default="1 kB" /></span> <span class="filemtime"> </span> Index: class.module_filemanager.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager/class.module_filemanager.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- class.module_filemanager.php 25 Aug 2004 21:21:01 -0000 1.7 +++ class.module_filemanager.php 29 Sep 2004 20:10:46 -0000 1.8 @@ -28,6 +28,10 @@ /* * $Log$ +* Revision 1.8 2004/09/29 20:10:46 mjahn +* completed phpCMS-config-part +* began the statistic part +* * Revision 1.7 2004/08/25 21:21:01 mjahn * step 1 is taken * @@ -69,11 +73,14 @@ function init () { // connect to actions $this->_registerAction ('doParseParam', 'parseParam'); - $this->_registerAction ('doProcess', 'process'); + $this->_registerAction ('doParseMenuMain', 'getMenuMain'); + $this->docroot = realpath ($_SERVER['DOCUMENT_ROOT']); + $actiondata1 = array ('module'=>'filemanager'); $this->_callEvent ('CONFIG_GET', $actiondata1); $this->CONF =& $actiondata1 ['config']; + include_once (dirname (__FILE__).'/config.filemanager.php'); } @@ -85,6 +92,10 @@ $actiondata1 = array ('filename'=>dirname (__FILE__).'/layout.filemanager.xml'); $this->_callEvent ('LAYOUT_ADD_TEMPLATE', $actiondata1); + $actiondata1 = array(); + $this->_callEvent ('USER_GET_STATUS', $actiondata1); + $this->_USER = $actiondata1; + $this->display = (isset ($actiondata['request']['moduleid']) && $actiondata['request']['moduleid'] == 'filemanager'); $this->viewdir = $this->viewfile = $this->editfile = $this->action = ''; @@ -108,56 +119,51 @@ if ($this->action == 'editfile' && isset ($actiondata['request']['file'])) { $this->editfile = $actiondata['request']['file']; } + + if ($this->display && $this->_USER ['isLoggedIn']) { + $this->_registerAction ('doProcess', 'processFiletree'); + } - if (is_dir ($this->docroot.'/'.$this->basedir.'/'.$this->viewdir)) { - $this->basedir = realpath ($this->docroot.'/'.$this->basedir.'/'.$this->viewdir).'/'; - if (strpos ($this->basedir, $this->docroot) === false) { - $this->basedir = '/'; - $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); - } - $this->viewdir = ''; - } } - /** - * @param array $actiondata - **/ - function process (&$actiondata) { - $actiondata1 = array(); - $this->_callEvent ('USER_GET_STATUS', $actiondata1); - $this->_USER = $actiondata1; + function processFiletree (&$actiondata) { - if (!$this->_USER['isLoggedIn']) { + if (!$this->display) { return true; } - $this->_registerAction ('doParseMenuMain', 'getMenuMain'); - - if (!$this->display) { + $this->_registerAction ('doParseContent', 'getContentFiletree'); + + if (!$this->_USER['isLoggedIn']) { return true; } - - $this->_registerAction ('doParseStatusbar', 'getContentBar'); - $this->_registerAction ('doParseMenuSub', 'getMenuSub'); - switch ($this->action) { - case 'viewfile': - case 'editfile': - break; - default: - $this->_registerAction ('doParseContent', 'getFileList'); - break; + if (is_dir ($this->docroot.'/'.$this->basedir.'/'.$this->viewdir)) { + $this->basedir = realpath ($this->docroot.'/'.$this->basedir.'/'.$this->viewdir).'/'; + if (strpos ($this->basedir, $this->docroot) === false) { + $this->basedir = '/'; + $actiondata1 = array ('errortext'=>'Das angeforderte Verzeichnis liegt außerhalb des zugelassenen Bereiches!'); + $this->_callEvent ('ERROR_NOTICE', $actiondata1); + } else { + $this->basedir = str_replace ($this->docroot, '', $this->basedir); + } + $this->viewdir = ''; + } else { + $this->basedir = '/'; + $actiondata1 = array ('errortext'=>'Das angeforderte Verzeichnis existiert nicht!'); + $this->_callEvent ('ERROR_NOTICE', $actiondata1); } - + } - + /** * @param array $actiondata **/ function getMenuMain (&$actiondata) { + if (!$this->_USER['isLoggedIn']) { + return true; + } + $root = $actiondata['_root']; $actiondata1 = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Dateimanager', 'module'=>'filemanager', '_id'=>'filemanager', '_root'=>'mainmenu'); if ($this->display) { @@ -167,62 +173,37 @@ } /** - * @param array $actiondata - **/ - function getMenuSub (&$actiondata) { - return true; - - $root = $actiondata['_root']; - - $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Dateimanager', 'module'=>'filemanager', '_id'=>'files'); - if ($this->action == '') { - $actiondata1['id'] = 'current'; - } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Hochladen', 'module'=>'filemanager', '_id'=>'uploads', 'action'=>'upload'); - if ($this->action == 'upload') { - $actiondata1['id'] = 'current'; - } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Backups', 'module'=>'filemanager', '_id'=>'backups', 'action'=>'backup'); - if ($this->action == 'backup') { - $actiondata1['id'] = 'current'; - } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Editor', 'module'=>'filemanager', '_id'=>'editor', 'action'=>'editor'); - if ($this->action == 'editor') { - $actiondata1['id'] = 'current'; - } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - + * Generates the output for the fileviewer + * + * @param array $actiondata + **/ + function getContentViewer (&$actiondata) { + $actiondata1 = array (); + $this->_callEvent ('EDITOR_VIEW_FILE', $actiondata1); } - + /** - * @param array $actiondata - **/ - function getContentBar (&$actiondata) { + * Generates the ouput for the editor + * + * @param array $actiondata + **/ + function getContentEditor (&$actiondata) { + $actiondata1 = array (); + $this->_callEvent ('EDITOR_EDIT_FILE', $actiondata1); } - + /** * Generates the list of folders and files in the current directory. * - * * @param array $actiondata * @todo The buttons in the beginning of the line (select, edit, view) are sub-elements * of filelist_entry. This enables the function to provide different buttons dependent * to the file-entry. **/ - function getFileList (&$actiondata) { + function getContentFiletree (&$actiondata) { $root = $actiondata ['_root']; $dir = $this->docroot.'/'.$this->basedir; - if (!file_exists ($dir) || !is_dir ($dir)) { - return false; - } - $files = $dirs = array(); $dh = opendir ($dir); while (false !== ($entry = readdir ($dh))) { Index: class.file_util.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager/class.file_util.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- class.file_util.php 25 Aug 2004 21:16:48 -0000 1.3 +++ class.file_util.php 29 Sep 2004 20:10:46 -0000 1.4 @@ -28,6 +28,10 @@ /* * $Log$ +* Revision 1.4 2004/09/29 20:10:46 mjahn +* completed phpCMS-config-part +* began the statistic part +* * Revision 1.3 2004/08/25 21:16:48 mjahn * step 1 is taken * @@ -63,36 +67,46 @@ 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' : '−') . + // 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' : '−')); - + (($in_Perms & 0x0400) ? 'S' : '-')); // world - $sP .= '<em>'; - $sP .= (($in_Perms & 0x0004) ? 'r' : '−') . - (($in_Perms & 0x0002) ? 'w' : '−') . + $sP .= (($in_Perms & 0x0004) ? 'r' : '-') . + (($in_Perms & 0x0002) ? 'w' : '-') . (($in_Perms & 0x0001) ? (($in_Perms & 0x0200) ? 't' : 'x' ) : - (($in_Perms & 0x0200) ? 'T' : '−')); - $sP .= '</em>'; + (($in_Perms & 0x0200) ? 'T' : '-')); return $sP; } function fileperms($filepath, $rwx = false) { $decperms = fileperms($filepath); + + list (,,,,$fileuid,$filegid,,,,,,,) = stat ($filepath); $octalperms = sprintf("%o",$decperms); if ($rwx) { - return file_util::chmodstr ($decperms); + $ret = file_util::chmodstr ($decperms); + if ($fileuid == posix_getuid ()) { + return '<em>'.substr ($ret, 0, 3).'</em>'.substr ($ret, 3, 6); + } + if ($filegid == posix_getgid ()) { + return substr ($ret, 0, 3).'<em>'.substr ($ret, 3, 6).'</em>'.substr ($ret, 6, 3); + } + return substr ($ret, 0, 6).'<em>'.substr ($ret, 6, 3).'</em>'; + } else { + $ret = substr($octalperms,-4); + if ($fileuid == posix_getuid ()) { + return '<em>'.substr ($ret, 0, 1).'</em>'.substr ($ret, 1, 2); + } + if ($filegid == posix_getgid ()) { + return substr ($ret, 0, 1).'<em>'.substr ($ret, 1, 1).'</em>'.substr ($ret, 2, 1); + } + return substr ($ret, 0, 2).'<em>'.substr ($ret, 2, 1).'</em>'; } - // -4 value should include ugo and strange bits for files and folders - return substr($octalperms,-4); } function checkpath ($ref, $check) { |