aboutsummaryrefslogtreecommitdiff
path: root/p/api/greader.php
diff options
context:
space:
mode:
authorGravatar Clément <clement@selfhost.fr> 2017-02-15 14:12:25 +0100
committerGravatar Clément <clement@selfhost.fr> 2017-02-15 14:12:25 +0100
commit2d097bc855dbd1ad06c7c306c05e78a198209084 (patch)
tree67028e45792c575c25c92616633f64cc7a4a13eb /p/api/greader.php
parentfe293900061263a1917fc1cf18ca369c8e07cb99 (diff)
parent5f637bd816b7323885bfe1751a1724ee59a822f6 (diff)
Merge remote-tracking branch 'FreshRSS/master' into dev
Diffstat (limited to 'p/api/greader.php')
-rw-r--r--p/api/greader.php317
1 files changed, 258 insertions, 59 deletions
diff --git a/p/api/greader.php b/p/api/greader.php
index 1a66c30fb..4965ffd3b 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -23,7 +23,7 @@ Server-side API compatible with Google Reader API layer 2
require('../../constants.php');
require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
-$ORIGINAL_INPUT = file_get_contents('php://input');
+$ORIGINAL_INPUT = file_get_contents('php://input', false, null, -1, 1048576);
if (PHP_INT_SIZE < 8) { //32-bit
function dec2hex($dec) {
@@ -46,6 +46,8 @@ function headerVariable($headerName, $varName) {
$upName = 'HTTP_' . strtoupper($headerName);
if (isset($_SERVER[$upName])) {
$header = $_SERVER[$upName];
+ } elseif (isset($_SERVER['REDIRECT_' . $upName])) {
+ $header = $_SERVER['REDIRECT_' . $upName];
} elseif (function_exists('getallheaders')) {
$ALL_HEADERS = getallheaders();
if (isset($ALL_HEADERS[$headerName])) {
@@ -77,7 +79,7 @@ class MyPDO extends Minz_ModelPdo {
}
function logMe($text) {
- file_put_contents(LOG_PATH . '/api.log', $text, FILE_APPEND);
+ file_put_contents(join_path(USERS_PATH, '_', 'log_api.txt'), date('c') . "\t" . $text . "\n", FILE_APPEND);
}
function debugInfo() {
@@ -96,7 +98,7 @@ function debugInfo() {
}
function badRequest() {
- logMe("badRequest()\n");
+ logMe("badRequest()");
logMe(debugInfo());
header('HTTP/1.1 400 Bad Request');
header('Content-Type: text/plain; charset=UTF-8');
@@ -104,7 +106,7 @@ function badRequest() {
}
function unauthorized() {
- logMe("unauthorized()\n");
+ logMe("unauthorized()");
logMe(debugInfo());
header('HTTP/1.1 401 Unauthorized');
header('Content-Type: text/plain; charset=UTF-8');
@@ -113,7 +115,7 @@ function unauthorized() {
}
function notImplemented() {
- logMe("notImplemented()\n");
+ logMe("notImplemented()");
logMe(debugInfo());
header('HTTP/1.1 501 Not Implemented');
header('Content-Type: text/plain; charset=UTF-8');
@@ -121,19 +123,20 @@ function notImplemented() {
}
function serviceUnavailable() {
- logMe("serviceUnavailable()\n");
+ logMe("serviceUnavailable()");
header('HTTP/1.1 503 Service Unavailable');
header('Content-Type: text/plain; charset=UTF-8');
die('Service Unavailable!');
}
function checkCompatibility() {
- logMe("checkCompatibility()\n");
+ logMe("checkCompatibility()");
header('Content-Type: text/plain; charset=UTF-8');
if (PHP_INT_SIZE < 8 && !function_exists('gmp_init')) {
die('FAIL 64-bit or GMP extension!');
}
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
@@ -143,23 +146,22 @@ function checkCompatibility() {
exit();
}
-function authorizationToUserConf() {
+function authorizationToUser() {
$headerAuth = headerVariable('Authorization', 'GoogleLogin_auth'); //Input is 'GoogleLogin auth', but PHP replaces spaces by '_' http://php.net/language.variables.external
if ($headerAuth != '') {
$headerAuthX = explode('/', $headerAuth, 2);
if (count($headerAuthX) === 2) {
$user = $headerAuthX[0];
if (ctype_alnum($user)) {
- try {
- $conf = new FreshRSS_Configuration($user);
- } catch (Exception $e) {
- logMe($e->getMessage() . "\n");
+ FreshRSS_Context::$user_conf = get_user_configuration($user);
+ if (FreshRSS_Context::$user_conf == null) {
+ Minz_Log::warning('Invalid API user ' . $user . ': configuration cannot be found.');
unauthorized();
}
- if ($headerAuthX[1] === sha1(Minz_Configuration::salt() . $conf->user . $conf->apiPasswordHash)) {
- return $conf;
+ if ($headerAuthX[1] === sha1(FreshRSS_Context::$system_conf->salt . $user . FreshRSS_Context::$user_conf->apiPasswordHash)) {
+ return $user;
} else {
- logMe('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1] . "\n");
+ logMe('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1]);
Minz_Log::warning('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1]);
unauthorized();
}
@@ -168,25 +170,25 @@ function authorizationToUserConf() {
}
}
}
- return null;
+ return '';
}
function clientLogin($email, $pass) { //http://web.archive.org/web/20130604091042/http://undoc.in/clientLogin.html
- logMe('clientLogin(' . $email . ")\n");
+ //logMe('clientLogin(' . $email . ")");
if (ctype_alnum($email)) {
if (!function_exists('password_verify')) {
include_once(LIB_PATH . '/password_compat.php');
}
- try {
- $conf = new FreshRSS_Configuration($email);
- } catch (Exception $e) {
- logMe($e->getMessage() . "\n");
- Minz_Log::warning('Invalid API user ' . $email);
+
+ FreshRSS_Context::$user_conf = get_user_configuration($email);
+ if (FreshRSS_Context::$user_conf == null) {
+ Minz_Log::warning('Invalid API user ' . $email . ': configuration cannot be found.');
unauthorized();
}
- if ($conf->apiPasswordHash != '' && password_verify($pass, $conf->apiPasswordHash)) {
+
+ if (FreshRSS_Context::$user_conf->apiPasswordHash != '' && password_verify($pass, FreshRSS_Context::$user_conf->apiPasswordHash)) {
header('Content-Type: text/plain; charset=UTF-8');
- $auth = $email . '/' . sha1(Minz_Configuration::salt() . $conf->user . $conf->apiPasswordHash);
+ $auth = $email . '/' . sha1(FreshRSS_Context::$system_conf->salt . $email . FreshRSS_Context::$user_conf->apiPasswordHash);
echo 'SID=', $auth, "\n",
'Auth=', $auth, "\n";
exit();
@@ -203,23 +205,36 @@ function clientLogin($email, $pass) { //http://web.archive.org/web/2013060409104
function token($conf) {
//http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/
//https://github.com/ericmann/gReader-Library/blob/master/greader.class.php
- logMe('token('. $conf->user . ")\n"); //TODO: Implement real token that expires
- $token = str_pad(sha1(Minz_Configuration::salt() . $conf->user . $conf->apiPasswordHash), 57, 'Z'); //Must have 57 characters
+ $user = Minz_Session::param('currentUser', '_');
+ //logMe('token('. $user . ")"); //TODO: Implement real token that expires
+ $token = str_pad(sha1(FreshRSS_Context::$system_conf->salt . $user . $conf->apiPasswordHash), 57, 'Z'); //Must have 57 characters
echo $token, "\n";
exit();
}
function checkToken($conf, $token) {
//http://code.google.com/p/google-reader-api/wiki/ActionToken
- logMe('checkToken(' . $token . ")\n");
- if ($token === str_pad(sha1(Minz_Configuration::salt() . $conf->user . $conf->apiPasswordHash), 57, 'Z')) {
+ $user = Minz_Session::param('currentUser', '_');
+ //logMe('checkToken(' . $token . ")");
+ if ($token === str_pad(sha1(FreshRSS_Context::$system_conf->salt . $user . $conf->apiPasswordHash), 57, 'Z')) {
return true;
}
unauthorized();
}
+function userInfo() { //https://github.com/theoldreader/api#user-info
+ //logMe("userInfo()");
+ $user = Minz_Session::param('currentUser', '_');
+ exit(json_encode(array(
+ 'userId' => $user,
+ 'userName' => $user,
+ 'userProfileId' => $user,
+ 'userEmail' => FreshRSS_Context::$user_conf->mail_login,
+ )));
+}
+
function tagList() {
- logMe("tagList()\n");
+ //logMe("tagList()");
header('Content-Type: application/json; charset=UTF-8');
$pdo = new MyPDO();
@@ -244,7 +259,7 @@ function tagList() {
}
function subscriptionList() {
- logMe("subscriptionList()\n");
+ //logMe("subscriptionList()");
header('Content-Type: application/json; charset=UTF-8');
$pdo = new MyPDO();
@@ -253,6 +268,7 @@ function subscriptionList() {
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
+ $salt = FreshRSS_Context::$system_conf->salt;
$subscriptions = array();
foreach ($res as $line) {
@@ -269,7 +285,7 @@ function subscriptionList() {
//'firstitemmsec' => 0,
'url' => $line['url'],
'htmlUrl' => $line['website'],
- //'iconUrl' => '',
+ 'iconUrl' => Minz_Url::display('/f.php?' . hash('crc32b', $salt . $line['url']), '', true),
);
}
@@ -277,8 +293,111 @@ function subscriptionList() {
exit();
}
+function subscriptionEdit($streamNames, $titles, $action, $add = '', $remove = '') {
+ //logMe("subscriptionEdit()");
+ //https://github.com/mihaip/google-reader-api/blob/master/wiki/ApiSubscriptionEdit.wiki
+ switch ($action) {
+ case 'subscribe':
+ case 'unsubscribe':
+ case 'edit':
+ break;
+ default:
+ badRequest();
+ }
+ $addCatId = 0;
+ $categoryDAO = null;
+ if ($add != '' || $remove != '') {
+ $categoryDAO = new FreshRSS_CategoryDAO();
+ }
+ $c_name = '';
+ if ($add != '' && strpos($add, 'user/') === 0) { //user/-/label/Example ; user/username/label/Example
+ if (strpos($add, 'user/-/label/') === 0) {
+ $c_name = substr($add, 13);
+ } else {
+ $user = Minz_Session::param('currentUser', '_');
+ $prefix = 'user/' . $user . '/label/';
+ if (strpos($add, $prefix) === 0) {
+ $c_name = substr($add, strlen($prefix));
+ } else {
+ $c_name = '';
+ }
+ }
+ $cat = $categoryDAO->searchByName($c_name);
+ $addCatId = $cat == null ? 0 : $cat->id();
+ } else if ($remove != '' && strpos($remove, 'user/-/label/')) {
+ $addCatId = 1; //Default category
+ }
+ $feedDAO = FreshRSS_Factory::createFeedDao();
+ for ($i = count($streamNames) - 1; $i >= 0; $i--) {
+ $streamName = $streamNames[$i]; //feed/http://example.net/sample.xml ; feed/338
+ if (strpos($streamName, 'feed/') === 0) {
+ $streamName = substr($streamName, 5);
+ $feedId = 0;
+ if (ctype_digit($streamName)) {
+ if ($action === 'subscribe') {
+ continue;
+ }
+ $feedId = $streamName;
+ } else {
+ $feed = $feedDAO->searchByUrl($streamName);
+ $feedId = $feed == null ? -1 : $feed->id();
+ }
+ $title = isset($titles[$i]) ? $titles[$i] : '';
+ switch ($action) {
+ case 'subscribe':
+ if ($feedId <= 0) {
+ $http_auth = ''; //TODO
+ try {
+ $feed = FreshRSS_feed_Controller::addFeed($streamName, $title, $addCatId, $c_name, $http_auth);
+ continue;
+ } catch (Exception $e) {
+ logMe("subscriptionEdit error subscribe: " . $e->getMessage());
+ }
+ }
+ badRequest();
+ break;
+ case 'unsubscribe':
+ if (!($feedId > 0 && FreshRSS_feed_Controller::deleteFeed($feedId))) {
+ badRequest();
+ }
+ break;
+ case 'edit':
+ if ($feedId > 0) {
+ if ($addCatId > 0 || $c_name != '') {
+ FreshRSS_feed_Controller::moveFeed($feedId, $addCatId, $c_name);
+ }
+ if ($title != '') {
+ FreshRSS_feed_Controller::renameFeed($feedId, $title);
+ }
+ } else {
+ badRequest();
+ }
+ break;
+ }
+ }
+ }
+ exit('OK');
+}
+
+function quickadd($url) {
+ //logMe("quickadd($url)");
+ try {
+ $feed = FreshRSS_feed_Controller::addFeed($url);
+ exit(json_encode(array(
+ 'numResults' => 1,
+ 'streamId' => $feed->id(),
+ )));
+ } catch (Exception $e) {
+ logMe("subscriptionEdit error subscribe: " . $e->getMessage());
+ die(json_encode(array(
+ 'numResults' => 0,
+ 'error' => $e->getMessage(),
+ )));
+ }
+}
+
function unreadCount() { //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#unread-count
- logMe("unreadCount()\n");
+ //logMe("unreadCount()");
header('Content-Type: application/json; charset=UTF-8');
$totalUnreads = 0;
@@ -325,7 +444,7 @@ function unreadCount() { //http://blog.martindoms.com/2009/10/16/using-the-googl
function streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation) {
//http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
//http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
- logMe("streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation)\n");
+ //logMe("streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation)");
header('Content-Type: application/json; charset=UTF-8');
$feedDAO = FreshRSS_Factory::createFeedDao();
@@ -356,6 +475,9 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex
case 'user/-/state/com.google/read':
$state = FreshRSS_Entry::STATE_NOT_READ;
break;
+ case 'user/-/state/com.google/unread':
+ $state = FreshRSS_Entry::STATE_READ;
+ break;
default:
$state = FreshRSS_Entry::STATE_ALL;
break;
@@ -366,7 +488,7 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex
}
$entryDAO = FreshRSS_Factory::createEntryDao();
- $entries = $entryDAO->listWhere($type, $include_target, $state, $order === 'o' ? 'ASC' : 'DESC', $count, $continuation, '', $start_time);
+ $entries = $entryDAO->listWhere($type, $include_target, $state, $order === 'o' ? 'ASC' : 'DESC', $count, $continuation, new FreshRSS_Search(''), $start_time);
$items = array();
foreach ($entries as $entry) {
@@ -431,7 +553,7 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude
//http://code.google.com/p/google-reader-api/wiki/ApiStreamItemsIds
//http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
//http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
- logMe("streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target)\n");
+ //logMe("streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target)");
$type = 'A';
$id = '';
@@ -444,7 +566,7 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude
$id = basename($streamId);
} elseif (strpos($streamId, 'user/-/label/') === 0) {
$type = 'c';
- $c_name = basename($streamId);
+ $c_name = substr($streamId, 13);
$categoryDAO = new FreshRSS_CategoryDAO();
$cat = $categoryDAO->searchByName($c_name);
$id = $cat == null ? -1 : $cat->id();
@@ -460,8 +582,11 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude
}
$entryDAO = FreshRSS_Factory::createEntryDao();
- $ids = $entryDAO->listIdsWhere($type, $id, $state, $order === 'o' ? 'ASC' : 'DESC', $count, '', '', $start_time);
+ $ids = $entryDAO->listIdsWhere($type, $id, $state, $order === 'o' ? 'ASC' : 'DESC', $count, '', new FreshRSS_Search(''), $start_time);
+ if (empty($ids)) { //For News+ bug https://github.com/noinnion/newsplus/issues/84#issuecomment-57834632
+ $ids[] = 0;
+ }
$itemRefs = array();
foreach ($ids as $id) {
$itemRefs[] = array(
@@ -476,7 +601,7 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude
}
function editTag($e_ids, $a, $r) {
- logMe("editTag()\n");
+ //logMe("editTag()");
foreach ($e_ids as $i => $e_id) {
$e_ids[$i] = hex2dec(basename($e_id)); //Strip prefix 'tag:google.com,2005:reader/item/'
@@ -507,18 +632,51 @@ function editTag($e_ids, $a, $r) {
break;
}
- echo 'OK';
- exit();
+ exit('OK');
+}
+
+function renameTag($s, $dest) {
+ //logMe("renameTag()");
+ if ($s != '' && strpos($s, 'user/-/label/') === 0 &&
+ $dest != '' && strpos($dest, 'user/-/label/') === 0) {
+ $s = substr($s, 13);
+ $categoryDAO = new FreshRSS_CategoryDAO();
+ $cat = $categoryDAO->searchByName($s);
+ if ($cat != null) {
+ $dest = substr($dest, 13);
+ $categoryDAO->updateCategory($cat->id(), array('name' => $dest));
+ exit('OK');
+ }
+ }
+ badRequest();
+}
+
+function disableTag($s) {
+ //logMe("disableTag($s)");
+ if ($s != '' && strpos($s, 'user/-/label/') === 0) {
+ $s = substr($s, 13);
+ $categoryDAO = new FreshRSS_CategoryDAO();
+ $cat = $categoryDAO->searchByName($s);
+ if ($cat != null) {
+ $feedDAO = FreshRSS_Factory::createFeedDao();
+ $feedDAO->changeCategory($cat->id(), 0);
+ if ($cat->id() > 1) {
+ $categoryDAO->deleteCategory($cat->id());
+ }
+ exit('OK');
+ }
+ }
+ badRequest();
}
function markAllAsRead($streamId, $olderThanId) {
- logMe("markAllAsRead($streamId, $olderThanId)\n");
+ //logMe("markAllAsRead($streamId, $olderThanId)");
$entryDAO = FreshRSS_Factory::createEntryDao();
if (strpos($streamId, 'feed/') === 0) {
$f_id = basename($streamId);
$entryDAO->markReadFeed($f_id, $olderThanId);
} elseif (strpos($streamId, 'user/-/label/') === 0) {
- $c_name = basename($streamId);
+ $c_name = substr($streamId, 13);
$categoryDAO = new FreshRSS_CategoryDAO();
$cat = $categoryDAO->searchByName($c_name);
$entryDAO->markReadCat($cat === null ? -1 : $cat->id(), $olderThanId);
@@ -526,28 +684,32 @@ function markAllAsRead($streamId, $olderThanId) {
$entryDAO->markReadEntries($olderThanId, false, -1);
}
- echo 'OK';
- exit();
+ exit('OK');
}
-logMe('----------------------------------------------------------------'."\n");
+//logMe('----------------------------------------------------------------');
//logMe(debugInfo());
$pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : urldecode($_SERVER['PATH_INFO']);
$pathInfos = explode('/', $pathInfo);
-Minz_Configuration::init();
-
-if (!Minz_Configuration::apiEnabled()) {
+Minz_Configuration::register('system',
+ DATA_PATH . '/config.php',
+ DATA_PATH . '/config.default.php');
+FreshRSS_Context::$system_conf = Minz_Configuration::get('system');
+if (!FreshRSS_Context::$system_conf->api_enabled) {
serviceUnavailable();
}
Minz_Session::init('FreshRSS');
-$conf = authorizationToUserConf();
-$user = $conf == null ? '' : $conf->user;
+$user = authorizationToUser();
+FreshRSS_Context::$user_conf = null;
+if ($user !== '') {
+ FreshRSS_Context::$user_conf = get_user_configuration($user);
+}
-logMe('User => ' . $user . "\n");
+//logMe('User => ' . $user);
Minz_Session::_param('currentUser', $user);
@@ -604,14 +766,33 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo
if (isset($pathInfos[5]) && $pathInfos[5] === 'list') {
$output = isset($_GET['output']) ? $_GET['output'] : '';
if ($output !== 'json') notImplemented();
- tagList($_GET['output']);
+ tagList($output);
}
break;
case 'subscription':
- if (isset($pathInfos[5]) && $pathInfos[5] === 'list') {
- $output = isset($_GET['output']) ? $_GET['output'] : '';
- if ($output !== 'json') notImplemented();
- subscriptionList($_GET['output']);
+ if (isset($pathInfos[5])) {
+ switch ($pathInfos[5]) {
+ case 'list':
+ $output = isset($_GET['output']) ? $_GET['output'] : '';
+ if ($output !== 'json') notImplemented();
+ subscriptionList($_GET['output']);
+ break;
+ case 'edit':
+ if (isset($_POST['s']) && isset($_POST['ac'])) {
+ $streamNames = multiplePosts('s'); //StreamId to operate on. The parameter may be repeated to edit multiple subscriptions at once
+ $titles = multiplePosts('t'); //Title to use for the subscription. For the `subscribe` action, if not specified then the feed's current title will be used. Can be used with the `edit` action to rename a subscription
+ $action = $_POST['ac']; //Action to perform on the given StreamId. Possible values are `subscribe`, `unsubscribe` and `edit`
+ $add = isset($_POST['a']) ? $_POST['a'] : ''; //StreamId to add the subscription to (generally a user label)
+ $remove = isset($_POST['r']) ? $_POST['r'] : ''; //StreamId to remove the subscription from (generally a user label)
+ subscriptionEdit($streamNames, $titles, $action, $add, $remove);
+ }
+ break;
+ case 'quickadd': //https://github.com/theoldreader/api
+ if (isset($_GET['quickadd'])) {
+ quickadd($_GET['quickadd']);
+ }
+ break;
+ }
}
break;
case 'unread-count':
@@ -622,15 +803,30 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo
break;
case 'edit-tag': //http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-part-3/
$token = isset($_POST['T']) ? trim($_POST['T']) : '';
- checkToken($conf, $token);
+ checkToken(FreshRSS_Context::$user_conf, $token);
$a = isset($_POST['a']) ? $_POST['a'] : ''; //Add: user/-/state/com.google/read user/-/state/com.google/starred
$r = isset($_POST['r']) ? $_POST['r'] : ''; //Remove: user/-/state/com.google/read user/-/state/com.google/starred
$e_ids = multiplePosts('i'); //item IDs
editTag($e_ids, $a, $r);
break;
+ case 'rename-tag': //https://github.com/theoldreader/api
+ $token = isset($_POST['T']) ? trim($_POST['T']) : '';
+ checkToken(FreshRSS_Context::$user_conf, $token);
+ $s = isset($_POST['s']) ? $_POST['s'] : ''; //user/-/label/Folder
+ $dest = isset($_POST['dest']) ? $_POST['dest'] : ''; //user/-/label/NewFolder
+ renameTag($s, $dest);
+ break;
+ case 'disable-tag': //https://github.com/theoldreader/api
+ $token = isset($_POST['T']) ? trim($_POST['T']) : '';
+ checkToken(FreshRSS_Context::$user_conf, $token);
+ $s_s = multiplePosts('s');
+ foreach ($s_s as $s) {
+ disableTag($s); //user/-/label/Folder
+ }
+ break;
case 'mark-all-as-read':
$token = isset($_POST['T']) ? trim($_POST['T']) : '';
- checkToken($conf, $token);
+ checkToken(FreshRSS_Context::$user_conf, $token);
$streamId = $_POST['s']; //StreamId
$ts = isset($_POST['ts']) ? $_POST['ts'] : '0'; //Older than timestamp in nanoseconds
if (!ctype_digit($ts)) {
@@ -639,7 +835,10 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo
markAllAsRead($streamId, $ts);
break;
case 'token':
- Token($conf);
+ token(FreshRSS_Context::$user_conf);
+ break;
+ case 'user-info':
+ userInfo();
break;
}
} elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') {