94 lines
2.6 KiB
PHP
94 lines
2.6 KiB
PHP
|
|
<?php
|
|||
|
|
/* Gestor de descargas de ficheros.
|
|||
|
|
*
|
|||
|
|
* Tipos de ficheros a descargar:
|
|||
|
|
* - CV (RRHH 4,GESTOR 3)
|
|||
|
|
* - Documentos (comprobar cada documento)
|
|||
|
|
* - Backup (ADMINISTRADOR TABLAS 2)
|
|||
|
|
*
|
|||
|
|
* Los par<EFBFBD>metros por GET ser<EFBFBD>n:
|
|||
|
|
* $tipo : tipo del documento cv|doc|bac
|
|||
|
|
* $cod : C<EFBFBD>digo del fichero para poder recuperarlo
|
|||
|
|
* - CV : codigo del documento
|
|||
|
|
* - Doc: id del documento
|
|||
|
|
* - Back: nombre del fichero
|
|||
|
|
*
|
|||
|
|
* Los documentos se guardan en la variable del sistema $srcDocs
|
|||
|
|
*
|
|||
|
|
*/
|
|||
|
|
//session_cache_limiter('none');
|
|||
|
|
session_cache_limiter('private');
|
|||
|
|
include("seguridad.php");
|
|||
|
|
include("functions.php");
|
|||
|
|
//include_once("html/cabecera.php");
|
|||
|
|
include_once("Objects/Administracion.php");
|
|||
|
|
$administracion=new Administracion($usuario,$locale);
|
|||
|
|
$constantes=$administracion->getItem("constantes");
|
|||
|
|
$url = $constantes['srcDocs'];
|
|||
|
|
$nombreFichero="";
|
|||
|
|
$nombreMostrar="";
|
|||
|
|
$estado=false;
|
|||
|
|
|
|||
|
|
switch ($_GET['tipo']) {
|
|||
|
|
case "cv": if(!$usuario->tieneRol("4") && !$usuario->tieneRol("3")){
|
|||
|
|
$msg=$locale['1491'];
|
|||
|
|
} else {
|
|||
|
|
$estado=true;
|
|||
|
|
try{
|
|||
|
|
$nombreFichero=$usuario->getRutaCV($_GET['cod']);
|
|||
|
|
|
|||
|
|
$nombreMostrar=$usuario->getNombreCV($_GET['cod']);
|
|||
|
|
} catch(Exception $e){
|
|||
|
|
$estado=false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case "doc": include_once("Objects/Documento.php");
|
|||
|
|
$documento=new Documento($_GET['cod']);
|
|||
|
|
$roles=$documento->getValor("rol");
|
|||
|
|
if($usuario->tieneRolLista($roles)){
|
|||
|
|
// Puede descargarselo
|
|||
|
|
$nombreFichero=SLASH."documentos".SLASH.$documento->getValor("ruta");
|
|||
|
|
$extension=strrchr($documento->getValor("ruta"),".");
|
|||
|
|
|
|||
|
|
$nombreMostrar=$documento->getValor("nombre").$extension;
|
|||
|
|
$estado=true;
|
|||
|
|
}else{
|
|||
|
|
$estado=false;
|
|||
|
|
$msg=$locale['1491'];
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case "back": if(!$usuario->tieneRol("2")){
|
|||
|
|
$msg=$locale['1491'];
|
|||
|
|
} else {
|
|||
|
|
$estado=true;
|
|||
|
|
$nombreFichero=SLASH."bdcopy".SLASH.$_GET['cod'];
|
|||
|
|
$nombreMostrar=$_GET['cod'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if($estado){
|
|||
|
|
$ruta=$url.SLASH.$nombreFichero;
|
|||
|
|
header( "Content-Disposition: attachment; filename=\"".$nombreMostrar."\"");
|
|||
|
|
header( "Content-type: application/octet-stream" );
|
|||
|
|
header( "Content-Description: File Transfer");
|
|||
|
|
header( "Content-Type: application/octet-stream");
|
|||
|
|
header( "Content-Transfer-Encoding: binary");
|
|||
|
|
header( "Expires: 0");
|
|||
|
|
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
|||
|
|
header( "Pragma: public");
|
|||
|
|
header( "Content-Length: ".filesize($ruta));
|
|||
|
|
@readfile( $ruta );
|
|||
|
|
//echo $ruta;
|
|||
|
|
} else {
|
|||
|
|
if($msg=="")
|
|||
|
|
$msg=$locale['1490'];
|
|||
|
|
include_once("showError.php");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
?>
|