Commit fe63e172 authored by Carsten  Rose's avatar Carsten Rose
Browse files

WIP: Refs #12085 Persistent download links. Multiple SQL download config

parent 7d847f07
Pipeline #5029 passed with stages
in 4 minutes and 36 seconds
......@@ -679,7 +679,7 @@ const DOWNLOAD_POPUP_REQUEST = 'true';
const DOWNLOAD_POPUP_REPLACE_TEXT = '#downloadPopupReplaceText#';
const DOWNLOAD_POPUP_REPLACE_TITLE = '#downloadPopupReplaceTitle#';
const SYSTEM_DRAG_AND_DROP_JS = 'hasDragAndDropJS';
const SYSTEM_SQL_DIRECT_DOWNLOAD = 'sqlDirectDownload';
const SYSTEM_SQL_DIRECT_DOWNLOAD = 'sqlDirect'; // becomes sqlDirectdownload.php, sqlDirectdl.php, sqlDirectdl2.php, sqlDirectdl3.php
const SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME = 'parameterLanguageFieldName';
const CSS_REQUIRED_RIGHT = 'required-right';
......
......@@ -680,6 +680,25 @@ class Download {
return $pathFilenameThumbnail;
}
/**
* Retrieve SQL query from QFQ config, specific to script name.
* Four script names are possible: download.php, dl.php, dl2.php, dl3.php
*
* @return array|bool|int|string|null
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
* @throws \UserReportException
*/
private function getDirectDownloadSql() {
$scriptName = $this->store->getVar('SCRIPT_NAME', STORE_CLIENT . STORE_EMPTY);
// Example: /var/www/html/qfq/dl.php >> dl.php
$scriptName = substr($scriptName, strrpos('/', $scriptName));
return $this->store->getVar(SYSTEM_SQL_DIRECT_DOWNLOAD . $scriptName, STORE_SYSTEM . STORE_EMPTY);
}
/**
* @return int[]
* @throws \CodeException
......@@ -688,11 +707,12 @@ class Download {
* @throws \UserReportException
*/
private function getDirectDownloadModeDetails() {
$sql = $this->store->getVar(SYSTEM_SQL_DIRECT_DOWNLOAD, STORE_SYSTEM);
$sql = $this->getDirectDownloadSql();
// Get, Clean: with http://loclhost/qfq/typo3conf/ext/qfq/Classes/Api/download.php/help is $_SERVER['PATH_INFO']='/help'.
$pathInfo = Sanitize::sanitize(urldecode($_SERVER['PATH_INFO'] ?? ''), SANITIZE_ALLOW_ALNUMX);
$pathInfo = $this->store->getVar('PATH_INFO', STORE_CLIENT . STORE_EMPTY);
$pathInfo = Sanitize::sanitize(urldecode($pathInfo), SANITIZE_ALLOW_ALNUMX);
$param = OnString::splitPathToArray($pathInfo);
// In case there are more question mark than parameter, duplicate the last parameter until enough parameter filled.
......
......@@ -387,5 +387,14 @@ custom29 =
# cat=custom/layout; type=string; label=Custom variable 30
custom30 =
# cat=file/file; type=string; label=Query for direct download mode. No default.: SELECT CONCAT('d:output.pdf|F:', n.pathFileName) FROM notiz AS n WHERE n.id=? AND NOW()<n.expire
sqlDirectDownload =
\ No newline at end of file
# cat=file/file; type=string; label=Query for direct download mode. Access via download.php. No default.: SELECT CONCAT('d:output.pdf|F:', n.pathFileName) FROM notiz AS n WHERE n.id=? AND NOW()<n.expire
sqlDirectdownload.php =
# cat=file/file; type=string; label=Query for direct download mode. Access via dl.php. No default.: SELECT CONCAT('d:output.pdf|F:', n.pathFileName) FROM notiz AS n WHERE n.id=? AND NOW()<n.expire
sqlDirectdl.php =
# cat=file/file; type=string; label=Query for direct download mode. Access via dl2.php. No default.: SELECT CONCAT('d:output.pdf|F:', n.pathFileName) FROM notiz AS n WHERE n.id=? AND NOW()<n.expire
sqlDirectdl2.php =
# cat=file/file; type=string; label=Query for direct download mode. Access via dl3.php. No default.: SELECT CONCAT('d:output.pdf|F:', n.pathFileName) FROM notiz AS n WHERE n.id=? AND NOW()<n.expire
sqlDirectdl3.php =
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment