source: pmb4.2/trunk/fuentes/pmb/descargas.php @ 828

Last change on this file since 828 was 828, checked in by jrpelegrina, 4 years ago

WIP in lliurex features and modifications 4

File size: 1.0 KB
Line 
1<?php
2//-------------------------------------> L L I U R E X <--------------------------------------
3//Modulo para descargar ficheros comprobando su extension y la ruta del fichero que se va a descargar
4$base_noheader= "YES";
5$base_path=".";                           
6$base_auth = "ADMINISTRATION_AUTH"; 
7$base_title = "\$msg[7]";   
8require_once ("$base_path/includes/init.inc.php"); 
9$extensiones = array("jpg", "png", "sql", "txt");
10    $f = $_GET["f"];
11    if(strpos($f,"/temp")==false){
12        die("$msg[descarg_err_a]");
13    }
14$f2=substr($f, 7); //saco el nombre de fichero unicamente "./temp/"
15$cont= (strlen($f))-3; //saca la extension (ultimos 3 digitos)
16$fExt=substr($f, $cont); 
17    if(!in_array($fExt, $extensiones)){
18        die("$msg[descarg_err_b] $f2");
19    }
20    header("Content-type: application/octet-stream");
21    header("Content-Disposition: attachment; filename=\"$f2\"\n");
22    $fp=fopen("$f", "r");
23    fpassthru($fp);
24//-------------------------------------> L L I U R E X <--------------------------------------
25?>
Note: See TracBrowser for help on using the repository browser.