'filemanager', 'nonavbar' => true, 'noheader' => true ); } require_once '../../header.inc.php'; $bo = CreateObject('filemanager.bofilemanager'); $c = CreateObject('phpgwapi.config','filemanager'); $c->read_repository(); $current_config = $c->config_data; $upload_max_size = $current_config['filemanager_Max_file_size']; $path = base64_decode($_POST['path']); $show_upload_boxes = $_POST['show_upload_boxes']; if($path != '/') for($i = 0; $i != $show_upload_boxes; $i++) { if($badchar = $bo->bad_chars($_FILES['upload_file']['name'][$i], True, True)) { $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Error:').lang('File names cannot contain "%1"', $badchar); continue; } # Check to see if the file exists in the database, and get its info at the same time $ls_array = $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') { $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Error:').lang('Cannot replace %1 because it is a directory', $fileinfo['name']); continue; } } if ($_FILES['upload_file']['size'][$i] > ($upload_max_size*1024*1024)) { $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('The size of %1 has exceded the limit: %2', $_FILES['upload_file']['name'][$i], $upload_max_size); continue; } else if(strlen($current_config['filemanager_antivirus_command']) > 0) { $command = "nice -n19 ".$current_config['filemanager_antivirus_command']." ".$_FILES['upload_file']['tmp_name'][$i]; exec("bash -c ".escapeshellcmd(escapeshellarg($command)),$output,$return); if ($return == 1) { $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Error:').lang('The file %1 sent was considered infected',$_FILES['upload_file']['name'][$i]); continue; } } if($_FILES['upload_file']['size'][$i] > 0) { if($fileinfo['name'] && $fileinfo['deleteable'] != 'N') { $tmp_arr=array( 'string'=> $_FILES['upload_file']['name'][$i], 'relatives' => array(RELATIVE_ALL), 'attributes' => array( 'owner_id' => $bo->userinfo['username'], 'modifiedby_id' => $bo->userinfo['username'], 'modified' => $now, 'size' => $_FILES['upload_file']['size'][$i], 'mime_type' => $_FILES['upload_file']['type'][$i], 'deleteable' => 'Y', 'comment' => stripslashes($_POST['upload_comment'][$i]) ) ); $bo->vfs->set_attributes($tmp_arr); $tmp_arr=array( 'from' => $_FILES['upload_file']['tmp_name'][$i], 'to' => lang('new')."_".$_FILES['upload_file']['name'][$i], 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) ); $bo->vfs->cp($tmp_arr); $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Created new %1', $_FILES['upload_file']['name'][$i])."\n"; } else { $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) )); $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($_POST['upload_comment'][$i]) ) )); $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Created %1,%2', $_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i])."\n"; } } elseif($_FILES['upload_file']['name'][$i]) { $bo->vfs->touch(array( 'string'=> $_FILES['upload_file']['name'][$i], 'relatives' => array(RELATIVE_ALL) )); $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($_POST['upload_comment'][$i]) ) )); $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Created %1,%2', $_FILES['upload_file']['name'][$i], $file_size[$i])."\n"; } } ?>