From: Jerome Jutteau
Date: Sat, 5 Dec 2020 12:43:22 +0000 (+0100)
Subject: [TASK] run php-cs-fixer
X-Git-Tag: 4.3.0~14
X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/b6f423726c6f71c769fc7d7f3b842f623595a808?hp=f55334d19ee35f6a163f574a54546449f7d44ca0
[TASK] run php-cs-fixer
php-cs-fixer fix --rules=@PSR2 .
Signed-off-by: Jerome Jutteau
---
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e7ee9c3..0692922 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -91,6 +91,7 @@ Quick walktrough:
## New Releases
* If the release is not done for security purposes: create a new issue and freeze next-release branch for at least week.
+* Make sure to run `php-cs-fixer fix --rules=@PSR2 .` and commit.
* Compare the [»next-release« branch to »master«](https://gitlab.com/mojo42/Jirafeau/compare/master...next-release)
* Add a list of noteworthy features and bugfixes to `CHANGELOG.md`
* Add eventual upgrade procedure to `CHANGELOG.md`
diff --git a/admin.php b/admin.php
index bcc291b..cfdfe30 100644
--- a/admin.php
+++ b/admin.php
@@ -43,40 +43,40 @@ if (php_sapi_name() == "cli") {
}
} else {
/* Disable admin interface if we have a empty admin password. */
- if (empty($cfg['admin_password']) && empty($cfg['admin_http_auth_user'])) {
- require(JIRAFEAU_ROOT . 'lib/template/header.php');
- echo ''.
+ if (empty($cfg['admin_password']) && empty($cfg['admin_http_auth_user'])) {
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
+ echo '
';
- require(JIRAFEAU_ROOT.'lib/template/footer.php');
- exit;
- }
+ require(JIRAFEAU_ROOT.'lib/template/footer.php');
+ exit;
+ }
- /* Unlog if asked. */
- if (jirafeau_admin_session_logged() && isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) {
- jirafeau_admin_session_end();
- }
+ /* Unlog if asked. */
+ if (jirafeau_admin_session_logged() && isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) {
+ jirafeau_admin_session_end();
+ }
- if (!jirafeau_admin_session_logged()) {
- /* Test HTTP authentification. */
- if (!empty($cfg['admin_http_auth_user']) &&
+ if (!jirafeau_admin_session_logged()) {
+ /* Test HTTP authentification. */
+ if (!empty($cfg['admin_http_auth_user']) &&
$cfg['admin_http_auth_user'] == $_SERVER['PHP_AUTH_USER']) {
- jirafeau_admin_session_start();
- }
- /* Test web password authentification. */
- else if (!empty($cfg['admin_password']) && isset($_POST['admin_password'])) {
- if ($cfg['admin_password'] === hash('sha256', $_POST['admin_password'])) {
- jirafeau_admin_session_start();
- } else {
- require(JIRAFEAU_ROOT . 'lib/template/header.php');
- echo '
';
- require(JIRAFEAU_ROOT.'lib/template/footer.php');
- exit;
- }
- }
- /* Admin password prompt form. */
- else {
- require(JIRAFEAU_ROOT . 'lib/template/header.php'); ?>
+ jirafeau_admin_session_start();
+ }
+ /* Test web password authentification. */
+ elseif (!empty($cfg['admin_password']) && isset($_POST['admin_password'])) {
+ if ($cfg['admin_password'] === hash('sha256', $_POST['admin_password'])) {
+ jirafeau_admin_session_start();
+ } else {
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
+ echo '
';
+ require(JIRAFEAU_ROOT.'lib/template/footer.php');
+ exit;
+ }
+ }
+ /* Admin password prompt form. */
+ else {
+ require(JIRAFEAU_ROOT . 'lib/template/header.php'); ?>
';
require(JIRAFEAU_ROOT.'lib/template/footer.php');
@@ -220,7 +219,6 @@ if (!$password_challenged && !$do_download && !$do_preview) {
echo '&k=' . urlencode($crypt_key);
} ?>';
document.getElementById('submit_post').submit ();"/>';
echo '';
@@ -253,7 +251,7 @@ if ($cfg['litespeed_workaround']) {
}
}
/* Read encrypted file. */
-else if ($link['crypted']) {
+elseif ($link['crypted']) {
/* Init module */
$m = mcrypt_module_open('rijndael-256', '', 'ofb', '');
/* Extract key and iv. */
diff --git a/index.php b/index.php
index 63906c1..cf54193 100644
--- a/index.php
+++ b/index.php
@@ -92,8 +92,7 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {
exit;
}
}
-}
-else {
+} else {
jirafeau_fatal_error(t('ACCESS_KO'), $cfg);
}
@@ -169,9 +168,9 @@ else {
0) {
- echo t('2_BIG') . ', ' . t('FILE_LIM') . " " . $cfg['maximal_upload_size'] . " MB.";
+ 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.";
}
?>')"/>
@@ -241,11 +240,11 @@ else {
if ($cfg['maximal_upload_size'] >= 1024) {
echo '' . t('FILE_LIM');
echo " " . number_format($cfg['maximal_upload_size'] / 1024, 2) . " GB.
";
- } else if ($cfg['maximal_upload_size'] > 0) {
+ } elseif ($cfg['maximal_upload_size'] > 0) {
echo '' . t('FILE_LIM');
echo " " . $cfg['maximal_upload_size'] . " MB.
";
} else {
- echo '
';
+ echo '
';
}
?>
@@ -256,12 +255,10 @@ else {
?>
diff --git a/install.php b/install.php
index 8d5f6fb..3ba2d5b 100644
--- a/install.php
+++ b/install.php
@@ -225,8 +225,11 @@ case 2:
0;
}
@@ -1190,7 +1205,7 @@ function jirafeau_challenge_upload_ip_without_password($cfg, $challengedIp)
* @param $password password to be challenged
* @return true if access is valid, false otherwise.
*/
-function jirafeau_challenge_upload ($cfg, $ip, $password)
+function jirafeau_challenge_upload($cfg, $ip, $password)
{
return jirafeau_challenge_upload_ip_without_password($cfg, $ip) ||
(!jirafeau_has_upload_password($cfg) && !jirafeau_upload_has_ip_restriction($cfg)) ||
diff --git a/lib/lang.php b/lib/lang.php
index bd7478c..cfb8f80 100644
--- a/lib/lang.php
+++ b/lib/lang.php
@@ -40,13 +40,15 @@ function t($string_id)
return "FIX ME";
}
-function t_visitor_langs() {
+function t_visitor_langs()
+{
$visitor_langs = t_parse_accept_language();
array_push($visitor_langs, "en");
return $visitor_langs;
}
-function t_parse_accept_language() {
+function t_parse_accept_language()
+{
if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
return [];
}
@@ -63,7 +65,8 @@ function t_parse_accept_language() {
return $langs;
}
-function t_in($string_id, $lang) {
+function t_in($string_id, $lang)
+{
$trans = t_get_json($lang);
if ($trans === false) {
return false;
@@ -74,7 +77,8 @@ function t_in($string_id, $lang) {
return $trans[$string_id];
}
-function t_get_raw_json($lang) {
+function t_get_raw_json($lang)
+{
$filename = str_replace("-", "_", $lang);
if (preg_match('/[^A-Za-z_\w]/', $filename)) {
return false;
@@ -90,7 +94,8 @@ function t_get_raw_json($lang) {
return $json;
}
-function t_get_json($lang) {
+function t_get_json($lang)
+{
$raw_j = t_get_raw_json($lang);
$array = json_decode($raw_j, true);
if ($array === null) {
@@ -99,14 +104,15 @@ function t_get_json($lang) {
return $array;
}
-function json_lang_generator($lang) {
+function json_lang_generator($lang)
+{
$r = false;
if ($lang === null) {
$lang_config = $GLOBALS['cfg']['lang'];
if ($lang_config != "auto") {
$r = t_get_raw_json($lang_config);
} else {
- foreach(t_visitor_langs() as $lang) {
+ foreach (t_visitor_langs() as $lang) {
$r = t_get_raw_json($lang);
if (!($r === false)) {
break;
diff --git a/lib/settings.php b/lib/settings.php
index fa9efaa..063b38c 100644
--- a/lib/settings.php
+++ b/lib/settings.php
@@ -30,12 +30,9 @@ if (file_exists(JIRAFEAU_ROOT . 'lib/config.local.php')) {
}
// Setup debug mode
-if ($cfg['debug'] === true)
-{
+if ($cfg['debug'] === true) {
@error_reporting(E_ALL);
-}
-else
-{
+} else {
@error_reporting(0);
}
@@ -78,4 +75,4 @@ define('JIRAFEAU_QUARTER', 7776000); // JIRAFEAU_DAY * 90
define('JIRAFEAU_YEAR', 31536000); // JIRAFEAU_DAY * 365
// set UTC as default timezone for all date/time functions
-date_default_timezone_set ('UTC');
+date_default_timezone_set('UTC');
diff --git a/script.php b/script.php
index 3f7d2f7..b8c4bcf 100644
--- a/script.php
+++ b/script.php
@@ -65,7 +65,7 @@ if (has_error()) {
/* Upload file */
if (isset($_FILES['file']) && is_writable(VAR_FILES)
&& is_writable(VAR_LINKS)) {
- if (isset ($_POST['upload_password'])) {
+ if (isset($_POST['upload_password'])) {
if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
echo 'Error 3: Invalid password';
exit;
@@ -127,11 +127,16 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
exit;
}
- $res = jirafeau_upload($_FILES['file'],
- isset($_POST['one_time_download']),
- $key, $time, get_ip_address($cfg),
- $cfg['enable_crypt'], $cfg['link_name_length'],
- $cfg['file_hash']);
+ $res = jirafeau_upload(
+ $_FILES['file'],
+ isset($_POST['one_time_download']),
+ $key,
+ $time,
+ get_ip_address($cfg),
+ $cfg['enable_crypt'],
+ $cfg['link_name_length'],
+ $cfg['file_hash']
+ );
if (empty($res) || $res['error']['has_error']) {
echo 'Error 6 ' . $res['error']['why'];
@@ -384,7 +389,6 @@ elif [ "$1" == "delete" ]; then
$curl $proxy "$2"
fi