From af942739137cd1c95c052157c1f44ea6d605f4c3 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 25 Jan 2016 21:05:35 +0100 Subject: More PHP 5.2 install compatibility https://github.com/FreshRSS/FreshRSS/issues/1055 --- app/install.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 83526b60c..7ac1c4cec 100644 --- a/app/install.php +++ b/app/install.php @@ -130,7 +130,7 @@ function saveStep2() { $_SESSION['mail_login'] = filter_var(param('mail_login', ''), FILTER_VALIDATE_EMAIL); $password_plain = param('passwordPlain', false); - if ($password_plain !== false) { + if ($password_plain !== false && cryptAvailable()) { if (!function_exists('password_hash')) { include_once(LIB_PATH . '/password_compat.php'); } @@ -681,10 +681,10 @@ function printStep2() { } $auth_type = isset($_SESSION['auth_type']) ? $_SESSION['auth_type'] : ''; ?> - + - + -- cgit v1.2.3 From 64ec0708a1404e1f39a5fdc0131c89b2e4038bee Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 21 Feb 2016 02:51:27 +0100 Subject: More work for CSP, in particular install Install needs testing. https://github.com/FreshRSS/FreshRSS/issues/1075 --- app/install.php | 92 +++++----------------------------------------------- p/scripts/install.js | 76 +++++++++++++++++++++++++++++++++++++++++++ p/scripts/main.js | 7 ++-- 3 files changed, 89 insertions(+), 86 deletions(-) create mode 100644 p/scripts/install.js (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 7ac1c4cec..03f6e2199 100644 --- a/app/install.php +++ b/app/install.php @@ -616,27 +616,6 @@ function printStep1() { - @@ -674,7 +653,7 @@ function printStep2() {
-
- -
@@ -778,7 +715,7 @@ function printStep3() {
-
-
@@ -897,13 +821,15 @@ case 5: } ?> - + - - + + <?php echo _t('install.title'); ?> - - + + + + diff --git a/p/scripts/install.js b/p/scripts/install.js new file mode 100644 index 000000000..52d8bf8e0 --- /dev/null +++ b/p/scripts/install.js @@ -0,0 +1,76 @@ +"use strict"; + +function show_password() { + var button = this; + var passwordField = document.getElementById(button.getAttribute('data-toggle')); + passwordField.setAttribute('type', 'text'); + button.className += ' active'; + return false; +} +function hide_password() { + var button = this; + var passwordField = document.getElementById(button.getAttribute('data-toggle')); + passwordField.setAttribute('type', 'password'); + button.className = button.className.replace(/(?:^|\s)active(?!\S)/g , ''); + return false; +} +var toggles = document.getElementsByClassName('toggle-password'); +for (var i = 0 ; i < toggles.length ; i++) { + toggles[i].addEventListener('mousedown', show_password); + toggles[i].addEventListener('mouseup', hide_password); +} + +function auth_type_change() { + var auth_type = document.getElementById('auth_type'); + if (auth_type) { + var auth_value = auth_type.value, + password_input = document.getElementById('passwordPlain'), + mail_input = document.getElementById('mail_login'); + + if (auth_value === 'form') { + password_input.required = true; + mail_input.required = false; + } else if (auth_value === 'persona') { + password_input.required = false; + mail_input.required = true; + } else { + password_input.required = false; + mail_input.required = false; + } + } +} +var auth_type = document.getElementById('auth_type'); +if (auth_type) { + auth_type_change(); + auth_type_change.addEventListener('change', auth_type_change); +} + +function mySqlShowHide() { + var mysql = document.getElementById('mysql'); + if (mysql) { + mysql.style.display = document.getElementById('type').value === 'mysql' ? 'block' : 'none'; + if (document.getElementById('type').value !== 'mysql') { + document.getElementById('host').value = ''; + document.getElementById('user').value = ''; + document.getElementById('pass').value = ''; + document.getElementById('base').value = ''; + document.getElementById('prefix').value = ''; + } + } +} +var bd_type = document.getElementById('type'); +if (bd_type) { + mySqlShowHide(); + bd_type.addEventListener('change', mySqlShowHide); +} + +function ask_confirmation(e) { + var str_confirmation = this.getAttribute('data-str-confirm'); + if (!confirm(str_confirmation)) { + e.preventDefault(); + } +} +var confirms = document.getElementsByClassName('confirm'); +for (var i = 0 ; i < confirms.length ; i++) { + confirms[i].addEventListener('click', ask_confirmation); +} diff --git a/p/scripts/main.js b/p/scripts/main.js index b7522df6a..31b07721a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -871,7 +871,7 @@ function notifs_html5_show(nb) { window.location.reload(); } - if (context['html5_notif_timeout'] !== 0){ + if (context['html5_notif_timeout'] !== 0) { setTimeout(function() { notification.close(); }, context['html5_notif_timeout'] * 1000); @@ -1246,8 +1246,9 @@ function init_configuration_alert() { } function parseJavaScriptCookie() { - var json = JSON.parse(decodeURIComponent(document.cookie.replace(/(?:(?:^|.*;\s*)FreshRSS-vars\s*\=\s*([^;]*).*$)|^.*$/, "$1"))) || {}; + var vars = decodeURIComponent(document.cookie.replace(/(?:(?:^|.*;\s*)FreshRSS-vars\s*\=\s*([^;]*).*$)|^.*$/, "$1")); document.cookie = 'FreshRSS-vars=; expires=Thu, 01 Jan 1970 00:00:00 GMT'; + var json = JSON.parse(vars); window.context = json.context; window.shortcuts = json.shortcuts; window.url = json.url; @@ -1256,7 +1257,6 @@ function parseJavaScriptCookie() { } function init_all() { - parseJavaScriptCookie(); if (!window.$) { if (window.console) { console.log('FreshRSS waiting for JS…'); @@ -1264,6 +1264,7 @@ function init_all() { window.setTimeout(init_all, 50); return; } + parseJavaScriptCookie(); init_notifications(); init_confirm_action(); $stream = $('#stream'); -- cgit v1.2.3 From 38c2d671e3480b8e9fb38491797e44fdea317006 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 21 Feb 2016 21:25:23 +0100 Subject: CSP different policies per controller https://github.com/FreshRSS/FreshRSS/issues/1075 --- app/FreshRSS.php | 14 ++++++++++---- app/install.php | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'app/install.php') diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 62ea18d96..bfbd7a6eb 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -111,10 +111,16 @@ class FreshRSS extends Minz_FrontController { } public static function preLayout() { - if (Minz_Request::controllerName() === 'stats') { - header("Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'"); - } else { - header("Content-Security-Policy: default-src 'self'; child-src *; img-src * data:; media-src *"); + switch (Minz_Request::controllerName()) { + case 'index': + header("Content-Security-Policy: default-src 'self'; child-src *; img-src * data:; media-src *"); + break; + case 'stats': + header("Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'"); + break; + default: + header("Content-Security-Policy: default-src 'self'"); + break; } } diff --git a/app/install.php b/app/install.php index 03f6e2199..a4a888af2 100644 --- a/app/install.php +++ b/app/install.php @@ -2,6 +2,7 @@ if (function_exists('opcache_reset')) { opcache_reset(); } +header("Content-Security-Policy: default-src 'self'"); define('BCRYPT_COST', 9); -- cgit v1.2.3 From 995cf58d249c6a2ddfd042cc5b509914295c882f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 28 Feb 2016 00:08:57 +0100 Subject: CSP bug in install script https://github.com/FreshRSS/FreshRSS/issues/1075 --- app/install.php | 2 +- p/scripts/install.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index a4a888af2..80e85354d 100644 --- a/app/install.php +++ b/app/install.php @@ -829,7 +829,6 @@ case 5: <?php echo _t('install.title'); ?> - @@ -877,5 +876,6 @@ case 5: ?>
+ diff --git a/p/scripts/install.js b/p/scripts/install.js index 52d8bf8e0..9a49e6031 100644 --- a/p/scripts/install.js +++ b/p/scripts/install.js @@ -42,7 +42,7 @@ function auth_type_change() { var auth_type = document.getElementById('auth_type'); if (auth_type) { auth_type_change(); - auth_type_change.addEventListener('change', auth_type_change); + auth_type.addEventListener('change', auth_type_change); } function mySqlShowHide() { -- cgit v1.2.3 From 6b19872b1a95113aa491626a64d4c3ff02e2ee00 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 28 Feb 2016 14:07:21 +0100 Subject: Install check XML / JSON https://github.com/FreshRSS/FreshRSS/issues/1094 https://github.com/FreshRSS/FreshRSS/issues/1092 --- app/i18n/cz/install.php | 10 +++++++++- app/i18n/de/install.php | 10 +++++++++- app/i18n/en/install.php | 10 +++++++++- app/i18n/fr/install.php | 10 +++++++++- app/i18n/it/install.php | 10 +++++++++- app/i18n/nl/install.php | 10 +++++++++- app/i18n/tr/install.php | 10 +++++++++- app/install.php | 18 +++++++++++++++++- 8 files changed, 80 insertions(+), 8 deletions(-) (limited to 'app/install.php') diff --git a/app/i18n/cz/install.php b/app/i18n/cz/install.php index a8bc62909..969b69271 100644 --- a/app/i18n/cz/install.php +++ b/app/i18n/cz/install.php @@ -51,7 +51,7 @@ return array( 'ok' => 'Oprávnění adresáře data jsou v pořádku.', ), 'dom' => array( - 'nok' => 'Nemáte požadovanou knihovnu pro procházení DOM (balíček php-xml).', + 'nok' => 'Nemáte požadovanou knihovnu pro procházení DOM.', 'ok' => 'Máte požadovanou knihovnu pro procházení DOM.', ), 'favicons' => array( @@ -62,6 +62,10 @@ return array( 'nok' => 'Zkontrolujte prosím že neměníte HTTP REFERER.', 'ok' => 'Váš HTTP REFERER je znám a odpovídá Vašemu serveru.', ), + 'json' => array( + 'nok' => 'You lack a recommended library to parse JSON.', + 'ok' => 'You have a recommended library to parse JSON.', + ), 'minz' => array( 'nok' => 'Nemáte framework Minz.', 'ok' => 'Máte framework Minz.', @@ -86,6 +90,10 @@ return array( 'nok' => 'Zkontrolujte oprávnění adresáře ./data/users. HTTP server musí mít do tohoto adresáře práva zápisu', 'ok' => 'Oprávnění adresáře users jsou v pořádku.', ), + 'xml' => array( + 'nok' => 'You lack the required library to parse XML.', + 'ok' => 'You have the required library to parse XML.', + ), ), 'conf' => array( '_' => 'Obecná nastavení', diff --git a/app/i18n/de/install.php b/app/i18n/de/install.php index 9bada0869..2da744cfb 100644 --- a/app/i18n/de/install.php +++ b/app/i18n/de/install.php @@ -51,7 +51,7 @@ return array( 'ok' => 'Die Berechtigungen des Verzeichnisses ./data sind in Ordnung.', ), 'dom' => array( - 'nok' => 'Ihnen fehlt eine benötigte Bibliothek um DOM zu durchstöbern (Paket php-xml).', + 'nok' => 'Ihnen fehlt eine benötigte Bibliothek um DOM zu durchstöbern.', 'ok' => 'Sie haben die benötigte Bibliothek um DOM zu durchstöbern.', ), 'favicons' => array( @@ -62,6 +62,10 @@ return array( 'nok' => 'Bitte stellen Sie sicher, dass Sie Ihren HTTP REFERER nicht abändern.', 'ok' => 'Ihr HTTP REFERER ist bekannt und entspricht Ihrem Server.', ), + 'json' => array( + 'nok' => 'You lack a recommended library to parse JSON.', + 'ok' => 'You have a recommended library to parse JSON.', + ), 'minz' => array( 'nok' => 'Ihnen fehlt das Minz-Framework.', 'ok' => 'Sie haben das Minz-Framework.', @@ -86,6 +90,10 @@ return array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses ./data/users. Der HTTP-Server muss Schreibrechte besitzen.', 'ok' => 'Die Berechtigungen des Verzeichnisses ./data/users sind in Ordnung.', ), + 'xml' => array( + 'nok' => 'You lack the required library to parse XML.', + 'ok' => 'You have the required library to parse XML.', + ), ), 'conf' => array( '_' => 'Allgemeine Konfiguration', diff --git a/app/i18n/en/install.php b/app/i18n/en/install.php index b94fbc299..4b5bbc62e 100644 --- a/app/i18n/en/install.php +++ b/app/i18n/en/install.php @@ -51,7 +51,7 @@ return array( 'ok' => 'Permissions on data directory are good.', ), 'dom' => array( - 'nok' => 'You lack a required library to browse the DOM (php-xml package).', + 'nok' => 'You lack a required library to browse the DOM.', 'ok' => 'You have the required library to browse the DOM.', ), 'favicons' => array( @@ -62,6 +62,10 @@ return array( 'nok' => 'Please check that you are not altering your HTTP REFERER.', 'ok' => 'Your HTTP REFERER is known and corresponds to your server.', ), + 'json' => array( + 'nok' => 'You lack a recommended library to parse JSON.', + 'ok' => 'You have a recommended library to parse JSON.', + ), 'minz' => array( 'nok' => 'You lack the Minz framework.', 'ok' => 'You have the Minz framework.', @@ -86,6 +90,10 @@ return array( 'nok' => 'Check permissions on ./data/users directory. HTTP server must have rights to write into', 'ok' => 'Permissions on users directory are good.', ), + 'xml' => array( + 'nok' => 'You lack the required library to parse XML.', + 'ok' => 'You have the required library to parse XML.', + ), ), 'conf' => array( '_' => 'General configuration', diff --git a/app/i18n/fr/install.php b/app/i18n/fr/install.php index 0401e1bbd..91dfbbb09 100644 --- a/app/i18n/fr/install.php +++ b/app/i18n/fr/install.php @@ -51,7 +51,7 @@ return array( 'ok' => 'Les droits sur le répertoire de data sont bons.', ), 'dom' => array( - 'nok' => 'Il manque une librairie pour parcourir le DOM (paquet php-xml).', + 'nok' => 'Il manque une librairie pour parcourir le DOM.', 'ok' => 'Vous disposez du nécessaire pour parcourir le DOM.', ), 'favicons' => array( @@ -62,6 +62,10 @@ return array( 'nok' => 'Veuillez vérifier que vous ne modifiez pas votre HTTP REFERER.', 'ok' => 'Le HTTP REFERER est connu et semble correspondre à votre serveur.', ), + 'json' => array( + 'nok' => 'Il manque une librairie recommandée pour JSON.', + 'ok' => 'Vouz disposez de la librairie recommandée pour JSON.', + ), 'minz' => array( 'nok' => 'Vous ne disposez pas de la librairie Minz.', 'ok' => 'Vous disposez du framework Minz', @@ -86,6 +90,10 @@ return array( 'nok' => 'Veuillez vérifier les droits sur le répertoire ./data/users. Le serveur HTTP doit être capable d’écrire dedans', 'ok' => 'Les droits sur le répertoire des utilisateurs sont bons.', ), + 'xml' => array( + 'nok' => 'Il manque une librairie requise pour XML.', + 'ok' => 'Vouz disposez de la librairie requise pour XML.', + ), ), 'conf' => array( '_' => 'Configuration générale', diff --git a/app/i18n/it/install.php b/app/i18n/it/install.php index 3ad22c5e9..8f5300bd5 100644 --- a/app/i18n/it/install.php +++ b/app/i18n/it/install.php @@ -51,7 +51,7 @@ return array( 'ok' => 'I permessi sulla cartella data sono corretti.', ), 'dom' => array( - 'nok' => 'Manca una libreria richiesta per leggere DOM (pacchetto php-xml).', + 'nok' => 'Manca una libreria richiesta per leggere DOM.', 'ok' => 'Libreria richiesta per leggere DOM presente.', ), 'favicons' => array( @@ -62,6 +62,10 @@ return array( 'nok' => 'Per favore verifica che non stai alterando il tuo HTTP REFERER.', 'ok' => 'Il tuo HTTP REFERER riconosciuto corrisponde al tuo server.', ), + 'json' => array( + 'nok' => 'You lack a recommended library to parse JSON.', + 'ok' => 'You have a recommended library to parse JSON.', + ), 'minz' => array( 'nok' => 'Manca il framework Minz.', 'ok' => 'Framework Minz presente.', @@ -87,6 +91,10 @@ return array( 'nok' => 'Verifica i permessi sulla cartella ./data/users. Il server HTTP deve avere i permessi per scriverci dentro', 'ok' => 'I permessi sulla cartella users sono corretti.', ), + 'xml' => array( + 'nok' => 'You lack the required library to parse XML.', + 'ok' => 'You have the required library to parse XML.', + ), ), 'conf' => array( '_' => 'Configurazioni generali', diff --git a/app/i18n/nl/install.php b/app/i18n/nl/install.php index e788261ea..3c44f7581 100644 --- a/app/i18n/nl/install.php +++ b/app/i18n/nl/install.php @@ -51,7 +51,7 @@ return array( 'ok' => 'Permissies van de data map zijn goed.', ), 'dom' => array( - 'nok' => 'U mist een benodigde bibliotheek om te bladeren in de DOM (php-xml package).', + 'nok' => 'U mist een benodigde bibliotheek om te bladeren in de DOM.', 'ok' => 'U hebt de benodigde bibliotheek om te bladeren in de DOM.', ), 'favicons' => array( @@ -62,6 +62,10 @@ return array( 'nok' => 'Controleer a.u.b. dat u niet uw HTTP REFERER wijzigd.', 'ok' => 'Uw HTTP REFERER is bekend en komt overeen met uw server.', ), + 'json' => array( + 'nok' => 'You lack a recommended library to parse JSON.', + 'ok' => 'You have a recommended library to parse JSON.', + ), 'minz' => array( 'nok' => 'U mist het Minz framework.', 'ok' => 'U hebt het Minz framework.', @@ -86,6 +90,10 @@ return array( 'nok' => 'Controleer permissies van de ./data/users map. HTTP server moet rechten hebben om er in te kunnen schrijven', 'ok' => 'Permissies van de users map zijn goed.', ), + 'xml' => array( + 'nok' => 'You lack the required library to parse XML.', + 'ok' => 'You have the required library to parse XML.', + ), ), 'conf' => array( '_' => 'Algemene configuratie', diff --git a/app/i18n/tr/install.php b/app/i18n/tr/install.php index 96c16931a..d4c7c4cd5 100644 --- a/app/i18n/tr/install.php +++ b/app/i18n/tr/install.php @@ -51,7 +51,7 @@ return array( 'ok' => 'Veri klasörü yetkileri sorunsuz.', ), 'dom' => array( - 'nok' => 'DOM kütüpbanesi eksik (php-xml package).', + 'nok' => 'DOM kütüpbanesi eksik.', 'ok' => 'DOM kütüphanesi sorunsuz.', ), 'favicons' => array( @@ -62,6 +62,10 @@ return array( 'nok' => 'Lütfen HTTP REFERER değiştirmediğinize emin olun.', 'ok' => 'HTTP REFERER ve sunucunuz arası iletişim sorunsuz.', ), + 'json' => array( + 'nok' => 'You lack a recommended library to parse JSON.', + 'ok' => 'You have a recommended library to parse JSON.', + ), 'minz' => array( 'nok' => 'Minz framework eksik.', 'ok' => 'Minz framework sorunsuz.', @@ -86,6 +90,10 @@ return array( 'nok' => './data/users klasör yetkisini kontrol edin. HTTP yazma yetkisi olmalı', 'ok' => 'Kullanıcılar klasörü yetkileri sorunsuz.', ), + 'xml' => array( + 'nok' => 'You lack the required library to parse XML.', + 'ok' => 'You have the required library to parse XML.', + ), ), 'conf' => array( '_' => 'Genel yapılandırma', diff --git a/app/install.php b/app/install.php index 80e85354d..b47effc84 100644 --- a/app/install.php +++ b/app/install.php @@ -318,6 +318,8 @@ function checkStep1() { $pcre = extension_loaded('pcre'); $ctype = extension_loaded('ctype'); $dom = class_exists('DOMDocument'); + $xml = function_exists('xml_parser_create'); + $json = function_exists('json_encode'); $data = DATA_PATH && is_writable(DATA_PATH); $cache = CACHE_PATH && is_writable(CACHE_PATH); $users = USERS_PATH && is_writable(USERS_PATH); @@ -335,13 +337,15 @@ function checkStep1() { 'pcre' => $pcre ? 'ok' : 'ko', 'ctype' => $ctype ? 'ok' : 'ko', 'dom' => $dom ? 'ok' : 'ko', + 'xml' => $xml ? 'ok' : 'ko', + 'json' => $json ? 'ok' : 'ko', 'data' => $data ? 'ok' : 'ko', 'cache' => $cache ? 'ok' : 'ko', 'users' => $users ? 'ok' : 'ko', 'favicons' => $favicons ? 'ok' : 'ko', 'persona' => $persona ? 'ok' : 'ko', 'http_referer' => $http_referer ? 'ok' : 'ko', - 'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom && + 'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom && $xml && $data && $cache && $users && $favicons && $persona && $http_referer ? 'ok' : 'ko' ); @@ -554,6 +558,12 @@ function printStep1() {

+ +

+ +

+ +

@@ -572,6 +582,12 @@ function printStep1() {

+ +

+ +

+ +

-- cgit v1.2.3 From ea4deb6e0568adca6c0f1bea536fac6869f9c7ec Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 12 Jun 2016 13:18:31 +0200 Subject: Check minimum PHP 5.3.0+ https://github.com/FreshRSS/FreshRSS/pull/1133 --- app/install.php | 4 ++-- app/views/update/checkInstall.phtml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index b47effc84..062f66814 100644 --- a/app/install.php +++ b/app/install.php @@ -309,7 +309,7 @@ function checkStep0() { } function checkStep1() { - $php = version_compare(PHP_VERSION, '5.2.1') >= 0; + $php = version_compare(PHP_VERSION, '5.3.0') >= 0; $minz = file_exists(join_path(LIB_PATH, 'Minz')); $curl = extension_loaded('curl'); $pdo_mysql = extension_loaded('pdo_mysql'); @@ -536,7 +536,7 @@ function printStep1() {

-

+

diff --git a/app/views/update/checkInstall.phtml b/app/views/update/checkInstall.phtml index a92860c7e..ed3858b56 100644 --- a/app/views/update/checkInstall.phtml +++ b/app/views/update/checkInstall.phtml @@ -9,7 +9,7 @@