diff --git a/filemanager/inc/class.bofilemanager.inc.php b/filemanager/inc/class.bofilemanager.inc.php index 047298307f..bf2609a199 100755 --- a/filemanager/inc/class.bofilemanager.inc.php +++ b/filemanager/inc/class.bofilemanager.inc.php @@ -2,52 +2,24 @@ class bofilemanager { + + // used + var $so; var $vfs; - var $sep; - var $file_attributes; - var $help_info; - var $rootdir; var $fakebase; var $appname; - var $settings; var $filesdir; var $hostname; var $userinfo = Array(); var $homedir; + var $sep; + var $file_attributes; - var $errors; + var $matches;//FIXME matches not defined - var $rename; - var $delete; - var $go; - var $copy; - var $move; - var $download; - var $createdir; - var $newdir; - var $createfile; - var $newfile; - - var $fileman = Array(); - var $op; - var $file; - var $help_name; - var $path; - var $disppath; - var $dispsep; - var $sortby = 'name'; - var $messages = Array(); - var $renamefiles; - var $comment_files = Array(); - var $show_upload_boxes = 5; - var $memberships; - var $now; - var $matches; - - // var $debug = True; var $debug = False; function bofilemanager() @@ -63,30 +35,30 @@ ### 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)) + $this->rootdir = $this->vfs->basedir; + $this->fakebase = $this->vfs->fakebase; + $this->appname = $GLOBALS['phpgw_info']['flags']['currentapp']; + + if (stristr ($this->rootdir, PHPGW_SERVER_ROOT)) { - $GLOBALS['filesdir'] = substr ($GLOBALS['rootdir'], strlen (PHPGW_SERVER_ROOT)); + $this->filesdir = substr ($this->rootdir, strlen (PHPGW_SERVER_ROOT)); } else { - unset ($GLOBALS['filesdir']); + unset ($this->filesdir); } - $GLOBALS['hostname'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . $GLOBALS['filesdir']; + $this->hostname = $GLOBALS['phpgw_info']['server']['webserver_url'] . $this->filesdir; +// die($this->hostname); ### # 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']; + $this->userinfo['username'] = $GLOBALS['phpgw_info']['user']['account_id']; + $this->userinfo['account_lid'] = $GLOBALS['phpgw']->accounts->id2name ($this->userinfo['username']); + $this->userinfo['hdspace'] = 10000000000; // to settings + $this->homedir = $this->fakebase.'/'.$this->userinfo['account_lid']; ### End Configuration Options ### @@ -199,8 +171,6 @@ function html_text ($string, $times = 1, $return = 0, $lang = 0) { - global $phpgw; - if ($lang) $string = lang($string); @@ -231,20 +201,23 @@ { $rstring = $string; - preg_match_all ("/=(.*)(&|$)/U", $string, $matches, PREG_SET_ORDER); + preg_match_all ("/=(.*)(&|$)/U", $string, $matches, PREG_SET_ORDER);//FIXME matches not defined + + reset ($matches);//FIXME matches not defined + + while (list (,$match_array) = each ($matches))//FIXME matches not defined - 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)) + elseif ($this->hostname != "" && ereg('^'.$this->hostname, $string)) +// elseif (ereg ('^'.$this->hostname, $string)) { - $rstring = ereg_replace ('^'.$GLOBALS['hostname'].'/', '', $string); + $rstring = ereg_replace ('^'.$this->hostname.'/', '', $string); $rstring = preg_replace ("/(.*)(\/|$)/Ue", "rawurlencode (base64_encode ('\\1')) . '\\2'", $rstring); - $rstring = $GLOBALS['hostname'].'/'.$rstring; + $rstring = $this->hostname.'/'.$rstring; } else { diff --git a/filemanager/inc/class.sofilemanager.inc.php b/filemanager/inc/class.sofilemanager.inc.php index 66300e8d86..5a8446ac98 100755 --- a/filemanager/inc/class.sofilemanager.inc.php +++ b/filemanager/inc/class.sofilemanager.inc.php @@ -3,30 +3,21 @@ class sofilemanager { var $db; -// var $phpgw; -// var $phpgw_info; function sofilemanager() { $this->db = $GLOBALS['phpgw']->db; -// $this->phpgw=$GLOBALS[phpgw]; -// $this->phpgw_info=$GLOBALS[phpgw_info]; } /* Any initializations that need to be done */ function db_init () { - //global $phpgw; - //global $phpgw_info; - $this->db->Auto_Free = 0; } /* General SQL query */ function db_query ($query) { - // global $phpgw; - // global $phpgw_info; return $this->db->query ($query); } @@ -34,8 +25,6 @@ /* Fetch next array for $query_id */ function db_fetch_array ($query_id) { -// global $phpgw; -// global $phpgw_info; // $phpgw->db->Query_ID = $query_id; $this->db->next_record (); @@ -48,8 +37,6 @@ */ function db_call ($function, $query_id) { -// global $phpgw; -// global $phpgw_info; // $phpgw->db->Query_ID = $query_id; return $this->db->$function (); diff --git a/filemanager/inc/class.uifilemanager.inc.php b/filemanager/inc/class.uifilemanager.inc.php index 7ca3a4c0be..387032daf4 100755 --- a/filemanager/inc/class.uifilemanager.inc.php +++ b/filemanager/inc/class.uifilemanager.inc.php @@ -51,11 +51,11 @@ var $todir; var $changedir; // for switching dir. var $cdtodir; // for switching dir. - var $createdir; +// var $createdir; var $newfile_or_dir; var $newdir_x; var $newfile_x; - var $createfile; + var $createfile_var; var $delete_x; var $renamefiles; var $rename_x; @@ -74,11 +74,12 @@ var $uploadprocess; // this ones must be checked thorougly; - var $fileman; + var $fileman = Array(); + //var $fileman; var $path; - var $file; + var $file; // FIXME WHERE IS THIS FILLED? var $sortby; - var $messages; + var $messages = array(); var $show_upload_boxes; var $debug = false; @@ -160,12 +161,12 @@ } // get appl. and user prefs - $pref = CreateObject('phpgwapi.preferences', $GLOBALS['userinfo']['username']); + $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']); $pref->read_repository(); // $GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); $pref->save_repository(True); $pref_array = $pref->read_repository(); - $this->prefs = $pref_array[$GLOBALS['appname']]; + $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array //always show name @@ -176,6 +177,78 @@ { $this->target = '_blank'; } + + + /* + Check for essential directories + admin must be able to disable these tests + */ + + // check if basedir exist + $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); + if($test[mime_type]!='Directory') + { + die('Base directory does not exist, Ask adminstrator to check the global configuration.'); + } + + $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); + if($test[mime_type]!='Directory') + { + + $this->bo->vfs->override_acl = 1; + + $this->bo->vfs->mkdir(array( + 'string' => $this->bo->fakebase, + 'relatives' => array(RELATIVE_NONE) + )); + + $this->bo->vfs->override_acl = 0; + + //test one more time + $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); + + if($test[mime_type]!='Directory') + { + die('Fake Base directory does not exist and could not be created, please ask the adminstrator to check the global configuration.'); + } + else + { + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( + lang('Fake Base Dir did not exist, eGroupWare created a new one.') + )); + } + } + +// die($this->bo->homedir); + $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); + if($test[mime_type]!='Directory') + { + $this->bo->vfs->override_acl = 1; + + $this->bo->vfs->mkdir(array( + 'string' => $this->bo->homedir, + 'relatives' => array(RELATIVE_NONE) + )); + + $this->bo->vfs->override_acl = 0; + + //test one more time + $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); + + if($test[mime_type]!='Directory') + { + die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.'); + } + else + { + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( + lang('Your Home Dir did not exist, eGroupWare created a new one.') + )); + // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content + } + } + + } function index() @@ -185,7 +258,7 @@ $noheader = True; $nofooter = True; $noappheader= True; - $nonavbar=True; + $nonavbar= True; } else { @@ -203,8 +276,6 @@ } - // var_dump($GLOBALS[HTTP_POST_VARS]); - //var_dump($this->delete_x); # Page to process users # Code is fairly hackish at the beginning, but it gets better @@ -231,7 +302,7 @@ if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') { - $this->path = $GLOBALS['homedir']; + $this->path = $this->bo->homedir; } } @@ -240,7 +311,7 @@ $pwd = $this->bo->vfs->pwd(); - if(!$this->cwd = substr($this->path, strlen($GLOBALS['homedir']) + 1)) + if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1)) { $this->cwd = '/'; } @@ -293,61 +364,68 @@ # 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', $this->path, $matches)) && $matches[1] != $GLOBALS['userinfo']['account_lid']) + if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined + { - $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]); + $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined + } else { - $this->bo->vfs->working_id = $GLOBALS['userinfo']['username']; + $this->bo->vfs->working_id = $this->bo->userinfo['username']; } # FIXME # comment waht happens here - if($this->path != $GLOBALS['homedir'] && $this->path != $GLOBALS['fakebase'] && $this->path != '/' && !$this->bo->vfs->acl_check(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE),'operation' => PHPGW_ACL_READ))) + if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->bo->vfs->acl_check(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE),'operation' => PHPGW_ACL_READ))) { - $this->messages.= $GLOBALS['phpgw']->common->error_list(array(lang('You do not have access to %1', $this->path))); - $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$GLOBALS['homedir'], lang('Go to your home directory')); + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('You do not have access to %1', $this->path))); + $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->homedir, lang('Go to your home directory')); $GLOBALS['phpgw']->common->phpgw_footer(); $GLOBALS['phpgw']->common->phpgw_exit(); } - $GLOBALS['userinfo']['working_id'] = $this->bo->vfs->working_id; - $GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($GLOBALS['userinfo']['working_id']); + $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id; + $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']); # If their home directory doesn't exist, we try to create it # Same for group directories - if(($this->path == $GLOBALS['homedir']) && !$this->bo->vfs->file_exists($pim_tmp_arr)) + + + // Moved to constructor + /* + if(($this->path == $this->homedir) && !$this->bo->vfs->file_exists($pim_tmp_arr)) { $this->bo->vfs->override_acl = 1; if(!$this->bo->vfs->mkdir(array( - 'string' => $GLOBALS['homedir'], + 'string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE) ))) { $p = $this->bo->vfs->path_parts($pim_tmp_arr); - $this->messages= $GLOBALS['phpgw']->common->error_list(array( + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( lang('Could not create directory %1', - $GLOBALS['homedir'] . ' (' . $p->real_full_path . ')' + $this->bo->homedir . ' (' . $p->real_full_path . ')' ))); } $this->bo->vfs->override_acl = 0; } + */ # Verify path is real - if($this->path != $GLOBALS['homedir'] && $this->path != '/' && $this->path != $GLOBALS['fakebase']) + if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) { if(!$this->bo->vfs->file_exists(array( 'string' => $this->path, 'relatives' => array(RELATIVE_NONE) ))) { - $this->messages = $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 does not exist', $this->path))); - $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$GLOBALS['homedir'], lang('Go to your home directory')); + $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 does not exist', $this->path))); + $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir, lang('Go to your home directory')); $GLOBALS['phpgw']->common->phpgw_footer(); $GLOBALS['phpgw']->common->phpgw_exit(); @@ -465,8 +543,16 @@ $vars[toolbar0]=$this->toolbar('location'); $vars[toolbar1]=$this->toolbar('list_nav'); - if($this->messages) $this->messages='

'.$this->messages.'

'; - $vars[messages]=$this->messages; + + if(count($this->messages)>0) + { + foreach($this->messages as $msg) + { + $messages.='

'.$msg.'

'; + } + } + + $vars[messages]=$messages; $this->t->set_var($vars); $this->t->pparse('out','filemanager_header'); @@ -492,7 +578,10 @@ } $this->t->set_var('row_tr_color','#dedede'); + + //kan dit weg? $this->t->parse('rows','row'); + $this->t->pparse('out','row'); } else @@ -563,7 +652,7 @@ } # Checkboxes - if(!$this->rename_x && !$this->edit_comments_x && $this->path != $GLOBALS['fakebase'] && $this->path != '/') + if(!$this->rename_x && !$this->edit_comments_x && $this->path != $this->bo->fakebase && $this->path != '/') { $cbox=''; $this->t->set_var('actions',$cbox); @@ -598,10 +687,10 @@ else { - if($this->prefs['viewonserver'] && isset($GLOBALS['filesdir']) && !$files['link_directory']) + if($this->prefs['viewonserver'] && isset($this->bo->filesdir) && !$files['link_directory']) { #FIXME - $clickview = $GLOBALS['filesdir'].$pwd.'/'.$files['name']; + $clickview = $this->filesdir.$pwd.'/'.$files['name']; if($phpwh_debug) { @@ -768,10 +857,10 @@ $vars[lang_used_space]=lang('Used space'); $vars[used_space]=$this->bo->borkb($usedspace, NULL, 1); - if($this->path == $GLOBALS['homedir'] || $this->path == $GLOBALS['fakebase']) + if($this->path == $this->bo->homedir || $this->path == $this->bo->fakebase) { $vars[lang_unused_space]=lang('Unused space'); - $vars[unused_space]=$this->bo->borkb($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1); + $vars[unused_space]=$this->bo->borkb($this->bo->userinfo['hdspace'] - $usedspace, NULL, 1); $tmp_arr=array( 'string' => $this->path, @@ -799,15 +888,16 @@ # $fakebase is a special directory. In that directory, we list the user's # home directory and the directories for the groups they're in $this->numoffiles = 0; - if($this->path == $GLOBALS['fakebase']) + if($this->path == $this->bo->fakebase) { - if(!$this->bo->vfs->file_exists(array('string' => $GLOBALS['homedir'], 'relatives' => array(RELATIVE_NONE)))) + // FIXME this test can be removed + if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) { - $this->bo->vfs->mkdir(array('string' => $GLOBALS['homedir'], 'relatives' => array(RELATIVE_NONE))); + $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))); } $ls_array = $this->bo->vfs->ls(array( - 'string' => $GLOBALS['homedir'], + 'string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'checksubdirs' => False, 'nofiles' => True @@ -819,26 +909,29 @@ while(list($num, $group_array) = each($this->readable_groups)) { # If the group doesn't have access to this app, we don't show it - if(!$this->groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) { continue; } - if(!$this->bo->vfs->file_exists(array('string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE)))) + if(!$this->bo->vfs->file_exists(array('string' => $this->bo->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'], + 'string' => $this->bo->fakebase.'/'.$group_array['account_name'], 'relatives' => array(RELATIVE_NONE) )); + // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content + + $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']))); + $this->bo->vfs->set_attributes(array('string' => $this->bo->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)); + $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True)); $this->files_array[] = $ls_array[0]; @@ -900,9 +993,9 @@ } // go home icon when we're not home already - if($this->path != $GLOBALS['homedir']) + if($this->path != $this->bo->homedir) { - $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$GLOBALS['homedir']); + $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir); $toolbar.=$this->buttonImage($link,'home',lang('go home')); } @@ -920,7 +1013,7 @@ '; $toolbar.=$this->inputImage('goto','goto',lang('Quick jump to')); // upload button - if($this->path != '/' && $this->path != $GLOBALS['fakebase'] && $this->can_add) + if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) { $toolbar.='spacer'; @@ -940,7 +1033,7 @@ '; // selectbox for change/move/and copy to // submit buttons for - if($this->path != '/' && $this->path != $GLOBALS['fakebase']) + if($this->path != '/' && $this->path != $this->bo->fakebase) { $toolbar.='spacer'; $toolbar.=' @@ -973,7 +1066,7 @@ if(!$this->rename_x && !$this->edit_comments_x) { // copy and move buttons - if($this->path != '/' && $this->path != $GLOBALS['fakebase']) + if($this->path != '/' && $this->path != $this->bo->fakebase) { $toolbar3.='spacer'; $toolbar3.='spacer'; @@ -989,7 +1082,7 @@ } // create dir and file button - if($this->path != '/' && $this->path != $GLOBALS['fakebase'] && $this->can_add) + if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) { $toolbar3.='spacer'; $toolbar3.='spacer'; @@ -1023,13 +1116,13 @@ # Handle File Uploads function fileUpload() { - if($this->path != '/' && $this->path != $GLOBALS['fakebase']) + if($this->path != '/' && $this->path != $this->bo->fakebase) { for($i = 0; $i != $this->show_upload_boxes; $i++) { if($badchar = $this->bo->bad_chars($_FILES['upload_file']['name'][$i], True, True)) { - $this->messages.= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); continue; } @@ -1048,7 +1141,7 @@ { if($fileinfo['mime_type'] == 'Directory') { - $this->messages.= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); continue; } } @@ -1061,8 +1154,8 @@ 'string'=> $_FILES['upload_file']['name'][$i], 'relatives' => array(RELATIVE_ALL), 'attributes' => array( - 'owner_id' => $GLOBALS['userinfo']['username'], - 'modifiedby_id' => $GLOBALS['userinfo']['username'], + 'owner_id' => $this->bo->userinfo['username'], + 'modifiedby_id' => $this->bo->userinfo['username'], 'modified' => $this->now, 'size' => $_FILES['upload_file']['size'][$i], 'mime_type' => $_FILES['upload_file']['type'][$i], @@ -1079,7 +1172,7 @@ ); $this->bo->vfs->cp($tmp_arr); - $this->messages.=lang('Replaced %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]); + $this->messages[]=lang('Replaced %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]); } else { @@ -1099,7 +1192,7 @@ ) )); - $this->messages.=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i]); + $this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i]); } } elseif($_FILES['upload_file']['name'][$i]) @@ -1118,7 +1211,7 @@ ) )); - $this->messages.=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $file_size[$i]); + $this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $file_size[$i]); } } @@ -1134,7 +1227,7 @@ { if($badchar = $this->bo->bad_chars($this->comment_files[$file], False, True)) { - $this->messages=$GLOBALS['phpgw']->common->error_list(array($file . $this->bo->html_encode(': ' . lang('Comments cannot contain "%1"', $badchar), 1))); + $this->messages[]=$GLOBALS['phpgw']->common->error_list(array($file . $this->bo->html_encode(': ' . lang('Comments cannot contain "%1"', $badchar), 1))); continue; } @@ -1146,7 +1239,7 @@ ) )); - $this->messages=lang('Updated comment for %1', $this->path.'/'.$file); + $this->messages[]=lang('Updated comment for %1', $this->path.'/'.$file); } $this->readFilesInfo(); @@ -1160,24 +1253,24 @@ { if($badchar = $this->bo->bad_chars($to, True, True)) { - $this->messages=$GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); + $this->messages[]=$GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); continue; } if(ereg("/", $to) || ereg("\\\\", $to)) { - $this->messages=$GLOBALS['phpgw']->common->error_list(array(lang("File names cannot contain \\ or /"))); + $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang("File names cannot contain \\ or /"))); } elseif(!$this->bo->vfs->mv(array( 'from' => $from, 'to' => $to ))) { - $this->messages= $GLOBALS['phpgw']->common->error_list(array(lang('Could not rename %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to))); + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Could not rename %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to))); } else { - $this->messages=lang('Renamed %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to); + $this->messages[]=lang('Renamed %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to); } } $this->readFilesInfo(); @@ -1196,11 +1289,11 @@ ))) { $moved++; - $this->messages=lang('Moved %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file); + $this->messages[]=lang('Moved %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file); } else { - $this->messages = $GLOBALS['phpgw']->common->error_list(array(lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file))); + $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file))); } } @@ -1248,13 +1341,13 @@ { if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True)) { - $this->messages= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1))); + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1))); } /* TODO is this right or should it be a single $ ? */ if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ') { - $this->messages= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot create directory because it begins or ends in a space'))); + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot create directory because it begins or ends in a space'))); } $ls_array = $this->bo->vfs->ls(array( @@ -1270,25 +1363,25 @@ { if($fileinfo['mime_type'] != 'Directory') { - $this->messages= $GLOBALS['phpgw']->common->error_list(array( + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( lang('%1 already exists as a file', $fileinfo['name']) )); } else { - $this->messages= $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 already exists', $fileinfo['name']))); + $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 already exists', $fileinfo['name']))); } } else { if($this->bo->vfs->mkdir(array('string' => $this->newfile_or_dir))) { - $this->messages=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir); + $this->messages[]=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir); } else { - $this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir))); + $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir))); } } @@ -1305,18 +1398,18 @@ { if($this->bo->vfs->delete(array('string' => $filename))) { - $this->messages .= lang('Deleted %1', $this->disppath.'/'.$filename).'
'; + $this->messages[]= lang('Deleted %1', $this->disppath.'/'.$filename).'
'; } else { - $this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('Could not delete %1', $this->disppath.'/'.$filename))); + $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Could not delete %1', $this->disppath.'/'.$filename))); } } } else { // make this a javascript func for quicker respons - $this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('Please select a file to delete.'))); + $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Please select a file to delete.'))); } $this->readFilesInfo(); $this->filelisting(); @@ -1359,7 +1452,7 @@ } # Show file upload boxes. Note the last argument to html(). Repeats $this->show_upload_boxes times - if($this->path != '/' && $this->path != $GLOBALS['fakebase'] && $this->can_add) + if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) { $vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index'); $vars[path]=$this->path; @@ -1396,12 +1489,12 @@ /* create textfile */ function createfile() { - $this->createfile=$this->newfile_or_dir; - if($this->createfile) + $this->createfile_var=$this->newfile_or_dir; + if($this->createfile_var) { - if($badchar = $this->bo->bad_chars($this->createfile, True, True)) + if($badchar = $this->bo->bad_chars($this->createfile_var, True, True)) { - $this->messages = $GLOBALS['phpgw']->common->error_list(array( + $this->messages[] = $GLOBALS['phpgw']->common->error_list(array( lang('File names cannot contain "%1"',$badchar), 1) ); @@ -1410,28 +1503,28 @@ } if($this->bo->vfs->file_exists(array( - 'string'=> $this->createfile, + 'string'=> $this->createfile_var, 'relatives' => array(RELATIVE_ALL) ))) { - $this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 already exists. Please edit it or delete it first.', $this->createfile))); + $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 already exists. Please edit it or delete it first.', $this->createfile_var))); $this->fileListing(); } if($this->bo->vfs->touch(array( - 'string' => $this->createfile, + 'string' => $this->createfile_var, 'relatives' => array(RELATIVE_ALL) ))) { $this->fileman = array(); - $this->fileman[0] = $this->createfile; + $this->fileman[0] = $this->createfile_var; $this->edit = 1; $this->numoffiles++; $this->edit(); } else { - $this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 could not be created.', $this->createfile))); + $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 could not be created.', $this->createfile_var))); $this->fileListing(); } } @@ -1469,7 +1562,7 @@ 'content' => $content ))) { - $this->messages=lang('Saved %1', $this->path.'/'.$this->edit_file); + $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file); if($this->edit_save_done_x) { @@ -1480,7 +1573,7 @@ } else { - $this->messages=lang('Could not save %1', $this->path.'/'.$this->edit_file); + $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file); } } @@ -1535,10 +1628,10 @@ function history() { - if($this->file) + if($this->file) // FIXME this-file is never defined { $journal_array = $this->bo->vfs->get_journal(array( - 'string' => $this->file, + 'string' => $this->file,//FIXME 'relatives' => array(RELATIVE_ALL) )); @@ -1590,10 +1683,10 @@ function view() { - if($this->file) + if($this->file) //FIXME { $ls_array = $this->bo->vfs->ls(array( - 'string' => $this->path.'/'.$this->file, + 'string' => $this->path.'/'.$this->file,//FIXME 'relatives' => array(RELATIVE_ALL), 'checksubdirs' => False, 'nofiles' => True @@ -1612,14 +1705,14 @@ if(in_array($mime_type,$viewable)) { header('Content-type: ' . $mime_type); - header('Content-disposition: filename="' . $this->file . '"'); + header('Content-disposition: filename="' . $this->file . '"');//FIXME } else { - $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type); + $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type);//FIXME } echo $this->bo->vfs->read(array( - 'string' => $this->path.'/'.$this->file, + 'string' => $this->path.'/'.$this->file,//FIXME 'relatives' => array(RELATIVE_NONE) )); $GLOBALS['phpgw']->common->phpgw_exit(); @@ -1647,10 +1740,10 @@ { # First we get the directories in their home directory $dirs = array(); - $dirs[] = array('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); + $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']); $tmp_arr=array( - 'string' => $GLOBALS['homedir'], + 'string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'checksubdirs' => True, 'mime_type' => 'Directory' @@ -1669,15 +1762,15 @@ while(list($num, $group_array) = each($this->readable_groups)) { # Don't list directories for groups that don't have access - if(!$this->groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) { continue; } - $dirs[] = array('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); + $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']); $tmp_arr=array( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'string' => $this->bo->fakebase.'/'.$group_array['account_name'], 'relatives' => array(RELATIVE_NONE), 'checksubdirs' => True, 'mime_type' => 'Directory' diff --git a/filemanager/index.php b/filemanager/index.php index 9e4dbf5dd3..9ceef8de0f 100755 --- a/filemanager/index.php +++ b/filemanager/index.php @@ -1,1835 +1,25 @@ 'filemanager', - 'noheader' => True, - 'nonavbar' => True, - 'noappheader' => True, - 'noappfooter' => True, - 'nofooter' => True - ); - - $GLOBALS['phpgw_info']['flags'] = $phpgw_flags; - - include('../header.inc.php'); - // $GLOBALS['phpgw']->common->phpgw_exit(); - - Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index')); - $GLOBALS['phpgw']->common->phpgw_exit(); - } - - - ### - # 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]; - } - - @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 (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))); - } - } - } - } - - - 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 (!count ($GLOBALS['settings'])) - { - $pref = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); - $pref->read_repository (); -// $GLOBALS['phpgw']->hooks->single ('add_def_pref', $GLOBALS['appname']); -// $pref->save_repository (True); - $pref_array = $pref->read_repository (); - $GLOBALS['settings'] = $pref_array[$GLOBALS['appname']]; - } -//experimental_new_code -//die($GLOBALS[][experimental_new_code]); -/* if($GLOBALS[settings][experimental_new_code]) - { - echo ' - - - '; - - } -*/ - - - - if ($execute && $command_line) - { - if ($result = $GLOBALS['phpgw']->vfs->command_line (array ('command_line' => stripslashes ($command_line)))) - { - $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 - { - $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: " . $GLOBALS['phpgw']->vfs->getabsolutepath (array ('target' => False, 'mask' => False, 'fake' => False)) . "
- 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 - ### - - $groups = array (); - - $groups = $GLOBALS['phpgw']->accounts->get_list ('groups'); - - $readable_groups = array (); - - while (list ($num, $account) = each ($groups)) - { - if ($GLOBALS['phpgw']->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']) -{ - $GLOBALS['phpgw']->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id ($matches[1]); -} -else -{ - $GLOBALS['phpgw']->vfs->working_id = $GLOBALS['userinfo']['username']; -} - -if ($path != $GLOBALS['homedir'] -&& $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))); - html_break (2); - html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], lang('Go to your home directory')); - html_page_close (); -} - -$GLOBALS['userinfo']['working_id'] = $GLOBALS['phpgw']->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']) -&& !$GLOBALS['phpgw']->vfs->file_exists (array ( - 'string' => $GLOBALS['homedir'], - 'relatives' => array (RELATIVE_NONE) -)) -) -{ - $GLOBALS['phpgw']->vfs->override_acl = 1; - - if (!$GLOBALS['phpgw']->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) - { - $p = $phpgw->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 . ')'))); - } - - $GLOBALS['phpgw']->vfs->override_acl = 0; -} - -### -# Verify path is real -### - -if ($path != $GLOBALS['homedir'] && $path != '/' && $path != $GLOBALS['fakebase']) -{ - if (!$GLOBALS['phpgw']->vfs->file_exists (array ('string' => $path, 'relatives' => array (RELATIVE_NONE)))) - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 does not exist', $path))); - html_break (2); - html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], lang('Go to your home directory')); - html_break (2); - html_link_back (); - 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) -{ - $GLOBALS['phpgw']->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 ($GLOBALS['phpgw']->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 -### - -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 (!$GLOBALS['phpgw']->vfs->file_exists (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) - { - $GLOBALS['phpgw']->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); - } - - $ls_array = $GLOBALS['phpgw']->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 (!$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 - ) -); - -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 $GLOBALS['phpgw']->vfs->read (array ('string' => $fileman[$i])); - $GLOBALS['phpgw']->common->phpgw_exit (); - } -} - -if ($op == 'view' && $file) -{ - $ls_array = $GLOBALS['phpgw']->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 $GLOBALS['phpgw']->vfs->read (array ( - 'string' => $path.'/'.$file, - 'relatives' => array (RELATIVE_NONE) -) - ); - $GLOBALS['phpgw']->common->phpgw_exit (); -} - -if ($op == 'history' && $file) -{ - $journal_array = $GLOBALS['phpgw']->vfs->get_journal (array ( - 'string' => $file, - 'relatives' => array (RELATIVE_ALL) - ) -); - -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_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')); -} - -} - -if ($newfile && $createfile) -{ - if ($badchar = bad_chars ($createfile, True, True)) - { - echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('File names cannot contain "%1"',$badchar), 1))); - html_break (2); - html_link_back (); - html_page_close (); - } - - 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 (); -} - -if ($GLOBALS['phpgw']->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]); - - html_font_set ('4'); - $title = ereg_replace ('_', ' ', $help_array[0]); - $title = ucwords ($title); - html_text ($title); - html_font_end (); - - html_break (2); - - html_font_set ('2'); - html_text ($help_array[1]); - html_font_end (); - } - - $GLOBALS['phpgw']->common->phpgw_exit (); -} - -### -# Start Main Page -### - -html_page_begin (lang('Users').' :: '.$GLOBALS['userinfo']['username']); -html_page_body_begin (HTML_PAGE_BODY_COLOR); - -if ($messages) -{ - html_text ($messages); -} - - -### -# Start Main Table -### - -if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$edit && !$comment_files) -{ - html_table_begin ('100%'); - html_table_row_begin (); - html_table_col_begin ('center', NULL, 'top'); - html_align ('center'); - html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path); - if ($numoffiles || $cwd) - { - while (list ($num, $name) = each ($GLOBALS['settings'])) - { - if ($name) - { - $columns++; - } - } - $columns++; - html_table_begin (); - html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_HEADER_BG_COLOR); - html_table_col_begin ('center', NULL, NULL, NULL, $columns); - 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.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.png', lang('Folder'), 'center'); - } - else - { - html_image ('images/folder.png', lang('Folder'), 'center'); - } - } - else - { - 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.png', lang('Home'), 'right', 0, NULL, 1)); - html_help_link ('home'); - } - - html_table_col_end (); - html_table_row_end (); - html_table_end (); - 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 - ### - - html_table_col_begin (); - html_text (lang('Sort by:') . html_nbsp (1, 1), NULL, NULL, 0); - html_help_link ('sort_by'); - html_table_col_end (); - - reset ($file_attributes); - while (list ($internal, $displayed) = each ($file_attributes)) - { - if ($GLOBALS['settings'][$internal]) - { - html_table_col_begin (); - html_link ($GLOBALS['appname'].'/index.php?path='.$path.'&sortby='.$internal, html_text_bold ($displayed, 1, 0)); - html_help_link (strtolower (ereg_replace (' ', '_', $displayed))); - html_table_col_end (); - } - } - - html_table_col_begin (); - html_table_col_end (); - html_table_row_end (); - - if ($GLOBALS['settings']['dotdot'] && $GLOBALS['settings']['name'] && $path != '/') - { - html_table_row_begin (); - html_table_col_begin (); - html_table_col_end (); - - /* We can assume the next column is the name */ - html_table_col_begin (); - html_image ('images/folder.png', lang('Folder')); - html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, '..'); - html_table_col_end (); - - if ($GLOBALS['settings']['mime_type']) - { - html_table_col_begin (); - html_text (lang('Directory')); - html_table_col_end (); - } - - 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; - } - - html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_BG_COLOR); - - ### - # Checkboxes - ### - - html_table_col_begin ('right'); - - if (!$rename && !$edit_comments && $path != $GLOBALS['fakebase'] && $path != '/') - { - html_form_input ('checkbox', 'fileman['.$i.']', base64_encode ($files['name'])); - } - elseif ($renamethis) - { - html_form_input ('hidden', 'fileman[' . base64_encode ($files['name']) . ']', $files['name'], NULL, NULL, 'checked'); - } - else - { - html_nbsp(); - } - - html_table_col_end (); - - ### - # File name and icon - ### - - if ($GLOBALS['settings']['name']) - { - if ($phpwh_debug) - { - echo 'Setting file name: '.$files['name'].'
'."\n"; - } - - html_table_col_begin (); - - if ($renamethis) - { - if ($files['mime_type'] == 'Directory') - { - html_image ('images/folder.png', lang('Folder')); - } - html_form_input ('text', 'renamefiles[' . base64_encode ($files['name']) . ']', $files['name'], 255); - } - else - { - if ($files['mime_type'] == 'Directory') - { - html_image ('images/folder.png', lang('Folder')); - html_link ($GLOBALS['appname'].'/index.php?path='.$path.$dispsep.$files['name'], $files['name']); - } - else - { - if ($GLOBALS['settings']['viewonserver'] && isset ($GLOBALS['filesdir']) && !$files['link_directory']) - { - $clickview = $GLOBALS['filesdir'].$pwd.'/'.$files['name']; - - if ($phpwh_debug) - { - echo 'Setting clickview = '.$clickview.'
'."\n"; - } - } - else - { - $clickview = $GLOBALS['appname'].'/index.php?op=view&file='.$files['name'].'&path='.$path; - } - - if ($GLOBALS['settings']['viewinnewwin']) - { - $target = '_new'; - } - - html_link ($clickview, $files['name'], 0, 1, 0, $target); - } - } - - html_table_col_end (); - } - - ### - # MIME type - ### - - if ($GLOBALS['settings']['mime_type']) - { - html_table_col_begin (); - html_text ($files['mime_type']); - html_table_col_end (); - } - - ### - # File size - ### - - if ($GLOBALS['settings']['size']) - { - html_table_col_begin (); - - $size = $GLOBALS['phpgw']->vfs->get_size (array ( - 'string' => $files['directory'] . '/' . $files['name'], - 'relatives' => array (RELATIVE_NONE) - ) - ); - - borkb ($size); - - html_table_col_end (); - } - - ### - # 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_text ($files['modified']); - } - html_table_col_end (); - } - - ### - # Owner name - ### - - 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_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.png', 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]; - } - else - { - $usedspace += $files['size']; - } - } - - html_table_end (); - html_break (2); - - if ($path != '/' && $path != $GLOBALS['fakebase']) - { - 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'); - } - } -} - -### -# Display some inputs and info, but not when renaming or editing comments -### - -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); - 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) - && $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']) - { - 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_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_nbsp (3); - - 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 (); - html_table_row_end (); - html_table_end (); - 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; - - html_break (1); - html_text_bold (lang('Preview of %1', $path.'/'.$edit_file)); - html_break (2); - - html_table_begin ('90%'); - html_table_row_begin (); - html_table_col_begin (); - html_text (nl2br ($content)); - html_table_col_end (); - html_table_row_end (); - html_table_end (); - } - elseif ($edit_save) - { - $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 (); - } -} - -/* 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 ($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); - } + written by Pim Snel */ - ### - # 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] && $GLOBALS['phpgw']->vfs->file_exists (array ( - 'string' => $fileman[$j], - 'relatives' => array (RELATIVE_ALL) - )) - ) - { - 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 (); - } -} -} - -### -# Handle File Uploads -### - -elseif ($op == 'upload' && $path != '/' && $path != $GLOBALS['fakebase']) -{ - for ($i = 0; $i != $show_upload_boxes; $i++) - { - if ($badchar = bad_chars ($_FILES['upload_file']['name'][$i], True, True)) - { - echo $GLOBALS['phpgw']->common->error_list (array (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 = $GLOBALS['phpgw']->vfs->ls (array ( - 'string' => $path . '/' . $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => True - ) + $phpgw_flags = Array( + 'currentapp' => 'filemanager', + 'noheader' => True, + 'nonavbar' => True, + 'noappheader' => True, + 'noappfooter' => True, + 'nofooter' => 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]) - ) - ) - ); - - $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]) - ) -) - ); - - html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); - } - } - elseif ($_FILES['upload_file']['name'][$i]) - { - $GLOBALS['phpgw']->vfs->touch (array ( - '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] - ) - ) - ); - - html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $file_size[$i]); -} - } - - html_break (2); - html_link_back (); -} - -### -# Handle Editing comments -### - -elseif ($comment_files) -{ - while (list ($file) = each ($comment_files)) - { - if ($badchar = bad_chars ($comment_files[$file], False, True)) - { - echo $GLOBALS['phpgw']->common->error_list (array (html_text_italic ($file, 1) . html_encode (': ' . lang('Comments cannot contain "%1"', $badchar), 1))); - continue; - } - - $GLOBALS['phpgw']->vfs->set_attributes (array ( - 'string' => $file, - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'comment' => stripslashes ($comment_files[$file]) - ) - ) - ); - - html_text_summary (lang('Updated comment for %1', $path.'/'.$file)); -} - -html_break (2); -html_link_back (); -} - -### -# Handle Renaming Files and Directories -### - -elseif ($renamefiles) -{ - while (list ($from, $to) = each ($renamefiles)) - { - if ($badchar = bad_chars ($to, True, True)) - { - echo $GLOBALS['phpgw']->common->error_list (array (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 (!$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)); - } -} - -html_break (2); -html_link_back (); -} - -### -# Handle Moving Files and Directories -### - -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) -{ - html_break (2); - html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); -} - -html_break (2); -html_link_back (); -} - -### -# Handle Copying of Files and Directories -### - -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) -{ - html_break (2); - html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); -} - -html_break (2); -html_link_back (); -} - -### -# Handle Deleting Files and Directories -### - -elseif ($delete) -{ - for ($i = 0; $i != $numoffiles; $i++) - { - if ($fileman[$i]) - { - if ($GLOBALS['phpgw']->vfs->delete (array ('string' => $fileman[$i]))) - { - 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]))); - } - } - } - - html_break (2); - html_link_back (); -} - -elseif ($newdir && $createdir) -{ - if ($badchar = bad_chars ($createdir, True, True)) - { - echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('Directory names cannot contain "%1"', $badchar), 1))); - html_break (2); - 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'))); - html_break (2); - html_link_back (); - html_page_close (); - } - - $ls_array = $GLOBALS['phpgw']->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']))); - 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 (); - } -} -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_page_close (); - - + $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(); ?>