From: Weblate Date: Wed, 22 Mar 2017 09:23:13 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/master' X-Git-Tag: 3.2.0~23 X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/commitdiff_plain/c447f2d7c18e5e89d83b420a8c706fbfa07c9b85?hp=03240df47e1ebcfd0619e9ab845e680a2be59447 Merge remote-tracking branch 'origin/master' --- diff --git a/.gitignore b/.gitignore index b83b750..cbcc532 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ lib/config.local.php lib/tos.local.txt +media/custom/ var-* *._* /vendor \ No newline at end of file diff --git a/README.md b/README.md index de1a54c..2e7127d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Next Release [![Build Status Next Release](https://gitlab.com/mojo42/Jirafeau/ba - Basic, adaptable »Terms Of Service« page - Basic API - Bash script to upload files via command line -- Skins +- Themes Jirafeau is a fork of the original project [Jyraphe](http://home.gna.org/jyraphe/) based on the 0.5 (stable version) with a **lot** of modifications. @@ -86,8 +86,8 @@ Installation steps: 1. The download URL changed * Add a rewrite rule in your web server configuration to rename ```file.php``` to ```f.php``` to make older, still existing links work again -1. The default skin changed - * Optionally change the skin in ```lib/config.local.php``` to »courgette« +1. The default theme changed + * Optionally change the theme in ```lib/config.local.php``` to »courgette« ### From version 1.2.0 to 2.0.0 @@ -209,6 +209,14 @@ If you have some strange behavior with IE, you may configure [compatibility mode Anyway I would recommend you to use another web browser. :) +### How can I change the theme? + +You may change the default theme to any of the existing ones or a custom. + +Open your ```lib/config.local.php``` and change setting in the »`style`« key to the name of any folder in the ```/media``` directory. + +Hint: To create a custom theme just copy the »courgette« folder and name your theme »custom« (this way it will be ignored by git and not overwritten during updates). You are invited to enhance the existing themes and send pull requests however. + ### I found a bug, what should I do? Feel free to open a bug in the [GitLab's issues](https://gitlab.com/mojo42/Jirafeau/issues). diff --git a/index.php b/index.php index 6d1dc10..09b37e4 100644 --- a/index.php +++ b/index.php @@ -34,32 +34,31 @@ if (has_error()) { require(JIRAFEAU_ROOT . 'lib/template/header.php'); /* Check if user is allowed to upload. */ -if (!jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) { - - /* Ask password if upload password is set. */ +// First check: Challenge by IP +if (true === jirafeau_challenge_upload_ip($cfg['upload_ip'], get_ip_address($cfg))) { + // Is an upload password required? if (jirafeau_has_upload_password($cfg)) { session_start(); - /* Unlog if asked. */ + // Logout action if (isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) { session_unset(); } - /* Auth. */ + // Challenge by password + // …save successful logins in session if (isset($_POST['upload_password'])) { if (jirafeau_challenge_upload_password($cfg, $_POST['upload_password'])) { $_SESSION['upload_auth'] = true; $_SESSION['user_upload_password'] = $_POST['upload_password']; } else { $_SESSION['admin_auth'] = false; - echo '

' . t('Wrong password.') . '

'; - require(JIRAFEAU_ROOT.'lib/template/footer.php'); - exit; + jirafeau_fatal_error(t('Wrong password.'), $cfg); } } - /* Show auth page. */ - if (!isset($_SESSION['upload_auth']) || $_SESSION['upload_auth'] != true) { + // Show login form if user session is not authorized yet + if (true === empty($_SESSION['upload_auth'])) { ?>
@@ -89,6 +88,9 @@ if (!jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) { } } } +else { + jirafeau_fatal_error(t('Access denied'), $cfg); +} ?>
diff --git a/install.php b/install.php index 9e05b8c..2739bc8 100644 --- a/install.php +++ b/install.php @@ -102,13 +102,6 @@ function jirafeau_add_ending_slash($path) return $path . ((substr($path, -1) == '/') ? '' : '/'); } -function jirafeau_fatal_error($errorText) -{ - echo '

Error

' . $errorText . '

'; - require(JIRAFEAU_ROOT . 'lib/template/footer.php'); - exit; -} - /** * Check installation **/ diff --git a/lib/functions.php b/lib/functions.php index 50ab345..7d15e1b 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -128,6 +128,13 @@ function jirafeau_get_datetimefield($timestamp) return $content; } +function jirafeau_fatal_error($errorText, $cfg = array()) +{ + echo '

Error

' . $errorText . '

'; + require(JIRAFEAU_ROOT . 'lib/template/footer.php'); + exit; +} + function jirafeau_clean_rm_link($link) { $p = s2p("$link"); @@ -1063,22 +1070,26 @@ function jirafeau_challenge_upload_password($cfg, $password) /** * Test if visitor's IP is authorized to upload. - * @param $ip IP to be challenged + * + * @param $allowedIpList array of allowed IPs + * @param $challengedIp IP to be challenged * @return true if IP is authorized, false otherwise. */ -function jirafeau_challenge_upload_ip($cfg, $ip) +function jirafeau_challenge_upload_ip($allowedIpList, $challengedIp) { - if (count($cfg['upload_ip']) == 0) { + // skip if list is empty = all IPs allowed + if (count($allowedIpList) == 0) { return true; } - foreach ($cfg['upload_ip'] as $i) { - if ($i == $ip) { + // test given IP against each allowed IP + foreach ($allowedIpList as $i) { + if ($i == $challengedIp) { return true; } // CIDR test for IPv4 only. if (strpos($i, '/') !== false) { list($subnet, $mask) = explode('/', $i); - if ((ip2long($ip) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet)) { + if ((ip2long($challengedIp) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet)) { return true; } } diff --git a/lib/template/footer.php b/lib/template/footer.php index 5bc158f..f33373f 100644 --- a/lib/template/footer.php +++ b/lib/template/footer.php @@ -9,8 +9,8 @@ ?> | '; echo '' . t('Terms of Service') . ''; } ?> diff --git a/lib/template/header.php b/lib/template/header.php index f984e1c..f03b2ba 100644 --- a/lib/template/header.php +++ b/lib/template/header.php @@ -7,6 +7,7 @@ header('x-ua-compatible: ie=edge'); <?php echo (true === empty($cfg['title']))? t('Jirafeau, your web file repository') : $cfg['title']; ?> + diff --git a/favicon.ico b/media/courgette/favicon.ico similarity index 100% rename from favicon.ico rename to media/courgette/favicon.ico diff --git a/media/elegantish/favicon.ico b/media/elegantish/favicon.ico new file mode 100644 index 0000000..c42c696 Binary files /dev/null and b/media/elegantish/favicon.ico differ diff --git a/media/industrial/favicon.ico b/media/industrial/favicon.ico new file mode 100644 index 0000000..c42c696 Binary files /dev/null and b/media/industrial/favicon.ico differ diff --git a/media/jyraphe/favicon.ico b/media/jyraphe/favicon.ico new file mode 100644 index 0000000..c42c696 Binary files /dev/null and b/media/jyraphe/favicon.ico differ