diff options
author | Barak Korren <[email protected]> | 2013-04-02 20:38:07 +0300 |
---|---|---|
committer | Barak Korren <[email protected]> | 2013-04-02 20:38:07 +0300 |
commit | 58a2577d48790c79adfd44bcfd662c980ce6cfe4 (patch) | |
tree | 523d814ea0b7b6f617fe515b186099c6e83fed72 /classes/pref/feeds.php | |
parent | e470a273cf09562fb2f9c0c899002303f19c8d16 (diff) | |
parent | cc332603431102a682feda22b9cf0093a29f0176 (diff) |
Merge branch 'master' of https://github.com/gothfox/Tiny-Tiny-RSS.git
Diffstat (limited to 'classes/pref/feeds.php')
-rw-r--r-- | classes/pref/feeds.php | 94 |
1 files changed, 89 insertions, 5 deletions
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 46c3d083b..7fb64623e 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1279,6 +1279,8 @@ class Pref_Feeds extends Handler_Protected { dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; print "<div onclick=\"batchSubscribe()\" dojoType=\"dijit.MenuItem\">".__('Batch subscribe')."</div>"; + print "<div dojoType=\"dijit.MenuItem\" onclick=\"removeSelectedFeeds()\">" + .__('Unsubscribe')."</div> "; print "</div></div>"; if (get_pref($this->link, 'ENABLE_FEED_CATS')) { @@ -1287,8 +1289,6 @@ class Pref_Feeds extends Handler_Protected { print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; print "<div onclick=\"createCategory()\" dojoType=\"dijit.MenuItem\">".__('Add category')."</div>"; - print "<div onclick=\"toggleHiddenFeedCats()\" - dojoType=\"dijit.MenuItem\">".__('(Un)hide empty categories')."</div>"; print "<div onclick=\"resetCatOrder()\" dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; print "<div onclick=\"removeSelectedCategories()\" @@ -1300,8 +1300,8 @@ class Pref_Feeds extends Handler_Protected { print $error_button; print $inactive_button; - print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">" - .__('Unsubscribe')."</button dojoType=\"dijit.form.Button\"> "; + print "<button onclick=\"toggleHiddenFeedCats()\" + dojoType=\"dijit.form.Button\">".__('(Un)hide empty categories')."</button>"; if (defined('_ENABLE_FEED_DEBUGGING')) { @@ -1751,7 +1751,7 @@ class Pref_Feeds extends Handler_Protected { } function batchSubscribe() { - print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">"; + 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 "<table width='100%'><tr><td> @@ -1798,6 +1798,90 @@ class Pref_Feeds extends Handler_Protected { </div>"; } + function batchAddFeeds() { + $cat_id = db_escape_string($this->link, $_REQUEST['cat']); + $feeds = explode("\n", db_escape_string($this->link, $_REQUEST['feeds'])); + $login = db_escape_string($this->link, $_REQUEST['login']); + $pass = db_escape_string($this->link, $_REQUEST['pass']); + + foreach ($feeds as $feed) { + $feed = trim($feed); + + if (validate_feed_url($feed)) { + + db_query($this->link, "BEGIN"); + + if ($cat_id == "0" || !$cat_id) { + $cat_qpart = "NULL"; + } else { + $cat_qpart = "'$cat_id'"; + } + + $result = db_query($this->link, + "SELECT id FROM ttrss_feeds + WHERE feed_url = '$feed' AND owner_uid = ".$_SESSION["uid"]); + + if (db_num_rows($result) == 0) { + $result = db_query($this->link, + "INSERT INTO ttrss_feeds + (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method) + VALUES ('".$_SESSION["uid"]."', '$feed', + '[Unknown]', $cat_qpart, '$login', '$pass', 0)"); + } + + db_query($this->link, "COMMIT"); + } + } + } + + function regenOPMLKey() { + $this->update_feed_access_key($this->link, 'OPML:Publish', + false, $_SESSION["uid"]); + + $new_link = Opml::opml_publish_url($this->link); + + print json_encode(array("link" => $new_link)); + } + + function regenFeedKey() { + $feed_id = db_escape_string($this->link, $_REQUEST['id']); + $is_cat = db_escape_string($this->link, $_REQUEST['is_cat']) == "true"; + + $new_key = $this->update_feed_access_key($this->link, $feed_id, $is_cat); + + print json_encode(array("link" => $new_key)); + } + + + private function update_feed_access_key($link, $feed_id, $is_cat, $owner_uid = false) { + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; + + $sql_is_cat = bool_to_sql_bool($is_cat); + + $result = db_query($link, "SELECT access_key FROM ttrss_access_keys + WHERE feed_id = '$feed_id' AND is_cat = $sql_is_cat + AND owner_uid = " . $owner_uid); + + if (db_num_rows($result) == 1) { + $key = db_escape_string($this->link, sha1(uniqid(rand(), true))); + + db_query($link, "UPDATE ttrss_access_keys SET access_key = '$key' + WHERE feed_id = '$feed_id' AND is_cat = $sql_is_cat + AND owner_uid = " . $owner_uid); + + return $key; + + } else { + return get_feed_access_key($link, $feed_id, $is_cat, $owner_uid); + } + } + + // Silent + function clearKeys() { + db_query($this->link, "DELETE FROM ttrss_access_keys WHERE + owner_uid = " . $_SESSION["uid"]); + } + } ?> |