Ignore:
Timestamp:
11/20/09 15:17:35 (14 years ago)
Author:
amuller
Message:

Ticket #597 - melhorias no modulo gerenciador de arquivos para arquivos grandes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/filemanager/inc/class.uifilemanager.inc.php

    r1678 r1693  
    2828                        'edit' => True, 
    2929                        'fileModels'=>True, 
     30                        'getReturnExecuteForm' => True, 
    3031                        'uploadModel'=>True 
    3132                ); 
     
    7071                var $edit_save_done_x; 
    7172                var $edit_cancel_x; 
    72                 var $comment_files; 
    7373                var $upload_x; 
    74                 var $uploadprocess; 
    7574 
    7675                // this ones must be checked thorougly; 
     
    125124                                'sortby'        => array('sortby' => ''), 
    126125                                'messages'      => array('messages'     => ''), 
    127                                 'comment_files' => array('comment_files' => ''), 
    128126                                'show_upload_boxes'     => array('show_upload_boxes' => '') 
    129127                        ); 
     
    163161                        $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']); 
    164162                        $pref->read_repository(); 
    165                         //                      $GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); 
     163                        //$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); 
    166164                        $pref->save_repository(True); 
    167165                        $pref_array = $pref->read_repository(); 
     
    246244                                        // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content 
    247245                                } 
    248                         } 
    249                          
     246 
     247 
     248                        } 
    250249                         
    251250                } 
     
    526525                                $this->createdir(); 
    527526                        } 
    528                         elseif($this->uploadprocess) 
    529                         { 
    530                                 $this->fileUpload(); 
    531                         } 
    532527                        elseif($this->upload_x || $this->show_upload_boxes) 
    533528                        { 
     
    739734                                                        $icon=$this->mime_icon($files['mime_type']); 
    740735                                                        $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)); 
    741737 
    742738                                                        $col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a>&nbsp;'. 
     
    11031099 
    11041100 
    1105                 // move to bo 
    1106                 # Handle File Uploads 
    1107                 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 time 
    1121                                         $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'       => True 
    1126                                         )); 
    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                                          else 
    1142                                                  $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                                                 else 
    1191                                                 { 
    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                 } 
    12351101                # Handle Moving Files and Directories 
    12361102                function moveTo() 
     
    13591225                        } 
    13601226                } 
     1227                function getReturnExecuteForm(){ 
     1228                        $response = $_SESSION['response']; 
     1229                        $_SESSION['response'] = null; 
     1230                        echo $response; 
     1231                        return; 
     1232                } 
    13611233                function showUploadboxes() 
    13621234                { 
     
    13681240                        if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) 
    13691241                        { 
    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'); 
    13711245                                $vars[path]=$this->path; 
    13721246                                $vars[lang_file]=lang('File'); 
     
    16531527                                        'nofiles'       => True 
    16541528                                )); 
    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; 
    16561534                                if($ls_array[0]['mime_type']) 
    16571535                                { 
     
    16661544                                if(in_array($mime_type,$viewable)) 
    16671545                                { 
    1668                                          
     1546                                        /*Note: if you put application/octet-stream you force download */ 
    16691547                                        header('Content-type: ' . $mime_type); 
    16701548                                        header('Content-disposition: filename="' . $this->file . '"');//FIXME 
     
    16751553                                        $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type);//FIXME 
    16761554                                } 
     1555  
     1556 
    16771557                                echo $this->bo->vfs->read(array( 
    16781558                                        'string'        => $this->path.'/'.$this->file,//FIXME 
Note: See TracChangeset for help on using the changeset viewer.