]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref/feeds.php
remove some redundant php closing tags
[tt-rss.git] / classes / pref / feeds.php
old mode 100644 (file)
new mode 100755 (executable)
index 530d851..47c474a
@@ -34,7 +34,7 @@ class Pref_Feeds extends Handler_Protected {
                else
                        $search = "";
 
-               if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')";
+               if ($search) $search_qpart = " AND (LOWER(title) LIKE LOWER('%$search%') OR LOWER(feed_url) LIKE LOWER('%$search%'))";
 
                // first one is set by API
                $show_empty_cats = $_REQUEST['force_show_empty'] ||
@@ -62,7 +62,7 @@ class Pref_Feeds extends Handler_Protected {
                        $cat['items'] = $this->get_category_items($line['id']);
 
                        $num_children = $this->calculate_children_count($cat);
-                       $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', $num_children), $num_children);
+                       $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
 
                        if ($num_children > 0 || $show_empty_cats)
                                array_push($items, $cat);
@@ -211,7 +211,7 @@ class Pref_Feeds extends Handler_Protected {
                                $cat['items'] = $this->get_category_items($line['id']);
 
                                $num_children = $this->calculate_children_count($cat);
-                               $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', $num_children), $num_children);
+                               $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
 
                                if ($num_children > 0 || $show_empty_cats)
                                        array_push($root['items'], $cat);
@@ -261,7 +261,7 @@ class Pref_Feeds extends Handler_Protected {
                                array_push($root['items'], $cat);
 
                        $num_children = $this->calculate_children_count($root);
-                       $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', $num_children), $num_children);
+                       $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
 
                } else {
                        $feed_result = $this->dbh->query("SELECT id, title, last_error,
@@ -297,7 +297,7 @@ class Pref_Feeds extends Handler_Protected {
                if ($_REQUEST['mode'] != 2) {
                        $fl['items'] = array($root);
                } else {
-                       $fl['items'] =& $root['items'];
+                       $fl['items'] = $root['items'];
                }
 
                return $fl;
@@ -324,7 +324,7 @@ class Pref_Feeds extends Handler_Protected {
 
                if ($debug) _debug("$prefix C: $item_id P: $parent_id");
 
-               $bare_item_id = substr($item_id, strpos($item_id, ':')+1);
+               $bare_item_id = $this->dbh->escape_string(substr($item_id, strpos($item_id, ':')+1));
 
                if ($item_id != 'root') {
                        if ($parent_id && $parent_id != 'root') {
@@ -346,7 +346,7 @@ class Pref_Feeds extends Handler_Protected {
                if ($cat && is_array($cat)) {
                        foreach ($cat as $item) {
                                $id = $item['_reference'];
-                               $bare_id = substr($id, strpos($id, ':')+1);
+                               $bare_id = $this->dbh->escape_string(substr($id, strpos($id, ':')+1));
 
                                if ($debug) _debug("$prefix [$order_id] $id/$bare_id");
 
@@ -410,7 +410,7 @@ class Pref_Feeds extends Handler_Protected {
                                                if (isset($item['items']['_reference'])) {
                                                        $data_map[$item['id']] = array($item['items']);
                                                } else {
-                                                       $data_map[$item['id']] =& $item['items'];
+                                                       $data_map[$item['id']] = $item['items'];
                                                }
                                        }
                                if ($item['id'] == 'root') {
@@ -548,9 +548,9 @@ class Pref_Feeds extends Handler_Protected {
                $title = htmlspecialchars($this->dbh->fetch_result($result,
                        0, "title"));
 
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$feed_id\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
+               print_hidden("id", "$feed_id");
+               print_hidden("op", "pref-feeds");
+               print_hidden("method", "editSave");
 
                print "<div class=\"dlgSec\">".__("Feed")."</div>";
                print "<div class=\"dlgSecCont\">";
@@ -641,11 +641,12 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<input dojoType=\"dijit.form.TextBox\" id=\"feedEditDlg_login\"
                        placeHolder=\"".__("Login")."\"
+                       autocomplete=\"new-password\"
                        name=\"auth_login\" value=\"$auth_login\"><hr/>";
 
                $auth_pass = $this->dbh->fetch_result($result, 0, "auth_pass");
 
-               if ($auth_pass_encrypted) {
+               if ($auth_pass_encrypted && function_exists("mcrypt_decrypt")) {
                        require_once "crypt.php";
                        $auth_pass = decrypt_string($auth_pass);
                }
@@ -653,6 +654,7 @@ class Pref_Feeds extends Handler_Protected {
                $auth_pass = htmlspecialchars($auth_pass);
 
                print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"
+                       autocomplete=\"new-password\"
                        placeHolder=\"".__("Password")."\"
                        value=\"$auth_pass\">";
 
@@ -727,7 +729,7 @@ class Pref_Feeds extends Handler_Protected {
                print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\"
                name=\"cache_images\"
                        $checked>&nbsp;<label for=\"cache_images\">".
-               __('Cache images locally')."</label>";
+               __('Cache media')."</label>";
 
                $mark_unread_on_update = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "mark_unread_on_update"));
 
@@ -779,7 +781,7 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<div class='dlgButtons'>
                        <div style=\"float : left\">
-                       <button dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
+                       <button class=\"danger\" dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
                                __('Unsubscribe')."</button>";
 
                if (PUBSUBHUBBUB_ENABLED) {
@@ -814,9 +816,9 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<p>";
 
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"ids\" value=\"$feed_ids\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchEditSave\">";
+               print_hidden("ids", "$feed_ids");
+               print_hidden("op", "pref-feeds");
+               print_hidden("method", "batchEditSave");
 
                print "<div class=\"dlgSec\">".__("Feed")."</div>";
                print "<div class=\"dlgSecCont\">";
@@ -878,11 +880,13 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<input dojoType=\"dijit.form.TextBox\"
                        placeHolder=\"".__("Login")."\" disabled=\"1\"
+                       autocomplete=\"new-password\"
                        name=\"auth_login\" value=\"\">";
 
                $this->batch_edit_cbox("auth_login");
 
                print "<hr/> <input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"
+                       autocomplete=\"new-password\"
                        placeHolder=\"".__("Password")."\" disabled=\"1\"
                        value=\"\">";
 
@@ -921,7 +925,7 @@ class Pref_Feeds extends Handler_Protected {
                        name=\"cache_images\"
                        dojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"cache_images_l\"
                        for=\"cache_images\">".
-               __('Cache images locally')."</label>";
+               __('Cache media')."</label>";
 
                print "&nbsp;"; $this->batch_edit_cbox("cache_images", "cache_images_l");
 
@@ -979,14 +983,7 @@ class Pref_Feeds extends Handler_Protected {
 
                $feed_language = $this->dbh->escape_string(trim($_POST["feed_language"]));
 
-               if (strlen(FEED_CRYPT_KEY) > 0) {
-                       require_once "crypt.php";
-                       $auth_pass = substr(encrypt_string($auth_pass), 0, 250);
-                       $auth_pass_encrypted = 'true';
-               } else {
-                       $auth_pass_encrypted = 'false';
-               }
-
+               $auth_pass_encrypted = 'false';
                $auth_pass = $this->dbh->escape_string($auth_pass);
 
                if (get_pref('ENABLE_FEED_CATS')) {
@@ -1414,6 +1411,7 @@ class Pref_Feeds extends Handler_Protected {
                <div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\"
                        dndController=\"dijit.tree.dndSource\"
                        betweenThreshold=\"5\"
+                       autoExpand='true'
                        model=\"feedModel\" openOnClick=\"false\">
                <script type=\"dojo/method\" event=\"onClick\" args=\"item\">
                        var id = String(item.id);
@@ -1443,7 +1441,8 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">";
 
-               print_notice(__("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . __("Only main settings profile can be migrated using OPML."));
+               print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") .
+                       __("Only main settings profile can be migrated using OPML.") . "</p>";
 
                print "<iframe id=\"upload_iframe\"
                        name=\"upload_iframe\" onload=\"opmlImportComplete(this)\"
@@ -1460,8 +1459,10 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<hr>";
 
+               $opml_export_filename = "TinyTinyRSS_".date("Y-m-d").".opml";
+
                print "<p>" . __('Filename:') .
-            " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" />&nbsp;" .
+            " <input type=\"text\" id=\"filename\" value=\"$opml_export_filename\" />&nbsp;" .
                                __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>";
 
                print "</p><button dojoType=\"dijit.form.Button\"
@@ -1470,9 +1471,9 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<hr>";
 
-               print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " ";
+               print "<p>" . __('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . "</p>";
 
-               print __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>";
+               print_warning("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.");
 
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">".
                        __('Display published OPML URL')."</button> ";
@@ -1503,7 +1504,7 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles / Generated feeds')."\">";
 
-               print_notice(__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.'));
+               print "<p>" . __('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.') . "</p>";
 
                $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() .
                                "/public.php?op=rss&id=-2&view-mode=all_articles");;
@@ -1513,7 +1514,7 @@ class Pref_Feeds extends Handler_Protected {
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('".__("View as RSS")."','generatedFeed', '$rss_url')\">".
                        __('Display URL')."</button> ";
 
-               print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">".
+               print "<button class=\"warning\" dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">".
                        __('Clear all generated URLs')."</button> ";
 
                print "</p>";
@@ -1643,7 +1644,7 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<div class='dlgButtons'>";
                print "<div style='float : left'>";
-               print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
+               print "<button class=\"danger\" dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
                        .__('Unsubscribe from selected feeds')."</button> ";
                print "</div>";
 
@@ -1709,7 +1710,7 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<div class='dlgButtons'>";
                print "<div style='float : left'>";
-               print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
+               print "<button class=\"danger\" dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
                        .__('Unsubscribe from selected feeds')."</button> ";
                print "</div>";
 
@@ -1811,8 +1812,8 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function batchSubscribe() {
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchaddfeeds\">";
+               print_hidden("op", "pref-feeds");
+               print_hidden("method", "batchaddfeeds");
 
                print "<table width='100%'><tr><td>
                        ".__("Add one valid RSS feed per line (no feed detection is done)")."
@@ -1837,6 +1838,7 @@ class Pref_Feeds extends Handler_Protected {
                                " <input
                                        placeHolder=\"".__("Password")."\"
                                        dojoType=\"dijit.form.TextBox\" type='password'
+                                       autocomplete=\"new-password\"
                                        style=\"width : 10em;\" name='pass'\">".
                                "</div>";
 
@@ -1881,14 +1883,7 @@ class Pref_Feeds extends Handler_Protected {
                                        "SELECT id FROM ttrss_feeds
                                        WHERE feed_url = '$feed' AND owner_uid = ".$_SESSION["uid"]);
 
-                               if (strlen(FEED_CRYPT_KEY) > 0) {
-                                       require_once "crypt.php";
-                                       $pass = substr(encrypt_string($pass), 0, 250);
-                                       $auth_pass_encrypted = 'true';
-                               } else {
-                                       $auth_pass_encrypted = 'false';
-                               }
-
+                               $auth_pass_encrypted = 'false';
                                $pass = $this->dbh->escape_string($pass);
 
                                if ($this->dbh->num_rows($result) == 0) {
@@ -1981,5 +1976,4 @@ class Pref_Feeds extends Handler_Protected {
 
                print (int) $this->dbh->fetch_result($result, 0, "num_inactive");
        }
-}
-?>
+}
\ No newline at end of file