phpldapadmin/htdocs/view_jpeg_photo.php

34 lines
1016 B
PHP
Raw Normal View History

2009-06-30 08:05:37 +00:00
<?php
2009-06-30 10:26:08 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/view_jpeg_photo.php,v 1.9.4.2 2005/12/08 11:58:14 wurley Exp $
2009-06-30 08:05:37 +00:00
2009-06-30 09:29:51 +00:00
/**
* @package phpLDAPadmin
*/
/**
*/
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 08:05:37 +00:00
$file = $_GET['file'];
2009-06-30 10:26:08 +00:00
/* Security check (we don't want anyone tryting to get at /etc/passwd or something)
Slashes and dots are not permitted in these names.*/
if (! preg_match('/^pla/',$file) || preg_match('/[\.\/\\\\]/',$file))
pla_error(sprintf('%s %s',_('Unsafe file name: '),htmlspecialchars($file)));
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
/* Little security measure here (prevents users from accessing
files, like /etc/passwd for example).*/
$file = basename(addcslashes($file,'/\\'));
2009-06-30 09:29:51 +00:00
$file = sprintf('%s/%s',$config->GetValue('jpeg','tmpdir'),$file);
2009-06-30 10:26:08 +00:00
if (! file_exists($file))
pla_error(sprintf('%s %s',_('No such file: '),htmlspecialchars($_GET['file'])));
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
$f = fopen($file,'r');
$jpeg = fread($f,filesize($file));
fclose($f);
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
Header('Content-type: image/jpeg');
Header('Content-disposition: inline; filename=jpeg_photo.jpg');
2009-06-30 08:05:37 +00:00
echo $jpeg;
?>