aboutsummaryrefslogtreecommitdiff
path: root/p
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-01-26 16:03:29 +0100
committerGravatar GitHub <noreply@github.com> 2019-01-26 16:03:29 +0100
commit8dcdde6251ae4dfc690b1a014488df125c5e5cdc (patch)
treef5762ac9c76acf708a50534f081e558489ccad86 /p
parentf0a359619fa2936d66a2b96dd086d4686e7405fa (diff)
parent38e8e265e0f2ead830aa12e7ef81de12599405b5 (diff)
Merge pull request #2220 from FreshRSS/dev1.13.1
FreshRSS 1.13.1
Diffstat (limited to 'p')
-rw-r--r--p/api/.htaccess11
-rw-r--r--p/api/greader.php21
-rw-r--r--p/api/index.php27
-rw-r--r--p/i/.gitignore2
-rwxr-xr-xp/i/index.php2
-rw-r--r--p/scripts/api.js62
-rw-r--r--p/scripts/main.js12
7 files changed, 107 insertions, 30 deletions
diff --git a/p/api/.htaccess b/p/api/.htaccess
index 41b653d96..937983ec9 100644
--- a/p/api/.htaccess
+++ b/p/api/.htaccess
@@ -1,4 +1,9 @@
-<IfModule mod_rewrite.c>
- RewriteEngine on
- RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+<IfModule mod_setenvif.c>
+ SetEnvIf "^Authorization$" "(.*)" HTTP_AUTHORIZATION=$1
+</IfModule>
+<IfModule !mod_setenvif.c>
+ <IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+ </IfModule>
</IfModule>
diff --git a/p/api/greader.php b/p/api/greader.php
index 7cd312f2c..d41430d3c 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -143,14 +143,11 @@ function checkCompatibility() {
Minz_Log::warning('checkCompatibility() ' . debugInfo(), API_LOG);
header('Content-Type: text/plain; charset=UTF-8');
if (PHP_INT_SIZE < 8 && !function_exists('gmp_init')) {
- die('FAIL 64-bit or GMP extension!');
+ die('FAIL 64-bit or GMP extension! Wrong PHP configuration.');
}
- if ((!array_key_exists('HTTP_AUTHORIZATION', $_SERVER)) && //Apache mod_rewrite trick should be fine
- (!array_key_exists('REDIRECT_HTTP_AUTHORIZATION', $_SERVER)) && //Apache mod_rewrite with FCGI
- (empty($_SERVER['SERVER_SOFTWARE']) || (stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') === false)) && //nginx should be fine
- (empty($_SERVER['SERVER_SOFTWARE']) || (stripos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') === false)) && //lighttpd should be fine
- ((!function_exists('getallheaders')) || (stripos(php_sapi_name(), 'cgi') !== false))) { //Main problem is Apache/CGI mode
- die('FAIL getallheaders! (probably)');
+ $headerAuth = headerVariable('Authorization', 'GoogleLogin_auth');
+ if ($headerAuth == '') {
+ die('FAIL get HTTP Authorization header! Wrong Web server configuration.');
}
echo 'PASS';
exit();
@@ -913,6 +910,10 @@ FreshRSS_Context::$system_conf = Minz_Configuration::get('system');
if (!FreshRSS_Context::$system_conf->api_enabled) {
serviceUnavailable();
+} elseif (count($pathInfos) < 3) {
+ badRequest();
+} elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') {
+ checkCompatibility();
}
ini_set('session.use_cookies', '0');
@@ -927,9 +928,7 @@ if ($user !== '') {
Minz_Session::_param('currentUser', $user);
-if (count($pathInfos) < 3) {
- badRequest();
-} elseif ($pathInfos[1] === 'accounts') {
+if ($pathInfos[1] === 'accounts') {
if (($pathInfos[2] === 'ClientLogin') && isset($_REQUEST['Email']) && isset($_REQUEST['Passwd'])) {
clientLogin($_REQUEST['Email'], $_REQUEST['Passwd']);
}
@@ -1088,8 +1087,6 @@ if (count($pathInfos) < 3) {
userInfo();
break;
}
-} elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') {
- checkCompatibility();
}
badRequest();
diff --git a/p/api/index.php b/p/api/index.php
index ee37b794b..d441099d7 100644
--- a/p/api/index.php
+++ b/p/api/index.php
@@ -5,6 +5,18 @@
<title>FreshRSS API endpoints</title>
<meta name="robots" content="noindex" />
<link rel="start" href="../i/" />
+<script src="../scripts/api.js" defer="defer"></script>
+<script id="jsonVars" type="application/json">
+<?php
+require(__DIR__ . '/../../constants.php');
+require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php');
+echo json_encode(array(
+ 'greader' => Minz_Url::display('/api/greader.php', 'php', true),
+ 'fever' => Minz_Url::display('/api/fever.php', 'php', true),
+ ));
+?>
+</script>
</head>
<body>
@@ -14,17 +26,11 @@
<dl>
<dt>Your API address:</dt>
<dd><?php
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
-Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php');
echo Minz_Url::display('/api/greader.php', 'html', true);
?></dd>
+<dt>Google Reader API configuration test:</dt>
+<dd id="greaderOutput">?</dd>
</dl>
-<ul>
-<li><a href="greader.php/check%2Fcompatibility" rel="nofollow">Check full server configuration</a></li>
-<li><a href="greader.php/check/compatibility" rel="nofollow">Check partial server
-configuration (without <code>%2F</code> support)</a></li>
-</ul>
<h2>Fever compatible API</h2>
<dl>
@@ -32,10 +38,9 @@ configuration (without <code>%2F</code> support)</a></li>
<dd><?php
echo Minz_Url::display('/api/fever.php', 'html', true);
?></dd>
+<dt>Fever API configuration test:</dt>
+<dd id="feverOutput">?</dd>
</dl>
-<ul>
-<li><a href="fever.php?api" rel="nofollow">Test</a></li>
-</ul>
</body>
</html>
diff --git a/p/i/.gitignore b/p/i/.gitignore
index 03c88fd7a..b76d11b5a 100644
--- a/p/i/.gitignore
+++ b/p/i/.gitignore
@@ -1 +1 @@
-.htaccess
+.ht*
diff --git a/p/i/index.php b/p/i/index.php
index 5bc9c0d76..8a4f529d4 100755
--- a/p/i/index.php
+++ b/p/i/index.php
@@ -50,5 +50,7 @@ if (file_exists(DATA_PATH . '/do-install.txt')) {
echo '### Fatal error! ###<br />', "\n";
Minz_Log::error($e->getMessage());
echo 'See logs files.';
+ prepareSyslog();
+ syslog(LOG_INFO, 'FreshRSS Fatal error! ' . $e->getMessage());
}
}
diff --git a/p/scripts/api.js b/p/scripts/api.js
new file mode 100644
index 000000000..841b16a6a
--- /dev/null
+++ b/p/scripts/api.js
@@ -0,0 +1,62 @@
+"use strict";
+/* jshint esversion:6, strict:global */
+
+function check(url, next) {
+ if (!url || !next) {
+ return;
+ }
+ const req = new XMLHttpRequest();
+ req.open('GET', url, true);
+ req.setRequestHeader('Authorization', 'GoogleLogin auth=test/1');
+ req.onerror = function (e) {
+ next('FAIL: HTTP ' + e);
+ };
+ req.onload = function () {
+ if (this.status == 200) {
+ next(this.response);
+ } else {
+ next('FAIL: HTTP error ' + this.status + ' ' + this.statusText);
+ }
+ };
+ req.send();
+}
+
+const jsonVars = JSON.parse(document.getElementById('jsonVars').innerHTML);
+
+check(jsonVars.greader + '/check/compatibility', function next(result1) {
+ const greaderOutput = document.getElementById('greaderOutput');
+ if (result1 === 'PASS') {
+ greaderOutput.innerHTML = '✔️ ' + result1;
+ } else {
+ check(jsonVars.greader + '/check%2Fcompatibility', function next(result2) {
+ if (result2 === 'PASS') {
+ greaderOutput.innerHTML = '⚠️ WARN: no <code>%2F</code> support, so some clients will not work!';
+ } else {
+ check('./greader.php/check/compatibility', function next(result3) {
+ if (result3 === 'PASS') {
+ greaderOutput.innerHTML = '⚠️ WARN: Probable invalid base URL in ./data/config.php';
+ } else {
+ greaderOutput.innerHTML = '❌ ' + result1;
+ }
+ });
+ }
+ });
+ }
+ });
+
+check(jsonVars.fever + '?api', function next(result1) {
+ const feverOutput = document.getElementById('feverOutput');
+ try {
+ JSON.parse(result1);
+ feverOutput.innerHTML = '✔️ PASS';
+ } catch (ex) {
+ check('./fever.php?api', function next(result2) {
+ try {
+ JSON.parse(result2);
+ feverOutput.innerHTML = '⚠️ WARN: Probable invalid base URL in ./data/config.php';
+ } catch (ex) {
+ feverOutput.innerHTML = '❌ ' + result1;
+ }
+ });
+ }
+ });
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 4ba329dc1..6cab2e55a 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -237,6 +237,9 @@ function mark_favorite(active) {
});
}
+var freshrssOpenArticleEvent = document.createEvent('Event');
+freshrssOpenArticleEvent.initEvent('freshrss:openArticle', true, true);
+
function toggleContent(new_active, old_active, skipping) {
// If skipping, move current without activating or marking as read
if (new_active.length === 0) {
@@ -299,8 +302,11 @@ function toggleContent(new_active, old_active, skipping) {
}
}
- if (context.auto_mark_article && new_active.hasClass('active') && !skipping) {
- mark_read(new_active, true);
+ if (new_active.hasClass('active') && !skipping) {
+ if (context.auto_mark_article) {
+ mark_read(new_active, true);
+ }
+ new_active[0].dispatchEvent(freshrssOpenArticleEvent);
}
}
@@ -543,7 +549,7 @@ function init_column_categories() {
}
});
$(this).parent().next(".tree-folder-items").slideToggle(300, function () {
- //Workaround for Gecko bug in Firefox 64-65(+?):
+ //Workaround for Gecko bug 1514498 in Firefox 64
var sidebar = document.getElementById('sidebar');
if (sidebar && sidebar.scrollHeight > sidebar.clientHeight && //if needs scrollbar
sidebar.scrollWidth >= sidebar.offsetWidth) { //but no scrollbar