summaryrefslogtreecommitdiff
path: root/p/api
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-06-03 15:18:04 +0200
committerGravatar GitHub <noreply@github.com> 2017-06-03 15:18:04 +0200
commitfd43ee546e419fc9fbb9a3ad974d2234d94cffaa (patch)
tree2df9fd1daf5b994d7bbde8dd46f7605e4370c268 /p/api
parentbe0bcfef7e38f27284ec7b377b342ba389515964 (diff)
parent6f3653d430c86b026f8e007a276fdba2b09b61b3 (diff)
Merge pull request #1549 from FreshRSS/dev1.7.0
Version 1.7.0
Diffstat (limited to 'p/api')
-rw-r--r--p/api/greader.php2
-rw-r--r--p/api/index.php2
-rw-r--r--p/api/pshb.php45
3 files changed, 35 insertions, 14 deletions
diff --git a/p/api/greader.php b/p/api/greader.php
index 01eca6d4f..e1f4202a7 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -695,7 +695,7 @@ $pathInfos = explode('/', $pathInfo);
Minz_Configuration::register('system',
DATA_PATH . '/config.php',
- DATA_PATH . '/config.default.php');
+ FRESHRSS_PATH . '/config.default.php');
FreshRSS_Context::$system_conf = Minz_Configuration::get('system');
if (!FreshRSS_Context::$system_conf->api_enabled) {
serviceUnavailable();
diff --git a/p/api/index.php b/p/api/index.php
index 3ab4e02b3..580c90255 100644
--- a/p/api/index.php
+++ b/p/api/index.php
@@ -16,7 +16,7 @@
<dd><?php
require('../../constants.php');
require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
-Minz_Configuration::register('system', DATA_PATH . '/config.php', DATA_PATH . '/config.default.php');
+Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php');
echo Minz_Url::display('/api/greader.php', 'html', true);
?></dd>
</dl>
diff --git a/p/api/pshb.php b/p/api/pshb.php
index e9b66b167..4b546908a 100644
--- a/p/api/pshb.php
+++ b/p/api/pshb.php
@@ -23,8 +23,13 @@ if (!ctype_xdigit($key)) {
chdir(PSHB_PATH);
$canonical64 = @file_get_contents('keys/' . $key . '.txt');
if ($canonical64 === false) {
+ if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] === 'unsubscribe') {
+ logMe('Warning: Accept unknown unsubscribe');
+ header('Connection: close');
+ exit(isset($_REQUEST['hub_challenge']) ? $_REQUEST['hub_challenge'] : '');
+ }
header('HTTP/1.1 404 Not Found');
- logMe('Error: Feed key not found!: ' . $key);
+ logMe('Warning: Feed key not found!: ' . $key);
die('Feed key not found!');
}
$canonical64 = trim($canonical64);
@@ -36,7 +41,7 @@ if (!preg_match('/^[A-Za-z0-9_-]+$/D', $canonical64)) {
$hubFile = @file_get_contents('feeds/' . $canonical64 . '/!hub.json');
if ($hubFile === false) {
header('HTTP/1.1 404 Not Found');
- //@unlink('keys/' . $key . '.txt');
+ unlink('keys/' . $key . '.txt');
logMe('Error: Feed info not found!: ' . $canonical64);
die('Feed info not found!');
}
@@ -50,8 +55,19 @@ chdir('feeds/' . $canonical64);
$users = glob('*.txt', GLOB_NOSORT);
if (empty($users)) {
header('HTTP/1.1 410 Gone');
- logMe('Error: Nobody is subscribed to this feed anymore!: ' . $canonical64);
- die('Nobody is subscribed to this feed anymore!');
+ $url = base64url_decode($canonical64);
+ logMe('Warning: Nobody subscribes to this feed anymore!: ' . $url);
+ unlink('../../keys/' . $key . '.txt');
+ Minz_Configuration::register('system',
+ DATA_PATH . '/config.php',
+ FRESHRSS_PATH . '/config.default.php');
+ FreshRSS_Context::$system_conf = Minz_Configuration::get('system');
+ $feed = new FreshRSS_Feed($url);
+ $feed->pubSubHubbubSubscribe(false);
+ unlink('!hub.json');
+ chdir('..');
+ recursive_unlink($canonical64);
+ die('Nobody subscribes to this feed anymore!');
}
if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] === 'subscribe') {
@@ -85,7 +101,7 @@ if ($ORIGINAL_INPUT == '') {
die('Missing XML payload!');
}
-Minz_Configuration::register('system', DATA_PATH . '/config.php', DATA_PATH . '/config.default.php');
+Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php');
$system_conf = Minz_Configuration::get('system');
$system_conf->auth_type = 'none'; // avoid necessity to be logged in (not saved!)
@@ -108,22 +124,27 @@ $nb = 0;
foreach ($users as $userFilename) {
$username = basename($userFilename, '.txt');
if (!file_exists(USERS_PATH . '/' . $username . '/config.php')) {
- break;
+ logMe('Warning: Removing broken user link: ' . $username . ' for ' . $self);
+ unlink($userFilename);
+ continue;
}
try {
Minz_Session::_param('currentUser', $username);
Minz_Configuration::register('user',
join_path(USERS_PATH, $username, 'config.php'),
- join_path(USERS_PATH, '_', 'config.default.php'));
+ join_path(FRESHRSS_PATH, 'config-user.default.php'));
new Minz_ModelPdo($username); //TODO: FIXME: Quick-fix while waiting for a better FreshRSS() constructor/init
FreshRSS_Context::init();
- list($updated_feeds, $feed) = FreshRSS_feed_Controller::actualizeFeed(0, $self, false, $simplePie);
- if ($updated_feeds > 0) {
+ list($updated_feeds, $feed, $nb_new_articles) = FreshRSS_feed_Controller::actualizeFeed(0, $self, false, $simplePie);
+ if ($updated_feeds > 0 || $feed != false) {
$nb++;
+ } else {
+ logMe('Warning: User ' . $username . ' does not subscribe anymore to ' . $self);
+ unlink($userFilename);
}
} catch (Exception $e) {
- logMe('Error: ' . $e->getMessage());
+ logMe('Error: ' . $e->getMessage() . ' for user ' . $username . ' and feed ' . $self);
}
}
@@ -132,8 +153,8 @@ unset($simplePie);
if ($nb === 0) {
header('HTTP/1.1 410 Gone');
- logMe('Error: Nobody is subscribed to this feed anymore after all!: ' . $self);
- die('Nobody is subscribed to this feed anymore after all!');
+ logMe('Warning: Nobody subscribes to this feed anymore after all!: ' . $self);
+ die('Nobody subscribes to this feed anymore after all!');
} elseif (!empty($hubJson['error'])) {
$hubJson['error'] = false;
file_put_contents('./!hub.json', json_encode($hubJson));