mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-25 12:21:26 +02:00
* Filemanager/Sharing: fix lost session on first load in sharing links with Firefox
This commit is contained in:
parent
83fd11f7c7
commit
04b83d4344
@ -15,30 +15,38 @@ use EGroupware\Api;
|
|||||||
|
|
||||||
$GLOBALS['egw_info'] = array('flags' => array(
|
$GLOBALS['egw_info'] = array('flags' => array(
|
||||||
'disable_Template_class' => True,
|
'disable_Template_class' => True,
|
||||||
'login' => True,
|
'noheader' => True,
|
||||||
'currentapp' => 'login',
|
// misuse session creation callback to send the image, in case we have no session
|
||||||
|
'autocreate_session_callback' => 'send_image',
|
||||||
|
'currentapp' => 'api',
|
||||||
));
|
));
|
||||||
|
|
||||||
require('../header.inc.php');
|
require('../header.inc.php');
|
||||||
|
|
||||||
$path = $GLOBALS['egw_info']['server']['files_dir'].'/anon-images';
|
send_image();
|
||||||
|
|
||||||
if (!file_exists($path) || empty($_GET['src']) ||
|
function send_image()
|
||||||
|
{
|
||||||
|
$path = $GLOBALS['egw_info']['server']['files_dir'] . '/anon-images';
|
||||||
|
|
||||||
|
if (!file_exists($path) || empty($_GET['src']) ||
|
||||||
basename($_GET['src']) !== $_GET['src'] || // make sure no directory traversal
|
basename($_GET['src']) !== $_GET['src'] || // make sure no directory traversal
|
||||||
!preg_match('/^[a-z 0-9._-]+\.(jpe?g|png|gif|svg|ico)$/i', $_GET['src']) || // only allow images, not eg. Javascript!
|
!preg_match('/^[a-z 0-9._-]+\.(jpe?g|png|gif|svg|ico)$/i', $_GET['src']) || // only allow images, not eg. Javascript!
|
||||||
!file_exists($path .= '/'.$_GET['src']) ||
|
!file_exists($path .= '/' . $_GET['src']) ||
|
||||||
!($fp = fopen($path, 'r')))
|
!($fp = fopen($path, 'r')))
|
||||||
{
|
{
|
||||||
error_log(__FILE__.": _GET[src]='$_GET[src]', path=$path returning HTTP status 404 Not Found");
|
error_log(__FILE__ . ": _GET[src]='$_GET[src]', path=$path returning HTTP status 404 Not Found");
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Api\Session::cache_control(864000); // 10 days
|
Api\Session::cache_control(864000); // 10 days
|
||||||
$size = filesize($path);
|
$size = filesize($path);
|
||||||
header('ETag: "'.md5($_GET['src'].$size.filemtime($path)).'"');
|
header('ETag: "' . md5($_GET['src'] . $size . filemtime($path)) . '"');
|
||||||
header('Content-Type: '.Api\MimeMagic::filename2mime($_GET['src']));
|
header('Content-Type: ' . Api\MimeMagic::filename2mime($_GET['src']));
|
||||||
header('Content-Length: '.$size);
|
header('Content-Length: ' . $size);
|
||||||
fpassthru($fp);
|
fpassthru($fp);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
}
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user