mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-19 06:53:53 +01:00
Use LSurl route to handle tmp file access
This commit is contained in:
parent
add68ec132
commit
958c5b16a8
3 changed files with 37 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
|||
RewriteEngine On
|
||||
|
||||
# Always rewrite tmp file access
|
||||
RewriteRule ^(tmp/.*)$ index.php?REQUESTED_URL=$1 [L,QSA]
|
||||
|
||||
# If the request is not for a valid file
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
# If the request is not for a valid link
|
||||
|
|
|
@ -2369,6 +2369,24 @@ class LSsession {
|
|||
return False;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le chemin du fichier temporaire à partir du nom du fichier (s'il existe)
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $hash La valeur du fichier
|
||||
*
|
||||
* @retval mixed
|
||||
**/
|
||||
public static function getTmpFileByFilename($filename) {
|
||||
foreach(self :: $tmp_file as $filePath => $contentHash) {
|
||||
if (basename($filePath) == $filename) {
|
||||
return $filePath;
|
||||
}
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime les fichiers temporaires
|
||||
*
|
||||
|
|
|
@ -249,6 +249,22 @@ function handle_image($request) {
|
|||
}
|
||||
LSurl :: add_handler('#^image/(?P<image>[^/]+)$#', 'handle_image', false);
|
||||
|
||||
/*
|
||||
* Handle tmp file request
|
||||
*
|
||||
* @param[in] $request LSurlRequest The request
|
||||
*
|
||||
* @retval void
|
||||
**/
|
||||
function handle_tmp_file($request) {
|
||||
$path = LSsession :: getTmpFileByFilename($request -> filename);
|
||||
if ($path && is_file($path)) {
|
||||
dumpFile($path);
|
||||
}
|
||||
LSurl :: error_404($request);
|
||||
}
|
||||
LSurl :: add_handler('#^tmp/(?P<filename>[^/]+)$#', 'handle_tmp_file');
|
||||
|
||||
/*
|
||||
************************************************************
|
||||
* LSobject views
|
||||
|
|
Loading…
Reference in a new issue