[1693] | 1 | <?php |
---|
| 2 | require_once '../../header.session.inc.php'; |
---|
| 3 | |
---|
| 4 | /* This single file is used to increase upload_max_filesize and post_max_size using .htaccess*/ |
---|
| 5 | if(!isset($GLOBALS['phpgw_info'])){ |
---|
| 6 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 7 | 'currentapp' => 'filemanager', |
---|
| 8 | 'nonavbar' => true, |
---|
| 9 | 'noheader' => true |
---|
| 10 | ); |
---|
| 11 | } |
---|
| 12 | require_once '../../header.inc.php'; |
---|
| 13 | |
---|
| 14 | $bo = CreateObject('filemanager.bofilemanager'); |
---|
| 15 | |
---|
| 16 | $c = CreateObject('phpgwapi.config','filemanager'); |
---|
| 17 | $c->read_repository(); |
---|
| 18 | $current_config = $c->config_data; |
---|
| 19 | $upload_max_size = $current_config['filemanager_Max_file_size']; |
---|
| 20 | $path = base64_decode($_POST['path']); |
---|
| 21 | $show_upload_boxes = $_POST['show_upload_boxes']; |
---|
| 22 | |
---|
| 23 | if($path != '/') |
---|
| 24 | for($i = 0; $i != $show_upload_boxes; $i++) |
---|
| 25 | { |
---|
| 26 | if($badchar = $bo->bad_chars($_FILES['upload_file']['name'][$i], True, True)) |
---|
| 27 | { |
---|
[1694] | 28 | $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Error:').lang('File names cannot contain "%1"', $badchar); |
---|
| 29 | continue; |
---|
[1693] | 30 | } |
---|
| 31 | |
---|
| 32 | # Check to see if the file exists in the database, and get its info at the same time |
---|
| 33 | $ls_array = $bo->vfs->ls(array( |
---|
| 34 | 'string'=> $path . '/' . $_FILES['upload_file']['name'][$i], |
---|
| 35 | 'relatives' => array(RELATIVE_NONE), |
---|
| 36 | 'checksubdirs' => False, |
---|
| 37 | 'nofiles' => True |
---|
| 38 | )); |
---|
| 39 | |
---|
| 40 | $fileinfo = $ls_array[0]; |
---|
| 41 | |
---|
| 42 | if($fileinfo['name']) |
---|
| 43 | { |
---|
| 44 | if($fileinfo['mime_type'] == 'Directory') |
---|
| 45 | { |
---|
[1694] | 46 | $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Error:').lang('Cannot replace %1 because it is a directory', $fileinfo['name']); |
---|
| 47 | continue; |
---|
[1693] | 48 | } |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | if ($_FILES['upload_file']['size'][$i] > ($upload_max_size*1024*1024)) |
---|
| 52 | { |
---|
[1694] | 53 | $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('The size of %1 has exceded the limit: %2', $_FILES['upload_file']['name'][$i], $upload_max_size); |
---|
| 54 | continue; |
---|
[1693] | 55 | } |
---|
| 56 | else if(strlen($current_config['filemanager_antivirus_command']) > 0) |
---|
| 57 | { |
---|
| 58 | $command = "nice -n19 ".$current_config['filemanager_antivirus_command']." ".$_FILES['upload_file']['tmp_name'][$i]; |
---|
| 59 | exec("bash -c ".escapeshellcmd(escapeshellarg($command)),$output,$return); |
---|
| 60 | if ($return == 1) |
---|
| 61 | { |
---|
[1694] | 62 | $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Error:').lang('The file %1 sent was considered infected',$_FILES['upload_file']['name'][$i]); |
---|
| 63 | continue; |
---|
[1693] | 64 | } |
---|
| 65 | } |
---|
| 66 | if($_FILES['upload_file']['size'][$i] > 0) |
---|
| 67 | { |
---|
| 68 | if($fileinfo['name'] && $fileinfo['deleteable'] != 'N') |
---|
| 69 | { |
---|
| 70 | $tmp_arr=array( |
---|
| 71 | 'string'=> $_FILES['upload_file']['name'][$i], |
---|
| 72 | 'relatives' => array(RELATIVE_ALL), |
---|
| 73 | 'attributes' => array( |
---|
| 74 | 'owner_id' => $bo->userinfo['username'], |
---|
| 75 | 'modifiedby_id' => $bo->userinfo['username'], |
---|
| 76 | 'modified' => $now, |
---|
| 77 | 'size' => $_FILES['upload_file']['size'][$i], |
---|
| 78 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
| 79 | 'deleteable' => 'Y', |
---|
| 80 | 'comment' => stripslashes($_POST['upload_comment'][$i]) |
---|
| 81 | ) |
---|
| 82 | ); |
---|
| 83 | $bo->vfs->set_attributes($tmp_arr); |
---|
| 84 | |
---|
| 85 | $tmp_arr=array( |
---|
| 86 | 'from' => $_FILES['upload_file']['tmp_name'][$i], |
---|
| 87 | 'to' => lang('new')."_".$_FILES['upload_file']['name'][$i], |
---|
| 88 | 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) |
---|
| 89 | ); |
---|
| 90 | $bo->vfs->cp($tmp_arr); |
---|
| 91 | |
---|
[1694] | 92 | $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Created new %1', $_FILES['upload_file']['name'][$i])."\n"; |
---|
[1693] | 93 | } |
---|
| 94 | else |
---|
| 95 | { |
---|
| 96 | |
---|
| 97 | $bo->vfs->cp(array( |
---|
| 98 | 'from'=> $_FILES['upload_file']['tmp_name'][$i], |
---|
| 99 | 'to'=> $_FILES['upload_file']['name'][$i], |
---|
| 100 | 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) |
---|
| 101 | )); |
---|
| 102 | |
---|
| 103 | $bo->vfs->set_attributes(array( |
---|
| 104 | 'string'=> $_FILES['upload_file']['name'][$i], |
---|
| 105 | 'relatives' => array(RELATIVE_ALL), |
---|
| 106 | 'attributes'=> array( |
---|
| 107 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
| 108 | 'comment' => stripslashes($_POST['upload_comment'][$i]) |
---|
| 109 | ) |
---|
| 110 | )); |
---|
| 111 | |
---|
[1694] | 112 | $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Created %1,%2', $_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i])."\n"; |
---|
[1693] | 113 | } |
---|
| 114 | } |
---|
| 115 | elseif($_FILES['upload_file']['name'][$i]) |
---|
| 116 | { |
---|
| 117 | $bo->vfs->touch(array( |
---|
| 118 | 'string'=> $_FILES['upload_file']['name'][$i], |
---|
| 119 | 'relatives' => array(RELATIVE_ALL) |
---|
| 120 | )); |
---|
| 121 | |
---|
| 122 | $bo->vfs->set_attributes(array( |
---|
| 123 | 'string'=> $_FILES['upload_file']['name'][$i], |
---|
| 124 | 'relatives' => array(RELATIVE_ALL), |
---|
| 125 | 'attributes'=> array( |
---|
| 126 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
| 127 | 'comment' => stripslashes($_POST['upload_comment'][$i]) |
---|
| 128 | ) |
---|
| 129 | )); |
---|
| 130 | |
---|
[1694] | 131 | $_SESSION['phpgw_info']['filemanager']['user']['messages'][] = lang('Created %1,%2', $_FILES['upload_file']['name'][$i], $file_size[$i])."\n"; |
---|
| 132 | |
---|
[1693] | 133 | } |
---|
| 134 | } |
---|
| 135 | ?> |
---|