From d29e05e805cc54b1cb0d1012bc61bff4c77c84dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 9 Dec 2024 12:40:30 +0100 Subject: [PATCH] split a.php with a.php (no send) and s.php (only send) --- src/Jirafeau/a.php | 38 +++++----------------------- src/Jirafeau/s.php | 56 ++++++++++++++++++++++++++++++++++++++++++ src/bash/filter.sh | 6 +++-- src/bash/filterTest.sh | 6 +++-- 4 files changed, 70 insertions(+), 36 deletions(-) create mode 100644 src/Jirafeau/s.php diff --git a/src/Jirafeau/a.php b/src/Jirafeau/a.php index 53054ca..2c33c39 100644 --- a/src/Jirafeau/a.php +++ b/src/Jirafeau/a.php @@ -2,7 +2,7 @@ /* * Kaz addon (see https://git.kaz.bzh/KAZ/depollueur for information) * create un archive for a set of file or update file deadline - * version : 2.21 (2024-06-04) + * version : 2.22 (2024-12-09) a.php?r=email => track a.php?p=email => period @@ -211,11 +211,6 @@ if (isset ($_REQUEST [A_GET]) && !empty ($_REQUEST [A_GET])) { $doDownload = true; } -$doUpload = false; -if (isset ($_FILES ['file'])) { - $doUpload = true; -} - // ======================================== function returnError ($msg) { require (JIRAFEAU_ROOT.'lib/template/header.php'); @@ -224,6 +219,11 @@ function returnError ($msg) { exit; } +if (isset ($_FILES ['file'])) { + // XXX t ("NoUpload") + returnError ("Can't upload file"); +} + // ======================================== function setSenderMode ($sender, $mode) { if (!$sender) @@ -707,32 +707,6 @@ function deleteAction ($linkName) { } } -// ======================================== -if ($doUpload) { - $maxtime = time ()+period2seconds ($_REQUEST ['time']); - $key = isset ($_REQUEST ['key']) ? $_REQUEST ['key'] : ''; - $ip = $_SERVER ['HTTP_X_REAL_IP']; // XXX - $res = jirafeau_upload ( - $_FILES['file'], - isset ($_POST ['one_time_download']), - $key, - $maxtime, - $ip, - $cfg['enable_crypt'], - $cfg['link_name_length'], - $cfg['file_hash'] - ); - if (! count ($res ['error']) || $res['error']['has_error']) - $content = 'Error 6 ' . $res['error']['why']; - else - $content = $res ['link'].NL.$res ['delete_link'].NL; - header ('HTTP/1.0 200 OK'); - header ('Content-Length: ' . strlen ($content)); - header ('Content-Type: text/plain'); - echo $content; - exit; -} - // ======================================== if ($doUpdate) { $maxTime = time ()+period2seconds ($_REQUEST [A_UPDATE]); diff --git a/src/Jirafeau/s.php b/src/Jirafeau/s.php new file mode 100644 index 0000000..a396961 --- /dev/null +++ b/src/Jirafeau/s.php @@ -0,0 +1,56 @@ +

' . $msg . '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +if (! isset ($_FILES ['file'])) { + // XXX t ("OnlyUpload") + returnError ("Only upload file"); +} + +// ======================================== +$maxtime = time ()+period2seconds ($_REQUEST ['time']); +$key = isset ($_REQUEST ['key']) ? $_REQUEST ['key'] : ''; +$ip = $_SERVER ['HTTP_X_REAL_IP']; // XXX +$res = jirafeau_upload ( + $_FILES['file'], + isset ($_POST ['one_time_download']), + $key, + $maxtime, + $ip, + $cfg['enable_crypt'], + $cfg['link_name_length'], + $cfg['file_hash'] +); +if (! count ($res ['error']) || $res['error']['has_error']) + $content = 'Error 6 ' . $res['error']['why']; +else + $content = $res ['link'].NL.$res ['delete_link'].NL; +header ('HTTP/1.0 200 OK'); +header ('Content-Length: ' . strlen ($content)); +header ('Content-Type: text/plain'); +echo $content; +exit; + +// ======================================== diff --git a/src/bash/filter.sh b/src/bash/filter.sh index 19e0e80..d5d89bd 100755 --- a/src/bash/filter.sh +++ b/src/bash/filter.sh @@ -32,6 +32,8 @@ # The fact that you are presently reading this means that you have had # # knowledge of the CeCILL-B license and that you accept its terms. # ########################################################################## +# Kaz addon (see https://git.kaz.bzh/KAZ/depollueur for information) +# version : 2.22 (2024-12-09) ########################################################################## # - installer l'utilitaire apg pour génération de mot de passes @@ -124,9 +126,9 @@ curlJirafeauSend () { type="type=$3;" [ -z "$3" -o "$3" = "/" ] && type="" - LOG_FIC " - curl -X POST -F \"time=$1\" -F \"key=$5\" -F \"file=@$2;${type}filename=\\\"$4\\\"\" \"${JIRAFEAU_LOCAL}/a.php\"" + LOG_FIC " - curl -X POST -F \"time=$1\" -F \"key=$5\" -F \"file=@$2;${type}filename=\\\"$4\\\"\" \"${JIRAFEAU_LOCAL}/s.php\"" for num in {1..2}; do - OUTPUT=$(curl -X POST -F "time=$1" -F "key=$5" -F "file=@$2;${type}filename=\"$4\"" "${JIRAFEAU_LOCAL}/a.php") + OUTPUT=$(curl -X POST -F "time=$1" -F "key=$5" -F "file=@$2;${type}filename=\"$4\"" "${JIRAFEAU_LOCAL}/s.php") read JIR_TOKEN <<< "${OUTPUT}" case "${JIR_TOKEN}" in "" | no | *Error* | \<* ) diff --git a/src/bash/filterTest.sh b/src/bash/filterTest.sh index 960efb4..99cfc02 100755 --- a/src/bash/filterTest.sh +++ b/src/bash/filterTest.sh @@ -32,6 +32,8 @@ # The fact that you are presently reading this means that you have had # # knowledge of the CeCILL-B license and that you accept its terms. # ########################################################################## +# Kaz addon (see https://git.kaz.bzh/KAZ/depollueur for information) +# version : 2.22 (2024-12-09) PRG=$(basename $0) @@ -117,8 +119,8 @@ curlJirafeauSend () { fi type="type=$3;" [ -z "$3" -o "$3" = "/" ] && type="" - LOG "curl -X POST -F \"time=$1\" -F \"key=$5\" -F \"file=@$2;${type}filename=\\\"$4\\\"\" \"${JIRAFEAU_LOCAL}/a.php\"" - curl -X POST -F "time=$1" -F "key=$5" -F "file=@$2;${type}filename=\"$4\"" "${JIRAFEAU_LOCAL}/a.php" || exit 1 + LOG "curl -X POST -F \"time=$1\" -F \"key=$5\" -F \"file=@$2;${type}filename=\\\"$4\\\"\" \"${JIRAFEAU_LOCAL}/s.php\"" + curl -X POST -F "time=$1" -F "key=$5" -F "file=@$2;${type}filename=\"$4\"" "${JIRAFEAU_LOCAL}/s.php" || exit 1 } ########################################