X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/4aa503f3fb44503b2f6fbe6abdfeaf71411e7e55..refs/merge-requests/3/head:/script.php?ds=sidebyside diff --git a/script.php b/script.php index f32ab20..6ef117e 100644 --- a/script.php +++ b/script.php @@ -81,51 +81,22 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES) $key = ''; if (isset($_POST['key'])) { $key = $_POST['key']; - if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex'){ - if (!preg_match($cfg['download_password_policy_regex'], $key)){ + if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex') { + if (!preg_match($cfg['download_password_policy_regex'], $key)) { echo 'Error 14: The download password is not complying to the security standards.'; exit; } } - }elseif ($cfg['download_password_requirement'] !== 'optional'){ + } elseif ($cfg['download_password_requirement'] !== 'optional') { echo 'Error 13: The parameter password is required.'; exit; } - $time = time(); if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) { echo 'Error 4: The parameter time is invalid.'; exit; } else { - switch ($_POST['time']) { - case 'minute': - $time += JIRAFEAU_MINUTE; - break; - case 'hour': - $time += JIRAFEAU_HOUR; - break; - case 'day': - $time += JIRAFEAU_DAY; - break; - case 'week': - $time += JIRAFEAU_WEEK; - break; - case 'fortnight': - $time += JIRAFEAU_FORTNIGHT; - break; - case 'month': - $time += JIRAFEAU_MONTH; - break; - case 'quarter': - $time += JIRAFEAU_QUARTER; - break; - case 'year': - $time += JIRAFEAU_YEAR; - break; - default: - $time = JIRAFEAU_INFINITY; - break; - } + $time = jirafeau_datestr_to_int($_POST['time']); } // Check file size @@ -175,13 +146,13 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES) $key = ''; if (isset($_POST['key'])) { $key = $_POST['key']; - if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex'){ - if (!preg_match($cfg['download_password_policy_regex'], $key)){ + if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex') { + if (!preg_match($cfg['download_password_policy_regex'], $key)) { echo 'Error 14: The download password is not complying to the security standards.'; exit; } } - }elseif ($cfg['download_password_requirement'] !== 'optional'){ + } elseif ($cfg['download_password_requirement'] !== 'optional') { echo 'Error 13: The parameter password is required.'; exit; } @@ -451,13 +422,13 @@ elseif (isset($_GET['init_async'])) { $key = ''; if (isset($_POST['key'])) { $key = $_POST['key']; - if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex'){ - if (!preg_match($cfg['download_password_policy_regex'], $key)){ + if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex') { + if (!preg_match($cfg['download_password_policy_regex'], $key)) { echo 'Error 14: The download password is not complying to the security standards.'; exit; } } - }elseif ($cfg['download_password_requirement'] !== 'optional'){ + } elseif ($cfg['download_password_requirement'] !== 'optional') { echo 'Error 13: The parameter password is required.'; exit; } @@ -468,40 +439,11 @@ elseif (isset($_GET['init_async'])) { exit; } - $time = time(); if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) { echo 'Error 22'; exit; } else { - switch ($_POST['time']) { - case 'minute': - $time += JIRAFEAU_MINUTE; - break; - case 'hour': - $time += JIRAFEAU_HOUR; - break; - case 'day': - $time += JIRAFEAU_DAY; - break; - case 'week': - $time += JIRAFEAU_WEEK; - break; - case 'fortnight': - $time += JIRAFEAU_FORTNIGHT; - break; - case 'month': - $time += JIRAFEAU_MONTH; - break; - case 'quarter': - $time += JIRAFEAU_QUARTER; - break; - case 'year': - $time += JIRAFEAU_YEAR; - break; - default: - $time = JIRAFEAU_INFINITY; - break; - } + $time = jirafeau_datestr_to_int($_POST['time']); } if ($cfg['store_uploader_ip']) {