Example #1
0
 function getUnread()
 {
     $login = db_escape_string($_REQUEST["login"]);
     $fresh = $_REQUEST["fresh"] == "1";
     $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '******'");
     if (db_num_rows($result) == 1) {
         $uid = db_fetch_result($result, 0, "id");
         print getGlobalUnread($this->link, $uid);
         if ($fresh) {
             print ";";
             print getFeedArticles($this->link, -3, false, true, $uid);
         }
     } else {
         print "-1;User not found";
     }
 }
Example #2
0
 function getUnread()
 {
     $feed_id = $this->dbh->escape_string($_REQUEST["feed_id"]);
     $is_cat = $this->dbh->escape_string($_REQUEST["is_cat"]);
     if ($feed_id) {
         $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread($feed_id, $is_cat)));
     } else {
         $this->wrap(self::STATUS_OK, array("unread" => getGlobalUnread()));
     }
 }
Example #3
0
function getGlobalCounters($global_unread = -1)
{
    $ret_arr = array();
    if ($global_unread == -1) {
        $global_unread = getGlobalUnread();
    }
    $cv = array("id" => "global-unread", "counter" => (int) $global_unread);
    array_push($ret_arr, $cv);
    $result = db_query("SELECT COUNT(id) AS fn FROM\n\t\t\tttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
    $subscribed_feeds = db_fetch_result($result, 0, "fn");
    $cv = array("id" => "subscribed-feeds", "counter" => (int) $subscribed_feeds);
    array_push($ret_arr, $cv);
    return $ret_arr;
}
Example #4
0
function getGlobalCounters($link, $global_unread = -1)
{
    if ($global_unread == -1) {
        $global_unread = getGlobalUnread($link);
    }
    print "<counter type=\"global\" id='global-unread' \n\t\t\tcounter='{$global_unread}'/>";
    $result = db_query($link, "SELECT COUNT(id) AS fn FROM \n\t\t\tttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
    $subscribed_feeds = db_fetch_result($result, 0, "fn");
    print "<counter type=\"global\" id='subscribed-feeds' \n\t\t\tcounter='{$subscribed_feeds}'/>";
}
Example #5
0
         authenticate_user($link, $user, $pass);
     }
     if ($_SESSION["uid"] || http_authenticate_user($link)) {
         generate_syndicated_feed($link, 0, $feed, $is_cat, $limit, $search, $search_mode, $match_on);
     }
     break;
     // rss
 // rss
 case "getUnread":
     $login = db_escape_string($_REQUEST["login"]);
     $fresh = $_REQUEST["fresh"] == "1";
     header("Content-Type: text/plain; charset=utf-8");
     $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '******'");
     if (db_num_rows($result) == 1) {
         $uid = db_fetch_result($result, 0, "id");
         print getGlobalUnread($link, $uid);
         if ($fresh) {
             print ";";
             print getFeedArticles($link, -3, false, true, $uid);
         }
     } else {
         print "-1;User not found";
     }
     $print_exec_time = false;
     break;
     // getUnread
 // getUnread
 case "digestTest":
     header("Content-Type: text/plain");
     print_r(prepare_headlines_digest($link, $_SESSION["uid"]));
     $print_exec_time = false;
Example #6
0
     }
     break;
 case "logout":
     logout_user();
     print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK"));
     break;
 case "isLoggedIn":
     print api_wrap_reply(API_STATUS_OK, $seq, array("status" => $_SESSION["uid"] != ''));
     break;
 case "getUnread":
     $feed_id = db_escape_string($_REQUEST["feed_id"]);
     $is_cat = db_escape_string($_REQUEST["is_cat"]);
     if ($feed_id) {
         print api_wrap_reply(API_STATUS_OK, $seq, array("unread" => getFeedUnread($link, $feed_id, $is_cat)));
     } else {
         print api_wrap_reply(API_STATUS_OK, $seq, array("unread" => getGlobalUnread($link)));
     }
     break;
     /* Method added for ttrss-reader for Android */
 /* Method added for ttrss-reader for Android */
 case "getCounters":
     /* flct (flc is the default) FIXME: document */
     $output_mode = db_escape_string($_REQUEST["output_mode"]);
     print api_wrap_reply(API_STATUS_OK, $seq, getAllCounters($link, $output_mode));
     break;
 case "getFeeds":
     $cat_id = db_escape_string($_REQUEST["cat_id"]);
     $unread_only = (bool) db_escape_string($_REQUEST["unread_only"]);
     $limit = (int) db_escape_string($_REQUEST["limit"]);
     $offset = (int) db_escape_string($_REQUEST["offset"]);
     $feeds = api_get_feeds($link, $cat_id, $unread_only, $limit, $offset);
Example #7
0
     }
     break;
 case "logout":
     logout_user();
     print json_encode(array("status" => "OK"));
     break;
 case "isLoggedIn":
     print json_encode(array("status" => $_SESSION["uid"] != ''));
     break;
 case "getUnread":
     $feed_id = db_escape_string($_REQUEST["feed_id"]);
     $is_cat = db_escape_string($_REQUEST["is_cat"]);
     if ($feed_id) {
         print json_encode(array("unread" => getFeedUnread($link, $feed_id, $is_cat)));
     } else {
         print json_encode(array("unread" => getGlobalUnread($link)));
     }
     break;
 case "getCounters":
     /* TODO */
     break;
 case "getFeeds":
     $cat_id = db_escape_string($_REQUEST["cat_id"]);
     $unread_only = (bool) db_escape_string($_REQUEST["unread_only"]);
     $limit = (int) db_escape_string($_REQUEST["limit"]);
     $offset = (int) db_escape_string($_REQUEST["offset"]);
     if ($limit) {
         $limit_qpart = "LIMIT {$limit} OFFSET {$offset}";
     } else {
         $limit_qpart = "";
     }
Example #8
0
function getTotalUnread($msg)
{
    global $link;
    $error_code = 0;
    $login_o = $msg->getParam(0);
    $pass_o = $msg->getParam(1);
    $login = $login_o->scalarval();
    $pass = $pass_o->scalarval();
    $user_id = authenticate_user($link, $login, $pass);
    if (authenticate_user($link, $login, $pass)) {
        $reply_msg = getGlobalUnread($link);
    } 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));
    }
}