From: Jerome Jutteau Date: Wed, 24 Aug 2022 22:08:43 +0000 (+0200) Subject: [TASK] Fix php-cs-fixer errors X-Git-Tag: 4.6.0~14^2~27 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/17d5977bf8d24a1b0abb5f52a8453322f21a994d [TASK] Fix php-cs-fixer errors Signed-off-by: Jerome Jutteau --- diff --git a/admin.php b/admin.php index d196f3f..68e0f3b 100644 --- a/admin.php +++ b/admin.php @@ -117,9 +117,9 @@ if (php_sapi_name() == "cli") { /* Show admin interface if not downloading a file. */ if (!(isset($_POST['action']) && strcmp($_POST['action'], 'download') == 0)) { require(JIRAFEAU_ROOT . 'lib/template/header.php'); ?>

(version )

(version )

+ ?>
diff --git a/index.php b/index.php index f7aeb04..b6dac09 100644 --- a/index.php +++ b/index.php @@ -41,7 +41,8 @@ if (isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) { /* Check if user is allowed to upload. */ // First check: Is user already logged -if (jirafeau_user_session_logged()) {} +if (jirafeau_user_session_logged()) { +} // Second check: Challenge by IP NO PASSWORD elseif (true === jirafeau_challenge_upload_ip_without_password($cfg, get_ip_address($cfg))) { jirafeau_user_session_start(); @@ -108,7 +109,7 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) { + ?>

@@ -118,7 +119,7 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {

+ } ?>

@@ -164,22 +165,22 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {

0) { - echo t('2_BIG') . ', ' . t('FILE_LIM') . " " . $cfg['maximal_upload_size'] . " MB."; - } - ?>')"/> + if ($cfg['maximal_upload_size'] >= 1024) { + echo t('2_BIG') . ', ' . t('FILE_LIM') . " " . number_format($cfg['maximal_upload_size']/1024, 2) . " GB."; + } elseif ($cfg['maximal_upload_size'] > 0) { + echo t('2_BIG') . ', ' . t('FILE_LIM') . " " . $cfg['maximal_upload_size'] . " MB."; + } +?>')"/>

'; - echo ''; - } - ?> + if ($cfg['one_time_download']) { + echo ''; + echo ''; + } +?> @@ -188,66 +189,66 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) { = 1024) { - echo '

' . t('FILE_LIM'); - echo " " . number_format($cfg['maximal_upload_size'] / 1024, 2) . " GB.

"; - } elseif ($cfg['maximal_upload_size'] > 0) { - echo '

' . t('FILE_LIM'); - echo " " . $cfg['maximal_upload_size'] . " MB.

"; - } else { - echo '

'; - } - ?> +if ($cfg['maximal_upload_size'] >= 1024) { + echo '

' . t('FILE_LIM'); + echo " " . number_format($cfg['maximal_upload_size'] / 1024, 2) . " GB.

"; +} elseif ($cfg['maximal_upload_size'] > 0) { + echo '

' . t('FILE_LIM'); + echo " " . $cfg['maximal_upload_size'] . " MB.

"; +} else { + echo '

'; +} +?>

@@ -263,14 +264,14 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) { + ?> +?> @@ -283,11 +284,11 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) { document.getElementById('send').style.display = 'none'; if (!check_html5_file_api ()) document.getElementById('max_file_size').innerHTML = ' 0) { - echo t('NO_BROWSER_SUPPORT') . $max_size; - } - ?>'; + $max_size = jirafeau_get_max_upload_size(); +if ($max_size > 0) { + echo t('NO_BROWSER_SUPPORT') . $max_size; +} +?>'; addCopyListener('upload_link_button', 'upload_link'); addCopyListener('preview_link_button', 'preview_link'); diff --git a/install.php b/install.php index 6dbefb5..ed99b19 100644 --- a/install.php +++ b/install.php @@ -62,26 +62,26 @@ if (!is_writable(JIRAFEAU_CFG) && !@chmod(JIRAFEAU_CFG, '0666')) { if (isset($_POST['step']) && isset($_POST['next'])) { switch ($_POST['step']) { - case 1: - if (strlen($_POST['admin_password'])) { - $cfg['admin_password'] = hash('sha256', $_POST['admin_password']); - } else { - $cfg['admin_password'] = ''; - } - jirafeau_export_cfg($cfg); - break; - - case 2: - $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']); - $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']); - jirafeau_export_cfg($cfg); - break; - - case 3: - $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']); - $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']); - jirafeau_export_cfg($cfg); - break; + case 1: + if (strlen($_POST['admin_password'])) { + $cfg['admin_password'] = hash('sha256', $_POST['admin_password']); + } else { + $cfg['admin_password'] = ''; + } + jirafeau_export_cfg($cfg); + break; + + case 2: + $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']); + $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']); + jirafeau_export_cfg($cfg); + break; + + case 3: + $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']); + $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']); + jirafeau_export_cfg($cfg); + break; } } @@ -95,20 +95,20 @@ if (isset($_POST['next'])) { } switch ($current) { -case 1: -default: - ?>

' . t('ONE_TIME_DL') . ':
' . t('ONE_TIME_DL') . ':
+ ?> @@ -117,90 +117,90 @@ default:

+ ?> + echo(empty($cfg['web_root']) ? jirafeau_default_web_root() : $cfg['web_root']); + ?>" size = "40" /> + ?> + ?>" size = "40" />
+ echo t('PREV_STEP'); ?>" />

+ ?>" />

'.$err['why'].'
'.NL; ?>

'.$err['why'].'
'.NL; ?>

'; - } else { - $cfg['installation_done'] = true; - jirafeau_export_cfg($cfg); - echo '

' . - t('JI_FONCTIONAL') . ':' . - '
' . - $cfg['web_root'].'

'; - } -break; + } else { + $cfg['installation_done'] = true; + jirafeau_export_cfg($cfg); + echo '

' . + t('JI_FONCTIONAL') . ':' . + '
' . + $cfg['web_root'].'

'; + } + break; } require(JIRAFEAU_ROOT . 'lib/template/footer.php'); diff --git a/lib/functions.php b/lib/functions.php index 9672fe1..850386b 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -190,23 +190,23 @@ function jirafeau_ini_to_bytes($value) $modifier = substr($value, -1); $bytes = substr($value, 0, -1); switch (strtoupper($modifier)) { - default: - return intval($value); - break; - case 'P': - $bytes *= 1024; - // no break - case 'T': - $bytes *= 1024; - // no break - case 'G': - $bytes *= 1024; - // no break - case 'M': - $bytes *= 1024; - // no break - case 'K': - $bytes *= 1024; + default: + return intval($value); + break; + case 'P': + $bytes *= 1024; + // no break + case 'T': + $bytes *= 1024; + // no break + case 'G': + $bytes *= 1024; + // no break + case 'M': + $bytes *= 1024; + // no break + case 'K': + $bytes *= 1024; } return $bytes; } @@ -264,19 +264,19 @@ function jirafeau_get_max_upload_chunk_size_bytes($max_upload_chunk_size_bytes = function jirafeau_upload_errstr($code) { switch ($code) { - case UPLOAD_ERR_INI_SIZE: - case UPLOAD_ERR_FORM_SIZE: - return t('Your file exceeds the maximum authorized file size. '); - - case UPLOAD_ERR_PARTIAL: - case UPLOAD_ERR_NO_FILE: - return - t('Your file was not uploaded correctly. You may succeed in retrying. '); - - case UPLOAD_ERR_NO_TMP_DIR: - case UPLOAD_ERR_CANT_WRITE: - case UPLOAD_ERR_EXTENSION: - return t('Internal error. You may not succeed in retrying. '); + case UPLOAD_ERR_INI_SIZE: + case UPLOAD_ERR_FORM_SIZE: + return t('Your file exceeds the maximum authorized file size. '); + + case UPLOAD_ERR_PARTIAL: + case UPLOAD_ERR_NO_FILE: + return + t('Your file was not uploaded correctly. You may succeed in retrying. '); + + case UPLOAD_ERR_NO_TMP_DIR: + case UPLOAD_ERR_CANT_WRITE: + case UPLOAD_ERR_EXTENSION: + return t('Internal error. You may not succeed in retrying. '); } return t('Unknown error. '); } diff --git a/script.php b/script.php index 99ebfeb..b861a47 100644 --- a/script.php +++ b/script.php @@ -25,8 +25,8 @@ require(JIRAFEAU_ROOT . 'lib/settings.php'); require(JIRAFEAU_ROOT . 'lib/functions.php'); require(JIRAFEAU_ROOT . 'lib/lang.php'); - global $script_langages; - $script_langages = array('bash' => 'Bash'); +global $script_langages; +$script_langages = array('bash' => 'Bash'); /* Operations may take a long time. * Be sure PHP's safe mode is off. @@ -113,7 +113,7 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES) case 'year': $time += JIRAFEAU_YEAR; break; - default: + default: $time = JIRAFEAU_INFINITY; break; } @@ -407,8 +407,8 @@ fi } /* Initialize an asynchronous upload. */ elseif (isset($_GET['init_async'])) { - if (jirafeau_user_session_logged()) {} - elseif (isset($_POST['upload_password'])) { + if (jirafeau_user_session_logged()) { + } elseif (isset($_POST['upload_password'])) { if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) { echo 'Error 20: Invalid password'; exit;