Changeset 1693


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

Files:
6 added
8 edited

Legend:

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

    r1506 r1693  
    110110                        if ($size < 1024) 
    111111                        $rstring = $left . $size . 'B' . $right; 
    112                         else 
    113                         $rstring = $left . round($size/1024) . 'KB' . $right; 
     112                        else if ($size < 1048576) 
     113                                $rstring = $left . round($size/1024) . 'KB' . $right; 
     114                        else if ($size < 1073741824) 
     115                                $rstring = $left . round($size/1024/1024) . 'MB' . $right; 
     116                        else 
     117                                $rstring = $left . round($size/1024/1024/1024) . 'GB' . $right; 
     118 
    114119 
    115120                        return ($this->eor ($rstring, $return)); 
  • 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 
  • sandbox/filemanager/inc/class.vfs_functions.inc.php

    r1654 r1693  
    216216                function download() 
    217217                { 
    218                         for($i = 0; $i != $this->numoffiles; $i++) 
    219                         { 
    220                                 if(!$this->fileman[$i]) 
    221                                 { 
    222                                         continue; 
    223                                 } 
    224  
    225                                 $download_browser = CreateObject('phpgwapi.browser'); 
    226                                 $download_browser->content_header($this->fileman[$i]); 
    227                                 echo $this->bo->vfs->read(array('string' => $this->fileman[$i])); 
     218                        if($this->file) 
     219                        { 
     220                                //$GLOBALS['phpgw']->browser->content_header($this->file); 
     221                                header ("Content-Type: application/octet-stream"); 
     222                                header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); 
     223                                header("Pragma: public"); 
     224                                header("Expires: 0"); 
     225                                header ("Content-Disposition: attachment; filename=\"". addslashes($this->file)."\""); 
     226                                echo $this->bo->vfs->read(array('string' => $this->file)); 
    228227                                $GLOBALS['phpgw']->common->phpgw_exit(); 
    229228                        } 
  • sandbox/filemanager/js/connector.js

    r1590 r1693  
    9696var connector = new cConnector(); 
    9797 
    98 function cExecuteForm(url, form, handler){ 
     98function cExecuteForm(form, handler){ 
    9999        connector.showProgressBar(); 
    100         var iframe_el = document.getElementById('nullFrame'); 
    101         if (!iframe_el) 
    102         { 
    103                 iframe_el = document.createElement('IFRAME'); 
    104                 iframe_el.id = "nullFrame"; 
     100        if(! (divUpload = document.getElementById('divUpload'))) { 
     101                divUpload               = document.createElement('DIV');                 
     102                divUpload.id    = 'divUpload'; 
     103                document.body.appendChild(divUpload); 
    105104        } 
    106         iframe_el.style.width = "0px"; 
    107         iframe_el.style.height = "0px"; 
    108         iframe_el.style.border = '0px'; 
    109         iframe_el.name = "nullFrame"; 
    110         iframe = document.body.appendChild(iframe_el); 
    111         iframe_el.setAttribute('onload', 'javascript:'+handler+'()'); 
    112         form.target = "nullFrame"; 
    113         form.submit(); 
     105 
     106        handlerExecuteForm = handler; 
     107        var form_handler = function (data){ 
     108                handlerExecuteForm(data); 
     109                handlerExecuteForm = null; 
     110        } 
     111        divUpload.innerHTML= "<iframe onload=\"connector.hideProgressBar();cExecute('./index.php/index.php?menuaction=filemanager.uifilemanager.getReturnExecuteForm',"+form_handler+");\"  style='display:none;width:0;height:0;' name='uploadFile'></iframe>"; 
     112        form.target ="uploadFile"; 
     113        form.submit(); 
    114114} 
    115115 
  • sandbox/filemanager/js/uploadForm.js

    r1627 r1693  
    1111        document.getElementById('show_upload_boxes').value +=1; 
    1212} 
     13 
     14function sendFiles(){ 
     15                cExecuteForm(document.getElementById('form_up'),handler_upload); 
     16                document.getElementById('button_up').style.visibility = "hidden"; 
     17                var line = document.getElementById('uploadOption'); 
     18                line.parentNode.innerHTML = "<img src='./filemanager/templates/default/images/progress.gif'>"; 
     19} 
     20 
     21function handler_upload(data){ 
     22        alert(data); 
     23        window.location = "/index.php?menuaction=filemanager.uifilemanager.index"; 
     24} 
  • sandbox/filemanager/setup/phpgw_pt-br.lang

    r1678 r1693  
    2727created %1      filemanager     pt-br   Criado %1 
    2828You have no permission to access this file      filemanager     pt-br   Você não tem permissão para acessar este arquivo 
    29 The file sent was considered infected   filemanager     pt-br   O arquivo enviado foi considerado infectado por vírus 
     29The file %1 sent was considered infected        filemanager     pt-bt   o arquivo (%1) enviado foi considerado infectado por vírus 
     30Note: Uploaded is limited to %1MB       filemanager     pt-br   Nota: O tamanho máximo de envio é limitado a %1MB 
    3031no comments     filemanager     pt-br   sem comentários 
    3132created %1,%2   filemanager     pt-br   Criado %1, %2 
  • sandbox/filemanager/templates/default/upload.tpl

    r1627 r1693  
    11<!-- BEGIN upload_header --> 
    22<script src="filemanager/js/uploadForm.js" type="text/javascript"></script> 
    3 <form method="post" action="{form_action}" enctype="multipart/form-data"> 
     3<form id="form_up" method="post" action="{form_action}" enctype="multipart/form-data"> 
    44<div> 
    55<table cellspacing="0" cellpadding="2"> 
     
    2121 
    2222</tbody></table> 
     23<span>{max_size}</span> 
     24<br> 
    2325<input value="true" name="uploadprocess" type="hidden"> 
    2426<input value="{path}" name="path" type="hidden"> 
    2527<input value="{num_upload_boxes}" name="show_upload_boxes" id="show_upload_boxes" type="hidden"> 
    26 <input value="{lang_upload}" name="upload_files" type="submit"> 
     28<input value="{lang_upload}" id="button_up" type="button" onclick="sendFiles();"> 
    2729</div> 
    2830</form> 
  • trunk/phpgwapi/inc/class.vfs_sql.inc.php

    r1648 r1693  
    23912391                                return False; 
    23922392                        } 
    2393                         // INSERT INTO phpgw_vfs_quota values('/home/amuller',200); 
    2394                         // 
    23952393                        return $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_vfs_quota VALUES ('".$data['string']."',".$data['new_quota'].");", __LINE__,__FILE__); 
    23962394                } 
Note: See TracChangeset for help on using the changeset viewer.