diff --git a/filemanager/images/folder-home.gif b/filemanager/images/folder-home.gif index 8555f88db2..e0b88cb102 100755 Binary files a/filemanager/images/folder-home.gif and b/filemanager/images/folder-home.gif differ diff --git a/filemanager/images/folder-home.png b/filemanager/images/folder-home.png index 794e7f2238..3afa803379 100644 Binary files a/filemanager/images/folder-home.png and b/filemanager/images/folder-home.png differ diff --git a/filemanager/images/folder-open.gif b/filemanager/images/folder-open.gif index da32bfada2..6050f3a8ae 100755 Binary files a/filemanager/images/folder-open.gif and b/filemanager/images/folder-open.gif differ diff --git a/filemanager/images/folder-open.png b/filemanager/images/folder-open.png index 0666ed33d1..33cc0bb90e 100644 Binary files a/filemanager/images/folder-open.png and b/filemanager/images/folder-open.png differ diff --git a/filemanager/images/folder-up.gif b/filemanager/images/folder-up.gif index 3dc1455429..9f0ffdaf05 100755 Binary files a/filemanager/images/folder-up.gif and b/filemanager/images/folder-up.gif differ diff --git a/filemanager/images/folder-up.png b/filemanager/images/folder-up.png index f83b23fdf1..8ec228df6b 100644 Binary files a/filemanager/images/folder-up.png and b/filemanager/images/folder-up.png differ diff --git a/filemanager/images/folder.gif b/filemanager/images/folder.gif index 43fbfb0969..bc825c5313 100755 Binary files a/filemanager/images/folder.gif and b/filemanager/images/folder.gif differ diff --git a/filemanager/images/folder.png b/filemanager/images/folder.png index d783a06122..dfd6894289 100644 Binary files a/filemanager/images/folder.png and b/filemanager/images/folder.png differ diff --git a/filemanager/images/locked.gif b/filemanager/images/locked.gif index 3397084cd7..0e04e1d78a 100755 Binary files a/filemanager/images/locked.gif and b/filemanager/images/locked.gif differ diff --git a/filemanager/images/locked.png b/filemanager/images/locked.png index 4b781544fa..669dc8d4d4 100644 Binary files a/filemanager/images/locked.png and b/filemanager/images/locked.png differ diff --git a/filemanager/inc/class.bofilemanager.inc.php b/filemanager/inc/class.bofilemanager.inc.php new file mode 100755 index 0000000000..a8e534b0b7 --- /dev/null +++ b/filemanager/inc/class.bofilemanager.inc.php @@ -0,0 +1,353 @@ +vfs = CreateObject('phpgwapi.vfs'); + + // This comes from the top of main (pim) // + error_reporting (4); + + /* if (@!is_object($GLOBALS['phpgw']->vfs)) + { + $GLOBALS['phpgw']->vfs = CreateObject ('phpgwapi.vfs'); + } + */ + ### Start Configuration Options ### + ### These are automatically set in phpGW - do not edit ### + + $this->sep = SEP; + $GLOBALS['rootdir'] = $this->vfs->basedir; + $GLOBALS['fakebase'] = $this->vfs->fakebase; + $GLOBALS['appname'] = $GLOBALS['phpgw_info']['flags']['currentapp']; + $GLOBALS['settings'] = $GLOBALS['phpgw_info']['user']['preferences'][$appname]; + + if (stristr ($GLOBALS['rootdir'], PHPGW_SERVER_ROOT)) + { + $GLOBALS['filesdir'] = substr ($GLOBALS['rootdir'], strlen (PHPGW_SERVER_ROOT)); + } + else + { + unset ($GLOBALS['filesdir']); + } + + $GLOBALS['hostname'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . $GLOBALS['filesdir']; + + ### + # Note that $userinfo["username"] is actually the id number, not the login name + ### + + $GLOBALS['userinfo']['username'] = $GLOBALS['phpgw_info']['user']['account_id']; + $GLOBALS['userinfo']['account_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['username']); + $GLOBALS['userinfo']['hdspace'] = 10000000000; + $GLOBALS['homedir'] = $GLOBALS['fakebase'].'/'.$GLOBALS['userinfo']['account_lid']; + + ### End Configuration Options ### + + if (!defined ('NULL')) + { + define ('NULL', ''); + } + + + // FIXME + require (PHPGW_APP_INC . '/db.inc.php'); + + /* Set up any initial db settings */ + db_init (); + //die('hallo?'); + + ### + # Get user settings from database + ### + + /* We have to define these by hand in phpGW, or rely on it's templates */ + + define ('HTML_TABLE_FILES_HEADER_BG_COLOR', ''); + define ('HTML_TABLE_FILES_HEADER_TEXT_COLOR', 'maroon'); + define ('HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR', '#cccccc'); + define ('HTML_TABLE_FILES_COLUMN_HEADER_TEXT_COLOR', '#000000'); + define ('HTML_TABLE_FILES_BG_COLOR', '#dedede'); + define ('HTML_TABLE_FILES_TEXT_COLOR', 'maroon'); + define ('HTML_TEXT_ERROR_COLOR', 'red'); + define ('HTML_TEXT_NAVIGATION_BACK_TO_USER', lang('Back to file manager')); + + ### + # Need to include this here so they recognize the settings + ### + + // require (PHPGW_APP_INC . '/html.inc.php'); + + ### + # Define the list of file attributes. Format is "internal_name" => "Displayed name" + # This is used both by internally and externally for things like preferences + ### + + $this->file_attributes = Array( + 'name' => lang('File Name'), + 'mime_type' => lang('MIME Type'), + 'size' => lang('Size'), + 'created' => lang('Created'), + 'modified' => lang('Modified'), + 'owner' => lang('Owner'), + 'createdby_id' => lang('Created by'), + 'modifiedby_id' => lang('Created by'), + 'modifiedby_id' => lang('Modified by'), + 'app' => lang('Application'), + 'comment' => lang('Comment'), + 'version' => lang('Version') + ); + + ### + # Calculate and display B or KB + # And yes, that first if is strange, + # but it does do something + ### + + $this->help_info = Array( +array ("up", "The Up button takes you to the directory above the current directory. For example, if you're in /home/jdoe/mydir, the Up button would take you to /home/jdoe."), +array ("directory_name", "The name of the directory you're currently in."), +array ("home", "The Home button takes you to your personal home directory."), +array ("sort_by", "Click on any of the column headers to sort the list by that column."), +array ("filename", "The name of the file or directory."), +array ("mime_type", "The MIME-type of the file. Examples include text/plain, text/html, image/jpeg. The special MIME-type Directory is used for directories."), +array ("size", "The size of the file or directory in the most convenient units: bytes (B), kilobytes (KB), megabytes (MB), gigabytes (GB). Sizes for directories include subfiles and subdirectories."), +array ("created", "When the file or directory was created."), +array ("modified", "When the file or directory was last modified."), +array ("owner", "The owner of the file or directory. This can be a user or group name."), +array ("created_by", "Displays who created the file or directory."), +array ("modified_by", "Displays who last modified the file or directory."), +array ("application", "The application associated with the file or directory. Usually the application used to create it. A blank application field is ok."), +array ("comment", "The comment for the file or directory. Comments can be set when creating the file or directory, and created or edited any time thereafter."), +array ("version", "The current version for the file or directory. Clicking on the version number will display a list of changes made to the file or directory."), +array ("edit", "Edit the text of the selected file(s). You can select more than one file; this is useful when you want to copy part of one file into another. Clicking Preview will show you a preview of the file. Click Save to save your changes."), +array ("rename", "Rename the selected file(s). You can select as many files or directories as you want. You are presented with a text field to enter the new name of each file or directory."), +array ("delete", "Delete the selected file(s). You can select as many files or directories as you want. When deleting directories, the entire directory and all of its contents are deleted. You will not be prompted to make sure you want to delete the file(s); make sure you really want to delete them before clicking Delete."), +array ("edit_comments", "Create a comment for a file or directory, or edit an existing comment. You can select as many files or directories as you want."), +array ("go_to", "The Go to button takes you to the directory selected in the drop down [directory_list|Directory List]."), +array ("copy_to", "This will copy all selected files and directories to the directory selected in the drop down [directory_list|Directory List]."), +array ("move_to", "This will move all selected files and directories to the directory selected in the drop down [directory_list|Directory List]."), +array ("directory_list", "The Directory List contains a list of all directories you have (at least) read access to. Selecting a directory and clicking one of the [go_to|Go to]/[copy_to|Copy to]/[move_to|Move to] buttons will perform the selected action on that directory. For example, if you select \"/home/somegroup/reports\" from the Directory List, and click the \"[copy_to|Copy to]\" button, all selected files and directories will be copied to \"/home/somegroup/reports\"."), +array ("download", "Download the first selected file to your local computer. You can only download one file at a time. Directories cannot be downloaded, only files."), +array ("create_folder", "Creates a directory (folder == directory). The name of the directory is specified in the text box next to the Create Folder button."), +array ("create_file", "Creates a file in the current directory. The name of the file is specified in the text box next to the Create File button. After clicking the Create File button you will be presented with the [edit|Edit] screen, where you may edit the file you just created. If you do not with to make any changes to the file at this time, simply click the Save button and the file will be saved as an empty file."), +array ("command_line", "Enter a Unix-style command line here, which will be executed when the [execute|Execute] button is pressed. If you don't know what this is, you probably should turn the option off in the Preferences."), +array ("execute", "Clicking the Execute button will execute the Unix-style [command_line|command line] specified in the text box above. If you don't know what this is, you probably should turn the option off in the Preferences."), +array ("update", "Sync the database with the filesystem for the current directory. This is useful if you use another interface to access the same files. Any new files or directories in the current directory will be read in, and the attributes for the other files will be updated to reflect any changes to the filesystem. Update is run automatically every few page loads (currently every 20 page loads as of this writing, but that may have changed by now)."), +array ("file_stats", "Various statistics on the number and size of the files in the current directory. In some situations, these reflect different statistics. For example, when in / or the base directory."), +array ("upload_file", "The full path of the local file to upload. You can type it in or use the Browse.. button to select it. The file will be uploaded to the current directory. You cannot upload directories, only files."), +array ("upload_comment", "The inital comment to use for the newly uploaded file. Totally optional and completely arbitrary. You can [edit_comments|create or edit the comment] at any time in the future."), +array ("upload_files", "This will upload the files listed in the input boxes above, and store them in the current directory."), +array ("show_upload_fields", "This setting determines how many [upload_files|upload fields] will be shown at once. You can change the default number that will be shown in the [preferences].") +); + + } + + + function borkb ($size, $enclosed = NULL, $return = 0) + { + if (!$size) + $size = 0; + + if ($enclosed) + { + $left = '('; + $right = ')'; + } + + if ($size < 1024) + $rstring = $left . $size . 'B' . $right; + else + $rstring = $left . round($size/1024) . 'KB' . $right; + + return ($this->eor ($rstring, $return)); + } + + ### + # Check for and return the first unwanted character + ### + + function bad_chars ($string, $all = True, $return = 0) + { + if ($all) + { + if (preg_match("-([\\/<>\'\"\&])-", $string, $badchars)) + $rstring = $badchars[1]; + } + else + { + if (preg_match("-([\\/<>])-", $string, $badchars)) + $rstring = $badchars[1]; + } + + return trim (($this->eor ($rstring, $return))); + } + + ### + # Match character in string using ord (). + ### + + function ord_match ($string, $charnum) + { + for ($i = 0; $i < strlen ($string); $i++) + { + $character = ord (substr ($string, $i, 1)); + + if ($character == $charnum) + { + return True; + } + } + + return False; + } + + ### + # Decide whether to echo or return. Used by HTML functions + ### + + function eor ($rstring, $return) + { + if ($return) + return ($rstring); + else + { + $this->html_text ($rstring . "\n"); + return (0); + } + } + + function html_text ($string, $times = 1, $return = 0, $lang = 0) + { + global $phpgw; + + if ($lang) + $string = $this->translate ($string); + + if ($times == NULL) + $times = 1; + for ($i = 0; $i != $times; $i++) + { + if ($return) + $rstring .= $string; + else + echo $string; + } + if ($return) + return ($rstring); + } + + ### + # URL encode a string + # First check if its a query string, then if its just a URL, then just encodes it all + # Note: this is a hack. It was made to work with form actions, form values, and links only, + # but should be able to handle any normal query string or URL + ### + + function string_encode ($string, $return = False) + { + if (preg_match ("/=(.*)(&|$)/U", $string)) + { + $rstring = $string; + + preg_match_all ("/=(.*)(&|$)/U", $string, $matches, PREG_SET_ORDER); + + reset ($matches); + while (list (,$match_array) = each ($matches)) + { + $var_encoded = rawurlencode (base64_encode ($match_array[1])); + $rstring = str_replace ($match_array[0], '=' . $var_encoded . $match_array[2], $rstring); + } + } + elseif (ereg ('^'.$GLOBALS['hostname'], $string)) + { + $rstring = ereg_replace ('^'.$GLOBALS['hostname'].'/', '', $string); + $rstring = preg_replace ("/(.*)(\/|$)/Ue", "rawurlencode (base64_encode ('\\1')) . '\\2'", $rstring); + $rstring = $GLOBALS['hostname'].'/'.$rstring; + } + else + { + $rstring = rawurlencode ($string); + + /* Terrible hack, decodes all /'s back to normal */ + $rstring = preg_replace ("/%2F/", '/', $rstring); + } + + return ($this->eor ($rstring, $return)); + } + + function string_decode ($string, $return = False) + { + $rstring = rawurldecode ($string); + + return ($this->eor ($rstring, $return)); + } + + ### + # HTML encode a string + # This should be used with anything in an HTML tag that might contain < or > + ### + + function html_encode ($string, $return) + { + $rstring = htmlspecialchars ($string); + + return ($this->eor ($rstring, $return)); + } + + function translate ($text) + { + return ($GLOBALS['phpgw']->lang($text)); + } + + + } + ?> diff --git a/filemanager/inc/class.uifilemanager.inc.php b/filemanager/inc/class.uifilemanager.inc.php new file mode 100755 index 0000000000..68c7d82227 --- /dev/null +++ b/filemanager/inc/class.uifilemanager.inc.php @@ -0,0 +1,2377 @@ + True, + ); + + var $bo; +// var $pref; + var $imgroot; + + function uifilemanager() + { + $this->bo = CreateObject('filemanager.bofilemanager'); + + //FIXME remove this one + $this->imgroot='filemanager/templates/default/'; + + + } + + + function index() + { + global $download,$path,$sortby,$op,$go,$file,$show_upload_boxes; + + ### + # Enable this to display some debugging info + ### + + $phpwh_debug = 0; + + @reset ($GLOBALS['HTTP_POST_VARS']); + while (list ($name,) = @each ($GLOBALS['HTTP_POST_VARS'])) + { + $$name = $GLOBALS['HTTP_POST_VARS'][$name]; + } + + // var_dump($GLOBALS['HTTP_POST_VARS']); + + + @reset ($GLOBALS['HTTP_GET_VARS']); + while (list ($name,) = @each ($GLOBALS['HTTP_GET_VARS'])) + { + $$name = $GLOBALS['HTTP_GET_VARS'][$name]; + } + + $to_decode = array + ( + /* + Decode + 'var' when 'avar' == 'value' + or + 'var' when 'var' is set + */ + 'op' => array ('op' => ''), + 'path' => array ('path' => ''), + 'file' => array ('file' => ''), + 'sortby' => array ('sortby' => ''), + 'fileman' => array ('fileman' => ''), + 'messages' => array ('messages' => ''), + 'help_name' => array ('help_name' => ''), + 'renamefiles' => array ('renamefiles' => ''), + 'comment_files' => array ('comment_files' => ''), + 'show_upload_boxes' => array ('show_upload_boxes' => '') + ); + + // FIXME (pim) decode doesn't work and I don't know where its for + + /* + + reset ($to_decode); + while (list ($var, $conditions) = each ($to_decode)) + { + while (list ($condvar, $condvalue) = each ($conditions)) + { + if (isset ($$condvar) && ($condvar == $var || $$condvar == $condvalue)) + { + if (is_array ($$var)) + { + $temp = array (); + //some fixes in this section were supplied by Michael Totschnig + while (list ($varkey, $varvalue) = each ($$var)) + { + if (is_int ($varkey)) + { + $temp[$varkey] = stripslashes (base64_decode(urldecode(($varvalue)))); + } + else + { + $temp[stripslashes (base64_decode(urldecode(($varkey))))] = $varvalue; + } + } + $$var = $temp; + } + elseif (isset ($$var)) + { + $$var = stripslashes (base64_decode(urldecode ($$var))); + } + } + } + } + + */ + + //FIXME re-enable this here above + + if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == 'view' && $file) || ($op == 'history' && $file) || ($op == 'help' && $help_name)) + { + $noheader = True; + $nofooter = True; + } + + $GLOBALS['phpgw_info']['flags'] = array + ( + 'currentapp' => 'filemanager', + 'noheader' => $noheader, + 'nofooter' => $nofooter, + 'noappheader' => False, + 'enable_browser_class' => True + ); + +// var_dump($GLOBALS['phpgw_info']['flags']); + $GLOBALS['phpgw']->common->phpgw_header(); + + + if ($execute && $command_line) + { + if ($result = $this->bo->vfs->command_line (array ('command_line' => stripslashes ($command_line)))) + { + $messages = $this->html_text_bold (lang('Command sucessfully run'),1); + if ($result != 1 && strlen ($result) > 0) + { + $messages .= $this->html_break (2, NULL, 1) . $result; + } + } + else + { + $messages = $GLOBALS['phpgw']->common->error_list (array (lang('Error running command'))); + } + } + + ### + # Page to process users + # Code is fairly hackish at the beginning, but it gets better + # Highly suggest turning wrapping off due to long SQL queries + ### + + ### + # Some hacks to set and display directory paths correctly + ### + + if ($go) + { + $path = $todir; + } + + // var_dump($GLOBALS['phpgw_info']); + // var_dump($GLOBALS['phpgw']); + // die(); + + if (!$path) + { + $path = $this->bo->vfs->pwd (); + + if (!$path || $this->bo->vfs->pwd (array ('full' => False)) == '') + { + $path = $GLOBALS['homedir']; + } + } + + + + $this->bo->vfs->cd (array ('string' => False, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); + $this->bo->vfs->cd (array ('string' => $path, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); + + $pwd = $this->bo->vfs->pwd (); + + if (!$cwd = substr ($path, strlen ($GLOBALS['homedir']) + 1)) + { + $cwd = '/'; + } + else + { + $cwd = substr ($pwd, strrpos ($pwd, '/') + 1); + } + + $disppath = $path; + + /* This just prevents // in some cases */ + if ($path == '/') + $dispsep = ''; + else + $dispsep = '/'; + + if (!($lesspath = substr ($path, 0, strrpos ($path, '/')))) + $lesspath = '/'; + + $now = date ('Y-m-d'); + + if ($phpwh_debug) + { + echo "PHPWebHosting debug:
+ path: $path
+ disppath: $disppath
+ cwd: $cwd
+ lesspath: $lesspath +

+ phpGW debug:
+ real getabsolutepath: " . $this->bo->vfs->getabsolutepath (array ('target' => False, 'mask' => False, 'fake' => False)) . "
+ fake getabsolutepath: " . $this->bo->vfs->getabsolutepath (array ('target' => False)) . "
+ appsession: " . $GLOBALS['phpgw']->session->appsession ('vfs','') . "
+ pwd: " . $this->bo->vfs->pwd () . "
"; + } + + ### + # Get their readable groups to be used throughout the script + ### + + $groups = array (); + + $groups = $GLOBALS['phpgw']->accounts->get_list ('groups'); + + $readable_groups = array (); + + while (list ($num, $account) = each ($groups)) + { + if ($this->bo->vfs->acl_check (array ( + 'owner_id' => $account['account_id'], + 'operation' => PHPGW_ACL_READ + )) + ) + { + $readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); + } + } + + $groups_applications = array (); + + while (list ($num, $group_array) = each ($readable_groups)) + { + $group_id = $GLOBALS['phpgw']->accounts->name2id ($group_array['account_name']); + + $applications = CreateObject('phpgwapi.applications', $group_id); + $groups_applications[$group_array['account_name']] = $applications->read_account_specific (); + } + + ### + # We determine if they're in their home directory or a group's directory, + # and set the VFS working_id appropriately + ### + + if ((preg_match ('+^'.$GLOBALS['fakebase'].'\/(.*)(\/|$)+U', $path, $matches)) && $matches[1] != $GLOBALS['userinfo']['account_lid']) + { + $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id ($matches[1]); + } + else + { + $this->bo->vfs->working_id = $GLOBALS['userinfo']['username']; + } + + if ($path != $GLOBALS['homedir'] + && $path != $GLOBALS['fakebase'] + && $path != '/' + && !$this->bo->vfs->acl_check (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'operation' => PHPGW_ACL_READ + )) + ) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('You do not have access to %1', $path))); + $this->html_break (2); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$GLOBALS['homedir'], lang('Go to your home directory')); + $this->html_page_close (); + } + + $GLOBALS['userinfo']['working_id'] = $this->bo->vfs->working_id; + $GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['working_id']); + + ### + # If their home directory doesn't exist, we create it + # Same for group directories + ### + + if (($path == $GLOBALS['homedir']) + && !$this->bo->vfs->file_exists (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE) + )) +) +{ + $this->bo->vfs->override_acl = 1; + + if (!$this->bo->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) + { + // FIXME (pim) ?? + $p = $this->bo->vfs->path_parts (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create directory %1', $GLOBALS['homedir'] . ' (' . $p->real_full_path . ')'))); + } + + $this->bo->vfs->override_acl = 0; +} + +### +# Verify path is real +### + +if ($path != $GLOBALS['homedir'] && $path != '/' && $path != $GLOBALS['fakebase']) +{ + if (!$this->bo->vfs->file_exists (array ('string' => $path, 'relatives' => array (RELATIVE_NONE)))) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 does not exist', $path))); + $this->html_break (2); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$GLOBALS['homedir'], lang('Go to your home directory')); + $this->html_break (2); + $this->html_link_back (); + $this->html_page_close (); + } +} + +/* Update if they request it, or one out of 20 page loads */ +srand ((double) microtime() * 1000000); +if ($update || rand (0, 19) == 4) +{ + $this->bo->vfs->update_real (array ('string' => $path, 'relatives' => array (RELATIVE_NONE))); +} + +### +# Check available permissions for $path, so we can disable unusable operations in user interface +### + +if ($this->bo->vfs->acl_check (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'operation' => PHPGW_ACL_ADD +)) + ) + { + $can_add = True; + } + + ### + # Default is to sort by name + ### + + if (!$sortby) + { + $sortby = 'name'; + } + + ### + # Decide how many upload boxes to show + ### + //var_dump($show_upload_boxes); + //die(); + + if (!$show_upload_boxes || $show_upload_boxes <= 0) + { + if (!$show_upload_boxes = $GLOBALS['settings']['show_upload_boxes']) + { + $show_upload_boxes = 5; + } + } + + ### + # Read in file info from database to use in the rest of the script + # $fakebase is a special directory. In that directory, we list the user's + # home directory and the directories for the groups they're in + ### + + $numoffiles = 0; + if ($path == $GLOBALS['fakebase']) + { + if (!$this->bo->vfs->file_exists (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) + { + $this->bo->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); + } + + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + $files_array[] = $ls_array[0]; + $numoffiles++; + // $files_array = $ls_array; + // $numoffiles = count($ls_array); + + reset ($readable_groups); + while (list ($num, $group_array) = each ($readable_groups)) + { + ### + # If the group doesn't have access to this app, we don't show it + ### + + if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + { + continue; + } + + if (!$this->bo->vfs->file_exists (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE) + )) + ) + { + $this->bo->vfs->override_acl = 1; + $this->bo->vfs->mkdir (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE) + ) + ); + $this->bo->vfs->override_acl = 0; + + $this->bo->vfs->set_attributes (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE), + 'attributes' => array ( + 'owner_id' => $group_array['account_id'], + 'createdby_id' => $group_array['account_id'] + ) + ) + ); + } + + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) +); + +$files_array[] = $ls_array[0]; + +$numoffiles++; + } + } + else + { + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => False, + 'orderby' => $sortby + ) + ); + + if ($phpwh_debug) + { + echo '# of files found in "'.$path.'" : '.count($ls_array).'
'."\n"; + } + + while (list ($num, $file_array) = each ($ls_array)) + { + $numoffiles++; + $files_array[] = $file_array; + if ($phpwh_debug) + { + echo 'Filename: '.$file_array['name'].'
'."\n"; + } + } + } + + if (!is_array ($files_array)) + { + $files_array = array (); + } + + if ($download) + { + for ($i = 0; $i != $numoffiles; $i++) + { + if (!$fileman[$i]) + { + continue; + } + + $download_browser = CreateObject ('phpgwapi.browser'); + $download_browser->content_header ($fileman[$i]); + echo $this->bo->vfs->read (array ('string' => $fileman[$i])); + $GLOBALS['phpgw']->common->phpgw_exit (); + } + } + + if ($op == 'view' && $file) + { + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $path.'/'.$file, + 'relatives' => array (RELATIVE_ALL), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + + if ($ls_array[0]['mime_type']) + { + $mime_type = $ls_array[0]['mime_type']; + } + elseif ($GLOBALS['settings']['viewtextplain']) + { + $mime_type = 'text/plain'; + } + + header('Content-type: ' . $mime_type); + echo $this->bo->vfs->read (array ( + 'string' => $path.'/'.$file, + 'relatives' => array (RELATIVE_NONE) + ) + ); + $GLOBALS['phpgw']->common->phpgw_exit (); +} + +if ($op == 'history' && $file) +{ + $journal_array = $this->bo->vfs->get_journal (array ( + 'string' => $file, + 'relatives' => array (RELATIVE_ALL) + ) +); + +if (is_array ($journal_array)) +{ + $this->html_table_begin (); + $this->html_table_row_begin (); + $this->html_table_col_begin (); + $this->html_text_bold (lang('Date')); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->html_text_bold (lang('Version')); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->html_text_bold (lang('Who')); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->html_text_bold (lang('Operation')); + $this->html_table_col_end (); + $this->html_table_row_end (); + + while (list ($num, $journal_entry) = each ($journal_array)) + { + $this->html_table_row_begin (); + $this->html_table_col_begin (); + $this->bo->html_text ($journal_entry['created'] . $this->html_nbsp (3, 1)); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->bo->html_text ($journal_entry['version'] . $this->html_nbsp (3, 1)); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($journal_entry['owner_id']) . $this->html_nbsp (3, 1)); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->bo->html_text ($journal_entry['comment']); + $this->html_table_col_end (); + } + + $this->html_table_end (); + $this->html_page_close (); +} +else +{ + $this->html_text_bold (lang('No version history for this file/directory')); +} + + } + + if ($newfile && $createfile) + { + if ($badchar = $this->bo->bad_chars ($createfile, True, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array ($this->bo->html_encode (lang('File names cannot contain "%1"',$badchar), 1))); + $this->html_break (2); + $this->html_link_back (); + $this->html_page_close (); + } + + if ($this->bo->vfs->file_exists (array ( + 'string' => $createfile, + 'relatives' => array (RELATIVE_ALL) + )) + ) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 already exists. Please edit it or delete it first.', $createfile))); + $this->html_break (2); + $this->html_link_back (); + $this->html_page_close (); + } + + if ($this->bo->vfs->touch (array ( + 'string' => $createfile, + 'relatives' => array (RELATIVE_ALL) + )) + ) + { + $fileman = array (); + $fileman[0] = $createfile; + $edit = 1; + $numoffiles++; + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 could not be created.', $createfile))); + } + } + + if ($op == 'help' && $help_name) + { + while (list ($num, $help_array) = each ($help_info)) + { + if ($help_array[0] != $help_name) + continue; + + $help_array[1] = preg_replace ("/\[(.*)\|(.*)\]/Ue", "html_help_link ('\\1', '\\2', False, True)", $help_array[1]); + $help_array[1] = preg_replace ("/\[(.*)\]/Ue", "html_help_link ('\\1', '\\1', False, True)", $help_array[1]); + + $this->html_font_set ('4'); + $title = ereg_replace ('_', ' ', $help_array[0]); + $title = ucwords ($title); + $this->bo->html_text ($title); + $this->html_font_end (); + + $this->html_break (2); + + $this->html_font_set ('2'); + $this->bo->html_text ($help_array[1]); + $this->html_font_end (); + } + + $GLOBALS['phpgw']->common->phpgw_exit (); + } + + ### + # Start Main Page + ### + + $this->html_page_begin (lang('Users').' :: '.$GLOBALS['userinfo']['username']); + $this->html_page_body_begin (HTML_PAGE_BODY_COLOR); + + if ($messages) + { + $this->bo->html_text ($messages); + } + + if (!count ($GLOBALS['settings'])) + { + $GLOBALS[pref] = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); + $GLOBALS[pref]->read_repository (); + $GLOBALS['phpgw']->hooks->single ('add_def_pref', $GLOBALS['appname']); + $GLOBALS[pref]->save_repository (True); + $pref_array = $GLOBALS[pref]->read_repository (); + $GLOBALS['settings'] = $pref_array[$GLOBALS['appname']]; + } + + ### + # Start Main Table + ### + + if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$edit && !$comment_files) + { + $this->html_table_begin ('100%'); + $this->html_table_row_begin (); + $this->html_table_col_begin ('center', NULL, 'top'); + $this->html_align ('center'); + $this->html_form_begin ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path); + if ($numoffiles || $cwd) + { + while (list ($num, $name) = each ($GLOBALS['settings'])) + { + if ($name) + { + $columns++; + } + } + $columns++; + $this->html_table_begin (); + $this->html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_HEADER_BG_COLOR); + $this->html_table_col_begin ('center', NULL, NULL, NULL, $columns); + $this->html_table_begin ('100%'); + $this->html_table_row_begin (); + $this->html_table_col_begin ('left'); + + if ($path != '/') + { + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$lesspath, $this->html_image ($this->imgroot.'images/folder-up.png', lang('Up'), 'left', 0, NULL, 1)); + $this->html_help_link ('up'); + } + + $this->html_table_col_end (); + $this->html_table_col_begin ('center'); + + if ($cwd) + { + if ($path == $GLOBALS['homedir']) + { + $this->html_image ($this->imgroot.'images/folder-home.png', lang('Folder'), 'center'); + } + else + { + $this->html_image ($this->imgroot.'images/folder.png', lang('Folder'), 'center'); + } + } + else + { + $this->html_image ($this->imgroot.'images/folder-home.png', lang('Home')); + } + + $this->html_font_set (4, HTML_TABLE_FILES_HEADER_TEXT_COLOR); + $this->html_text_bold ($disppath); + $this->html_font_end (); + $this->html_help_link ('directory_name'); + $this->html_table_col_end (); + $this->html_table_col_begin ('right'); + + if ($path != $GLOBALS['homedir']) + { + $this->html_link ('/index.php'.'menuaction=filemanager.uifilemanager.index&path='.$GLOBALS['homedir'], $this->html_image ($this->imgroot.'images/folder-home.png', lang('Home'), 'right', 0, NULL, 1)); + $this->html_help_link ('home'); + } + + $this->html_table_col_end (); + $this->html_table_row_end (); + $this->html_table_end (); + $this->html_table_col_end (); + $this->html_table_row_end (); + $this->html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR); + + ### + # Start File Table Column Headers + # Reads values from $file_attributes array and preferences + ### + + $this->html_table_col_begin (); + $this->bo->html_text (lang('Sort by:') . $this->html_nbsp (1, 1), NULL, NULL, 0); + $this->html_help_link ('sort_by'); + $this->html_table_col_end (); + + reset ($this->bo->file_attributes); + while (list ($internal, $displayed) = each ($this->bo->file_attributes)) + { + if ($GLOBALS['settings'][$internal]) + { + $this->html_table_col_begin (); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path.'&sortby='.$internal, $this->html_text_bold ($displayed, 1, 0)); + $this->html_help_link (strtolower (ereg_replace (' ', '_', $displayed))); + $this->html_table_col_end (); + } + } + + $this->html_table_col_begin (); + $this->html_table_col_end (); + $this->html_table_row_end (); + + if ($GLOBALS['settings']['dotdot'] && $GLOBALS['settings']['name'] && $path != '/') + { + $this->html_table_row_begin (); + $this->html_table_col_begin (); + $this->html_table_col_end (); + + /* We can assume the next column is the name */ + $this->html_table_col_begin (); + $this->html_image ($this->imgroot.'images/folder.png', lang('Folder')); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$lesspath, '..'); + $this->html_table_col_end (); + + if ($GLOBALS['settings']['mime_type']) + { + $this->html_table_col_begin (); + $this->bo->html_text (lang('Directory')); + $this->html_table_col_end (); + } + + $this->html_table_row_end (); + } + + ### + # List all of the files, with their attributes + ### + + reset ($files_array); + for ($i = 0; $i != $numoffiles; $i++) + { + $files = $files_array[$i]; + + if ($rename || $edit_comments) + { + unset ($this_selected); + unset ($renamethis); + unset ($edit_this_comment); + + for ($j = 0; $j != $numoffiles; $j++) + { + if ($fileman[$j] == $files['name']) + { + $this_selected = 1; + break; + } + } + + if ($rename && $this_selected) + { + $renamethis = 1; + } + elseif ($edit_comments && $this_selected) + { + $edit_this_comment = 1; + } + } + + if (!$GLOBALS['settings']['dotfiles'] && ereg ("^\.", $files['name'])) + { + continue; + } + + $this->html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_BG_COLOR); + + ### + # Checkboxes + ### + + $this->html_table_col_begin ('right'); + + if (!$rename && !$edit_comments && $path != $GLOBALS['fakebase'] && $path != '/') + { + $this->html_form_input ('checkbox', 'fileman['.$i.']', base64_encode ($files['name'])); + } + elseif ($renamethis) + { + $this->html_form_input ('hidden', 'fileman[' . base64_encode ($files['name']) . ']', $files['name'], NULL, NULL, 'checked'); + } + else + { + $this->html_nbsp(); + } + + $this->html_table_col_end (); + + ### + # File name and icon + ### + + if ($GLOBALS['settings']['name']) + { + if ($phpwh_debug) + { + echo 'Setting file name: '.$files['name'].'
'."\n"; + } + + $this->html_table_col_begin (); + + if ($renamethis) + { + if ($files['mime_type'] == 'Directory') + { + $this->html_image ($this->imgroot.'images/folder.png', lang('Folder')); + } + $this->html_form_input ('text', 'renamefiles[' . base64_encode ($files['name']) . ']', $files['name'], 255); + } + else + { + if ($files['mime_type'] == 'Directory') + { + $this->html_image ($this->imgroot.'images/folder.png', lang('Folder')); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path.$dispsep.$files['name'], $files['name']); + } + else + { + if ($GLOBALS['settings']['viewinnewwin']) + { + $target = '_new'; + } + + if ($GLOBALS['settings']['viewonserver'] && isset ($GLOBALS['filesdir']) && !$files['link_directory']) + { + #FIXME + $clickview = $GLOBALS['filesdir'].$pwd.'/'.$files['name']; + + if ($phpwh_debug) + { + echo 'Setting clickview = '.$clickview.'
'."\n"; + $this->html_link ($clickview, '',$files['name'], 0, 1, 0, ''); + } + } + else + { + #FIXME?? + // $clickview = $GLOBALS['appname'].'/index.php?op=view&file='.$files['name'].'&path='.$path; + $this->html_link ('index.php','menuaction=filemanager.uifilemanager.index&op=view&file='.$files['name'].'&path='.$path, $files['name'], 0, 1, 0, $target); + } + + + #FIXME + //$this->html_link ($clickview, $files['name'], 0, 1, 0, $target); + } + } + + $this->html_table_col_end (); + } + + ### + # MIME type + ### + + if ($GLOBALS['settings']['mime_type']) + { + $this->html_table_col_begin (); + $this->bo->html_text ($files['mime_type']); + $this->html_table_col_end (); + } + + ### + # File size + ### + + if ($GLOBALS['settings']['size']) + { + $this->html_table_col_begin (); + + $size = $this->bo->vfs->get_size (array ( + 'string' => $files['directory'] . '/' . $files['name'], + 'relatives' => array (RELATIVE_NONE) + ) + ); + + $this->bo->borkb ($size); + + $this->html_table_col_end (); + } + + ### + # Date created + ### + if ($GLOBALS['settings']['created']) + { + $this->html_table_col_begin (); + $this->bo->html_text ($files['created']); + $this->html_table_col_end (); + } + + ### + # Date modified + ### + + if ($GLOBALS['settings']['modified']) + { + $this->html_table_col_begin (); + if ($files['modified'] != '0000-00-00') + { + $this->bo->html_text ($files['modified']); + } + $this->html_table_col_end (); + } + + ### + # Owner name + ### + + if ($GLOBALS['settings']['owner']) + { + $this->html_table_col_begin (); + $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($files['owner_id'])); + $this->html_table_col_end (); + } + + ### + # Creator name + ### + + if ($GLOBALS['settings']['createdby_id']) + { + $this->html_table_col_begin (); + if ($files['createdby_id']) + { + $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($files['createdby_id'])); + } + $this->html_table_col_end (); + } + + ### + # Modified by name + ### + + if ($GLOBALS['settings']['modifiedby_id']) + { + $this->html_table_col_begin (); + if ($files['modifiedby_id']) + { + $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($files['modifiedby_id'])); + } + $this->html_table_col_end (); + } + + ### + # Application + ### + + if ($GLOBALS['settings']['app']) + { + $this->html_table_col_begin (); + $this->bo->html_text ($files['app']); + $this->html_table_col_end (); + } + + ### + # Comment + ### + + if ($GLOBALS['settings']['comment']) + { + $this->html_table_col_begin (); + if ($edit_this_comment) + { + $this->html_form_input ('text', 'comment_files[' . base64_encode ($files['name']) . ']', $this->bo->html_encode ($files['comment'], 1), 255); + } + else + { + $this->bo->html_text ($files['comment']); + } + $this->html_table_col_end (); + } + + ### + # Version + ### + + if ($GLOBALS['settings']['version']) + { + $this->html_table_col_begin (); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&op=history&file='.$files['name'].'&path='.$path, $files['version'], NULL, True, NULL, '_new'); + $this->html_table_col_end (); + } + + ### + # Deleteable (currently not used) + ### + + if ($GLOBALS['settings']['deleteable']) + { + if ($files['deleteable'] == 'N') + { + $this->html_table_col_begin (); + $this->html_image ($this->imgroot.'images/locked.png', lang('Locked')); + $this->html_table_col_end (); + } + else + { + $this->html_table_col_begin (); + $this->html_table_col_end (); + } + } + + $this->html_table_row_end (); + + if ($files['mime_type'] == 'Directory') + { + $usedspace += $fileinfo[0]; + } + else + { + $usedspace += $files['size']; + } + } + + $this->html_table_end (); + $this->html_break (2); + + if ($path != '/' && $path != $GLOBALS['fakebase']) + { + if (!$rename && !$edit_comments) + { + $this->html_form_input ('submit', 'edit', lang('Edit')); + $this->html_help_link ('edit'); + $this->html_nbsp (3); + } + + if (!$edit_comments) + { + $this->html_form_input ('submit', 'rename', lang('Rename')); + $this->html_help_link ('rename'); + $this->html_nbsp (3); + } + + if (!$rename && !$edit_comments) + { + $this->html_form_input ('submit', 'delete', lang('Delete')); + $this->html_help_link ('delete'); + $this->html_nbsp (3); + } + + if (!$rename) + { + $this->html_form_input ('submit', 'edit_comments', lang('Edit comments')); + $this->html_help_link ('edit_comments'); + } + } + } + + ### + # Display some inputs and info, but not when renaming or editing comments + ### + + if (!$rename && !$edit_comments) + { + ### + # Begin Copy to/Move to selection + ### + + $this->html_break (1); + $this->html_form_input ('submit', 'go', lang('Go to:')); + $this->html_help_link ('go_to'); + + if ($path != '/' && $path != $GLOBALS['fakebase']) + { + $this->html_form_input ('submit', 'copy', lang('Copy to:')); + $this->html_help_link ('copy_to'); + $this->html_form_input ('submit', 'move', lang('Move to:')); + $this->html_help_link ('move_to'); + } + + $this->html_form_select_begin ('todir'); + + $this->html_break (1); + + ### + # First we get the directories in their home directory + ### + + $dirs = array (); + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); + + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => True, + 'mime_type' => 'Directory' + ) + ); + + while (list ($num, $dir) = each ($ls_array)) + { + $dirs[] = $dir; + } + + + ### + # Then we get the directories in their readable groups' home directories + ### + + reset ($readable_groups); + while (list ($num, $group_array) = each ($readable_groups)) + { + ### + # Don't list directories for groups that don't have access + ### + + if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + { + continue; + } + + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); + + // FIXME?? (pim) + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => True, + 'mime_type' => 'Directory' + ) + ); + while (list ($num, $dir) = each ($ls_array)) + { + $dirs[] = $dir; + } +} + +reset ($dirs); +while (list ($num, $dir) = each ($dirs)) +{ + if (!$dir['directory']) + { + continue; + } + + ### + # So we don't display // + ### + + if ($dir['directory'] != '/') + { + $dir['directory'] .= '/'; + } + + ### + # No point in displaying the current directory, or a directory that doesn't exist + ### + + if ((($dir['directory'] . $dir['name']) != $path) + && $this->bo->vfs->file_exists (array ( + 'string' => $dir['directory'] . $dir['name'], + 'relatives' => array (RELATIVE_NONE) + )) +) +{ + $this->html_form_option ($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); +} + } + + $this->html_form_select_end (); + $this->html_help_link ('directory_list'); + + if ($path != '/' && $path != $GLOBALS['fakebase']) + { + $this->html_break (1); + + $this->html_form_input ('submit', 'download', lang('Download')); + $this->html_help_link ('download'); + $this->html_nbsp (3); + + if ($can_add) + { + $this->html_form_input ('text', 'createdir', NULL, 255, 15); + $this->html_form_input ('submit', 'newdir', lang('Create Folder')); + $this->html_help_link ('create_folder'); + } + } + + $this->html_break (1); + $this->html_form_input ('submit', 'update', lang('Update')); + $this->html_help_link ('update'); + + if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) + { + $this->html_nbsp (3); + $this->html_form_input ('text', 'createfile', NULL, 255, 15); + $this->html_form_input ('submit', 'newfile', lang('Create File')); + $this->html_help_link ('create_file'); + } + + if ($GLOBALS['settings']['show_command_line']) + { + $this->html_break (2); + $this->html_form_input ('text', 'command_line', NULL, NULL, 50); + $this->html_help_link ('command_line'); + + $this->html_break (1); + $this->html_form_input ('submit', 'execute', lang('Execute')); + $this->html_help_link ('execute'); + } + + $this->html_form_end (); + + $this->html_help_link ('file_stats'); + $this->html_break (1); + $this->html_text_bold (lang('Files').': '); + $this->bo->html_text ($numoffiles); + $this->html_nbsp (3); + + $this->html_text_bold (lang('Used space').': '); + $this->bo->html_text ($this->bo->borkb ($usedspace, NULL, 1)); + $this->html_nbsp (3); + + if ($path == $GLOBALS['homedir'] || $path == $GLOBALS['fakebase']) + { + $this->html_text_bold (lang('Unused space').': '); + $this->bo->html_text ($this->bo->borkb ($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1)); + + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE) + ) + ); + + $i = count ($ls_array); + + $this->html_break (2); + $this->html_text_bold (lang('Total Files').': '); + $this->bo->html_text ($i); + } + + ### + # Show file upload boxes. Note the last argument to html (). Repeats $show_upload_boxes times + ### + + if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) + { + $this->html_break (2); + $this->html_form_begin ('/index.php','menuaction=filemanager.uifilemanager.index&op=upload&path='.$path, 'post', 'multipart/form-data'); + $this->html_table_begin (); + $this->html_table_row_begin ('center'); + $this->html_table_col_begin (); + $this->html_text_bold (lang('File')); + $this->html_help_link ('upload_file'); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->html_text_bold (lang('Comment')); + $this->html_help_link ('upload_comment'); + $this->html_table_col_end (); + $this->html_table_row_end (); + + $this->html_table_row_begin (); + $this->html_table_col_begin (); + $this->html_form_input ('hidden', 'show_upload_boxes', base64_encode ($show_upload_boxes)); + $this->html ($this->html_form_input ('file', 'upload_file[]', NULL, 255, NULL, NULL, NULL, 1) . $this->html_break (1, NULL, 1), $show_upload_boxes); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->html ($this->html_form_input ('text', 'upload_comment[]', NULL, NULL, NULL, NULL, NULL, 1) . $this->html_break (1, NULL, 1), $show_upload_boxes); + $this->html_table_col_end (); + $this->html_table_row_end (); + $this->html_table_end (); + $this->html_form_input ('submit', 'upload_files', lang('Upload files')); + $this->html_help_link ('upload_files'); + $this->html_break (2); + $this->bo->html_text (lang('Show') . $this->html_nbsp (1, True)); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&show_upload_boxes=5', '5'); + $this->html_nbsp (); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&show_upload_boxes=10', '10'); + $this->html_nbsp (); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&show_upload_boxes=20', '20'); + $this->html_nbsp (); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&show_upload_boxes=50', '50'); + $this->html_nbsp (); + $this->bo->html_text (lang('upload fields')); + $this->html_nbsp (); + $this->html_help_link ('show_upload_fields'); + $this->html_form_end (); + } + } + + $this->html_table_col_end (); + $this->html_table_row_end (); + $this->html_table_end (); + $this->html_page_close (); + } + + ### + # Handle Editing files + ### + + if ($edit) + { + ### + # If $edit is "Edit", we do nothing, and let the for loop take over + ### + + if ($edit_file) + { + $edit_file_content = stripslashes ($edit_file_content); + } + + if ($edit_preview) + { + $content = $edit_file_content; + + $this->html_break (1); + $this->html_text_bold (lang('Preview of %1', $path.'/'.$edit_file)); + $this->html_break (2); + + $this->html_table_begin ('90%'); + $this->html_table_row_begin (); + $this->html_table_col_begin (); + $this->bo->html_text (nl2br ($content)); + $this->html_table_col_end (); + $this->html_table_row_end (); + $this->html_table_end (); + } + elseif ($edit_save) + { + $content = $edit_file_content; + + if ($this->bo->vfs->write (array ( + 'string' => $edit_file, + 'relatives' => array (RELATIVE_ALL), + 'content' => $content + )) + ) + { + $this->html_text_bold (lang('Saved %1', $path.'/'.$edit_file)); + $this->html_break (2); + $this->html_link_back (); + } + else + { + $this->html_text_error (lang('Could not save %1', $path.'/'.$edit_file)); + $this->html_break (2); + $this->html_link_back (); + } + } + + /* This doesn't work just yet + elseif ($edit_save_all) + { + for ($j = 0; $j != $numoffiles; $j++) + { + $fileman[$j]; + + $content = $fileman[$j]; + echo 'fileman['.$j.']: '.$fileman[$j].'
'.$content.'
'; + continue; + + if ($this->bo->vfs->write (array ( + 'string' => $fileman[$j], + 'relatives' => array (RELATIVE_ALL), + 'content' => $content + )) + ) + { + $this->html_text_bold (lang('Saved %1', $path.'/'.$fileman[$j])); + $this->html_break (1); + } + else + { + $this->html_text_error (lang('Could not save %1', $path.'/'.$fileman[$j])); + $this->html_break (1); + } + } + + $this->html_break (1); + } + */ + + ### + # Now we display the edit boxes and forms + ### + + for ($j = 0; $j != $numoffiles; $j++) + { + ### + # If we're in preview or save mode, we only show the file + # being previewed or saved + ### + + if ($edit_file && ($fileman[$j] != $edit_file)) + { + continue; + } + + if ($fileman[$j] && $this->bo->vfs->file_exists (array ( + 'string' => $fileman[$j], + 'relatives' => array (RELATIVE_ALL) + )) + ) + { + if ($edit_file) + { + $content = stripslashes ($edit_file_content); + } + else + { + $content = $this->bo->vfs->read (array ('string' => $fileman[$j])); + } + + $this->html_table_begin ('100%'); + $this->html_form_begin ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path); + $this->html_form_input ('hidden', 'edit', True); + $this->html_form_input ('hidden', 'edit_file', $fileman[$j]); + + ### + # We need to include all of the fileman entries for each file's form, + # so we loop through again + ### + + for ($i = 0; $i != $numoffiles; $i++) + { + $this->html_form_input ('hidden', 'fileman['.$i.']', base64_encode ($fileman[$i])); + } + + $this->html_table_row_begin (); + $this->html_table_col_begin (); + $this->html_form_textarea ('edit_file_content', 35, 75, $content); + $this->html_table_col_end (); + $this->html_table_col_begin ('center'); + $this->html_form_input ('submit', 'edit_preview', lang('Preview %1', $this->bo->html_encode ($fileman[$j], 1))); + $this->html_break (1); + $this->html_form_input ('submit', 'edit_save', lang('Save %1', $this->bo->html_encode ($fileman[$j], 1))); + // $this->html_break (1); + // $this->html_form_input ('submit', 'edit_save_all', lang('Save all')); + $this->html_table_col_end (); + $this->html_table_row_end (); + $this->html_break (2); + $this->html_form_end (); + $this->html_table_end (); + } +} + } + + ### + # Handle File Uploads + ### + + elseif ($op == 'upload' && $path != '/' && $path != $GLOBALS['fakebase']) + { + for ($i = 0; $i != $show_upload_boxes; $i++) + { + if ($badchar = $this->bo->bad_chars ($_FILES['upload_file']['name'][$i], True, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array ($this->bo->html_encode (lang('File names cannot contain "%1"', $badchar), 1))); + + continue; + } + + ### + # Check to see if the file exists in the database, and get its info at the same time + ### + + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $path . '/' . $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + + $fileinfo = $ls_array[0]; + + if ($fileinfo['name']) + { + if ($fileinfo['mime_type'] == 'Directory') + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); + continue; + } + } + + if ($_FILES['upload_file']['size'][$i] > 0) + { + if ($fileinfo['name'] && $fileinfo['deleteable'] != 'N') + { + $this->bo->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'owner_id' => $GLOBALS['userinfo']['username'], + 'modifiedby_id' => $GLOBALS['userinfo']['username'], + 'modified' => $now, + 'size' => $_FILES['upload_file']['size'][$i], + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'deleteable' => 'Y', + 'comment' => stripslashes ($upload_comment[$i]) + ) + ) + ); + + $this->bo->vfs->cp(array ( + 'from' => $_FILES['upload_file']['tmp_name'][$i], + 'to' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) + ) + ); + + $this->html_text_summary(lang('Replaced %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); + } + else + { + $this->bo->vfs->cp (array ( + 'from' => $_FILES['upload_file']['tmp_name'][$i], + 'to' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) + ) + ); + + $this->bo->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'comment' => stripslashes ($upload_comment[$i]) + ) + ) + ); + + $this->html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); + } +} +elseif ($_FILES['upload_file']['name'][$i]) +{ + $this->bo->vfs->touch (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL) + ) +); + +$this->bo->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'comment' => $upload_comment[$i] + ) +) + ); + + $this->html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $file_size[$i]); + } + } + + $this->html_break (2); + $this->html_link_back (); + } + + ### + # Handle Editing comments + ### + + elseif ($comment_files) + { + while (list ($file) = each ($comment_files)) + { + if ($badchar = $this->bo->bad_chars ($comment_files[$file], False, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array ($this->html_text_italic ($file, 1) . $this->bo->html_encode (': ' . lang('Comments cannot contain "%1"', $badchar), 1))); + continue; + } + + $this->bo->vfs->set_attributes (array ( + 'string' => $file, + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'comment' => stripslashes ($comment_files[$file]) + ) + ) + ); + + $this->html_text_summary (lang('Updated comment for %1', $path.'/'.$file)); + } + + $this->html_break (2); + $this->html_link_back (); + } + + ### + # Handle Renaming Files and Directories + ### + + elseif ($renamefiles) + { + while (list ($from, $to) = each ($renamefiles)) + { + if ($badchar = $this->bo->bad_chars ($to, True, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array ($this->bo->html_encode (lang('File names cannot contain "%1"', $badchar), 1))); + continue; + } + + if (ereg ("/", $to) || ereg ("\\\\", $to)) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang("File names cannot contain \\ or /"))); + } + elseif (!$this->bo->vfs->mv (array ( + 'from' => $from, + 'to' => $to + )) + ) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not rename %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to))); + } + else + { + $this->html_text_summary (lang('Renamed %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to)); + } + } + + $this->html_break (2); + $this->html_link_back (); + } + + ### + # Handle Moving Files and Directories + ### + + elseif ($move) + { + while (list ($num, $file) = each ($fileman)) + { + if ($this->bo->vfs->mv (array ( + 'from' => $file, + 'to' => $todir . '/' . $file, + 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) + )) + ) + { + $moved++; + $this->html_text_summary (lang('Moved %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not move %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); + } + } + + if ($moved) + { + $this->html_break (2); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index?path='.$todir, lang('Go to %1', $todir)); + } + + $this->html_break (2); + $this->html_link_back (); +} + +### +# Handle Copying of Files and Directories +### + +elseif ($copy) +{ + while (list ($num, $file) = each ($fileman)) + { + if ($this->bo->vfs->cp (array ( + 'from' => $file, + 'to' => $todir . '/' . $file, + 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) + )) + ) + { + $copied++; + $this->html_text_summary (lang('Copied %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not copy %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); + } +} + +if ($copied) +{ + $this->html_break (2); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$todir, lang('Go to %1', $todir)); +} + +$this->html_break (2); +$this->html_link_back (); + } + + ### + # Handle Deleting Files and Directories + ### + + elseif ($delete) + { + for ($i = 0; $i != $numoffiles; $i++) + { + if ($fileman[$i]) + { + if ($this->bo->vfs->delete (array ('string' => $fileman[$i]))) + { + $this->html_text_summary (lang('Deleted %1', $disppath.'/'.$fileman[$i]), $fileinfo['size']); + } + else + { + $GLOBALS['phpgw']->common->error_list (array (lang('Could not delete %1', $disppath.'/'.$fileman[$i]))); + } + } + } + + $this->html_break (2); + $this->html_link_back (); + } + + elseif ($newdir && $createdir) + { + if ($this->bo->badchar = $this->bo->bad_chars ($createdir, True, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array ($this->bo->html_encode (lang('Directory names cannot contain "%1"', $badchar), 1))); + $this->html_break (2); + $this->html_link_back (); + $this->html_page_close (); + } + + if ($createdir[strlen($createdir)-1] == ' ' || $createdir[0] == ' ') + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot create directory because it begins or ends in a space'))); + $this->html_break (2); + $this->html_link_back (); + $this->html_page_close (); + } + + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $path . '/' . $createdir, + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + + $fileinfo = $ls_array[0]; + + if ($fileinfo['name']) + { + if ($fileinfo['mime_type'] != 'Directory') + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('%1 already exists as a file', $fileinfo['name']))); + $this->html_break (2); + $this->html_link_back (); + $this->html_page_close (); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 already exists', $fileinfo['name']))); + $this->html_break (2); + $this->html_link_back (); + $this->html_page_close (); + } + } + else + { + if ($this->bo->vfs->mkdir (array ('string' => $createdir))) + { + $this->html_text_summary (lang('Created directory %1', $disppath.'/'.$createdir)); + $this->html_break (2); + $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$disppath.'/'.$createdir, lang('Go to %1', $disppath.'/'.$createdir)); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create %1', $disppath.'/'.$createdir))); + } + } + + $this->html_break (2); + $this->html_link_back (); + } + + $this->html_page_close (); + } + + function html_form_begin ($action,$args, $method = 'post', $enctype = NULL, $string = HTML_FORM_BEGIN_STRING, $return = 0) + { + $action = $this->bo->string_encode ($action, 1); + $action = SEP . $action; + //FIXME + $text = 'action="'.$this->html_link ($action, $args,NULL, 1, 0, 1).'"'; + + if ($method == NULL) + { + $method = 'post'; + } + $text .= ' method="'.$method.'"'; + + if ($enctype != NULL && $enctype) + { + $text .= ' enctype="'.$enctype.'"'; + } + + $rstring = '

'; + return ($this->bo->eor ($rstring, $return)); + } + + function html_form_input ($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = HTML_FORM_INPUT_STRING, $return = 0) + { + $text = ' '; + if ($type != NULL && $type) + { + if ($type == 'checkbox') + { + $value = $this->bo->string_encode ($value, 1); + } + $text .= 'type="'.$type.'" '; + } + if ($name != NULL && $name) + { + $text .= 'name="'.$name.'" '; + } + if ($value != NULL && $value) + { + $text .= 'value="'.$value.'" '; + } + if (is_int ($maxlength) && $maxlength >= 0) + { + $text .= 'maxlength="'.$maxlength.'" '; + } + if (is_int ($size) && $size >= 0) + { + $text .= 'size="'.$size.'" '; + } + if ($checked != NULL && $checked) + { + $text .= 'checked '; + } + + $rstring = ''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_form_textarea ($name = NULL, $rows = NULL, $cols = NULL, $value = NULL, $string = HTML_FORM_TEXTAREA_STRING, $return = 0) + { + $text =' '; + if ($name != NULL && $name) + { + $text .= 'name="'.$name.'" '; + } + if (is_int ($rows) && $rows >= 0) + { + $text .= 'rows="'.$rows.'" '; + } + if (is_int ($cols) && $cols >= 0) + { + $text .= 'cols="'.$cols.'" '; + } + $rstring = ''.$value.''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_form_select_begin ($name = NULL, $return = 0) + { + $text = ' '; + if ($name != NULL && $name) + { + $text .= 'name="'.$name.'" '; + } + $rstring = ''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_form_select_end ($return = 0) + { + $rstring = ''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_form_option ($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) + { + $text = ' '; + if ($value != NULL && $value) + { + $text .= ' value="'.$value.'" '; + } + if ($selected != NULL && $selected) + { + $text .= ' selected'; + } + $rstring = ''.$displayed.''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_form_end ($return = 0) + { + $rstring = ''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_nbsp ($times = 1, $return = 0) + { + if ($times == NULL) + { + $times = 1; + } + for ($i = 0; $i != $times; $i++) + { + if ($return) + { + $rstring .= ' '; + } + else + { + echo ' '; + } + } + if ($return) + { + return ($rstring); + } + } + + function html ($string, $times = 1, $return = 0) + { + for ($i = 0; $i != $times; $i++) + { + if ($return) + { + $rstring .= $string; + } + else + { + echo $string; + } + } + if ($return) + { + return ($rstring); + } + } + + function html_break ($break, $string = '', $return = 0) + { + switch($break) + { + case 1: + $break_str = '
'; + break; + case 2: + $break_str = '

'; + break; + case 5: + $break_str = '


'; + break; + } + return ($this->bo->eor ($break_str . $string, $return)); + } + + function html_page_begin ($title = NULL, $return = 0) + { + // $rstring = HTML_PAGE_BEGIN_BEFORE_TITLE . $title . HTML_PAGE_BEGIN_AFTER_TITLE; + return ($this->bo->eor ($rstring, $return)); + } + + function html_page_body_begin ($bgcolor = HTML_PAGE_BODY_COLOR, $background = NULL, $text = NULL, $link = NULL, $vlink = NULL, $alink = NULL, $string = HTML_PAGE_BODY_STRING, $return = 0) + { + $text_out = ' '; + if ($bgcolor != NULL && $bgcolor) + { + $text_out .= 'bgcolor="'.$bgcolor.'" '; + } + if ($background != NULL && $background) + { + $text_out .= 'background="'.$background.'" '; + } + if ($text != NULL && $text) + { + $text_out .= 'text="'.$text.'" '; + } + if ($link != NULL && $link) + { + $text_out .= 'link="'.$link.'" '; + } + if ($vlink != NULL && $vlink) + { + $text_out .= 'vlink="'.$vlink.'" '; + } + if ($alink != NULL && $alink) + { + $text_out .= 'alink="'.$alink.'" '; + } + // $rstring = ''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_page_body_end ($return = 0) + { + // $rstring = ''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_page_end ($return = 0) + { + // $rstring = ''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_page_close () + { + // html_page_body_end (); + // html_page_end (); + $GLOBALS['phpgw']->common->phpgw_footer (); + $GLOBALS['phpgw']->common->phpgw_exit (); + } + function html_text_bold ($text = NULL, $return = 0, $lang = 0) + { + if ($lang) + { + $text = $this->bo->translate ($text); + } + $rstring = ''.$text.''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_text_underline ($text = NULL, $return = 0, $lang = 0) + { + if ($lang) + { + $text = $this->bo->translate ($text); + } + $rstring = ''.$text.''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_text_italic ($text = NULL, $return = 0, $lang = 0) + { + if ($lang) + { + $text = $this->bo->translate ($text); + } + $rstring = ''.$text.''; + return ($this->bo->eor ($rstring, $return)); + } + + function html_text_summary ($text = NULL, $size = NULL, $return = 0, $lang = 0) + { + if ($lang) + { + $text = $this->bo->translate ($text); + } + $rstring = $this->html_break (1, NULL, $return); + $rstring .= $this->html_text_bold ($text, $return); + $rstring .= $this->html_nbsp (3, $return); + if ($size != NULL && $size >= 0) + $rstring .= $this->bo->borkb ($size, 1, $return); + + $rstring = $this->bo->html_encode ($rstring, 1); + + if ($return) + { + return ($rstring); + } + } + + function html_text_summary_error ($text = NULL, $text2 = NULL, $size = NULL, $return = 0, $lang = 0) + { + if ($lang) + { + $text = $this->bo->translate ($lang); + } + $rstring = $this->html_text_error ($text, 1, $return); + + if (($text2 != NULL && $text2) || ($size != NULL && $size)) + { + $rstring .= $this->html_nbsp (3, $return); + } + if ($text2 != NULL && $text2) + { + $rstring .= $this->html_text_error ($text2, NULL, $return); + } + if ($size != NULL && $size >= 0) + { + $rstring .= $this->bo->borkb ($size, 1, $return); + } + + if ($return) + { + return ($rstring); + } + } + + function html_font_set ($size = NULL, $color = NULL, $family = NULL, $return = 0) + { + if ($size != NULL && $size) + $size = "size=$size"; + if ($color != NULL && $color) + $color = "color=$color"; + if ($family != NULL && $family) + $family = "family=$family"; + + $rstring = ""; + return ($this->bo->eor ($rstring, $return)); + } + + function html_font_end ($return = 0) + { + $rstring = ""; + return ($this->bo->eor ($rstring, $return)); + } + + function html_text_error ($errorwas = NULL, $break = 1, $return = 0) + { + if ($break) + $rstring .= $this->html_break (1, NULL, 1); + + $rstring .= $this->html_font_set (NULL, HTML_TEXT_ERROR_COLOR, NULL, 1); + $rstring .= $this->html_text_bold ($this->html_text_italic ($errorwas, 1), 1); + $rstring .= $this->html_font_end (1); + return ($this->bo->eor ($rstring, $return)); + } + + function html_page_error ($errorwas = NULL, $title = "Error", $return = 0) + { + $rstring = $this->html_page_begin ($title, $return); + $rstring .= $this->html_page_body_begin (HTML_PAGE_BODY_COLOR, $return); + $rstring .= $this->html_break (2, NULL, $return); + $rstring .= $this->html_text_error ($errorwas, $return); + $rstring .= $this->html_page_body_end ($return); + $rstring .= $this->html_page_end ($return); + if (!$return) + $this->html_page_close (); + else + return ($rstring); + } + + function html_link ($href = NULL, $args = NULL ,$text = NULL, $return = 0, $encode = 1, $linkonly = 0, $target = NULL) + { + if ($encode) + $href = $this->bo->string_encode ($href, 1); + + //echo $encode; + + ### + # This decodes / back to normal + ### + $href = preg_replace ("/%2F/", "/", $href); + $text = trim ($text); + + /* Auto-detect and don't disturb absolute links */ + if (!preg_match ("|^http(.{0,1})://|", $href)) + { + //Only add an extra / if there isn't already one there + + // die(SEP); + if (!($href[0] == SEP)) + { + $href = SEP . $href; + } + + /* $phpgw->link requires that the extra vars be passed separately */ + // $link_parts = explode ("?", $href); + $address = $GLOBALS['phpgw']->link ($href, $args); + } + else + { + $address = $href; + } + + /* If $linkonly is set, don't add any HTML */ + if ($linkonly) + { + $rstring = $address; + } + else + { + if ($target) + { + $target = 'target='.$target; + } + + $rstring = ''.$text.''; + } + + return ($this->bo->eor ($rstring, $return)); + } + + function html_link_back ($return = 0) + { + global $path; + + $rstring .= $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path, HTML_TEXT_NAVIGATION_BACK_TO_USER, 1); + + return ($this->bo->eor ($rstring, $return)); + } + + function html_table_begin ($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = HTML_TABLE_BEGIN_STRING, $return = 0) + { + if ($width != NULL && $width) + $width = "width=$width"; + if (is_int ($border) && $border >= 0) + $border = "border=$border"; + if (is_int ($cellspacing) && $cellspacing >= 0) + $cellspacing = "cellspacing=$cellspacing"; + if (is_int ($cellpadding) && $cellpadding >= 0) + $cellpadding = "cellpadding=$cellpadding"; + if ($rules != NULL && $rules) + $rules = "rules=$rules"; + + $rstring = ""; + return ($this->bo->eor ($rstring, $return)); + } + + function html_link_email ($address = NULL, $text = NULL, $return = 0, $encode = 1) + { + if ($encode) + $href = $this->bo->string_encode ($href, 1); + + $rstring = "$text"; + return ($this->bo->eor ($rstring, $return)); + } + + function html_table_end ($return = 0) + { + $rstring = "
"; + return ($this->bo->eor ($rstring, $return)); + } + + function html_table_row_begin ($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = HTML_TABLE_ROW_BEGIN_STRING, $return = 0) + { + if ($align != NULL && $align) + $align = "align=$align"; + if ($halign != NULL && $halign) + $halign = "halign=$halign"; + if ($valign != NULL && $valign) + $valign = "valign=$valign"; + if ($bgcolor != NULL && $bgcolor) + $bgcolor = "bgcolor=$bgcolor"; + $rstring = ""; + return ($this->bo->eor ($rstring, $return)); + } + + function html_table_row_end ($return = 0) + { + $rstring = ""; + return ($this->bo->eor ($rstring, $return)); + } + + function html_table_col_begin ($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = HTML_TABLE_COL_BEGIN_STRING, $return = 0) + { + if ($align != NULL && $align) + $align = "align=$align"; + if ($halign != NULL && $halign) + $halign = "halign=$halign"; + if ($valign != NULL && $valign) + $valign = "valign=$valign"; + if (is_int ($rowspan) && $rowspan >= 0) + $rowspan = "rowspan=$rowspan"; + if (is_int ($colspan) && $colspan >= 0) + $colspan = "colspan=$colspan"; + + $rstring = ""; + return ($this->bo->eor ($rstring, $return)); + } + + function html_table_col_end ($return = 0) + { + $rstring = ""; + return ($this->bo->eor ($rstring, $return)); + } + + + function html_text_header ($size = 1, $string = NULL, $return = 0, $lang = 0) + { + $rstring = "$string"; + return ($this->bo->eor ($rstring, $return)); + } + + function html_align ($align = NULL, $string = HTML_ALIGN_MAIN_STRING, $return = 0) + { + $rstring = "

"; + return ($this->bo->eor ($rstring, $return)); + } + + function html_image ($src = NULL, $alt = NULL, $align = NULL, $border = NULL, $string = HTML_IMAGE_MAIN_STRING, $return = 0) + { + if ($src != NULL && $src) + $src = "src=$src"; + if ($alt != NULL && $alt) + $alt = "alt=\"$alt\""; + if ($align != NULL && $align) + $align = "align=$align"; + if (is_int ($border) && $border >= 0) + $border = "border=$border"; + $rstring = ""; + return ($this->bo->eor ($rstring, $return)); + } + + function html_help_link ($help_name = NULL, $text = "[?]", $target = "_new", $return = 0) + { + global $settings; + global $appname; + + if (!$settings["show_help"]) + { + return 0; + } + + $rstring = $this->html_link ('index.php','menuaction=filemanager.uifilemanager.index&op=help&help_name=$help_name', $text, True, 1, 0, $target); + + return ($this->bo->eor ($rstring, $return)); + } + + + } + diff --git a/filemanager/index.php b/filemanager/index.php index c1f31e932a..307dd654ac 100755 --- a/filemanager/index.php +++ b/filemanager/index.php @@ -1,172 +1,198 @@ array ('op' => ''), - 'path' => array ('path' => ''), - 'file' => array ('file' => ''), - 'sortby' => array ('sortby' => ''), - 'fileman' => array ('fileman' => ''), - 'messages' => array ('messages' => ''), - 'help_name' => array ('help_name' => ''), - 'renamefiles' => array ('renamefiles' => ''), - 'comment_files' => array ('comment_files' => ''), - 'show_upload_boxes' => array ('show_upload_boxes' => '') -); -reset ($to_decode); -while (list ($var, $conditions) = each ($to_decode)) -{ - while (list ($condvar, $condvalue) = each ($conditions)) + eGroupWare - http://www.egroupware.org + + */ + + $Experiment_New_Code=false; + + if($Experiment_New_Code) + { + $phpgw_flags = Array( + 'currentapp' => 'filemanager', + 'noheader' => True, + 'nonavbar' => True, + 'noappheader' => True, + 'noappfooter' => True, + 'nofooter' => True + ); + + $GLOBALS['phpgw_info']['flags'] = $phpgw_flags; + + include('../header.inc.php'); + + Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index')); + $GLOBALS['phpgw']->common->phpgw_exit(); + } + + ### + # DEV NOTE: + # + # index.php is depreciated by the inc/class.xxphpwebhosting.inc.php files. + # index.php is still used in the 0.9.14 release, but all future changes should be + # made to the inc/class.xxphpwebhosting.inc.php files (3-tiered). This includes using templates. + ### + + ### + # Enable this to display some debugging info + ### + + $phpwh_debug = 0; + + @reset ($GLOBALS['HTTP_POST_VARS']); + while (list ($name,) = @each ($GLOBALS['HTTP_POST_VARS'])) { - if (isset ($$condvar) && ($condvar == $var || $$condvar == $condvalue)) + $$name = $GLOBALS['HTTP_POST_VARS'][$name]; + } + + @reset ($GLOBALS['HTTP_GET_VARS']); + while (list ($name,) = @each ($GLOBALS['HTTP_GET_VARS'])) + { + $$name = $GLOBALS['HTTP_GET_VARS'][$name]; + } + + $to_decode = array + ( + /* + Decode + 'var' when 'avar' == 'value' + or + 'var' when 'var' is set + */ + 'op' => array ('op' => ''), + 'path' => array ('path' => ''), + 'file' => array ('file' => ''), + 'sortby' => array ('sortby' => ''), + 'fileman' => array ('fileman' => ''), + 'messages' => array ('messages' => ''), + 'help_name' => array ('help_name' => ''), + 'renamefiles' => array ('renamefiles' => ''), + 'comment_files' => array ('comment_files' => ''), + 'show_upload_boxes' => array ('show_upload_boxes' => '') + ); + + reset ($to_decode); + while (list ($var, $conditions) = each ($to_decode)) + { + while (list ($condvar, $condvalue) = each ($conditions)) { - if (is_array ($$var)) + if (isset ($$condvar) && ($condvar == $var || $$condvar == $condvalue)) { - $temp = array (); - //some fixes in this section were supplied by Michael Totschnig - while (list ($varkey, $varvalue) = each ($$var)) + if (is_array ($$var)) { - if (is_int ($varkey)) + $temp = array (); + //some fixes in this section were supplied by Michael Totschnig + while (list ($varkey, $varvalue) = each ($$var)) { - $temp[$varkey] = stripslashes (base64_decode(urldecode(($varvalue)))); - } - else - { - $temp[stripslashes (base64_decode(urldecode(($varkey))))] = $varvalue; + if (is_int ($varkey)) + { + $temp[$varkey] = stripslashes (base64_decode(urldecode(($varvalue)))); + } + else + { + $temp[stripslashes (base64_decode(urldecode(($varkey))))] = $varvalue; + } } + $$var = $temp; + } + elseif (isset ($$var)) + { + $$var = stripslashes (base64_decode(urldecode ($$var))); } - $$var = $temp; - } - elseif (isset ($$var)) - { - $$var = stripslashes (base64_decode(urldecode ($$var))); } } } -} -if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == 'view' && $file) || ($op == 'history' && $file) || ($op == 'help' && $help_name)) -{ - $noheader = True; - $nofooter = True; -} - -$GLOBALS['phpgw_info']['flags'] = array -( - 'currentapp' => 'filemanager', - 'noheader' => $noheader, - 'nofooter' => $nofooter, - 'noappheader' => False, - 'enable_vfs_class' => True, - 'enable_browser_class' => True -); - -include ('../header.inc.php'); - -if ($execute && $command_line) -{ - if ($result = $GLOBALS['phpgw']->vfs->command_line (array ('command_line' => stripslashes ($command_line)))) + if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == 'view' && $file) || ($op == 'history' && $file) || ($op == 'help' && $help_name)) { - $messages = html_text_bold (lang('Command sucessfully run'),1); - if ($result != 1 && strlen ($result) > 0) + $noheader = True; + $nofooter = True; + } + + $GLOBALS['phpgw_info']['flags'] = array + ( + 'currentapp' => 'filemanager', + 'noheader' => $noheader, + 'nofooter' => $nofooter, + 'noappheader' => False, + 'enable_vfs_class' => True, + 'enable_browser_class' => True + ); + + include ('../header.inc.php'); + + if ($execute && $command_line) + { + if ($result = $GLOBALS['phpgw']->vfs->command_line (array ('command_line' => stripslashes ($command_line)))) { - $messages .= html_break (2, NULL, 1) . $result; + $messages = html_text_bold (lang('Command sucessfully run'),1); + if ($result != 1 && strlen ($result) > 0) + { + $messages .= html_break (2, NULL, 1) . $result; + } } + else + { + $messages = $GLOBALS['phpgw']->common->error_list (array (lang('Error running command'))); + } + } + + ### + # Page to process users + # Code is fairly hackish at the beginning, but it gets better + # Highly suggest turning wrapping off due to long SQL queries + ### + + ### + # Some hacks to set and display directory paths correctly + ### + + if ($go) + { + $path = $todir; + } + + if (!$path) + { + $path = $GLOBALS['phpgw']->vfs->pwd (); + + if (!$path || $GLOBALS['phpgw']->vfs->pwd (array ('full' => False)) == '') + { + $path = $GLOBALS['homedir']; + } + } + + $GLOBALS['phpgw']->vfs->cd (array ('string' => False, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); + $GLOBALS['phpgw']->vfs->cd (array ('string' => $path, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); + + $pwd = $GLOBALS['phpgw']->vfs->pwd (); + + if (!$cwd = substr ($path, strlen ($GLOBALS['homedir']) + 1)) + { + $cwd = '/'; } else { - $messages = $GLOBALS['phpgw']->common->error_list (array (lang('Error running command'))); + $cwd = substr ($pwd, strrpos ($pwd, '/') + 1); } -} -### -# Page to process users -# Code is fairly hackish at the beginning, but it gets better -# Highly suggest turning wrapping off due to long SQL queries -### + $disppath = $path; -### -# Some hacks to set and display directory paths correctly -### - -if ($go) -{ - $path = $todir; -} - -if (!$path) -{ - $path = $GLOBALS['phpgw']->vfs->pwd (); - - if (!$path || $GLOBALS['phpgw']->vfs->pwd (array ('full' => False)) == '') - { - $path = $GLOBALS['homedir']; - } -} - -$GLOBALS['phpgw']->vfs->cd (array ('string' => False, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); -$GLOBALS['phpgw']->vfs->cd (array ('string' => $path, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); - -$pwd = $GLOBALS['phpgw']->vfs->pwd (); - -if (!$cwd = substr ($path, strlen ($GLOBALS['homedir']) + 1)) -{ - $cwd = '/'; -} -else -{ - $cwd = substr ($pwd, strrpos ($pwd, '/') + 1); -} - -$disppath = $path; - -/* This just prevents // in some cases */ -if ($path == '/') + /* This just prevents // in some cases */ + if ($path == '/') $dispsep = ''; -else + else $dispsep = '/'; -if (!($lesspath = substr ($path, 0, strrpos ($path, '/')))) + if (!($lesspath = substr ($path, 0, strrpos ($path, '/')))) $lesspath = '/'; -$now = date ('Y-m-d'); + $now = date ('Y-m-d'); -if ($phpwh_debug) -{ - echo "PHPWebHosting debug:
+ if ($phpwh_debug) + { + echo "PHPWebHosting debug:
path: $path
disppath: $disppath
cwd: $cwd
@@ -177,21 +203,21 @@ if ($phpwh_debug) fake getabsolutepath: " . $GLOBALS['phpgw']->vfs->getabsolutepath (array ('target' => False)) . "
appsession: " . $GLOBALS['phpgw']->session->appsession ('vfs','') . "
pwd: " . $GLOBALS['phpgw']->vfs->pwd () . "
"; -} + } -### -# Get their readable groups to be used throughout the script -### + ### + # Get their readable groups to be used throughout the script + ### -$groups = array (); + $groups = array (); -$groups = $GLOBALS['phpgw']->accounts->get_list ('groups'); + $groups = $GLOBALS['phpgw']->accounts->get_list ('groups'); -$readable_groups = array (); + $readable_groups = array (); -while (list ($num, $account) = each ($groups)) -{ - if ($GLOBALS['phpgw']->vfs->acl_check (array ( + while (list ($num, $account) = each ($groups)) + { + if ($GLOBALS['phpgw']->vfs->acl_check (array ( 'owner_id' => $account['account_id'], 'operation' => PHPGW_ACL_READ )) @@ -226,13 +252,13 @@ else } if ($path != $GLOBALS['homedir'] - && $path != $GLOBALS['fakebase'] - && $path != '/' - && !$GLOBALS['phpgw']->vfs->acl_check (array ( - 'string' => $path, - 'relatives' => array (RELATIVE_NONE), - 'operation' => PHPGW_ACL_READ - )) +&& $path != $GLOBALS['fakebase'] +&& $path != '/' +&& !$GLOBALS['phpgw']->vfs->acl_check (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'operation' => PHPGW_ACL_READ +)) ) { echo $GLOBALS['phpgw']->common->error_list (array (lang('You do not have access to %1', $path))); @@ -250,10 +276,10 @@ $GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLO ### if (($path == $GLOBALS['homedir']) - && !$GLOBALS['phpgw']->vfs->file_exists (array ( - 'string' => $GLOBALS['homedir'], - 'relatives' => array (RELATIVE_NONE) - )) +&& !$GLOBALS['phpgw']->vfs->file_exists (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE) +)) ) { $GLOBALS['phpgw']->vfs->override_acl = 1; @@ -296,10 +322,10 @@ if ($update || rand (0, 19) == 4) ### if ($GLOBALS['phpgw']->vfs->acl_check (array ( - 'string' => $path, - 'relatives' => array (RELATIVE_NONE), - 'operation' => PHPGW_ACL_ADD - )) + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'operation' => PHPGW_ACL_ADD +)) ) { $can_add = True; @@ -342,93 +368,93 @@ if ($path == $GLOBALS['fakebase']) } $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $GLOBALS['homedir'], + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) +); +$files_array[] = $ls_array[0]; +$numoffiles++; +// $files_array = $ls_array; +// $numoffiles = count($ls_array); + +reset ($readable_groups); +while (list ($num, $group_array) = each ($readable_groups)) +{ + ### + # If the group doesn't have access to this app, we don't show it + ### + + if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + { + continue; + } + + if (!$GLOBALS['phpgw']->vfs->file_exists (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE) + )) +) +{ + $GLOBALS['phpgw']->vfs->override_acl = 1; + $GLOBALS['phpgw']->vfs->mkdir (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE) + ) +); +$GLOBALS['phpgw']->vfs->override_acl = 0; + +$GLOBALS['phpgw']->vfs->set_attributes (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE), + 'attributes' => array ( + 'owner_id' => $group_array['account_id'], + 'createdby_id' => $group_array['account_id'] + ) +) + ); + } + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], 'relatives' => array (RELATIVE_NONE), 'checksubdirs' => False, 'nofiles' => True ) ); + $files_array[] = $ls_array[0]; + $numoffiles++; -// $files_array = $ls_array; -// $numoffiles = count($ls_array); - - reset ($readable_groups); - while (list ($num, $group_array) = each ($readable_groups)) - { - ### - # If the group doesn't have access to this app, we don't show it - ### - - if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) - { - continue; - } - - if (!$GLOBALS['phpgw']->vfs->file_exists (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE) - )) - ) - { - $GLOBALS['phpgw']->vfs->override_acl = 1; - $GLOBALS['phpgw']->vfs->mkdir (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE) - ) - ); - $GLOBALS['phpgw']->vfs->override_acl = 0; - - $GLOBALS['phpgw']->vfs->set_attributes (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE), - 'attributes' => array ( - 'owner_id' => $group_array['account_id'], - 'createdby_id' => $group_array['account_id'] - ) - ) - ); - } - - $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => True - ) - ); - - $files_array[] = $ls_array[0]; - - $numoffiles++; - } +} } else { $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $path, - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => False, - 'orderby' => $sortby - ) - ); + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => False, + 'orderby' => $sortby + ) +); +if ($phpwh_debug) +{ + echo '# of files found in "'.$path.'" : '.count($ls_array).'
'."\n"; +} + +while (list ($num, $file_array) = each ($ls_array)) +{ + $numoffiles++; + $files_array[] = $file_array; if ($phpwh_debug) { - echo '# of files found in "'.$path.'" : '.count($ls_array).'
'."\n"; - } - - while (list ($num, $file_array) = each ($ls_array)) - { - $numoffiles++; - $files_array[] = $file_array; - if ($phpwh_debug) - { - echo 'Filename: '.$file_array['name'].'
'."\n"; - } + echo 'Filename: '.$file_array['name'].'
'."\n"; } } +} if (!is_array ($files_array)) { @@ -454,27 +480,27 @@ if ($download) if ($op == 'view' && $file) { $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $path.'/'.$file, - 'relatives' => array (RELATIVE_ALL), - 'checksubdirs' => False, - 'nofiles' => True - ) - ); + 'string' => $path.'/'.$file, + 'relatives' => array (RELATIVE_ALL), + 'checksubdirs' => False, + 'nofiles' => True + ) +); - if ($ls_array[0]['mime_type']) - { - $mime_type = $ls_array[0]['mime_type']; - } - elseif ($GLOBALS['settings']['viewtextplain']) - { - $mime_type = 'text/plain'; - } +if ($ls_array[0]['mime_type']) +{ + $mime_type = $ls_array[0]['mime_type']; +} +elseif ($GLOBALS['settings']['viewtextplain']) +{ + $mime_type = 'text/plain'; +} - header('Content-type: ' . $mime_type); - echo $GLOBALS['phpgw']->vfs->read (array ( - 'string' => $path.'/'.$file, - 'relatives' => array (RELATIVE_NONE) - ) +header('Content-type: ' . $mime_type); +echo $GLOBALS['phpgw']->vfs->read (array ( + 'string' => $path.'/'.$file, + 'relatives' => array (RELATIVE_NONE) +) ); $GLOBALS['phpgw']->common->phpgw_exit (); } @@ -482,54 +508,54 @@ if ($op == 'view' && $file) if ($op == 'history' && $file) { $journal_array = $GLOBALS['phpgw']->vfs->get_journal (array ( - 'string' => $file, - 'relatives' => array (RELATIVE_ALL) - ) - ); + 'string' => $file, + 'relatives' => array (RELATIVE_ALL) + ) +); - if (is_array ($journal_array)) +if (is_array ($journal_array)) +{ + html_table_begin (); + html_table_row_begin (); + html_table_col_begin (); + html_text_bold (lang('Date')); + html_table_col_end (); + html_table_col_begin (); + html_text_bold (lang('Version')); + html_table_col_end (); + html_table_col_begin (); + html_text_bold (lang('Who')); + html_table_col_end (); + html_table_col_begin (); + html_text_bold (lang('Operation')); + html_table_col_end (); + html_table_row_end (); + + while (list ($num, $journal_entry) = each ($journal_array)) { - html_table_begin (); html_table_row_begin (); html_table_col_begin (); - html_text_bold (lang('Date')); + html_text ($journal_entry['created'] . html_nbsp (3, 1)); html_table_col_end (); html_table_col_begin (); - html_text_bold (lang('Version')); + html_text ($journal_entry['version'] . html_nbsp (3, 1)); html_table_col_end (); html_table_col_begin (); - html_text_bold (lang('Who')); + html_text ($GLOBALS['phpgw']->accounts->id2name ($journal_entry['owner_id']) . html_nbsp (3, 1)); html_table_col_end (); html_table_col_begin (); - html_text_bold (lang('Operation')); + html_text ($journal_entry['comment']); html_table_col_end (); - html_table_row_end (); - - while (list ($num, $journal_entry) = each ($journal_array)) - { - html_table_row_begin (); - html_table_col_begin (); - html_text ($journal_entry['created'] . html_nbsp (3, 1)); - html_table_col_end (); - html_table_col_begin (); - html_text ($journal_entry['version'] . html_nbsp (3, 1)); - html_table_col_end (); - html_table_col_begin (); - html_text ($GLOBALS['phpgw']->accounts->id2name ($journal_entry['owner_id']) . html_nbsp (3, 1)); - html_table_col_end (); - html_table_col_begin (); - html_text ($journal_entry['comment']); - html_table_col_end (); - } - - html_table_end (); - html_page_close (); - } - else - { - html_text_bold (lang('No version history for this file/directory')); } + html_table_end (); + html_page_close (); +} +else +{ + html_text_bold (lang('No version history for this file/directory')); +} + } if ($newfile && $createfile) @@ -543,21 +569,21 @@ if ($newfile && $createfile) } if ($GLOBALS['phpgw']->vfs->file_exists (array ( - 'string' => $createfile, - 'relatives' => array (RELATIVE_ALL) - )) - ) - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 already exists. Please edit it or delete it first.', $createfile))); - html_break (2); - html_link_back (); - html_page_close (); - } + 'string' => $createfile, + 'relatives' => array (RELATIVE_ALL) + )) +) +{ + echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 already exists. Please edit it or delete it first.', $createfile))); + html_break (2); + html_link_back (); + html_page_close (); +} - if ($GLOBALS['phpgw']->vfs->touch (array ( - 'string' => $createfile, - 'relatives' => array (RELATIVE_ALL) - )) +if ($GLOBALS['phpgw']->vfs->touch (array ( + 'string' => $createfile, + 'relatives' => array (RELATIVE_ALL) +)) ) { $fileman = array (); @@ -576,7 +602,7 @@ if ($op == 'help' && $help_name) while (list ($num, $help_array) = each ($help_info)) { if ($help_array[0] != $help_name) - continue; + continue; $help_array[1] = preg_replace ("/\[(.*)\|(.*)\]/Ue", "html_help_link ('\\1', '\\2', False, True)", $help_array[1]); $help_array[1] = preg_replace ("/\[(.*)\]/Ue", "html_help_link ('\\1', '\\1', False, True)", $help_array[1]); @@ -646,42 +672,42 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed html_table_begin ('100%'); html_table_row_begin (); html_table_col_begin ('left'); - + if ($path != '/') { - html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, html_image ('images/folder-up.gif', lang('Up'), 'left', 0, NULL, 1)); + html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, html_image ('images/folder-up.png', lang('Up'), 'left', 0, NULL, 1)); html_help_link ('up'); } - + html_table_col_end (); html_table_col_begin ('center'); - + if ($cwd) { if ($path == $GLOBALS['homedir']) { - html_image ('images/folder-home.gif', lang('Folder'), 'center'); + html_image ('images/folder-home.png', lang('Folder'), 'center'); } else { - html_image ('images/folder.gif', lang('Folder'), 'center'); + html_image ('images/folder.png', lang('Folder'), 'center'); } } else { - html_image ('images/folder-home.gif', lang('Home')); + html_image ('images/folder-home.png', lang('Home')); } - + html_font_set (4, HTML_TABLE_FILES_HEADER_TEXT_COLOR); html_text_bold ($disppath); html_font_end (); html_help_link ('directory_name'); html_table_col_end (); html_table_col_begin ('right'); - + if ($path != $GLOBALS['homedir']) { - html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], html_image ('images/folder-home.gif', lang('Home'), 'right', 0, NULL, 1)); + html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], html_image ('images/folder-home.png', lang('Home'), 'right', 0, NULL, 1)); html_help_link ('home'); } @@ -691,7 +717,7 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed html_table_col_end (); html_table_row_end (); html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR); - + ### # Start File Table Column Headers # Reads values from $file_attributes array and preferences @@ -726,7 +752,7 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed /* We can assume the next column is the name */ html_table_col_begin (); - html_image ('images/folder.gif', lang('Folder')); + html_image ('images/folder.png', lang('Folder')); html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, '..'); html_table_col_end (); @@ -819,7 +845,7 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed { if ($files['mime_type'] == 'Directory') { - html_image ('images/folder.gif', lang('Folder')); + html_image ('images/folder.png', lang('Folder')); } html_form_input ('text', 'renamefiles[' . base64_encode ($files['name']) . ']', $files['name'], 255); } @@ -827,7 +853,7 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed { if ($files['mime_type'] == 'Directory') { - html_image ('images/folder.gif', lang('Folder')); + html_image ('images/folder.png', lang('Folder')); html_link ($GLOBALS['appname'].'/index.php?path='.$path.$dispsep.$files['name'], $files['name']); } else @@ -878,260 +904,260 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed html_table_col_begin (); $size = $GLOBALS['phpgw']->vfs->get_size (array ( - 'string' => $files['directory'] . '/' . $files['name'], - 'relatives' => array (RELATIVE_NONE) - ) - ); + 'string' => $files['directory'] . '/' . $files['name'], + 'relatives' => array (RELATIVE_NONE) + ) + ); - borkb ($size); + borkb ($size); - html_table_col_end (); - } + html_table_col_end (); + } - ### - # Date created - ### - if ($GLOBALS['settings']['created']) + ### + # Date created + ### + if ($GLOBALS['settings']['created']) + { + html_table_col_begin (); + html_text ($files['created']); + html_table_col_end (); + } + + ### + # Date modified + ### + + if ($GLOBALS['settings']['modified']) + { + html_table_col_begin (); + if ($files['modified'] != '0000-00-00') { - html_table_col_begin (); - html_text ($files['created']); - html_table_col_end (); + html_text ($files['modified']); } + html_table_col_end (); + } - ### - # Date modified - ### + ### + # Owner name + ### - if ($GLOBALS['settings']['modified']) + if ($GLOBALS['settings']['owner']) + { + html_table_col_begin (); + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['owner_id'])); + html_table_col_end (); + } + + ### + # Creator name + ### + + if ($GLOBALS['settings']['createdby_id']) + { + html_table_col_begin (); + if ($files['createdby_id']) { - html_table_col_begin (); - if ($files['modified'] != '0000-00-00') - { - html_text ($files['modified']); - } - html_table_col_end (); + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['createdby_id'])); } + html_table_col_end (); + } - ### - # Owner name - ### + ### + # Modified by name + ### - if ($GLOBALS['settings']['owner']) + if ($GLOBALS['settings']['modifiedby_id']) + { + html_table_col_begin (); + if ($files['modifiedby_id']) { - html_table_col_begin (); - html_text ($GLOBALS['phpgw']->accounts->id2name ($files['owner_id'])); - html_table_col_end (); + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['modifiedby_id'])); } + html_table_col_end (); + } - ### - # Creator name - ### + ### + # Application + ### - if ($GLOBALS['settings']['createdby_id']) + if ($GLOBALS['settings']['app']) + { + html_table_col_begin (); + html_text ($files['app']); + html_table_col_end (); + } + + ### + # Comment + ### + + if ($GLOBALS['settings']['comment']) + { + html_table_col_begin (); + if ($edit_this_comment) { - html_table_col_begin (); - if ($files['createdby_id']) - { - html_text ($GLOBALS['phpgw']->accounts->id2name ($files['createdby_id'])); - } - html_table_col_end (); - } - - ### - # Modified by name - ### - - if ($GLOBALS['settings']['modifiedby_id']) - { - html_table_col_begin (); - if ($files['modifiedby_id']) - { - html_text ($GLOBALS['phpgw']->accounts->id2name ($files['modifiedby_id'])); - } - html_table_col_end (); - } - - ### - # Application - ### - - if ($GLOBALS['settings']['app']) - { - html_table_col_begin (); - html_text ($files['app']); - html_table_col_end (); - } - - ### - # Comment - ### - - if ($GLOBALS['settings']['comment']) - { - html_table_col_begin (); - if ($edit_this_comment) - { - html_form_input ('text', 'comment_files[' . base64_encode ($files['name']) . ']', html_encode ($files['comment'], 1), 255); - } - else - { - html_text ($files['comment']); - } - html_table_col_end (); - } - - ### - # Version - ### - - if ($GLOBALS['settings']['version']) - { - html_table_col_begin (); - html_link ($GLOBALS['appname'].'/index.php?op=history&file='.$files['name'].'&path='.$path, $files['version'], NULL, True, NULL, '_new'); - html_table_col_end (); - } - - ### - # Deleteable (currently not used) - ### - - if ($GLOBALS['settings']['deleteable']) - { - if ($files['deleteable'] == 'N') - { - html_table_col_begin (); - html_image ('images/locked.gif', lang('Locked')); - html_table_col_end (); - } - else - { - html_table_col_begin (); - html_table_col_end (); - } - } - - html_table_row_end (); - - if ($files['mime_type'] == 'Directory') - { - $usedspace += $fileinfo[0]; + html_form_input ('text', 'comment_files[' . base64_encode ($files['name']) . ']', html_encode ($files['comment'], 1), 255); } else { - $usedspace += $files['size']; + html_text ($files['comment']); + } + html_table_col_end (); + } + + ### + # Version + ### + + if ($GLOBALS['settings']['version']) + { + html_table_col_begin (); + html_link ($GLOBALS['appname'].'/index.php?op=history&file='.$files['name'].'&path='.$path, $files['version'], NULL, True, NULL, '_new'); + html_table_col_end (); + } + + ### + # Deleteable (currently not used) + ### + + if ($GLOBALS['settings']['deleteable']) + { + if ($files['deleteable'] == 'N') + { + html_table_col_begin (); + html_image ('images/locked.png', lang('Locked')); + html_table_col_end (); + } + else + { + html_table_col_begin (); + html_table_col_end (); } } - html_table_end (); - html_break (2); + html_table_row_end (); - if ($path != '/' && $path != $GLOBALS['fakebase']) + if ($files['mime_type'] == 'Directory') { - if (!$rename && !$edit_comments) - { - html_form_input ('submit', 'edit', lang('Edit')); - html_help_link ('edit'); - html_nbsp (3); - } - - if (!$edit_comments) - { - html_form_input ('submit', 'rename', lang('Rename')); - html_help_link ('rename'); - html_nbsp (3); - } - - if (!$rename && !$edit_comments) - { - html_form_input ('submit', 'delete', lang('Delete')); - html_help_link ('delete'); - html_nbsp (3); - } - - if (!$rename) - { - html_form_input ('submit', 'edit_comments', lang('Edit comments')); - html_help_link ('edit_comments'); - } + $usedspace += $fileinfo[0]; + } + else + { + $usedspace += $files['size']; } } - ### - # Display some inputs and info, but not when renaming or editing comments - ### + html_table_end (); + html_break (2); - if (!$rename && !$edit_comments) + if ($path != '/' && $path != $GLOBALS['fakebase']) { - ### - # Begin Copy to/Move to selection - ### - - html_break (1); - html_form_input ('submit', 'go', lang('Go to:')); - html_help_link ('go_to'); - - if ($path != '/' && $path != $GLOBALS['fakebase']) + if (!$rename && !$edit_comments) { - html_form_input ('submit', 'copy', lang('Copy to:')); - html_help_link ('copy_to'); - html_form_input ('submit', 'move', lang('Move to:')); - html_help_link ('move_to'); + html_form_input ('submit', 'edit', lang('Edit')); + html_help_link ('edit'); + html_nbsp (3); } - html_form_select_begin ('todir'); - - html_break (1); - - ### - # First we get the directories in their home directory - ### - - $dirs = array (); - $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); - - $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $GLOBALS['homedir'], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => True, - 'mime_type' => 'Directory' - ) - ); - - while (list ($num, $dir) = each ($ls_array)) + if (!$edit_comments) { - $dirs[] = $dir; + html_form_input ('submit', 'rename', lang('Rename')); + html_help_link ('rename'); + html_nbsp (3); } - - ### - # Then we get the directories in their readable groups' home directories - ### - - reset ($readable_groups); - while (list ($num, $group_array) = each ($readable_groups)) + if (!$rename && !$edit_comments) { - ### - # Don't list directories for groups that don't have access - ### + html_form_input ('submit', 'delete', lang('Delete')); + html_help_link ('delete'); + html_nbsp (3); + } - if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) - { - continue; - } + if (!$rename) + { + html_form_input ('submit', 'edit_comments', lang('Edit comments')); + html_help_link ('edit_comments'); + } + } +} - $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); +### +# Display some inputs and info, but not when renaming or editing comments +### - $ls_array = $phpgw->vfs->ls (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => True, - 'mime_type' => 'Directory' - ) - ); - while (list ($num, $dir) = each ($ls_array)) - { - $dirs[] = $dir; - } +if (!$rename && !$edit_comments) +{ + ### + # Begin Copy to/Move to selection + ### + + html_break (1); + html_form_input ('submit', 'go', lang('Go to:')); + html_help_link ('go_to'); + + if ($path != '/' && $path != $GLOBALS['fakebase']) + { + html_form_input ('submit', 'copy', lang('Copy to:')); + html_help_link ('copy_to'); + html_form_input ('submit', 'move', lang('Move to:')); + html_help_link ('move_to'); + } + + html_form_select_begin ('todir'); + + html_break (1); + + ### + # First we get the directories in their home directory + ### + + $dirs = array (); + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => True, + 'mime_type' => 'Directory' + ) +); + +while (list ($num, $dir) = each ($ls_array)) +{ + $dirs[] = $dir; +} + + +### +# Then we get the directories in their readable groups' home directories +### + +reset ($readable_groups); +while (list ($num, $group_array) = each ($readable_groups)) +{ + ### + # Don't list directories for groups that don't have access + ### + + if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + { + continue; + } + + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); + + $ls_array = $phpgw->vfs->ls (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => True, + 'mime_type' => 'Directory' + ) +); +while (list ($num, $dir) = each ($ls_array)) +{ + $dirs[] = $dir; +} } reset ($dirs); @@ -1141,7 +1167,7 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed { continue; } - + ### # So we don't display // ### @@ -1154,137 +1180,137 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed ### # No point in displaying the current directory, or a directory that doesn't exist ### - + if ((($dir['directory'] . $dir['name']) != $path) - && $GLOBALS['phpgw']->vfs->file_exists (array ( - 'string' => $dir['directory'] . $dir['name'], - 'relatives' => array (RELATIVE_NONE) - )) - ) - { - html_form_option ($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); - } - } - - html_form_select_end (); - html_help_link ('directory_list'); - - if ($path != '/' && $path != $GLOBALS['fakebase']) + && $GLOBALS['phpgw']->vfs->file_exists (array ( + 'string' => $dir['directory'] . $dir['name'], + 'relatives' => array (RELATIVE_NONE) + )) + ) { - html_break (1); - - html_form_input ('submit', 'download', lang('Download')); - html_help_link ('download'); - html_nbsp (3); - - if ($can_add) - { - html_form_input ('text', 'createdir', NULL, 255, 15); - html_form_input ('submit', 'newdir', lang('Create Folder')); - html_help_link ('create_folder'); - } + html_form_option ($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); } + } + html_form_select_end (); + html_help_link ('directory_list'); + + if ($path != '/' && $path != $GLOBALS['fakebase']) + { html_break (1); - html_form_input ('submit', 'update', lang('Update')); - html_help_link ('update'); - if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) - { - html_nbsp (3); - html_form_input ('text', 'createfile', NULL, 255, 15); - html_form_input ('submit', 'newfile', lang('Create File')); - html_help_link ('create_file'); - } - - if ($GLOBALS['settings']['show_command_line']) - { - html_break (2); - html_form_input ('text', 'command_line', NULL, NULL, 50); - html_help_link ('command_line'); - - html_break (1); - html_form_input ('submit', 'execute', lang('Execute')); - html_help_link ('execute'); - } - - html_form_end (); - - html_help_link ('file_stats'); - html_break (1); - html_text_bold (lang('Files').': '); - html_text ($numoffiles); + html_form_input ('submit', 'download', lang('Download')); + html_help_link ('download'); html_nbsp (3); - html_text_bold (lang('Used space').': '); - html_text (borkb ($usedspace, NULL, 1)); + if ($can_add) + { + html_form_input ('text', 'createdir', NULL, 255, 15); + html_form_input ('submit', 'newdir', lang('Create Folder')); + html_help_link ('create_folder'); + } + } + + html_break (1); + html_form_input ('submit', 'update', lang('Update')); + html_help_link ('update'); + + if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) + { html_nbsp (3); - - if ($path == $GLOBALS['homedir'] || $path == $GLOBALS['fakebase']) - { - html_text_bold (lang('Unused space').': '); - html_text (borkb ($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1)); + html_form_input ('text', 'createfile', NULL, 255, 15); + html_form_input ('submit', 'newfile', lang('Create File')); + html_help_link ('create_file'); + } - $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $path, - 'relatives' => array (RELATIVE_NONE) - ) - ); + if ($GLOBALS['settings']['show_command_line']) + { + html_break (2); + html_form_input ('text', 'command_line', NULL, NULL, 50); + html_help_link ('command_line'); - $i = count ($ls_array); + html_break (1); + html_form_input ('submit', 'execute', lang('Execute')); + html_help_link ('execute'); + } - html_break (2); - html_text_bold (lang('Total Files').': '); - html_text ($i); - } - - ### - # Show file upload boxes. Note the last argument to html (). Repeats $show_upload_boxes times - ### + html_form_end (); - if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) - { - html_break (2); - html_form_begin ($GLOBALS['appname'].'/index.php?op=upload&path='.$path, 'post', 'multipart/form-data'); - html_table_begin (); - html_table_row_begin ('center'); - html_table_col_begin (); - html_text_bold (lang('File')); - html_help_link ('upload_file'); - html_table_col_end (); - html_table_col_begin (); - html_text_bold (lang('Comment')); - html_help_link ('upload_comment'); - html_table_col_end (); - html_table_row_end (); + html_help_link ('file_stats'); + html_break (1); + html_text_bold (lang('Files').': '); + html_text ($numoffiles); + html_nbsp (3); - html_table_row_begin (); - html_table_col_begin (); - html_form_input ('hidden', 'show_upload_boxes', base64_encode ($show_upload_boxes)); - html (html_form_input ('file', 'upload_file[]', NULL, 255, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); - html_table_col_end (); - html_table_col_begin (); - html (html_form_input ('text', 'upload_comment[]', NULL, NULL, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); - html_table_col_end (); - html_table_row_end (); - html_table_end (); - html_form_input ('submit', 'upload_files', lang('Upload files')); - html_help_link ('upload_files'); - html_break (2); - html_text (lang('Show') . html_nbsp (1, True)); - html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=5', '5'); - html_nbsp (); - html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=10', '10'); - html_nbsp (); - html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=20', '20'); - html_nbsp (); - html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=50', '50'); - html_nbsp (); - html_text (lang('upload fields')); - html_nbsp (); - html_help_link ('show_upload_fields'); - html_form_end (); - } + html_text_bold (lang('Used space').': '); + html_text (borkb ($usedspace, NULL, 1)); + html_nbsp (3); + + if ($path == $GLOBALS['homedir'] || $path == $GLOBALS['fakebase']) + { + html_text_bold (lang('Unused space').': '); + html_text (borkb ($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1)); + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE) + ) + ); + + $i = count ($ls_array); + + html_break (2); + html_text_bold (lang('Total Files').': '); + html_text ($i); +} + +### +# Show file upload boxes. Note the last argument to html (). Repeats $show_upload_boxes times +### + +if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) +{ + html_break (2); + html_form_begin ($GLOBALS['appname'].'/index.php?op=upload&path='.$path, 'post', 'multipart/form-data'); + html_table_begin (); + html_table_row_begin ('center'); + html_table_col_begin (); + html_text_bold (lang('File')); + html_help_link ('upload_file'); + html_table_col_end (); + html_table_col_begin (); + html_text_bold (lang('Comment')); + html_help_link ('upload_comment'); + html_table_col_end (); + html_table_row_end (); + + html_table_row_begin (); + html_table_col_begin (); + html_form_input ('hidden', 'show_upload_boxes', base64_encode ($show_upload_boxes)); + html (html_form_input ('file', 'upload_file[]', NULL, 255, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); + html_table_col_end (); + html_table_col_begin (); + html (html_form_input ('text', 'upload_comment[]', NULL, NULL, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); + html_table_col_end (); + html_table_row_end (); + html_table_end (); + html_form_input ('submit', 'upload_files', lang('Upload files')); + html_help_link ('upload_files'); + html_break (2); + html_text (lang('Show') . html_nbsp (1, True)); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=5', '5'); + html_nbsp (); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=10', '10'); + html_nbsp (); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=20', '20'); + html_nbsp (); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=50', '50'); + html_nbsp (); + html_text (lang('upload fields')); + html_nbsp (); + html_help_link ('show_upload_fields'); + html_form_end (); +} } html_table_col_end (); @@ -1329,55 +1355,55 @@ if ($edit) $content = $edit_file_content; if ($GLOBALS['phpgw']->vfs->write (array ( - 'string' => $edit_file, - 'relatives' => array (RELATIVE_ALL), - 'content' => $content - )) - ) - { - html_text_bold (lang('Saved %1', $path.'/'.$edit_file)); - html_break (2); - html_link_back (); - } - else - { - html_text_error (lang('Could not save %1', $path.'/'.$edit_file)); - html_break (2); - html_link_back (); - } + 'string' => $edit_file, + 'relatives' => array (RELATIVE_ALL), + 'content' => $content + )) + ) + { + html_text_bold (lang('Saved %1', $path.'/'.$edit_file)); + html_break (2); + html_link_back (); } + else + { + html_text_error (lang('Could not save %1', $path.'/'.$edit_file)); + html_break (2); + html_link_back (); + } +} /* This doesn't work just yet - elseif ($edit_save_all) +elseif ($edit_save_all) +{ + for ($j = 0; $j != $numoffiles; $j++) { - for ($j = 0; $j != $numoffiles; $j++) - { - $fileman[$j]; + $fileman[$j]; - $content = $fileman[$j]; - echo 'fileman['.$j.']: '.$fileman[$j].'
'.$content.'
'; - continue; - - if ($GLOBALS['phpgw']->vfs->write (array ( - 'string' => $fileman[$j], - 'relatives' => array (RELATIVE_ALL), - 'content' => $content - )) - ) - { - html_text_bold (lang('Saved %1', $path.'/'.$fileman[$j])); - html_break (1); - } - else - { - html_text_error (lang('Could not save %1', $path.'/'.$fileman[$j])); - html_break (1); - } - } + $content = $fileman[$j]; + echo 'fileman['.$j.']: '.$fileman[$j].'
'.$content.'
'; + continue; + if ($GLOBALS['phpgw']->vfs->write (array ( + 'string' => $fileman[$j], + 'relatives' => array (RELATIVE_ALL), + 'content' => $content + )) + ) + { + html_text_bold (lang('Saved %1', $path.'/'.$fileman[$j])); html_break (1); } -*/ + else + { + html_text_error (lang('Could not save %1', $path.'/'.$fileman[$j])); + html_break (1); + } +} + +html_break (1); + } + */ ### # Now we display the edit boxes and forms @@ -1396,53 +1422,53 @@ if ($edit) } if ($fileman[$j] && $GLOBALS['phpgw']->vfs->file_exists (array ( - 'string' => $fileman[$j], - 'relatives' => array (RELATIVE_ALL) - )) - ) + 'string' => $fileman[$j], + 'relatives' => array (RELATIVE_ALL) + )) + ) + { + if ($edit_file) { - if ($edit_file) - { - $content = stripslashes ($edit_file_content); - } - else - { - $content = $GLOBALS['phpgw']->vfs->read (array ('string' => $fileman[$j])); - } - - html_table_begin ('100%'); - html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path); - html_form_input ('hidden', 'edit', True); - html_form_input ('hidden', 'edit_file', $fileman[$j]); - - ### - # We need to include all of the fileman entries for each file's form, - # so we loop through again - ### - - for ($i = 0; $i != $numoffiles; $i++) - { - html_form_input ('hidden', 'fileman['.$i.']', base64_encode ($fileman[$i])); - } - - html_table_row_begin (); - html_table_col_begin (); - html_form_textarea ('edit_file_content', 35, 75, $content); - html_table_col_end (); - html_table_col_begin ('center'); - html_form_input ('submit', 'edit_preview', lang('Preview %1', html_encode ($fileman[$j], 1))); - html_break (1); - html_form_input ('submit', 'edit_save', lang('Save %1', html_encode ($fileman[$j], 1))); -// html_break (1); -// html_form_input ('submit', 'edit_save_all', lang('Save all')); - html_table_col_end (); - html_table_row_end (); - html_break (2); - html_form_end (); - html_table_end (); + $content = stripslashes ($edit_file_content); } + else + { + $content = $GLOBALS['phpgw']->vfs->read (array ('string' => $fileman[$j])); + } + + html_table_begin ('100%'); + html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path); + html_form_input ('hidden', 'edit', True); + html_form_input ('hidden', 'edit_file', $fileman[$j]); + + ### + # We need to include all of the fileman entries for each file's form, + # so we loop through again + ### + + for ($i = 0; $i != $numoffiles; $i++) + { + html_form_input ('hidden', 'fileman['.$i.']', base64_encode ($fileman[$i])); + } + + html_table_row_begin (); + html_table_col_begin (); + html_form_textarea ('edit_file_content', 35, 75, $content); + html_table_col_end (); + html_table_col_begin ('center'); + html_form_input ('submit', 'edit_preview', lang('Preview %1', html_encode ($fileman[$j], 1))); + html_break (1); + html_form_input ('submit', 'edit_save', lang('Save %1', html_encode ($fileman[$j], 1))); + // html_break (1); + // html_form_input ('submit', 'edit_save_all', lang('Save all')); + html_table_col_end (); + html_table_row_end (); + html_break (2); + html_form_end (); + html_table_end (); } } +} ### # Handle File Uploads @@ -1464,69 +1490,69 @@ elseif ($op == 'upload' && $path != '/' && $path != $GLOBALS['fakebase']) ### $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $path . '/' . $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => True + 'string' => $path . '/' . $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + + $fileinfo = $ls_array[0]; + + if ($fileinfo['name']) + { + if ($fileinfo['mime_type'] == 'Directory') + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); + continue; + } + } + + if ($_FILES['upload_file']['size'][$i] > 0) + { + if ($fileinfo['name'] && $fileinfo['deleteable'] != 'N') + { + $GLOBALS['phpgw']->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'owner_id' => $GLOBALS['userinfo']['username'], + 'modifiedby_id' => $GLOBALS['userinfo']['username'], + 'modified' => $now, + 'size' => $_FILES['upload_file']['size'][$i], + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'deleteable' => 'Y', + 'comment' => stripslashes ($upload_comment[$i]) + ) ) ); - $fileinfo = $ls_array[0]; + $GLOBALS['phpgw']->vfs->cp(array ( + 'from' => $_FILES['upload_file']['tmp_name'][$i], + 'to' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) + ) + ); - if ($fileinfo['name']) - { - if ($fileinfo['mime_type'] == 'Directory') - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); - continue; - } - } + html_text_summary(lang('Replaced %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); +} +else +{ + $GLOBALS['phpgw']->vfs->cp (array ( + 'from' => $_FILES['upload_file']['tmp_name'][$i], + 'to' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) + ) +); - if ($_FILES['upload_file']['size'][$i] > 0) - { - if ($fileinfo['name'] && $fileinfo['deleteable'] != 'N') - { - $GLOBALS['phpgw']->vfs->set_attributes (array ( - 'string' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'owner_id' => $GLOBALS['userinfo']['username'], - 'modifiedby_id' => $GLOBALS['userinfo']['username'], - 'modified' => $now, - 'size' => $_FILES['upload_file']['size'][$i], - 'mime_type' => $_FILES['upload_file']['type'][$i], - 'deleteable' => 'Y', - 'comment' => stripslashes ($upload_comment[$i]) - ) - ) - ); - - $GLOBALS['phpgw']->vfs->cp(array ( - 'from' => $_FILES['upload_file']['tmp_name'][$i], - 'to' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) - ) - ); - - html_text_summary(lang('Replaced %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); - } - else - { - $GLOBALS['phpgw']->vfs->cp (array ( - 'from' => $_FILES['upload_file']['tmp_name'][$i], - 'to' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) - ) - ); - - $GLOBALS['phpgw']->vfs->set_attributes (array ( - 'string' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'mime_type' => $_FILES['upload_file']['type'][$i], - 'comment' => stripslashes ($upload_comment[$i]) - ) - ) +$GLOBALS['phpgw']->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'comment' => stripslashes ($upload_comment[$i]) + ) +) ); html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); @@ -1535,23 +1561,23 @@ elseif ($op == 'upload' && $path != '/' && $path != $GLOBALS['fakebase']) elseif ($_FILES['upload_file']['name'][$i]) { $GLOBALS['phpgw']->vfs->touch (array ( - 'string' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_ALL) - ) - ); + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL) + ) + ); - $GLOBALS['phpgw']->vfs->set_attributes (array ( - 'string' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'mime_type' => $_FILES['upload_file']['type'][$i], - 'comment' => $upload_comment[$i] - ) - ) - ); + $GLOBALS['phpgw']->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'comment' => $upload_comment[$i] + ) + ) + ); - html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $file_size[$i]); - } + html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $file_size[$i]); +} } html_break (2); @@ -1573,19 +1599,19 @@ elseif ($comment_files) } $GLOBALS['phpgw']->vfs->set_attributes (array ( - 'string' => $file, - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'comment' => stripslashes ($comment_files[$file]) - ) + 'string' => $file, + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'comment' => stripslashes ($comment_files[$file]) ) - ); + ) + ); - html_text_summary (lang('Updated comment for %1', $path.'/'.$file)); - } + html_text_summary (lang('Updated comment for %1', $path.'/'.$file)); +} - html_break (2); - html_link_back (); +html_break (2); +html_link_back (); } ### @@ -1607,21 +1633,21 @@ elseif ($renamefiles) echo $GLOBALS['phpgw']->common->error_list (array (lang("File names cannot contain \\ or /"))); } elseif (!$GLOBALS['phpgw']->vfs->mv (array ( - 'from' => $from, - 'to' => $to - )) - ) - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not rename %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to))); - } - else - { - html_text_summary (lang('Renamed %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to)); - } + 'from' => $from, + 'to' => $to + )) + ) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not rename %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to))); } + else + { + html_text_summary (lang('Renamed %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to)); + } +} - html_break (2); - html_link_back (); +html_break (2); +html_link_back (); } ### @@ -1633,29 +1659,29 @@ elseif ($move) while (list ($num, $file) = each ($fileman)) { if ($GLOBALS['phpgw']->vfs->mv (array ( - 'from' => $file, - 'to' => $todir . '/' . $file, - 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) - )) - ) - { - $moved++; - html_text_summary (lang('Moved %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); - } - else - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not move %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); - } - } - - if ($moved) + 'from' => $file, + 'to' => $todir . '/' . $file, + 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) + )) + ) { - html_break (2); - html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); + $moved++; + html_text_summary (lang('Moved %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not move %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); + } +} +if ($moved) +{ html_break (2); - html_link_back (); + html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); +} + +html_break (2); +html_link_back (); } ### @@ -1667,29 +1693,29 @@ elseif ($copy) while (list ($num, $file) = each ($fileman)) { if ($GLOBALS['phpgw']->vfs->cp (array ( - 'from' => $file, - 'to' => $todir . '/' . $file, - 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) - )) - ) - { - $copied++; - html_text_summary (lang('Copied %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); - } - else - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not copy %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); - } - } - - if ($copied) + 'from' => $file, + 'to' => $todir . '/' . $file, + 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) + )) + ) { - html_break (2); - html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); + $copied++; + html_text_summary (lang('Copied %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not copy %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); + } +} +if ($copied) +{ html_break (2); - html_link_back (); + html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); +} + +html_break (2); +html_link_back (); } ### @@ -1726,7 +1752,7 @@ elseif ($newdir && $createdir) html_link_back (); html_page_close (); } - + if ($createdir[strlen($createdir)-1] == ' ' || $createdir[0] == ' ') { echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot create directory because it begins or ends in a space'))); @@ -1736,50 +1762,53 @@ elseif ($newdir && $createdir) } $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $path . '/' . $createdir, - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => True - ) - ); + 'string' => $path . '/' . $createdir, + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) +); - $fileinfo = $ls_array[0]; +$fileinfo = $ls_array[0]; - if ($fileinfo['name']) +if ($fileinfo['name']) +{ + if ($fileinfo['mime_type'] != 'Directory') { - if ($fileinfo['mime_type'] != 'Directory') - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('%1 already exists as a file', $fileinfo['name']))); - html_break (2); - html_link_back (); - html_page_close (); - } - else - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 already exists', $fileinfo['name']))); - html_break (2); - html_link_back (); - html_page_close (); - } + echo $GLOBALS['phpgw']->common->error_list (array (lang('%1 already exists as a file', $fileinfo['name']))); + html_break (2); + html_link_back (); + html_page_close (); } else { - if ($GLOBALS['phpgw']->vfs->mkdir (array ('string' => $createdir))) - { - html_text_summary (lang('Created directory %1', $disppath.'/'.$createdir)); - html_break (2); - html_link ($GLOBALS['appname'].'/index.php?path='.$disppath.'/'.$createdir, lang('Go to %1', $disppath.'/'.$createdir)); - } - else - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create %1', $disppath.'/'.$createdir))); - } + echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 already exists', $fileinfo['name']))); + html_break (2); + html_link_back (); + html_page_close (); } +} +else +{ + if ($GLOBALS['phpgw']->vfs->mkdir (array ('string' => $createdir))) + { + html_text_summary (lang('Created directory %1', $disppath.'/'.$createdir)); + html_break (2); + html_link ($GLOBALS['appname'].'/index.php?path='.$disppath.'/'.$createdir, lang('Go to %1', $disppath.'/'.$createdir)); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create %1', $disppath.'/'.$createdir))); + } +} - html_break (2); - html_link_back (); +html_break (2); +html_link_back (); } html_page_close (); + + + ?> diff --git a/filemanager/templates/default/images/folder-home.gif b/filemanager/templates/default/images/folder-home.gif new file mode 100755 index 0000000000..9641d91eb6 Binary files /dev/null and b/filemanager/templates/default/images/folder-home.gif differ diff --git a/filemanager/templates/default/images/folder-home.png b/filemanager/templates/default/images/folder-home.png new file mode 100644 index 0000000000..3afa803379 Binary files /dev/null and b/filemanager/templates/default/images/folder-home.png differ diff --git a/filemanager/templates/default/images/folder-open.gif b/filemanager/templates/default/images/folder-open.gif new file mode 100755 index 0000000000..d732f9a983 Binary files /dev/null and b/filemanager/templates/default/images/folder-open.gif differ diff --git a/filemanager/templates/default/images/folder-open.png b/filemanager/templates/default/images/folder-open.png new file mode 100644 index 0000000000..33cc0bb90e Binary files /dev/null and b/filemanager/templates/default/images/folder-open.png differ diff --git a/filemanager/templates/default/images/folder-up.gif b/filemanager/templates/default/images/folder-up.gif new file mode 100755 index 0000000000..2407bc2fee Binary files /dev/null and b/filemanager/templates/default/images/folder-up.gif differ diff --git a/filemanager/templates/default/images/folder-up.png b/filemanager/templates/default/images/folder-up.png new file mode 100644 index 0000000000..8ec228df6b Binary files /dev/null and b/filemanager/templates/default/images/folder-up.png differ diff --git a/filemanager/templates/default/images/folder.gif b/filemanager/templates/default/images/folder.gif index 89d4c1f193..d656958e0d 100755 Binary files a/filemanager/templates/default/images/folder.gif and b/filemanager/templates/default/images/folder.gif differ diff --git a/filemanager/templates/default/images/folder.png b/filemanager/templates/default/images/folder.png index d783a06122..dfd6894289 100644 Binary files a/filemanager/templates/default/images/folder.png and b/filemanager/templates/default/images/folder.png differ diff --git a/filemanager/templates/default/images/locked.gif b/filemanager/templates/default/images/locked.gif index aa4cbbe65b..97bf068cdb 100755 Binary files a/filemanager/templates/default/images/locked.gif and b/filemanager/templates/default/images/locked.gif differ diff --git a/filemanager/templates/default/images/locked.png b/filemanager/templates/default/images/locked.png index 4b781544fa..669dc8d4d4 100644 Binary files a/filemanager/templates/default/images/locked.png and b/filemanager/templates/default/images/locked.png differ diff --git a/filemanager/templates/default/images/navbar.gif b/filemanager/templates/default/images/navbar.gif index 3b0c2f8ce9..be338b17c0 100755 Binary files a/filemanager/templates/default/images/navbar.gif and b/filemanager/templates/default/images/navbar.gif differ diff --git a/filemanager/templates/default/images/navbar.png b/filemanager/templates/default/images/navbar.png index 1c741bd675..0644f13170 100644 Binary files a/filemanager/templates/default/images/navbar.png and b/filemanager/templates/default/images/navbar.png differ