From a55857db5010ad53d5c2949937abceab1dd82bff Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 13:24:49 +0400 Subject: [PATCH 01/14] installer: mention lack of curl --- install/index.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/install/index.php b/install/index.php index 6e141f07..3deb7ad2 100644 --- a/install/index.php +++ b/install/index.php @@ -283,9 +283,27 @@ exit; } - ?> + $notices = array(); - + if (!function_exists("curl_init")) { + array_push($notices, "It is highly recommended to enable support for CURL in PHP."); + } + + if (count($notices) > 0) { + print_notice("Configuration check succeeded with minor problems:"); + + print ""; + } else { + print_notice("Configuration check succeeded."); + } + + ?>

Checking database

From 168680976f9678e2769b77324e8a80527c16d287 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 13:58:08 +0400 Subject: [PATCH 02/14] sessions: initialize connection on include, not in ttrss_open --- include/sessions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/sessions.php b/include/sessions.php index dd1ca663..4923a05b 100644 --- a/include/sessions.php +++ b/include/sessions.php @@ -19,6 +19,10 @@ ini_set("session.use_only_cookies", true); ini_set("session.gc_maxlifetime", $session_expire); + global $session_connection; + + $session_connection = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); + function session_get_schema_version($link, $nocache = false) { global $schema_version; @@ -34,6 +38,7 @@ function validate_session($link) { if (SINGLE_USER_MODE) return true; + if (!$link) return false; $check_ip = $_SESSION['ip_address']; @@ -95,8 +100,6 @@ global $session_connection; - $session_connection = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - return true; } From c35b6d8e14fd930128cd70c7dc46bef9e1c39d9d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:04:47 +0400 Subject: [PATCH 03/14] initialize session connection in ttrss_open but define session_connection in global context --- include/sessions.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/sessions.php b/include/sessions.php index 4923a05b..539b81a0 100644 --- a/include/sessions.php +++ b/include/sessions.php @@ -21,8 +21,6 @@ global $session_connection; - $session_connection = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - function session_get_schema_version($link, $nocache = false) { global $schema_version; @@ -97,9 +95,10 @@ function ttrss_open ($s, $n) { - global $session_connection; + $session_connection = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); + return true; } From 76f2113b359d3c488cc3a149237908cb3bbb535f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:27:15 +0400 Subject: [PATCH 04/14] instances: fix a few wrong calls, move genHash method from rpc --- classes/rpc.php | 26 -------------------------- plugins/instances/init.php | 7 +++++++ plugins/instances/instances.js | 10 +++++----- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/classes/rpc.php b/classes/rpc.php index 34f623b0..d7872477 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -640,32 +640,6 @@ class RPC extends Handler_Protected { return; } - function verifyRegexp() { - $reg_exp = $_REQUEST["reg_exp"]; - - $status = @preg_match("/$reg_exp/i", "TEST") !== false; - - print json_encode(array("status" => $status)); - } - - /* function buttonPlugin() { - $pclass = "button_" . basename($_REQUEST['plugin']); - $method = $_REQUEST['plugin_method']; - - if (class_exists($pclass)) { - $plugin = new $pclass($this->link); - if (method_exists($plugin, $method)) { - return $plugin->$method(); - } - } - } */ - - function genHash() { - $hash = sha1(uniqid(rand(), true)); - - print json_encode(array("hash" => $hash)); - } - function batchAddFeeds() { $cat_id = db_escape_string($this->link, $_REQUEST['cat']); $feeds = explode("\n", db_escape_string($this->link, $_REQUEST['feeds'])); diff --git a/plugins/instances/init.php b/plugins/instances/init.php index 6a7f7003..7f822c7b 100644 --- a/plugins/instances/init.php +++ b/plugins/instances/init.php @@ -442,5 +442,12 @@ class Instances extends Plugin implements IHandler { return; } + function genHash() { + $hash = sha1(uniqid(rand(), true)); + + print json_encode(array("hash" => $hash)); + } + + } ?> diff --git a/plugins/instances/instances.js b/plugins/instances/instances.js index 4a60692b..f699acf7 100644 --- a/plugins/instances/instances.js +++ b/plugins/instances/instances.js @@ -11,7 +11,7 @@ function addInstance() { style: "width: 600px", regenKey: function() { new Ajax.Request("backend.php", { - parameters: "?op=rpc&method=genHash", + parameters: "op=pluginhandler&plugin=instances&method=genHash", onComplete: function(transport) { var reply = JSON.parse(transport.responseText); if (reply) @@ -47,7 +47,7 @@ function addInstance() { function updateInstanceList(sort_key) { new Ajax.Request("backend.php", { - parameters: "?op=pref-instances&sort=" + param_escape(sort_key), + parameters: "op=pluginhandler&plugin=instances&sort=" + param_escape(sort_key), onComplete: function(transport) { dijit.byId('instanceConfigTab').attr('content', transport.responseText); selectTab("instanceConfig", true); @@ -62,7 +62,7 @@ function editInstance(id, event) { selectTableRows('prefInstanceList', 'none'); selectTableRowById('LIRR-'+id, 'LICHK-'+id, true); - var query = "backend.php?op=pref-instances&method=edit&id=" + + var query = "backend.php?op=pluginhandler&plugin=instances&method=edit&id=" + param_escape(id); if (dijit.byId("instanceEditDlg")) @@ -74,7 +74,7 @@ function editInstance(id, event) { style: "width: 600px", regenKey: function() { new Ajax.Request("backend.php", { - parameters: "?op=rpc&method=genHash", + parameters: "op=pluginhandler&plugin=instances&method=genHash", onComplete: function(transport) { var reply = JSON.parse(transport.responseText); if (reply) @@ -124,7 +124,7 @@ function removeSelectedInstances() { if (ok) { notify_progress("Removing selected instances..."); - var query = "?op=pref-instances&method=remove&ids="+ + var query = "op=pluginhandler&plugin=instances&method=remove&ids="+ param_escape(sel_rows.toString()); new Ajax.Request("backend.php", { From 8f2ad8e134e8d8110ec83ed4d14089549a63b5bb Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:29:11 +0400 Subject: [PATCH 05/14] remove some old ?op syntax notation calls --- include/login_form.php | 2 +- plugins/digest/digest.js | 18 +++++++++--------- plugins/import_export/import_export.js | 2 +- plugins/updater/updater.js | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/login_form.php b/include/login_form.php index 4fc08261..7ac7111c 100644 --- a/include/login_form.php +++ b/include/login_form.php @@ -122,7 +122,7 @@ function init() { function fetchProfiles() { try { - var query = "?op=getProfiles&login=" + param_escape(document.forms["loginForm"].login.value); + var query = "op=getProfiles&login=" + param_escape(document.forms["loginForm"].login.value); if (query) { new Ajax.Request("public.php", { diff --git a/plugins/digest/digest.js b/plugins/digest/digest.js index 6d90a9c8..5815e60e 100644 --- a/plugins/digest/digest.js +++ b/plugins/digest/digest.js @@ -29,7 +29,7 @@ function catchup_feed(feed_id, callback) { if (feed_id < 0) is_cat = "true"; // KLUDGE - var query = "?op=rpc&method=catchupFeed&feed_id=" + + var query = "op=rpc&method=catchupFeed&feed_id=" + feed_id + "&is_cat=" + is_cat; new Ajax.Request("backend.php", { @@ -71,7 +71,7 @@ function catchup_visible_articles(callback) { if (confirm(ngettext("Mark %d displayed article as read?", "Mark %d displayed articles as read?", ids.length).replace("%d", ids.length))) { - var query = "?op=rpc&method=catchupSelected" + + var query = "op=rpc&method=catchupSelected" + "&cmode=0&ids=" + param_escape(ids); new Ajax.Request("backend.php", { @@ -91,7 +91,7 @@ function catchup_visible_articles(callback) { function catchup_article(article_id, callback) { try { - var query = "?op=rpc&method=catchupSelected" + + var query = "op=rpc&method=catchupSelected" + "&cmode=0&ids=" + article_id; new Ajax.Request("backend.php", { @@ -172,7 +172,7 @@ function update(callback) { window.clearTimeout(_update_timeout); new Ajax.Request("backend.php", { - parameters: "?op=digest&method=digestinit", + parameters: "op=digest&method=digestinit", onComplete: function(transport) { fatal_error_check(transport); parse_feeds(transport); @@ -223,7 +223,7 @@ function view(article_id) { }, 500); new Ajax.Request("backend.php", { - parameters: "?op=digest&method=digestgetcontents&article_id=" + + parameters: "op=digest&method=digestgetcontents&article_id=" + article_id, onComplete: function(transport) { fatal_error_check(transport); @@ -331,7 +331,7 @@ function viewfeed(feed_id, offset, replace, no_effects, no_indicator, callback) if (!offset) $("headlines").scrollTop = 0; - var query = "backend.php?op=digest&method=digestupdate&feed_id=" + + var query = "op=digest&method=digestupdate&feed_id=" + param_escape(feed_id) + "&offset=" + offset + "&seq=" + _update_seq; @@ -669,7 +669,7 @@ function parse_headlines(transport, replace, no_effects) { function init_second_stage() { try { new Ajax.Request("backend.php", { - parameters: "backend.php?op=digest&method=digestinit&init=1", + parameters: "op=digest&method=digestinit&init=1", onComplete: function(transport) { parse_feeds(transport); Element.hide("overlay"); @@ -705,7 +705,7 @@ function toggle_mark(img, id) { try { - var query = "?op=rpc&id=" + id + "&method=mark"; + var query = "op=rpc&id=" + id + "&method=mark"; if (!img) return; @@ -734,7 +734,7 @@ function toggle_pub(img, id, note) { try { - var query = "?op=rpc&id=" + id + "&method=publ"; + var query = "op=rpc&id=" + id + "&method=publ"; if (note != undefined) { query = query + "¬e=" + param_escape(note); diff --git a/plugins/import_export/import_export.js b/plugins/import_export/import_export.js index 86b0458b..780f6bfc 100644 --- a/plugins/import_export/import_export.js +++ b/plugins/import_export/import_export.js @@ -17,7 +17,7 @@ function exportData() { notify_progress("Loading, please wait..."); new Ajax.Request("backend.php", { - parameters: "?op=pluginhandler&plugin=import_export&method=exportrun&offset=" + exported, + parameters: "op=pluginhandler&plugin=import_export&method=exportrun&offset=" + exported, onComplete: function(transport) { try { var rv = JSON.parse(transport.responseText); diff --git a/plugins/updater/updater.js b/plugins/updater/updater.js index 17452d73..40fcc871 100644 --- a/plugins/updater/updater.js +++ b/plugins/updater/updater.js @@ -16,7 +16,7 @@ function updateSelf() { notify_progress("Loading, please wait...", true); new Ajax.Request("backend.php", { - parameters: "?op=pluginhandler&plugin=updater&method=performUpdate&step=" + step + + parameters: "op=pluginhandler&plugin=updater&method=performUpdate&step=" + step + "¶ms=" + param_escape(JSON.stringify(dialog.attr("update-params"))), onComplete: function(transport) { try { From 96e3ae8ccebf144880844475b9bbac51ec5cb135 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:32:10 +0400 Subject: [PATCH 06/14] move batchAddFeeds to pref-feeds --- classes/pref/feeds.php | 37 ++++++++++++++++++++++++++++++++++++- classes/rpc.php | 36 ------------------------------------ 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index eda03d12..aa018ee1 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1751,7 +1751,7 @@ class Pref_Feeds extends Handler_Protected { } function batchSubscribe() { - print ""; + print ""; print ""; print "
@@ -1798,6 +1798,41 @@ class Pref_Feeds extends Handler_Protected { "; } + 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"); + } + } + } } ?> diff --git a/classes/rpc.php b/classes/rpc.php index d7872477..36d7083a 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -640,42 +640,6 @@ class RPC extends Handler_Protected { return; } - 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 setScore() { $ids = db_escape_string($this->link, $_REQUEST['id']); $score = (int)db_escape_string($this->link, $_REQUEST['score']); From c88e4a2af317d5b1dfa60e639df9336a72fe879a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:34:17 +0400 Subject: [PATCH 07/14] remove small_article_preview --- cdm.css | 19 ------------------- classes/rpc.php | 27 --------------------------- index.php | 2 -- js/viewfeed.js | 45 --------------------------------------------- 4 files changed, 93 deletions(-) diff --git a/cdm.css b/cdm.css index 13f88dd4..9893f43f 100644 --- a/cdm.css +++ b/cdm.css @@ -192,23 +192,4 @@ div.cdm.expanded div.cdmHeader a.title, div.cdm.active div.cdmHeader a.title { font-size : 13px; } -div#small_article_preview { - width : 300px; - max-height : 350px; - overflow : hidden; - border : 1px solid #c0c0c0; - background : white; - position : absolute; - box-shadow : 2px 2px 4px #c0c0c0; - z-index : 2; -} -div#small_article_preview div.content { - padding : 5px; - font-size : 12px; - color : gray; -} - -div#small_article_preview div.content img { - max-width : 290px; -} diff --git a/classes/rpc.php b/classes/rpc.php index 36d7083a..f0218f91 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -834,32 +834,5 @@ class RPC extends Handler_Protected { } } - function cdmArticlePreview() { - $id = db_escape_string($this->link, $_REQUEST['id']); - - $result = db_query($this->link, "SELECT link, - ttrss_entries.title, content, feed_url - FROM - ttrss_entries, ttrss_user_entries - LEFT JOIN ttrss_feeds ON (ttrss_user_entries.feed_id = ttrss_feeds.id) - WHERE ref_id = '$id' AND ref_id = ttrss_entries.id AND - ttrss_user_entries.owner_uid = ". $_SESSION["uid"]); - - if (db_num_rows($result) != 0) { - $link = db_fetch_result($result, 0, "link"); - $title = db_fetch_result($result, 0, "title"); - $feed_url = db_fetch_result($result, 0, "feed_url"); - - $content = sanitize($this->link, - db_fetch_result($result, 0, "content"), false, false, $feed_url); - - print "
".$content.""; - - } else { - print "Article not found."; - } - - } - } ?> diff --git a/index.php b/index.php index 3b905d1b..e390edff 100644 --- a/index.php +++ b/index.php @@ -140,8 +140,6 @@
- -
 
diff --git a/js/viewfeed.js b/js/viewfeed.js index c24dec62..e3d73b89 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -13,8 +13,6 @@ var catchup_timeout_id = false; var cids_requested = []; var loaded_article_ids = []; -var _post_preview_timeout = false; - var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null; function headlines_callback2(transport, offset, background, infscroll_req) { @@ -1153,53 +1151,10 @@ function getActiveArticleId() { function postMouseIn(e, id) { post_under_pointer = id; - - if (_post_preview_timeout) window.clearTimeout(_post_preview_timeout); - - /* if (!isCdmMode() || !getInitParam("cdm_expanded")) { - _post_preview_timeout = window.setTimeout(function() { - displaySmallArticlePreview(e, id); - }, 1000); - } */ -} - -function displaySmallArticlePreview(e, id) { - try { - var query = "?op=rpc&method=cdmarticlepreview&id=" + id; - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - cexc = $("CEXC-" + id); - preview = $("small_article_preview"); - row = $("RROW-" + id); - ctr = $("headlines-frame"); - - if (id != getActiveArticleId() && (!isCdmMode() || (cexc && Element.visible(cexc))) && row && preview) { - preview.innerHTML = transport.responseText; - new Effect.Appear(preview, {duration:0.2}); - - preview.setStyle({ - left: (e.clientX + 20) + 'px', - top: (row.offsetTop + row.offsetHeight*2 + 20 - ctr.scrollTop) + 'px' }); - - } - - } }); - - - } catch (e) { - exception_error("displaySmallArticlePreview", e); - } } function postMouseOut(id) { post_under_pointer = false; - - if (_post_preview_timeout) window.clearTimeout(_post_preview_timeout); - - if (Element.visible("small_article_preview")) - Element.hide("small_article_preview"); } function unpackVisibleHeadlines() { From 8956b3a607be2d0a28704713d6a5d915e6c82fd3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:36:00 +0400 Subject: [PATCH 08/14] remove obsolete checkDate stuff --- classes/rpc.php | 8 -------- js/functions.js | 50 ------------------------------------------------- 2 files changed, 58 deletions(-) diff --git a/classes/rpc.php b/classes/rpc.php index f0218f91..64e09d1e 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -480,14 +480,6 @@ class RPC extends Handler_Protected { print json_encode($articles); } - function checkDate() { - $date = db_escape_string($this->link, $_REQUEST["date"]); - $date_parsed = strtotime($date); - - print json_encode(array("result" => (bool)$date_parsed, - "date" => date("c", $date_parsed))); - } - function assigntolabel() { return $this->labelops(true); } diff --git a/js/functions.js b/js/functions.js index 0b39cc46..56074259 100644 --- a/js/functions.js +++ b/js/functions.js @@ -548,28 +548,6 @@ function fatalError(code, msg, ext_info) { } } -/* function filterDlgCheckType(sender) { - - try { - - var ftype = sender.value; - - // if selected filter type is 5 (Date) enable the modifier dropbox - if (ftype == 5) { - Element.show("filterDlg_dateModBox"); - Element.show("filterDlg_dateChkBox"); - } else { - Element.hide("filterDlg_dateModBox"); - Element.hide("filterDlg_dateChkBox"); - - } - - } catch (e) { - exception_error("filterDlgCheckType", e); - } - -} */ - function filterDlgCheckAction(sender) { try { @@ -603,34 +581,6 @@ function filterDlgCheckAction(sender) { } -function filterDlgCheckDate() { - try { - var dialog = dijit.byId("filterEditDlg"); - - var reg_exp = dialog.attr('value').reg_exp; - - var query = "?op=rpc&method=checkDate&date=" + reg_exp; - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - - var reply = JSON.parse(transport.responseText); - - if (reply['result'] == true) { - alert(__("Date syntax appears to be correct:") + " " + reply['date']); - return; - } else { - alert(__("Date syntax is incorrect.")); - } - - } }); - - - } catch (e) { - exception_error("filterDlgCheckDate", e); - } -} function explainError(code) { return displayDlg(__("Error explained"), "explainError", code); From d719b062404f551594bbe5ee37f1eb306061c118 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:41:41 +0400 Subject: [PATCH 09/14] rpc: move setScore to article --- classes/article.php | 11 +++++++++++ classes/rpc.php | 11 ----------- js/viewfeed.js | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/classes/article.php b/classes/article.php index 79c94f59..6e423693 100644 --- a/classes/article.php +++ b/classes/article.php @@ -208,5 +208,16 @@ class Article extends Handler_Protected { } + function setScore() { + $ids = db_escape_string($this->link, $_REQUEST['id']); + $score = (int)db_escape_string($this->link, $_REQUEST['score']); + + db_query($this->link, "UPDATE ttrss_user_entries SET + score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]); + + print json_encode(array("id" => $id, + "score_pic" => get_score_pic($score))); + } + } diff --git a/classes/rpc.php b/classes/rpc.php index 64e09d1e..d61b2891 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -632,17 +632,6 @@ class RPC extends Handler_Protected { return; } - function setScore() { - $ids = db_escape_string($this->link, $_REQUEST['id']); - $score = (int)db_escape_string($this->link, $_REQUEST['score']); - - db_query($this->link, "UPDATE ttrss_user_entries SET - score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]); - - print json_encode(array("id" => $id, - "score_pic" => get_score_pic($score))); - } - function setpanelmode() { $wide = (int) $_REQUEST["wide"]; diff --git a/js/viewfeed.js b/js/viewfeed.js index e3d73b89..be2b88f4 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -2020,7 +2020,7 @@ function setSelectionScore() { var score = prompt(__("Please enter new score for selected articles:"), score); if (score != undefined) { - var query = "op=rpc&method=setScore&id=" + param_escape(ids.toString()) + + var query = "op=article&method=setScore&id=" + param_escape(ids.toString()) + "&score=" + param_escape(score); new Ajax.Request("backend.php", { @@ -2063,7 +2063,7 @@ function changeScore(id, pic) { if (new_score != undefined) { - var query = "op=rpc&method=setScore&id=" + param_escape(id) + + var query = "op=article&method=setScore&id=" + param_escape(id) + "&score=" + param_escape(new_score); new Ajax.Request("backend.php", { From 195187c4903583846edbd58516809ae743bd110e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:47:43 +0400 Subject: [PATCH 10/14] rpc: move several feed-related calls to pref-feeds --- classes/pref/feeds.php | 49 ++++++++++++++++++++++++++++++++++++++++++ classes/rpc.php | 47 ---------------------------------------- js/functions.js | 2 +- js/prefs.js | 4 ++-- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index aa018ee1..7fb64623 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1834,5 +1834,54 @@ class Pref_Feeds extends Handler_Protected { } } + 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"]); + } + + } ?> diff --git a/classes/rpc.php b/classes/rpc.php index d61b2891..3593bd5d 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -411,15 +411,6 @@ class RPC extends Handler_Protected { "content" => $tags_str, "content_full" => $tags_str_full)); } - 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 completeLabels() { $search = db_escape_string($this->link, $_REQUEST["search"]); @@ -609,21 +600,6 @@ class RPC extends Handler_Protected { print_feed_cat_select($this->link, "cat_id", $id); } - 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)); - } - - // Silent - function clearKeys() { - db_query($this->link, "DELETE FROM ttrss_access_keys WHERE - owner_uid = " . $_SESSION["uid"]); - } - // Silent function clearArticleKeys() { db_query($this->link, "UPDATE ttrss_user_entries SET uuid = '' WHERE @@ -716,29 +692,6 @@ class RPC extends Handler_Protected { } - 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); - } - } - private function markArticlesById($link, $ids, $cmode) { $tmp_ids = array(); diff --git a/js/functions.js b/js/functions.js index 56074259..4e4d0355 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1357,7 +1357,7 @@ function genUrlChangeKey(feed, is_cat) { notify_progress("Trying to change address...", true); - var query = "?op=rpc&method=regenFeedKey&id=" + param_escape(feed) + + var query = "?op=pref-feeds&method=regenFeedKey&id=" + param_escape(feed) + "&is_cat=" + param_escape(is_cat); new Ajax.Request("backend.php", { diff --git a/js/prefs.js b/js/prefs.js index 358625e9..b4ecd258 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -1221,7 +1221,7 @@ function opmlRegenKey() { notify_progress("Trying to change address...", true); - var query = "?op=rpc&method=regenOPMLKey"; + var query = "?op=pref-feeds&method=regenOPMLKey"; new Ajax.Request("backend.php", { parameters: query, @@ -1521,7 +1521,7 @@ function clearFeedAccessKeys() { if (ok) { notify_progress("Clearing URLs..."); - var query = "?op=rpc&method=clearKeys"; + var query = "?op=pref-feeds&method=clearKeys"; new Ajax.Request("backend.php", { parameters: query, From 5df8be5c0ac69db8716fcb29a27b2bbc3fbcbace Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:52:21 +0400 Subject: [PATCH 11/14] rpc: move setArticleTags to article --- classes/article.php | 66 ++++++++++++++++++++++++++++++++++++++++++++- classes/rpc.php | 64 ------------------------------------------- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/classes/article.php b/classes/article.php index 6e423693..bf1e5566 100644 --- a/classes/article.php +++ b/classes/article.php @@ -185,7 +185,7 @@ class Article extends Handler_Protected { $tags_str = join(", ", $tags); print ""; - print ""; + print ""; print ""; print "
"; @@ -220,4 +220,68 @@ class Article extends Handler_Protected { } + function setArticleTags() { + + $id = db_escape_string($this->link, $_REQUEST["id"]); + + $tags_str = db_escape_string($this->link, $_REQUEST["tags_str"]); + $tags = array_unique(trim_array(explode(",", $tags_str))); + + db_query($this->link, "BEGIN"); + + $result = db_query($this->link, "SELECT int_id FROM ttrss_user_entries WHERE + ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1"); + + if (db_num_rows($result) == 1) { + + $tags_to_cache = array(); + + $int_id = db_fetch_result($result, 0, "int_id"); + + db_query($this->link, "DELETE FROM ttrss_tags WHERE + post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'"); + + foreach ($tags as $tag) { + $tag = sanitize_tag($tag); + + if (!tag_is_valid($tag)) { + continue; + } + + if (preg_match("/^[0-9]*$/", $tag)) { + continue; + } + + // print ""; + + if ($tag != '') { + db_query($this->link, "INSERT INTO ttrss_tags + (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')"); + } + + array_push($tags_to_cache, $tag); + } + + /* update tag cache */ + + sort($tags_to_cache); + $tags_str = join(",", $tags_to_cache); + + db_query($this->link, "UPDATE ttrss_user_entries + SET tag_cache = '$tags_str' WHERE ref_id = '$id' + AND owner_uid = " . $_SESSION["uid"]); + } + + db_query($this->link, "COMMIT"); + + $tags = get_article_tags($this->link, $id); + $tags_str = format_tags_string($tags, $id); + $tags_str_full = join(", ", $tags); + + if (!$tags_str_full) $tags_str_full = __("no tags"); + + print json_encode(array("id" => (int)$id, + "content" => $tags_str, "content_full" => $tags_str_full)); + } + } diff --git a/classes/rpc.php b/classes/rpc.php index 3593bd5d..a78e079c 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -347,70 +347,6 @@ class RPC extends Handler_Protected { print json_encode($reply); } - function setArticleTags() { - - $id = db_escape_string($this->link, $_REQUEST["id"]); - - $tags_str = db_escape_string($this->link, $_REQUEST["tags_str"]); - $tags = array_unique(trim_array(explode(",", $tags_str))); - - db_query($this->link, "BEGIN"); - - $result = db_query($this->link, "SELECT int_id FROM ttrss_user_entries WHERE - ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1"); - - if (db_num_rows($result) == 1) { - - $tags_to_cache = array(); - - $int_id = db_fetch_result($result, 0, "int_id"); - - db_query($this->link, "DELETE FROM ttrss_tags WHERE - post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'"); - - foreach ($tags as $tag) { - $tag = sanitize_tag($tag); - - if (!tag_is_valid($tag)) { - continue; - } - - if (preg_match("/^[0-9]*$/", $tag)) { - continue; - } - - // print ""; - - if ($tag != '') { - db_query($this->link, "INSERT INTO ttrss_tags - (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')"); - } - - array_push($tags_to_cache, $tag); - } - - /* update tag cache */ - - sort($tags_to_cache); - $tags_str = join(",", $tags_to_cache); - - db_query($this->link, "UPDATE ttrss_user_entries - SET tag_cache = '$tags_str' WHERE ref_id = '$id' - AND owner_uid = " . $_SESSION["uid"]); - } - - db_query($this->link, "COMMIT"); - - $tags = get_article_tags($this->link, $id); - $tags_str = format_tags_string($tags, $id); - $tags_str_full = join(", ", $tags); - - if (!$tags_str_full) $tags_str_full = __("no tags"); - - print json_encode(array("id" => (int)$id, - "content" => $tags_str, "content_full" => $tags_str_full)); - } - function completeLabels() { $search = db_escape_string($this->link, $_REQUEST["search"]); From c83554bdddd1efb8a600d2dc6dbd119e3104013c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:53:36 +0400 Subject: [PATCH 12/14] rpc: move completeTags to article --- classes/article.php | 17 +++++++++++++++++ classes/rpc.php | 16 ---------------- js/viewfeed.js | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/classes/article.php b/classes/article.php index bf1e5566..e75af0e7 100644 --- a/classes/article.php +++ b/classes/article.php @@ -284,4 +284,21 @@ class Article extends Handler_Protected { "content" => $tags_str, "content_full" => $tags_str_full)); } + + function completeTags() { + $search = db_escape_string($this->link, $_REQUEST["search"]); + + $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags + WHERE owner_uid = '".$_SESSION["uid"]."' AND + tag_name LIKE '$search%' ORDER BY tag_name + LIMIT 10"); + + print "
    "; + while ($line = db_fetch_assoc($result)) { + print "
  • " . $line["tag_name"] . "
  • "; + } + print "
"; + } + + } diff --git a/classes/rpc.php b/classes/rpc.php index a78e079c..04b763c4 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -363,22 +363,6 @@ class RPC extends Handler_Protected { print ""; } - - function completeTags() { - $search = db_escape_string($this->link, $_REQUEST["search"]); - - $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags - WHERE owner_uid = '".$_SESSION["uid"]."' AND - tag_name LIKE '$search%' ORDER BY tag_name - LIMIT 10"); - - print "
    "; - while ($line = db_fetch_assoc($result)) { - print "
  • " . $line["tag_name"] . "
  • "; - } - print "
"; - } - function purge() { $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"])); $days = sprintf("%d", $_REQUEST["days"]); diff --git a/js/viewfeed.js b/js/viewfeed.js index be2b88f4..31eff1b8 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -1114,7 +1114,7 @@ function editArticleTags(id) { dojo.disconnect(tmph); new Ajax.Autocompleter('tags_str', 'tags_choices', - "backend.php?op=rpc&method=completeTags", + "backend.php?op=article&method=completeTags", { tokens: ',', paramName: "search" }); }); From 9c96a3e28cb360fc79d1e58f4871ce47ad55333e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:54:31 +0400 Subject: [PATCH 13/14] rpc: remove getArticles --- classes/rpc.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/classes/rpc.php b/classes/rpc.php index 04b763c4..de52a9e8 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -378,19 +378,6 @@ class RPC extends Handler_Protected { } } - function getArticles() { - $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"])); - $articles = array(); - - foreach ($ids as $id) { - if ($id) { - array_push($articles, format_article($this->link, $id, 0, false)); - } - } - - print json_encode($articles); - } - function assigntolabel() { return $this->labelops(true); } From 4b7726f0b44db36ad12c0a0918a9129c8cbb1caa Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:56:08 +0400 Subject: [PATCH 14/14] rpc: move labelops to article --- classes/article.php | 42 ++++++++++++++++++++++++++++++++++++++++++ classes/rpc.php | 41 ----------------------------------------- js/viewfeed.js | 4 ++-- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/classes/article.php b/classes/article.php index e75af0e7..9a097014 100644 --- a/classes/article.php +++ b/classes/article.php @@ -300,5 +300,47 @@ class Article extends Handler_Protected { print ""; } + function assigntolabel() { + return $this->labelops(true); + } + + function removefromlabel() { + return $this->labelops(false); + } + + private function labelops($assign) { + $reply = array(); + + $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"])); + $label_id = db_escape_string($this->link, $_REQUEST["lid"]); + + $label = db_escape_string($this->link, label_find_caption($this->link, $label_id, + $_SESSION["uid"])); + + $reply["info-for-headlines"] = array(); + + if ($label) { + + foreach ($ids as $id) { + + if ($assign) + label_add_article($this->link, $id, $label, $_SESSION["uid"]); + else + label_remove_article($this->link, $id, $label, $_SESSION["uid"]); + + $labels = get_article_labels($this->link, $id, $_SESSION["uid"]); + + array_push($reply["info-for-headlines"], + array("id" => $id, "labels" => format_article_labels($labels, $id))); + + } + } + + $reply["message"] = "UPDATE_COUNTERS"; + + print json_encode($reply); + } + + } diff --git a/classes/rpc.php b/classes/rpc.php index de52a9e8..a6339209 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -378,47 +378,6 @@ class RPC extends Handler_Protected { } } - function assigntolabel() { - return $this->labelops(true); - } - - function removefromlabel() { - return $this->labelops(false); - } - - function labelops($assign) { - $reply = array(); - - $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"])); - $label_id = db_escape_string($this->link, $_REQUEST["lid"]); - - $label = db_escape_string($this->link, label_find_caption($this->link, $label_id, - $_SESSION["uid"])); - - $reply["info-for-headlines"] = array(); - - if ($label) { - - foreach ($ids as $id) { - - if ($assign) - label_add_article($this->link, $id, $label, $_SESSION["uid"]); - else - label_remove_article($this->link, $id, $label, $_SESSION["uid"]); - - $labels = get_article_labels($this->link, $id, $_SESSION["uid"]); - - array_push($reply["info-for-headlines"], - array("id" => $id, "labels" => format_article_labels($labels, $id))); - - } - } - - $reply["message"] = "UPDATE_COUNTERS"; - - print json_encode($reply); - } - function updateFeedBrowser() { $search = db_escape_string($this->link, $_REQUEST["search"]); $limit = db_escape_string($this->link, $_REQUEST["limit"]); diff --git a/js/viewfeed.js b/js/viewfeed.js index 31eff1b8..48137a13 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -678,7 +678,7 @@ function selectionRemoveLabel(id, ids) { return; } - var query = "?op=rpc&method=removeFromLabel&ids=" + + var query = "?op=article&method=removeFromLabel&ids=" + param_escape(ids.toString()) + "&lid=" + param_escape(id); console.log(query); @@ -706,7 +706,7 @@ function selectionAssignLabel(id, ids) { return; } - var query = "?op=rpc&method=assignToLabel&ids=" + + var query = "?op=article&method=assignToLabel&ids=" + param_escape(ids.toString()) + "&lid=" + param_escape(id); console.log(query);