Changeset 1693 for sandbox/filemanager/inc/class.uifilemanager.inc.php
- Timestamp:
- 11/20/09 15:17:35 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/filemanager/inc/class.uifilemanager.inc.php
r1678 r1693 28 28 'edit' => True, 29 29 'fileModels'=>True, 30 'getReturnExecuteForm' => True, 30 31 'uploadModel'=>True 31 32 ); … … 70 71 var $edit_save_done_x; 71 72 var $edit_cancel_x; 72 var $comment_files;73 73 var $upload_x; 74 var $uploadprocess;75 74 76 75 // this ones must be checked thorougly; … … 125 124 'sortby' => array('sortby' => ''), 126 125 'messages' => array('messages' => ''), 127 'comment_files' => array('comment_files' => ''),128 126 'show_upload_boxes' => array('show_upload_boxes' => '') 129 127 ); … … 163 161 $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']); 164 162 $pref->read_repository(); 165 // 163 //$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); 166 164 $pref->save_repository(True); 167 165 $pref_array = $pref->read_repository(); … … 246 244 // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content 247 245 } 248 } 249 246 247 248 } 250 249 251 250 } … … 526 525 $this->createdir(); 527 526 } 528 elseif($this->uploadprocess)529 {530 $this->fileUpload();531 }532 527 elseif($this->upload_x || $this->show_upload_boxes) 533 528 { … … 739 734 $icon=$this->mime_icon($files['mime_type']); 740 735 $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.view','file='.$files['name'].'&path='.$this->path); 736 //$link=$this->encode_href('inc/download.php','file='.base64_encode($files['name']).'&path='.base64_encode($this->path)); 741 737 742 738 $col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a> '. … … 1103 1099 1104 1100 1105 // move to bo1106 # Handle File Uploads1107 function fileUpload()1108 {1109 if($this->path != '/' && $this->path != $this->bo->fakebase)1110 {1111 for($i = 0; $i != $this->show_upload_boxes; $i++)1112 {1113 if($badchar = $this->bo->bad_chars($_FILES['upload_file']['name'][$i], True, True))1114 {1115 $this->messages[]=lang('Error:').lang('File names cannot contain "%1"', $badchar);1116 1117 continue;1118 }1119 1120 # Check to see if the file exists in the database, and get its info at the same time1121 $ls_array = $this->bo->vfs->ls(array(1122 'string'=> $this->path . '/' . $_FILES['upload_file']['name'][$i],1123 'relatives' => array(RELATIVE_NONE),1124 'checksubdirs' => False,1125 'nofiles' => True1126 ));1127 1128 $fileinfo = $ls_array[0];1129 1130 if($fileinfo['name'])1131 {1132 if($fileinfo['mime_type'] == 'Directory')1133 {1134 $this->messages[]= lang('Error:').lang('Cannot replace %1 because it is a directory', $fileinfo['name']);1135 continue;1136 }1137 }1138 $max_size = $this->current_config['filemanager_Max_file_size'];1139 if (! $max_size)1140 $max_size = ini_get('upload_max_filesize');1141 else1142 $max_size .= "M";1143 1144 $upload_max_filesize = str_replace("M","",$max_size) * 1024 * 1024;1145 1146 if ($_FILES['upload_file']['size'][$i] > $upload_max_filesize)1147 {1148 $this->messages[]=lang('The size of %1 has exceded the limit: %2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $max_size);1149 }1150 else if(strlen($this->current_config['filemanager_antivirus_command']) > 0)1151 {1152 $command = "nice -n19 ".$this->current_config['filemanager_antivirus_command']." ".$_FILES['upload_file']['tmp_name'][$i];1153 exec("bash -c ".escapeshellcmd(escapeshellarg($command)),$output,$return);1154 if ($return == 1)1155 {1156 $this->messages[]=lang('Error:').lang('The file sent was considered infected');1157 $this->readFilesInfo();1158 $this->filelisting();1159 return true;1160 }1161 }1162 if($_FILES['upload_file']['size'][$i] > 0)1163 {1164 if($fileinfo['name'] && $fileinfo['deleteable'] != 'N')1165 {1166 $tmp_arr=array(1167 'string'=> $_FILES['upload_file']['name'][$i],1168 'relatives' => array(RELATIVE_ALL),1169 'attributes' => array(1170 'owner_id' => $this->bo->userinfo['username'],1171 'modifiedby_id' => $this->bo->userinfo['username'],1172 'modified' => $this->now,1173 'size' => $_FILES['upload_file']['size'][$i],1174 'mime_type' => $_FILES['upload_file']['type'][$i],1175 'deleteable' => 'Y',1176 'comment' => stripslashes($_POST['upload_comment'][$i])1177 )1178 );1179 $this->bo->vfs->set_attributes($tmp_arr);1180 1181 $tmp_arr=array(1182 'from' => $_FILES['upload_file']['tmp_name'][$i],1183 'to' => lang('new')."_".$_FILES['upload_file']['name'][$i],1184 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)1185 );1186 $this->bo->vfs->cp($tmp_arr);1187 1188 $this->messages[]=lang('Created new %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]);1189 }1190 else1191 {1192 1193 $this->bo->vfs->cp(array(1194 'from'=> $_FILES['upload_file']['tmp_name'][$i],1195 'to'=> $_FILES['upload_file']['name'][$i],1196 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)1197 ));1198 1199 $this->bo->vfs->set_attributes(array(1200 'string'=> $_FILES['upload_file']['name'][$i],1201 'relatives' => array(RELATIVE_ALL),1202 'attributes'=> array(1203 'mime_type' => $_FILES['upload_file']['type'][$i],1204 'comment' => stripslashes($_POST['upload_comment'][$i])1205 )1206 ));1207 1208 $this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i]);1209 }1210 }1211 elseif($_FILES['upload_file']['name'][$i])1212 {1213 $this->bo->vfs->touch(array(1214 'string'=> $_FILES['upload_file']['name'][$i],1215 'relatives' => array(RELATIVE_ALL)1216 ));1217 1218 $this->bo->vfs->set_attributes(array(1219 'string'=> $_FILES['upload_file']['name'][$i],1220 'relatives' => array(RELATIVE_ALL),1221 'attributes'=> array(1222 'mime_type' => $_FILES['upload_file']['type'][$i],1223 'comment' => stripslashes($_POST['upload_comment'][$i])1224 )1225 ));1226 1227 $this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $file_size[$i]);1228 }1229 }1230 1231 $this->readFilesInfo();1232 $this->filelisting();1233 }1234 }1235 1101 # Handle Moving Files and Directories 1236 1102 function moveTo() … … 1359 1225 } 1360 1226 } 1227 function getReturnExecuteForm(){ 1228 $response = $_SESSION['response']; 1229 $_SESSION['response'] = null; 1230 echo $response; 1231 return; 1232 } 1361 1233 function showUploadboxes() 1362 1234 { … … 1368 1240 if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) 1369 1241 { 1370 $vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index'); 1242 $vars[max_size]=lang('Note: Uploaded is limited to %1MB',($this->current_config['filemanager_Max_file_size'])); 1243 $vars[form_action]=$GLOBALS[phpgw]->link('/filemanager/inc/upload.php'); 1244 //$vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index'); 1371 1245 $vars[path]=$this->path; 1372 1246 $vars[lang_file]=lang('File'); … … 1653 1527 'nofiles' => True 1654 1528 )); 1655 1529 if ($ls_array[0]['size'] > 4194304){ 1530 header('Location:'.$this->encode_href('inc/download.php','file='.base64_encode($this->file).'&path='.base64_encode($this->path))); 1531 return; 1532 } 1533 $_SESSION['debug'][] = $ls_array; 1656 1534 if($ls_array[0]['mime_type']) 1657 1535 { … … 1666 1544 if(in_array($mime_type,$viewable)) 1667 1545 { 1668 1546 /*Note: if you put application/octet-stream you force download */ 1669 1547 header('Content-type: ' . $mime_type); 1670 1548 header('Content-disposition: filename="' . $this->file . '"');//FIXME … … 1675 1553 $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type);//FIXME 1676 1554 } 1555 1556 1677 1557 echo $this->bo->vfs->read(array( 1678 1558 'string' => $this->path.'/'.$this->file,//FIXME
Note: See TracChangeset
for help on using the changeset viewer.