|
|
@ -2,6 +2,8 @@
|
|
|
|
require "xmlrpc/lib/xmlrpc.inc";
|
|
|
|
require "xmlrpc/lib/xmlrpc.inc";
|
|
|
|
require "xmlrpc/lib/xmlrpcs.inc";
|
|
|
|
require "xmlrpc/lib/xmlrpcs.inc";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$xmlrpc_defencoding = "UTF8";
|
|
|
|
|
|
|
|
|
|
|
|
require_once "sanity_check.php";
|
|
|
|
require_once "sanity_check.php";
|
|
|
|
require_once "config.php";
|
|
|
|
require_once "config.php";
|
|
|
|
|
|
|
|
|
|
|
@ -49,7 +51,8 @@
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
"feed_url" => new xmlrpcval($line["feed_url"]),
|
|
|
|
"feed_url" => new xmlrpcval($line["feed_url"]),
|
|
|
|
"title" => new xmlrpcval($line["title"]),
|
|
|
|
"title" => new xmlrpcval($line["title"]),
|
|
|
|
"last_updated" => new xmlrpcval(strtotime($line["last_updated"]))
|
|
|
|
"id" => new xmlrpcval($line["id"], "int"),
|
|
|
|
|
|
|
|
"last_updated" => new xmlrpcval(strtotime($line["last_updated"]), "int")
|
|
|
|
),
|
|
|
|
),
|
|
|
|
"struct");
|
|
|
|
"struct");
|
|
|
|
|
|
|
|
|
|
|
@ -68,6 +71,8 @@
|
|
|
|
function subscribeToFeed($msg) {
|
|
|
|
function subscribeToFeed($msg) {
|
|
|
|
global $link;
|
|
|
|
global $link;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$error_code = 0;
|
|
|
|
|
|
|
|
|
|
|
|
$login_o = $msg->getParam(0);
|
|
|
|
$login_o = $msg->getParam(0);
|
|
|
|
$pass_o = $msg->getParam(1);
|
|
|
|
$pass_o = $msg->getParam(1);
|
|
|
|
$feed_url_o = $msg->getParam(2);
|
|
|
|
$feed_url_o = $msg->getParam(2);
|
|
|
@ -76,19 +81,262 @@
|
|
|
|
$pass = $pass_o->scalarval();
|
|
|
|
$pass = $pass_o->scalarval();
|
|
|
|
$feed_url = $feed_url_o->scalarval();
|
|
|
|
$feed_url = $feed_url_o->scalarval();
|
|
|
|
|
|
|
|
|
|
|
|
$user_id = authenticate_user($link, $login, $pass);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (authenticate_user($link, $login, $pass)) {
|
|
|
|
if (authenticate_user($link, $login, $pass)) {
|
|
|
|
if (subscribe_to_feed($link, $feed_url)) {
|
|
|
|
if (subscribe_to_feed($link, $feed_url)) {
|
|
|
|
$reply_msg = "Subscribed successfully.";
|
|
|
|
$reply_msg = "Subscribed successfully.";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$reply_msg = "Feed already exists in the database.";
|
|
|
|
$reply_msg = "Feed already exists in the database.";
|
|
|
|
|
|
|
|
$error_code = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$reply_msg = "Login failed.";
|
|
|
|
$reply_msg = "Login failed.";
|
|
|
|
|
|
|
|
$error_code = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($error_code != 0) {
|
|
|
|
|
|
|
|
return new xmlrpcresp(0, $error_code, $reply_msg);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return new xmlrpcresp(new xmlrpcval($reply_msg));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getFeedHeadlines($msg) {
|
|
|
|
|
|
|
|
global $link;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$error_code = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login_o = $msg->getParam(0);
|
|
|
|
|
|
|
|
$pass_o = $msg->getParam(1);
|
|
|
|
|
|
|
|
$feed_id_o = $msg->getParam(2);
|
|
|
|
|
|
|
|
$limit_o = $msg->getParam(3);
|
|
|
|
|
|
|
|
$filter_o = $msg->getParam(4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login = $login_o->scalarval();
|
|
|
|
|
|
|
|
$pass = $pass_o->scalarval();
|
|
|
|
|
|
|
|
$feed_id = $feed_id_o->scalarval();
|
|
|
|
|
|
|
|
$limit = $limit_o->scalarval();
|
|
|
|
|
|
|
|
$filter = $filter_o->scalarval();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (authenticate_user($link, $login, $pass)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($limit > 0) {
|
|
|
|
|
|
|
|
$limit_query_part = "LIMIT $limit";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($filter == 1) {
|
|
|
|
|
|
|
|
$query_strategy_part = "unread = true";
|
|
|
|
|
|
|
|
} else if ($filter == 2) {
|
|
|
|
|
|
|
|
$query_strategy_part = "marked = true";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$query_strategy_part = "ttrss_entries.id > 0";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query = "SELECT
|
|
|
|
|
|
|
|
ttrss_entries.id,ttrss_entries.title,
|
|
|
|
|
|
|
|
SUBSTRING(updated,1,16) as updated,
|
|
|
|
|
|
|
|
unread,feed_id,marked,link,last_read,
|
|
|
|
|
|
|
|
SUBSTRING(last_read,1,19) as last_read_noms,
|
|
|
|
|
|
|
|
SUBSTRING(updated,1,19) as updated_noms
|
|
|
|
|
|
|
|
FROM
|
|
|
|
|
|
|
|
ttrss_entries,ttrss_user_entries,ttrss_feeds
|
|
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
|
|
ttrss_feeds.id = '$feed_id' AND
|
|
|
|
|
|
|
|
ttrss_user_entries.feed_id = ttrss_feeds.id AND
|
|
|
|
|
|
|
|
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
|
|
|
|
|
|
|
ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND
|
|
|
|
|
|
|
|
$query_strategy_part ORDER BY updated
|
|
|
|
|
|
|
|
$limit_query_part";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = db_query($link, $query);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$articles = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ($line = db_fetch_assoc($result)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$line_struct = new xmlrpcval(
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
"id" => new xmlrpcval($line["id"], "int"),
|
|
|
|
|
|
|
|
"unread" => new xmlrpcval(sql_bool_to_bool($line["unread"]), "boolean"),
|
|
|
|
|
|
|
|
"marked" => new xmlrpcval(sql_bool_to_bool($line["marked"]), "boolean"),
|
|
|
|
|
|
|
|
"updated" => new xmlrpcval(strtotime($line["updated"]), "int"),
|
|
|
|
|
|
|
|
"title" => new xmlrpcval($line["title"])
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
"struct");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
array_push($articles, $line_struct);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$reply = new xmlrpcval($articles, "array");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$reply_msg = "Login failed.";
|
|
|
|
|
|
|
|
$error_code = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($error_code != 0) {
|
|
|
|
|
|
|
|
return new xmlrpcresp(0, $error_code, $reply_msg);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return new xmlrpcresp($reply);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getArticle($msg) {
|
|
|
|
|
|
|
|
global $link;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$error_code = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login_o = $msg->getParam(0);
|
|
|
|
|
|
|
|
$pass_o = $msg->getParam(1);
|
|
|
|
|
|
|
|
$article_id_o = $msg->getParam(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login = $login_o->scalarval();
|
|
|
|
|
|
|
|
$pass = $pass_o->scalarval();
|
|
|
|
|
|
|
|
$article_id = $article_id_o->scalarval();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (authenticate_user($link, $login, $pass)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query = "SELECT title,link,content,feed_id,comments,int_id,
|
|
|
|
|
|
|
|
marked,unread,
|
|
|
|
|
|
|
|
SUBSTRING(updated,1,16) as updated,
|
|
|
|
|
|
|
|
author
|
|
|
|
|
|
|
|
FROM ttrss_entries,ttrss_user_entries
|
|
|
|
|
|
|
|
WHERE id = '$article_id' AND ref_id = id AND owner_uid = " . $_SESSION["uid"] ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = db_query($link, $query);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (db_num_rows($result) == 1) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$line = db_fetch_assoc($result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$reply = new xmlrpcval(
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
"title" => new xmlrpcval($line["title"]),
|
|
|
|
|
|
|
|
"link" => new xmlrpcval($line["link"]),
|
|
|
|
|
|
|
|
"unread" => new xmlrpcval(sql_bool_to_bool($line["unread"]), "boolean"),
|
|
|
|
|
|
|
|
"marked" => new xmlrpcval(sql_bool_to_bool($line["marked"]), "boolean"),
|
|
|
|
|
|
|
|
"comments" => new xmlrpcval($line["comments"]),
|
|
|
|
|
|
|
|
"author" => new xmlrpcval($line["author"]),
|
|
|
|
|
|
|
|
"updated" => new xmlrpcval(strtotime($line["updated"], "int")),
|
|
|
|
|
|
|
|
"content" => new xmlrpcval($line["content"])
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
"struct");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$reply_msg = "Article not found.";
|
|
|
|
|
|
|
|
$error_code = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$reply_msg = "Login failed.";
|
|
|
|
|
|
|
|
$error_code = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($error_code != 0) {
|
|
|
|
|
|
|
|
return new xmlrpcresp(0, $error_code, $reply_msg);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return new xmlrpcresp($reply);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setArticleMarked($msg) {
|
|
|
|
|
|
|
|
global $link;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$error_code = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login_o = $msg->getParam(0);
|
|
|
|
|
|
|
|
$pass_o = $msg->getParam(1);
|
|
|
|
|
|
|
|
$article_id_o = $msg->getParam(2);
|
|
|
|
|
|
|
|
$marked_o = $msg->getParam(3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login = $login_o->scalarval();
|
|
|
|
|
|
|
|
$pass = $pass_o->scalarval();
|
|
|
|
|
|
|
|
$article_id = $article_id_o->scalarval();
|
|
|
|
|
|
|
|
$marked = $marked_o->scalarval();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (authenticate_user($link, $login, $pass)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($marked == 0) {
|
|
|
|
|
|
|
|
$query_strategy_part = "marked = false";
|
|
|
|
|
|
|
|
} else if ($marked == 1) {
|
|
|
|
|
|
|
|
$query_strategy_part = "marked = true";
|
|
|
|
|
|
|
|
} else if ($marked == 2) {
|
|
|
|
|
|
|
|
$query_strategy_part = "marked = NOT marked";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = db_query($link, "UPDATE ttrss_user_entries SET
|
|
|
|
|
|
|
|
$query_strategy_part WHERE ref_id = '$article_id' AND
|
|
|
|
|
|
|
|
owner_uid = " . $_SESSION["uid"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (db_affected_rows($link, $result) == 1) {
|
|
|
|
|
|
|
|
$reply_msg = "OK";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$error_code = 2;
|
|
|
|
|
|
|
|
$reply_msg = "Failed to update article.";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$reply_msg = "Login failed.";
|
|
|
|
|
|
|
|
$error_code = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($error_code != 0) {
|
|
|
|
|
|
|
|
return new xmlrpcresp(0, $error_code, $reply_msg);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return new xmlrpcresp(new xmlrpcval($reply_msg));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setArticleRead($msg) {
|
|
|
|
|
|
|
|
global $link;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$error_code = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login_o = $msg->getParam(0);
|
|
|
|
|
|
|
|
$pass_o = $msg->getParam(1);
|
|
|
|
|
|
|
|
$article_id_o = $msg->getParam(2);
|
|
|
|
|
|
|
|
$read_o = $msg->getParam(3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login = $login_o->scalarval();
|
|
|
|
|
|
|
|
$pass = $pass_o->scalarval();
|
|
|
|
|
|
|
|
$article_id = $article_id_o->scalarval();
|
|
|
|
|
|
|
|
$read = $read_o->scalarval();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (authenticate_user($link, $login, $pass)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($read == 0) {
|
|
|
|
|
|
|
|
$query_strategy_part = "unread = true";
|
|
|
|
|
|
|
|
} else if ($read == 1) {
|
|
|
|
|
|
|
|
$query_strategy_part = "unread = false";
|
|
|
|
|
|
|
|
} else if ($read == 2) {
|
|
|
|
|
|
|
|
$query_strategy_part = "unread = NOT unread";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = db_query($link, "UPDATE ttrss_user_entries SET
|
|
|
|
|
|
|
|
$query_strategy_part WHERE ref_id = '$article_id' AND
|
|
|
|
|
|
|
|
owner_uid = " . $_SESSION["uid"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (db_affected_rows($link, $result) == 1) {
|
|
|
|
|
|
|
|
$reply_msg = "OK";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$error_code = 2;
|
|
|
|
|
|
|
|
$reply_msg = "Failed to update article.";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$reply_msg = "Login failed.";
|
|
|
|
|
|
|
|
$error_code = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($error_code != 0) {
|
|
|
|
|
|
|
|
return new xmlrpcresp(0, $error_code, $reply_msg);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return new xmlrpcresp(new xmlrpcval($reply_msg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new xmlrpcresp(new xmlrpcval($reply_msg));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$subscribeToFeed_sig = array(array($xmlrpcString,
|
|
|
|
$subscribeToFeed_sig = array(array($xmlrpcString,
|
|
|
@ -97,8 +345,28 @@
|
|
|
|
$getSubscribedFeeds_sig = array(array($xmlrpcString,
|
|
|
|
$getSubscribedFeeds_sig = array(array($xmlrpcString,
|
|
|
|
$xmlrpcString, $xmlrpcString));
|
|
|
|
$xmlrpcString, $xmlrpcString));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$getFeedHeadlines_sig = array(array($xmlrpcString,
|
|
|
|
|
|
|
|
$xmlrpcString, $xmlrpcString, $xmlrpcInt, $xmlrpcInt, $xmlrpcInt));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$getArticle_sig = array(array($xmlrpcString,
|
|
|
|
|
|
|
|
$xmlrpcString, $xmlrpcString, $xmlrpcInt));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$setArticleMarked_sig = array(array($xmlrpcString,
|
|
|
|
|
|
|
|
$xmlrpcString, $xmlrpcString, $xmlrpcInt, $xmlrpcInt));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$setArticleUnread_sig = array(array($xmlrpcString,
|
|
|
|
|
|
|
|
$xmlrpcString, $xmlrpcString, $xmlrpcInt, $xmlrpcInt));
|
|
|
|
|
|
|
|
|
|
|
|
$s = new xmlrpc_server(
|
|
|
|
$s = new xmlrpc_server(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
|
|
|
|
"rss.setArticleRead" => array("function" => "setArticleRead",
|
|
|
|
|
|
|
|
"signature" => $setArticleRead_sig),
|
|
|
|
|
|
|
|
"rss.setArticleMarked" => array("function" => "setArticleMarked",
|
|
|
|
|
|
|
|
"signature" => $setArticleMarked_sig),
|
|
|
|
|
|
|
|
"rss.getArticle" => array("function" => "getArticle",
|
|
|
|
|
|
|
|
"signature" => $getArticle_sig),
|
|
|
|
|
|
|
|
"rss.getFeedHeadlines" => array("function" => "getFeedHeadlines",
|
|
|
|
|
|
|
|
"signature" => $getFeedHeadlines_sig),
|
|
|
|
"rss.getSubscribedFeeds" => array("function" => "getSubscribedFeeds",
|
|
|
|
"rss.getSubscribedFeeds" => array("function" => "getSubscribedFeeds",
|
|
|
|
"signature" => $getSubscribedFeeds_sig),
|
|
|
|
"signature" => $getSubscribedFeeds_sig),
|
|
|
|
"rss.subscribeToFeed" => array("function" => "subscribeToFeed",
|
|
|
|
"rss.subscribeToFeed" => array("function" => "subscribeToFeed",
|
|
|
|