split a.php with a.php (no send) and s.php (only send)

This commit is contained in:
François 2024-12-09 12:40:30 +01:00
parent 15dbc26592
commit d29e05e805
4 changed files with 70 additions and 36 deletions

View File

@ -2,7 +2,7 @@
/* /*
* Kaz addon (see https://git.kaz.bzh/KAZ/depollueur for information) * Kaz addon (see https://git.kaz.bzh/KAZ/depollueur for information)
* create un archive for a set of file or update file deadline * 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?r=email => track
a.php?p=email => period a.php?p=email => period
@ -211,11 +211,6 @@ if (isset ($_REQUEST [A_GET]) && !empty ($_REQUEST [A_GET])) {
$doDownload = true; $doDownload = true;
} }
$doUpload = false;
if (isset ($_FILES ['file'])) {
$doUpload = true;
}
// ======================================== // ========================================
function returnError ($msg) { function returnError ($msg) {
require (JIRAFEAU_ROOT.'lib/template/header.php'); require (JIRAFEAU_ROOT.'lib/template/header.php');
@ -224,6 +219,11 @@ function returnError ($msg) {
exit; exit;
} }
if (isset ($_FILES ['file'])) {
// XXX t ("NoUpload")
returnError ("Can't upload file");
}
// ======================================== // ========================================
function setSenderMode ($sender, $mode) { function setSenderMode ($sender, $mode) {
if (!$sender) 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) { if ($doUpdate) {
$maxTime = time ()+period2seconds ($_REQUEST [A_UPDATE]); $maxTime = time ()+period2seconds ($_REQUEST [A_UPDATE]);

56
src/Jirafeau/s.php Normal file
View File

@ -0,0 +1,56 @@
<?php
/*
* Kaz addon (see https://git.kaz.bzh/KAZ/depollueur for information)
* only upload file for restricted acces purpose
* version : 2.22 (2024-12-09)
*/
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/');
require (JIRAFEAU_ROOT . 'lib/settings.php');
require (JIRAFEAU_ROOT . 'lib/functions.php');
require (JIRAFEAU_ROOT . 'lib/lang.php');
// ========================================
function returnError ($msg) {
require (JIRAFEAU_ROOT.'lib/template/header.php');
echo '<div class="error"><p>' . $msg . '</p></div>';
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;
// ========================================

View File

@ -32,6 +32,8 @@
# The fact that you are presently reading this means that you have had # # 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. # # 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 # - installer l'utilitaire apg pour génération de mot de passes
@ -124,9 +126,9 @@ curlJirafeauSend () {
type="type=$3;" type="type=$3;"
[ -z "$3" -o "$3" = "/" ] && type="" [ -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 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}" read JIR_TOKEN <<< "${OUTPUT}"
case "${JIR_TOKEN}" in case "${JIR_TOKEN}" in
"" | no | *Error* | \<* ) "" | no | *Error* | \<* )

View File

@ -32,6 +32,8 @@
# The fact that you are presently reading this means that you have had # # 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. # # 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) PRG=$(basename $0)
@ -117,8 +119,8 @@ curlJirafeauSend () {
fi fi
type="type=$3;" type="type=$3;"
[ -z "$3" -o "$3" = "/" ] && type="" [ -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\"" 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}/a.php" || exit 1 curl -X POST -F "time=$1" -F "key=$5" -F "file=@$2;${type}filename=\"$4\"" "${JIRAFEAU_LOCAL}/s.php" || exit 1
} }
######################################## ########################################