Changeset 1068


Ignore:
Timestamp:
12/10/09 20:29:47 (2 years ago)
Author:
savin.tiberiu@…
Message:

Fixed: Large files could be uploaded by zipping them.
Reviewed: http://reviewboard.infoarena.ro/r/104/

Location:
trunk/www/controllers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/controllers/attachment.php

    r1034 r1068  
    109109    if (!$form_errors) { 
    110110        if ($autoextract) { 
    111             $attachments = get_zipped_attachments($_FILES['file_name']['tmp_name']); 
    112  
    113             if (false === $attachments) { 
     111            $zip_files = get_zipped_attachments($_FILES['file_name']['tmp_name']); 
     112 
     113            if (false === $zip_files) { 
    114114                $form_errors['file_name'] = 'Arhiva ZIP este invalida sau nu poate fi recunoscuta'; 
     115            } else { 
     116                $attachments = $zip_files['attachments']; 
     117                $skipped_files = $zip_files['total_files'] - count($attachments); 
    115118            } 
    116119        } 
     
    232235    if (!$form_errors) { 
    233236        if ($autoextract) { 
    234             $msg = "Am extras si incarcat {$attach_okcount} fisiere."; 
    235             if ($rewrite_count) { 
    236                 $msg .= " {$rewrite_count} fisiere vechi au fost rescrise."; 
     237            if ($attach_okcount == 1) { 
     238                $msg = "Am extras si incarcat un fisier."; 
     239            } else { 
     240                $msg = "Am extras si incarcat {$attach_okcount} fisiere."; 
     241            } 
     242 
     243            if ($rewrite_count == 1) { 
     244                $msg .= " Un fisier mai vechi a fost rescris."; 
     245            } else if ($rewrite_count > 1) { 
     246                $msg .= " {$rewrite_count} fisiere mai vechi au fost rescrise."; 
     247            } 
     248 
     249            if ($skipped_files == 1) { 
     250                $msg .= " Un fisier nu a fost dezarhivat deoarece era prea mare sau era invalid."; 
     251            } else if ($skipped_files > 1) { 
     252                $msg .= " {$skipped_files} fisiere nu au fost dezarhivate deoarece erau prea mari sau erau invalide."; 
    237253            } 
    238254        } 
  • trunk/www/controllers/zip_attachment.php

    r900 r1068  
    77    $attachments = array(); 
    88    $namehash = array(); 
     9    $total_files = 0; 
    910 
    1011    log_print('Exploring ZIP archive '.$filename); 
     
    2425            } 
    2526 
     27            $total_files++; 
     28            // Skip big files 
     29            if ($stat['size'] > IA_ATTACH_MAXSIZE) { 
     30                continue; 
     31            } 
     32 
    2633            // validate file name and make sure there are no duplicates 
    2734            $aname = basename($stat['name']); 
     
    3744        $zip->close(); 
    3845    } 
    39     return $attachments; 
     46    return array('total_files' => $total_files, 'attachments' => $attachments); 
    4047} 
    4148 
Note: See TracChangeset for help on using the changeset viewer.