1
0
Fork 0
milfskleper/archivos/index.php

97 lines
3.4 KiB
PHP

<?php
session_start();
// Comprobamos si existe la variable
/*if ( !isset ( $_SESSION['id'] ) ) {
// Si no existe
header("Location: ../nodisponible.jpg");
// echo "hola mundo2";
}*/
if(!isset($_GET['archivo']) ){
header("Location: ../images/sinimagen.jpg");
}else {$archivo = $_GET['archivo'];}
include("../includes/datos.php");
function remplacetas($tabla,$campo,$valor,$por,$and){
include_once("../funciones/conex.php");
$link=Conectarse_recursivo();
mysqli_set_charset($link, "utf8");
if(@$and !=''){$AND = "AND $and";}else{$AND ="";}
//$consulta = "SELECT * , md5(binary $por ) as md5_".$por." FROM $tabla WHERE $campo = '$valor' $AND order by $campo DESC limit 1";
$consulta = "SELECT * , md5(binary $por ) as md5_".$por." FROM $tabla WHERE $campo = '$valor' $AND order by id DESC limit 1";
$sql=mysqli_query($link,$consulta);
if (@mysqli_num_rows($sql)!=0){
$resultado[] = mysqli_result($sql,0,$por);
$resultado[] = mysqli_result($sql,0,'id');
$resultado[] = $consulta;
$resultado[] = mysqli_result($sql,0,"md5_$por");
$resultado[] = @mysqli_result($sql,0,"timestamp");
$resultado[] = @mysqli_result($sql,0,"form_id");
$resultado[] = @mysqli_result($sql,0,"id_usuario"); //6
$resultado[] = @mysqli_result($sql,0,"id_empresa"); //7
$resultado[] = @mysqli_result($sql,0,"equipo");
}else{
$resultado[0] = '';
$resultado[1] ="";
$resultado[2] = $consulta;
$resultado[3] = NULL;
$resultado[4] = NULL;
$resultado[4] = NULL;
}
return $resultado;
}
function mysqli_result($res,$row=0,$col=0){
$numrows = @mysqli_num_rows($res);
if ($numrows && $row <= ($numrows-1) && $row >=0){
mysqli_data_seek($res,$row);
$resrow = (is_numeric($col)) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res);
if (isset($resrow[$col])){
return $resrow[$col];
}
}
return false;
}
$control = remplacetas('form_datos','contenido',"$archivo",'control',"") ;
$privacidad = remplacetas('form_id','id',"$control[5]",'publico',"") ;
//if($privacidad[0] == 0 AND ($_SESSION['id'] != $control[6] OR $_SESSION['id_empresa'] != $control[7]) or $_SESSION['equipo'] != $control[8] ) {
if($privacidad[0] == 0 AND ($_SESSION['id'] != $control[6] OR $_SESSION['id_empresa'] != $control[7] or $_SESSION['equipo'] != $control[8] )) {
header("Location: ../images/seguridad.gif");
//echo "if($privacidad[0] == 0 AND ($_SESSION[id] != $control[6] OR $_SESSION[id_empresa] != $control[7] or $_SESSION[equipo] != $control[8])";
exit();
}
//else{ echo "$privacidad[2]"; exit();}
$dir="$path_images_secure/full/";
if ((!$file=realpath($dir.$_GET['archivo']))
|| strpos($file,realpath($dir))!==0 || substr($file,-4)=='.php'){
//header('HTTP/1.0 404 Not Found');
header("Location: ../images/sinimagen.jpg");
exit();
}
$ref=$_SERVER['HTTP_REFERER'];
if (strpos($ref,'https://')===0 || strpos($ref,'https')!==0){
/* $mime=array(
'jpg'=>'image/jpeg',
'png'=>'image/png',
'mid'=>'audio/x-midi',
'wav'=>'audio/x-wav'
);
if($mime[substr($file,-3)] =='') {
header('Location: ../pixel.png');
exit();
}*/
$stat=stat($file);
header('Content-Type: '.$mime[substr($file,-3)]);
header('Content-Length: '.$stat[7]);
header('Last-Modified: '.gmdate('D, d M Y H:i:s',$stat[9]).' GMT');
readfile($file);
exit();
}
header('Pragma: no-cache');
header('Cache-Control: no-cache, no-store, must-revalidate');
include($file.'.php');
?>