Changeset 1869


Ignore:
Timestamp:
12/17/09 15:16:25 (14 years ago)
Author:
amuller
Message:

Ticket #597 - Melhoria do FM, Implementação do arquivamento

Location:
sandbox/filemanager
Files:
6 edited

Legend:

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

    r1693 r1869  
    129129                        if ($all) 
    130130                        { 
    131                                 if (preg_match("-([\\/<>\'\"\&])-", $string, $badchars)) 
     131                                if (preg_match("-([\\/<>\|\'\"\&])-", $string, $badchars)) 
    132132                                $rstring = $badchars[1]; 
    133133                        } 
  • sandbox/filemanager/inc/class.vfs_functions.inc.php

    r1865 r1869  
    5353                function vfs_functions() 
    5454                { 
    55                         $this->now = date('Y-m-d'); 
     55                        $this->now = date('Y-m-d H:i:s'); 
    5656 
    5757                        $this->bo = CreateObject('filemanager.bofilemanager'); 
     
    197197                                ) 
    198198                                { 
    199                                         echo "True:".$this->file; 
     199                                        echo "True|".$this->file; 
    200200                                } 
    201201                                else 
     
    244244         
    245245                function delete(){ 
    246                         foreach($this->fileman as $filename) 
    247                         { 
     246                        foreach($this->fileman as $filecode) 
     247                        { 
     248                                $filename = base64_decode($filecode); 
    248249                                if($this->verifyLock($filename,RELATIVE_ALL) && $this->bo->vfs->rm(array( 
    249250                                        'string' => $this->path.'/'.$filename, 
     
    251252                                ))) 
    252253                                { 
    253                                         echo $filename.":"; 
    254                                 } 
    255                                 else 
    256                                 { 
    257                                         echo "False:".$filename; 
     254                                        echo $filename."|"; 
     255                                } 
     256                                else 
     257                                { 
     258                                        echo "False|".$filename; 
    258259                                        return False; 
    259260                                } 
     
    261262                } 
    262263                function archive(){ 
    263                         foreach($this->fileman as $filename) 
    264                         { 
     264                        foreach($this->fileman as $filecode) 
     265                        { 
     266                                $filename = base64_decode($filecode); 
    265267                                if(!$this->verifyLock($filename,RELATIVE_ALL)) 
    266268                                { 
    267                                         echo "locked:".$filename; 
     269                                        echo "locked|".$filename; 
    268270                                        return False; 
    269271                                } 
    270272                                $command .= " ".escapeshellarg($filename); 
    271273                        } 
    272                         $zipFileName=$GLOBALS['phpgw_info']['user']['account_lid'].date("Ymd").".zip"; 
     274                        $zipFileName=$GLOBALS['phpgw_info']['user']['account_lid'].date("Y-m-d,H:i:s").".zip"; 
    273275                        $zipFilePath=ini_get("session.save_path")."/".$zipFileName; 
    274276                        $command = $zipFilePath.$command; 
     
    278280                        } 
    279281 
    280                         exec("cd ".$this->bo->vfs->basedir.$this->path.";".escapeshellcmd("nice -n19 zip -9 ".$command)."; history -c"); 
     282                        exec("cd ".$this->bo->vfs->basedir.$this->path.";".escapeshellcmd("nice -n19 zip -9 ".$command),$output,$return_var); 
     283                        exec("history -c"); // privacy is good, we dont want get passwords! 
     284                        if ($return_var > 1){ 
     285                                echo "False|".$return_var; 
     286                                return false; 
     287                        } 
    281288 
    282289                        $this->bo->vfs->cp(array( 
     
    305312 
    306313                        if ($return_var == 9 || $return_var == 5 || $return_var == 82){ 
    307                                 echo "wpasswd:$command"; 
     314                                echo "wpasswd|"; 
    308315                                return false; 
    309316                        }else if($return_var > 1){ 
    310                                 echo "False:"; 
     317                                echo "False|"; 
    311318                        } 
    312319 
     
    322329                                if($badchar = $this->bo->bad_chars($this->comment, False, True)) 
    323330                                { 
    324                                         echo "False:badchar:".$badchar; 
     331                                        echo "False|badchar|".$badchar; 
    325332                                        return False; 
    326333                                } 
     
    334341                                ))) 
    335342                                { 
    336                                         echo "True:".$this->file; 
     343                                        echo "True|".$this->file; 
    337344                                        return True; 
    338345                                } 
     
    345352                                if($badchar = $this->bo->bad_chars($this->to, True, True)) 
    346353                                { 
    347                                         echo "Error:badchar:".$badchar; 
     354                                        echo "Error|badchar|".$badchar; 
    348355                                        return false; 
    349356                                } 
    350357                                if(ereg("/", $this->to) || ereg("\\\\", $this->to)) 
    351358                                { 
    352                                         echo "Error:slashes"; 
     359                                        echo "Error|slashes"; 
    353360                                        return false; 
    354361                                } 
    355362                                elseif(!$this->verifyLock($this->file,RELATIVE_CURRENT)) 
    356                                         echo "Error:editing"; 
     363                                        echo "Error|editing"; 
    357364                                elseif ($this->bo->vfs->mv(array( 
    358365                                        'from'  => $this->path.'/'.$this->file, 
     
    361368                                ))) 
    362369                                { 
    363                                         echo "True:".$this->file.":".$this->to; 
    364                                 } 
    365                                 else 
    366                                 { 
    367                                         echo "Error:".$this->file.":".$this->to; 
     370                                        echo "True|".$this->file."|".$this->to; 
     371                                } 
     372                                else 
     373                                { 
     374                                        echo "Error|".$this->file."|".$this->to; 
    368375                                } 
    369376                        } 
  • sandbox/filemanager/inc/upload.php

    r1838 r1869  
    1818$current_config = $c->config_data; 
    1919$upload_max_size = $current_config['filemanager_Max_file_size']; 
    20 $path = base64_decode($_POST['path']); 
     20$path = $_POST['path']; 
    2121$show_upload_boxes = count($_FILES['upload_file']['name'])-1; 
    2222 
     
    107107                        if($fileinfo['name'] && $fileinfo['deleteable'] != 'N') 
    108108                        { 
     109                                $_FILES['upload_file']['name'][$i] = date('Ymd-H:i')."-".$_FILES['upload_file']['name'][$i]; 
     110                                $tmp_arr=array( 
     111                                        'from'  => $_FILES['upload_file']['tmp_name'][$i], 
     112                                        'to'    => $_FILES['upload_file']['name'][$i], 
     113                                        'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) 
     114 
     115                                ); 
     116                                $bo->vfs->cp($tmp_arr); 
    109117                                $tmp_arr=array( 
    110118                                        'string'=> $_FILES['upload_file']['name'][$i], 
     
    113121                                                'owner_id' => $bo->userinfo['username'], 
    114122                                                'modifiedby_id' => $bo->userinfo['username'], 
    115                                                 'modified' => $now, 
    116123                                                'size' => $_FILES['upload_file']['size'][$i], 
    117124                                                'mime_type' => $_FILES['upload_file']['type'][$i], 
     
    122129                                $bo->vfs->set_attributes($tmp_arr); 
    123130 
    124                                 $tmp_arr=array( 
    125                                         'from'  => $_FILES['upload_file']['tmp_name'][$i], 
    126                                         'to'    => lang('new')."_".$_FILES['upload_file']['name'][$i], 
    127                                         'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) 
    128                                 ); 
    129                                 $bo->vfs->cp($tmp_arr); 
     131                                $return[] = lang("There is a file %1, that was not replaced",$_FILES['upload_file']['name'][$i]); 
    130132                        } 
    131133                        else 
    132134                        { 
    133                  
     135 
    134136                                if ($bo->vfs->cp(array( 
    135137                                        'from'=> $_FILES['upload_file']['tmp_name'][$i], 
     
    142144                                                'relatives'     => array(RELATIVE_ALL), 
    143145                                                'attributes'=> array( 
    144                                                 'mime_type' => $_FILES['upload_file']['type'][$i], 
    145                                                 'comment' => stripslashes($_POST['upload_comment'][$i]) 
    146                                         ) 
    147                                 )); 
    148                                         if (!(strpos(strtoupper($_FILES['upload_file']['type'][$i]),'IMAGE') === FALSE)) 
    149                                         { 
    150                                                 $content = create_summaryImage($_FILES['upload_file']['tmp_name'][$i]); 
    151                                                 if ($content){ 
    152                                                         $bo->vfs->set_summary(array( 
    153                                                         'string'=> $_FILES['upload_file']['name'][$i], 
    154                                                         'relatives' => array(RELATIVE_ALL), 
    155                                                         'summary'=> $content 
    156                                                         )); 
    157                                                 } 
    158  
    159                                         } 
     146                                                        'mime_type' => $_FILES['upload_file']['type'][$i], 
     147                                                        'comment' => stripslashes($_POST['upload_comment'][$i]) 
     148                                                ) 
     149                                        )); 
    160150                                } 
    161151                                else{ 
     
    177167                                'relatives'     => array(RELATIVE_ALL), 
    178168                                'attributes'=> array( 
    179                                 'mime_type' => $_FILES['upload_file']['type'][$i], 
    180                                 'comment' => stripslashes($_POST['upload_comment'][$i]) 
     169                                        'mime_type' => $_FILES['upload_file']['type'][$i], 
     170                                        'comment' => stripslashes($_POST['upload_comment'][$i]) 
    181171                                ) 
    182172                        )); 
    183173 
    184174                } 
     175 
     176                if (!(strpos(strtoupper($_FILES['upload_file']['type'][$i]),'IMAGE') === FALSE)) 
     177                { 
     178                        $content = create_summaryImage($_FILES['upload_file']['tmp_name'][$i]); 
     179                        if ($content){ 
     180                                $bo->vfs->set_summary(array( 
     181                                        'string'=> $_FILES['upload_file']['name'][$i], 
     182                                        'relatives' => array(RELATIVE_ALL), 
     183                                        'summary'=> $content 
     184                                )); 
     185                        } 
     186 
     187                } 
    185188        } 
    186         if (count($return) > 0) 
     189if (count($return) > 0) 
    187190                $_SESSION['response'] = serialize($return); 
    188191        else 
  • sandbox/filemanager/js/common_functions.js

    r1865 r1869  
    160160        if (el.value == oldValue) return; 
    161161        var filename = base64_encode(el.id); 
    162         cExecute('./index.php?menuaction=filemanager.vfs_functions.editComment&file='+filename+'&comment='+base64_encode(el.value),updateComment); 
     162        cExecute('./index.php?menuaction=filemanager.vfs_functions.editComment&file='+filename+'&comment='+base64_encode(el.value),handler.updateComment); 
    163163} 
    164164 
     
    168168} 
    169169 
    170 function updateComment(data) { 
    171         var returnVal = data.split(':'); 
    172         if (data.indexOf("True") == 0){ 
    173                 write_msg(get_lang('Updated comment for %1',returnVal[1])); 
    174         } 
    175         else 
    176         { 
    177                 if (returnVal[1] == "badchar") 
    178                         write_error(get_lang('Comments cannot contain "%1"',returnVal[2])); 
    179                 else 
    180                         write_error(get_lang('You have no permission to access this file')); 
    181         } 
    182  
    183 } 
     170 
    184171function EditColumns(param){ 
    185172        if (param == 'close') 
  • sandbox/filemanager/js/draw_api.js

    r1865 r1869  
    459459                                if (files[i].checked){ 
    460460                                        one_checked = true; 
    461                                         filesUrl += "&fileman["+j+"]="+files[i].value; 
     461                                        filesUrl += "&fileman["+j+"]="+base64_encode(files[i].value); 
    462462                                        j++; 
    463463                                } 
     
    479479                                if (files[i].checked){ 
    480480                                        one_checked = true; 
    481                                         filesUrl += "&fileman["+j+"]="+files[i].value; 
     481                                        filesUrl += "&fileman["+j+"]="+base64_encode(files[i].value); 
    482482                                        j++; 
    483483                                } 
  • sandbox/filemanager/js/handler.js

    r1865 r1869  
    22} 
    33handler.prototype.del = function(data){ 
    4         var returnVal = data.split(':'); 
     4        var returnVal = data.split('|'); 
    55        var deletedFiles = ""; 
    66        for (i=0; i < returnVal.length; i++) 
     
    1616                                pai.parentNode.removeChild(pai); 
    1717                        } 
     18                        if (i > 3) //to avoid big message 
     19                        { 
     20                                deletedFiles = "  " +returnVal.length + " " +get_lang("files"); 
     21                                break; 
     22                        } 
    1823                } 
    1924                write_msg(get_lang('Deleted %1',deletedFiles.substr(2))); 
     
    2631        } 
    2732        else 
    28                 var returnVal = data.split(':'); 
     33                var returnVal = data.split('|'); 
    2934        if ( returnVal[0] == "True" ){ 
    3035                if (returnVal[1] != returnVal[2]) write_msg(get_lang('Renamed %1 to %2',returnVal[1],returnVal[2])); 
     
    4449        else 
    4550        { 
    46                 if (returnVal[1] == "badchar") 
    47                         write_error(get_lang('File names cannot contain "%1"',returnVal[2])); 
    48                 else 
    49                         if (returnVal[1] == "slashes") 
    50                                 write_error(get_lang('File names cannot contain \\ or /')); 
    51                         if (returnVal[1] == "editing") 
    52                                 write_error(get_lang('This file is being edited right now')); 
    53                         else 
    54                                 write_error(get_lang('Could not rename %1 to %2', returnVal[1], returnVal[2])); 
     51                if (returnVal[1] == "badchar") 
     52                        write_error(get_lang('File names cannot contain "%1"',returnVal[2])); 
     53                else if (returnVal[1] == "slashes") 
     54                        write_error(get_lang('File names cannot contain \\ or /')); 
     55                else if (returnVal[1] == "editing") 
     56                        write_error(get_lang('This file is being edited right now')); 
     57                else 
     58                        write_error(get_lang('Could not rename %1 to %2', returnVal[1], returnVal[2])); 
    5559        } 
    5660 
     
    6973handler.prototype.restricted = function(data){ 
    7074        if (data.indexOf("True") == 0){ 
    71                 returnVal = data.split(':'); 
     75                returnVal = data.split('|'); 
    7276                var img_lock = document.getElementById('restrict_'+returnVal[1]); 
    7377                if (img_lock.src.indexOf('button_unlock') > 0) 
     
    8690} 
    8791handler.prototype.archive = function(data) { 
    88         returnVal = data.split(':'); 
     92        returnVal = data.split('|'); 
    8993        if (returnVal[0] == 'False') 
    9094        { 
     
    102106 
    103107} 
     108handler.prototype.updateComment = function (data) { 
     109        var returnVal = data.split('|'); 
     110        if (data.indexOf("True") == 0) 
     111        { 
     112                write_msg(get_lang('Updated comment for %1',returnVal[1])); 
     113        } 
     114        else 
     115        { 
     116                if (returnVal[1] == "badchar") 
     117                        write_error(get_lang('Comments cannot contain "%1"',returnVal[2])); 
     118                else 
     119                        write_error(get_lang('You have no permission to access this file')); 
     120        } 
     121 
     122} 
    104123 
    105124var handler = new handler(); 
Note: See TracChangeset for help on using the changeset viewer.