diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/api.php | 17 | ||||
-rw-r--r-- | classes/feeds.php | 60 | ||||
-rw-r--r-- | classes/handler/public.php | 33 | ||||
-rw-r--r-- | classes/opml.php | 6 | ||||
-rw-r--r-- | classes/pluginhost.php | 39 | ||||
-rw-r--r-- | classes/pref/feeds.php | 39 | ||||
-rw-r--r-- | classes/pref/prefs.php | 34 | ||||
-rw-r--r-- | classes/pref/users.php | 2 | ||||
-rw-r--r-- | classes/rpc.php | 4 |
9 files changed, 198 insertions, 36 deletions
diff --git a/classes/api.php b/classes/api.php index ba0eebb36..1efa3865f 100644 --- a/classes/api.php +++ b/classes/api.php @@ -47,6 +47,9 @@ class API extends Handler { } function login() { + @session_destroy(); + @session_start(); + $login = db_escape_string($this->link, $_REQUEST["user"]); $password = $_REQUEST["password"]; $password_base64 = base64_decode($_REQUEST["password"]); @@ -701,6 +704,20 @@ class API extends Handler { } } + function getFeedTree() { + $pf = new Pref_Feeds($this->link, $_REQUEST); + + $_REQUEST['mode'] = 2; + + if ($pf){ + $data = $pf->makefeedtree(); + print $this->wrap(self::STATUS_OK, array("categories" => $data)); + } else { + print $this->wrap(self::STATUS_ERR, array("error" => + 'UNABLE_TO_INSTANTIATE_OBJECT')); + } + + } } ?> diff --git a/classes/feeds.php b/classes/feeds.php index 89ebd4a0a..20e3e7004 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -217,9 +217,38 @@ class Feeds extends Handler_Protected { $search_mode = $method; } // error_log("search_mode: " . $search_mode); - $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view, - $search, $search_mode, $override_order, $offset, 0, - false, 0, $include_children); + + if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX) { + global $pluginhost; + + $handler = $pluginhost->get_feed_handler( + PluginHost::feed_to_pfeed_id($feed)); + + // function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) { + + if ($handler) { + $options = array( + "limit" => $limit, + "view_mode" => $view_mode, + "cat_view" => $cat_view, + "search" => $search, + "search_mode" => $search_mode, + "override_order" => $override_order, + "offset" => $offset, + "owner_uid" => $_SESSION["uid"], + "filter" => false, + "since_id" => 0, + "include_children" => $include_children); + + $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), + $options); + } + + } else { + $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view, + $search, $search_mode, $override_order, $offset, 0, + false, 0, $include_children); + } if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info); @@ -351,7 +380,9 @@ class Feeds extends Handler_Protected { # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" . # $line["title"] . "</a>"; - $updated_fmt = make_local_datetime($this->link, $line["updated_noms"], false); + $updated_fmt = make_local_datetime($this->link, $line["updated"], false); + $date_entered_fmt = T_sprintf("Imported at %s", + make_local_datetime($this->link, $line["date_entered"], false)); if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) { $content_preview = truncate_string(strip_tags($line["content_preview"]), @@ -454,12 +485,14 @@ class Feeds extends Handler_Protected { if (@$line["feed_title"]) { $reply['content'] .= "<div class=\"hlFeed\"> <a href=\"#\" onclick=\"viewfeed($feed_id)\">". - $line["feed_title"]."</a> + truncate_string($line["feed_title"],30)."</a> </div>"; } } - $reply['content'] .= "$updated_fmt</span>"; + $reply['content'] .= "<span title='$date_entered_fmt'>$updated_fmt</span> + </span>"; + $reply['content'] .= "<div class=\"hlRight\">"; $reply['content'] .= $score_pic; @@ -561,12 +594,13 @@ class Feeds extends Handler_Protected { if (@$line["feed_title"]) { $reply['content'] .= "<div class=\"hlFeed\"> <a href=\"#\" onclick=\"viewfeed($feed_id)\">". - $line["feed_title"]."</a> + truncate_string($line["feed_title"],30)."</a> </div>"; } } - $reply['content'] .= "<span class='updated'>$updated_fmt</span>"; + $reply['content'] .= "<span class='updated' title='$date_entered_fmt'> + $updated_fmt</span>"; $reply['content'] .= "<div style=\"vertical-align : middle\">"; $reply['content'] .= "$score_pic"; @@ -700,7 +734,7 @@ class Feeds extends Handler_Protected { $message = __("No starred articles found to display."); break; default: - if ($feed < -10) { + if ($feed < LABEL_BASE_INDEX) { $message = __("No articles found to display. You can assign articles to labels manually (see the Actions menu above) or use a filter."); } else { $message = __("No articles found to display."); @@ -710,7 +744,7 @@ class Feeds extends Handler_Protected { if (!$offset && $message) { $reply['content'] .= "<div class='whiteBox'>$message"; - $reply['content'] .= "<p class=\"small\"><span class=\"insensitive\">"; + $reply['content'] .= "<p><span class=\"insensitive\">"; $result = db_query($this->link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); @@ -777,8 +811,8 @@ class Feeds extends Handler_Protected { $result = false; - if ($feed < -10) { - $label_feed = -11-$feed; + if ($feed < LABEL_BASE_INDEX) { + $label_feed = feed_to_label_id($feed); $result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE id = '$label_feed' AND owner_uid = " . $_SESSION['uid']); } else if (!$cat_view && is_numeric($feed) && $feed > 0) { @@ -898,7 +932,7 @@ class Feeds extends Handler_Protected { $reply['headlines']['toolbar'] = ''; $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.'); - $reply['headlines']['content'] .= "<p class=\"small\"><span class=\"insensitive\">"; + $reply['headlines']['content'] .= "<p><span class=\"insensitive\">"; $result = db_query($link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); diff --git a/classes/handler/public.php b/classes/handler/public.php index 53051a1f8..84d6aa18e 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -349,6 +349,18 @@ class Handler_Public extends Handler { include "rssfuncs.php"; // Update all feeds needing a update. update_daemon_common($this->link, 0, true, false); + + // Update feedbrowser + update_feedbrowser_cache($this->link); + + // Purge orphans and cleanup tags + purge_orphans($this->link); + + cleanup_tags($this->link, 14, 50000); + + global $pluginhost; + $pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op); + } function sharepopup() { @@ -480,7 +492,6 @@ class Handler_Public extends Handler { } function login() { - $_SESSION["prefs_cache"] = array(); if (!SINGLE_USER_MODE) { @@ -489,6 +500,14 @@ class Handler_Public extends Handler { $password = $_POST["password"]; $remember_me = $_POST["remember_me"]; + if ($remember_me) { + session_set_cookie_params(SESSION_COOKIE_LIFETIME); + } else { + session_set_cookie_params(0); + } + + @session_start(); + if (authenticate_user($this->link, $login, $password)) { $_POST["password"] = ""; @@ -537,9 +556,9 @@ class Handler_Public extends Handler { <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/> </head> <body> - <img class=\"floatingLogo\" src=\"images/logo_wide.png\" + <img class=\"floatingLogo\" src=\"images/logo_small.png\" alt=\"Tiny Tiny RSS\"/> - <h1>".__("Subscribe to feed...")."</h1>"; + <h1>".__("Subscribe to feed...")."</h1><div class='content'>"; $rc = subscribe_to_feed($this->link, $feed_url); @@ -612,7 +631,7 @@ class Handler_Public extends Handler { <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> </form></p>"; - print "</body></html>"; + print "</div></body></html>"; } else { render_login_form($this->link); @@ -720,8 +739,11 @@ class Handler_Public extends Handler { </head> <body id='forgotpass'>"; - print '<div class="floatingLogo"><img src="images/logo_wide.png"></div>'; + print '<div class="floatingLogo"><img src="images/logo_small.png"></div>'; print "<h1>".__("Reset password")."</h1>"; + print "<div class='content'>"; + + print "<p>".__("You will need to provide valid account name and email. New password will be sent on your email address.")."</p>"; @$method = $_POST['method']; @@ -790,6 +812,7 @@ class Handler_Public extends Handler { } + print "</div>"; print "</body>"; print "</html>"; diff --git a/classes/opml.php b/classes/opml.php index d4a0e9875..4c188de5e 100644 --- a/classes/opml.php +++ b/classes/opml.php @@ -29,8 +29,8 @@ class Opml extends Handler_Protected { <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/> </head> <body> - <div class=\"floatingLogo\"><img src=\"images/logo_wide.png\"></div> - <h1>".__('OPML Utility')."</h1>"; + <div class=\"floatingLogo\"><img src=\"images/logo_small.png\"></div> + <h1>".__('OPML Utility')."</h1><div class='content'>"; add_feed_category($this->link, "Imported feeds"); @@ -41,7 +41,7 @@ class Opml extends Handler_Protected { <input type=\"submit\" value=\"".__("Return to preferences")."\"> </form>"; - print "</body></html>"; + print "</div></body></html>"; } diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 0ef17b77e..5f584cd00 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -6,6 +6,7 @@ class PluginHost { private $handlers = array(); private $commands = array(); private $storage = array(); + private $feeds = array(); private $owner_uid; private $debug; @@ -301,5 +302,43 @@ class PluginHost { function get_debug() { return $this->debug; } + + // Plugin feed functions are *EXPERIMENTAL*! + + // cat_id: only -1 is supported (Special) + function add_feed($cat_id, $title, $icon, $sender) { + if (!$this->feeds[$cat_id]) $this->feeds[$cat_id] = array(); + + $id = count($this->feeds[$cat_id]); + + array_push($this->feeds[$cat_id], + array('id' => $id, 'title' => $title, 'sender' => $sender, 'icon' => $icon)); + + return $id; + } + + function get_feeds($cat_id) { + return $this->feeds[$cat_id]; + } + + // convert feed_id (e.g. -129) to pfeed_id first + function get_feed_handler($pfeed_id) { + foreach ($this->feeds as $cat) { + foreach ($cat as $feed) { + if ($feed['id'] == $pfeed_id) { + return $feed['sender']; + } + } + } + } + + static function pfeed_to_feed_id($label) { + return PLUGIN_FEED_BASE_INDEX - 1 - abs($label); + } + + static function feed_to_pfeed_id($feed) { + return PLUGIN_FEED_BASE_INDEX - 1 + abs($feed); + } + } ?> diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index ca4ae344f..cd208335b 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -87,6 +87,10 @@ class Pref_Feeds extends Handler_Protected { } function getfeedtree() { + print json_encode($this->makefeedtree()); + } + + function makefeedtree() { if ($_REQUEST['mode'] != 2) $search = $_SESSION["prefs_feed_search"]; @@ -115,6 +119,32 @@ class Pref_Feeds extends Handler_Protected { array_push($cat['items'], $this->feedlist_init_feed($i)); } + /* Plugin feeds for -1 */ + + global $pluginhost; + + $feeds = $pluginhost->get_feeds(-1); + + if ($feeds) { + foreach ($feeds as $feed) { + $feed_id = PluginHost::pfeed_to_feed_id($feed['id']); + + $item = array(); + $item['id'] = 'FEED:' . $feed_id; + $item['bare_id'] = (int)$feed_id; + $item['name'] = $feed['title']; + $item['checkbox'] = false; + $item['error'] = ''; + $item['icon'] = $feed['icon']; + + $item['param'] = ''; + $item['unread'] = 0; //$feed['sender']->get_unread($feed['id']); + $item['type'] = 'feed'; + + array_push($cat['items'], $item); + } + } + if ($enable_cats) { array_push($root['items'], $cat); } else { @@ -134,7 +164,7 @@ class Pref_Feeds extends Handler_Protected { while ($line = db_fetch_assoc($result)) { - $label_id = -$line['id'] - 11; + $label_id = label_to_feed_id($line['id']); $feed = $this->feedlist_init_feed($label_id, false, 0); @@ -258,8 +288,7 @@ class Pref_Feeds extends Handler_Protected { $fl['items'] =& $root['items']; } - print json_encode($fl); - return; + return $fl; } function catsortreset() { @@ -1700,8 +1729,8 @@ class Pref_Feeds extends Handler_Protected { ccache_remove($link, $id, $owner_uid); } else { - label_remove($link, -11-$id, $owner_uid); - ccache_remove($link, -11-$id, $owner_uid); + label_remove($link, feed_to_label_id($id), $owner_uid); + //ccache_remove($link, $id, $owner_uid); don't think labels are cached } } diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index a5a699a67..3226ccde9 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -121,8 +121,9 @@ class Pref_Prefs extends Handler_Protected { global $access_level_names; - $prefs_blacklist = array("HIDE_READ_FEEDS", "FEEDS_SORT_BY_UNREAD", - "STRIP_UNSAFE_TAGS"); + $prefs_blacklist = array("STRIP_UNSAFE_TAGS"); + + /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */ $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", @@ -412,10 +413,12 @@ class Pref_Prefs extends Handler_Protected { $profile_qpart = "profile IS NULL"; } - if ($_SESSION["prefs_show_advanced"]) + /* if ($_SESSION["prefs_show_advanced"]) $access_query = "true"; else - $access_query = "(access_level = 0 AND section_id != 3)"; + $access_query = "(access_level = 0 AND section_id != 3)"; */ + + $access_query = 'true'; $result = db_query($this->link, "SELECT DISTINCT ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, @@ -602,7 +605,7 @@ class Pref_Prefs extends Handler_Protected { print " "; - $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : ""; + /* $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : ""; print "<input onclick='toggleAdvancedPrefs()' id='prefs_show_advanced' @@ -610,7 +613,7 @@ class Pref_Prefs extends Handler_Protected { $checked type=\"checkbox\"></input> <label for='prefs_show_advanced'>" . - __("Show additional preferences") . "</label>"; + __("Show additional preferences") . "</label>"; */ global $pluginhost; $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, @@ -626,7 +629,9 @@ class Pref_Prefs extends Handler_Protected { print "<h2>".__("Plugins")."</h2>"; - print_notice(__("You will need to reload Tiny Tiny RSS for plugin changes to take effect.")); + print "<p>" . __("You will need to reload Tiny Tiny RSS for plugin changes to take effect.") . "</p>"; + + print_notice(__("Download more plugins at tt-rss.org <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/forum/viewforum.php?f=22\">forums</a> or <a target=\"_blank\" class=\"visibleLink\" href=\"http://tt-rss.org/wiki/Plugins\">wiki</a>.")); print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">"; @@ -685,7 +690,12 @@ class Pref_Prefs extends Handler_Protected { type=\"checkbox\"></td>"; print "<td>$name</td>"; - print "<td>" . htmlspecialchars($about[1]) . "</td>"; + print "<td>" . htmlspecialchars($about[1]); + if (@$about[4]) { + print " — <a target=\"_blank\" class=\"visibleLink\" + href=\"".htmlspecialchars($about[4])."\">".__("more info")."</a>"; + } + print "</td>"; print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>"; print "<td>" . htmlspecialchars($about[2]) . "</td>"; @@ -737,7 +747,13 @@ class Pref_Prefs extends Handler_Protected { type=\"checkbox\"></td>"; print "<td><label for='FPCHK-$name'>$name</label></td>"; - print "<td><label for='FPCHK-$name'>" . htmlspecialchars($about[1]) . "</label></td>"; + print "<td><label for='FPCHK-$name'>" . htmlspecialchars($about[1]) . "</label>"; + if (@$about[4]) { + print " — <a target=\"_blank\" class=\"visibleLink\" + href=\"".htmlspecialchars($about[4])."\">".__("more info")."</a>"; + } + print "</td>"; + print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>"; print "<td>" . htmlspecialchars($about[2]) . "</td>"; diff --git a/classes/pref/users.php b/classes/pref/users.php index 4055bca45..45260fd93 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -203,7 +203,7 @@ class Pref_Users extends Handler_Protected { $uid = db_escape_string($this->link, $_REQUEST["id"]); $access_level = (int) $_REQUEST["access_level"]; $email = db_escape_string($this->link, trim($_REQUEST["email"])); - $password = db_escape_string($this->link, trim($_REQUEST["password"])); + $password = $_REQUEST["password"]; if ($password) { $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); diff --git a/classes/rpc.php b/classes/rpc.php index eb241591b..72028759e 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -735,6 +735,10 @@ class RPC extends Handler_Protected { } } + // Purge orphans and cleanup tags + purge_orphans($this->link); + cleanup_tags($this->link, 14, 50000); + if ($num_updated > 0) { print json_encode(array("message" => "UPDATE_COUNTERS", "num_updated" => $num_updated)); |