Ticket #9: bearfile.patch

File bearfile.patch, 1.2 KB (added by Benjamin Linet, 9 years ago)
  • bearfile.php

    old new  
    8282      $bfh['error'] = "Could not write file, maximum number of versions ($max) reached.";
    8383      return $bfh;
    8484    }
    85     $target = preg_replace('/(\..+)?$/', "-$try\$1", $target0 , 1);
     85    $target = preg_replace('/\.[^.]+$/', "-$try\$0", $target0 , 1);
    8686  }
    8787
     88  $name = preg_replace('/.*\//', "", $target, 1);
     89
    8890  if ((!move_uploaded_file($up['tmp_name'], $target))) {
    89     $bfh['error'] = 'Could not write file, please contact your technical support.';
     91    $bfh['error'] = "Could not write file $name please contact your technical support.";
    9092    return $bfh;
    9193  }
    9294  chmod($target, 0660);
     
    123125  }
    124126
    125127  $fname = "{$bfh['store']}/$name";
     128  $upname = preg_replace('/.*/', "$name", $fname, 1);
    126129  $ftype = mime_content_type($fname);
    127130  $fh = fopen($fname, "r");
    128131  if (!$fh) {
     
    131134  }
    132135
    133136  header("Content-Type: $ftype");
    134   header('Content-Disposition: attachment; filename="'.$fname.'"');
     137  header('Content-Disposition: attachment; filename="'.$upname.'"');
     138
    135139  fpassthru($fh);
    136140  fclose($fh);
    137141  exit(0);