From 2324f15325d32475c8aede8e08df2f7d54b90276 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 1 Apr 2013 21:35:00 +0400 Subject: add sv_SE translation --- include/functions.php | 1 + include/localized_schema.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/functions.php b/include/functions.php index 5fe5c5a65..75ca6daf9 100644 --- a/include/functions.php +++ b/include/functions.php @@ -63,6 +63,7 @@ "ru_RU" => "Русский", "pt_BR" => "Portuguese/Brazil", "zh_CN" => "Simplified Chinese", + "sv_SE" => "Svenska", "fi_FI" => "Suomi"); return $tr; diff --git a/include/localized_schema.php b/include/localized_schema.php index 51d11f79a..418c9d014 100644 --- a/include/localized_schema.php +++ b/include/localized_schema.php @@ -1,4 +1,4 @@ - Date: Tue, 2 Apr 2013 00:04:05 +0400 Subject: add php native gzdecode() --- include/functions.php | 114 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/functions.php b/include/functions.php index 75ca6daf9..a559ed1da 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3934,9 +3934,121 @@ } if (!function_exists('gzdecode')) { - function gzdecode($string) { // no support for 2nd argument + /* function gzdecode($string) { // no support for 2nd argument return file_get_contents('compress.zlib://data:who/cares;base64,'. base64_encode($string)); + } */ + + + function gzdecode($data, &$filename = '', &$error = '', $maxlength = null) { + $len = strlen($data); + if ($len < 18 || strcmp(substr($data,0,2),"\x1f\x8b")) { + $error = "Not in GZIP format."; + return null; // Not GZIP format (See RFC 1952) + } + $method = ord(substr($data,2,1)); // Compression method + $flags = ord(substr($data,3,1)); // Flags + if ($flags & 31 != $flags) { + $error = "Reserved bits not allowed."; + return null; + } + // NOTE: $mtime may be negative (PHP integer limitations) + $mtime = unpack("V", substr($data,4,4)); + $mtime = $mtime[1]; + $xfl = substr($data,8,1); + $os = substr($data,8,1); + $headerlen = 10; + $extralen = 0; + $extra = ""; + if ($flags & 4) { + // 2-byte length prefixed EXTRA data in header + if ($len - $headerlen - 2 < 8) { + return false; // invalid + } + $extralen = unpack("v",substr($data,8,2)); + $extralen = $extralen[1]; + if ($len - $headerlen - 2 - $extralen < 8) { + return false; // invalid + } + $extra = substr($data,10,$extralen); + $headerlen += 2 + $extralen; + } + $filenamelen = 0; + $filename = ""; + if ($flags & 8) { + // C-style string + if ($len - $headerlen - 1 < 8) { + return false; // invalid + } + $filenamelen = strpos(substr($data,$headerlen),chr(0)); + if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 < 8) { + return false; // invalid + } + $filename = substr($data,$headerlen,$filenamelen); + $headerlen += $filenamelen + 1; + } + $commentlen = 0; + $comment = ""; + if ($flags & 16) { + // C-style string COMMENT data in header + if ($len - $headerlen - 1 < 8) { + return false; // invalid + } + $commentlen = strpos(substr($data,$headerlen),chr(0)); + if ($commentlen === false || $len - $headerlen - $commentlen - 1 < 8) { + return false; // Invalid header format + } + $comment = substr($data,$headerlen,$commentlen); + $headerlen += $commentlen + 1; + } + $headercrc = ""; + if ($flags & 2) { + // 2-bytes (lowest order) of CRC32 on header present + if ($len - $headerlen - 2 < 8) { + return false; // invalid + } + $calccrc = crc32(substr($data,0,$headerlen)) & 0xffff; + $headercrc = unpack("v", substr($data,$headerlen,2)); + $headercrc = $headercrc[1]; + if ($headercrc != $calccrc) { + $error = "Header checksum failed."; + return false; // Bad header CRC + } + $headerlen += 2; + } + // GZIP FOOTER + $datacrc = unpack("V",substr($data,-8,4)); + $datacrc = sprintf('%u',$datacrc[1] & 0xFFFFFFFF); + $isize = unpack("V",substr($data,-4)); + $isize = $isize[1]; + // decompression: + $bodylen = $len-$headerlen-8; + if ($bodylen < 1) { + // IMPLEMENTATION BUG! + return null; + } + $body = substr($data,$headerlen,$bodylen); + $data = ""; + if ($bodylen > 0) { + switch ($method) { + case 8: + // Currently the only supported compression method: + $data = gzinflate($body,$maxlength); + break; + default: + $error = "Unknown compression method."; + return false; + } + } // zero-byte body content is allowed + // Verifiy CRC32 + $crc = sprintf("%u",crc32($data)); + $crcOK = $crc == $datacrc; + $lenOK = $isize == strlen($data); + if (!$lenOK || !$crcOK) { + $error = ( $lenOK ? '' : 'Length check FAILED. ') . ( $crcOK ? '' : 'Checksum FAILED.'); + return false; + } + return $data; } } -- cgit v1.2.3-54-g00ecf From 129562e0b169897cb4b6781a4b62f907c4902775 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 09:03:35 +0400 Subject: opml: add some data length limiting --- classes/opml.php | 14 +++++++------- include/functions.php | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/classes/opml.php b/classes/opml.php index 4c188de5e..7a49f757c 100644 --- a/classes/opml.php +++ b/classes/opml.php @@ -253,13 +253,13 @@ class Opml extends Handler_Protected { private function opml_import_feed($doc, $node, $cat_id, $owner_uid) { $attrs = $node->attributes; - $feed_title = db_escape_string($this->link, $attrs->getNamedItem('text')->nodeValue); - if (!$feed_title) $feed_title = db_escape_string($this->link, $attrs->getNamedItem('title')->nodeValue); + $feed_title = db_escape_string($this->link, mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250)); + if (!$feed_title) $feed_title = db_escape_string($this->link, mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250)); - $feed_url = db_escape_string($this->link, $attrs->getNamedItem('xmlUrl')->nodeValue); - if (!$feed_url) $feed_url = db_escape_string($this->link, $attrs->getNamedItem('xmlURL')->nodeValue); + $feed_url = db_escape_string($this->link, mb_substr($attrs->getNamedItem('xmlUrl')->nodeValue, 0, 250)); + if (!$feed_url) $feed_url = db_escape_string($this->link, mb_substr($attrs->getNamedItem('xmlURL')->nodeValue, 0, 250)); - $site_url = db_escape_string($this->link, $attrs->getNamedItem('htmlUrl')->nodeValue); + $site_url = db_escape_string($this->link, mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250)); if ($feed_url && $feed_title) { $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE @@ -386,10 +386,10 @@ class Opml extends Handler_Protected { $default_cat_id = (int) get_feed_category($this->link, 'Imported feeds', false); if ($root_node) { - $cat_title = db_escape_string($this->link, $root_node->attributes->getNamedItem('text')->nodeValue); + $cat_title = db_escape_string($this->link, mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250)); if (!$cat_title) - $cat_title = db_escape_string($this->link, $root_node->attributes->getNamedItem('title')->nodeValue); + $cat_title = db_escape_string($this->link, mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250)); if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) { $cat_id = get_feed_category($this->link, $cat_title, $parent_id); diff --git a/include/functions.php b/include/functions.php index a559ed1da..d321dc2ed 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3406,6 +3406,8 @@ $parent_insert = "NULL"; } + $feed_cat = mb_substr($feed_cat, 0, 250); + $result = db_query($link, "SELECT id FROM ttrss_feed_categories WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); -- cgit v1.2.3-54-g00ecf From eab5a5e241ccf911c40bb4a4d89f2e6d9e69f0e3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 09:19:20 +0400 Subject: Revert "add php native gzdecode()" This reverts commit f2c624a23640eb1e47d83842d0bf8303209155b6. --- include/functions.php | 114 +------------------------------------------------- 1 file changed, 1 insertion(+), 113 deletions(-) (limited to 'include') diff --git a/include/functions.php b/include/functions.php index d321dc2ed..c04e6a81a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3936,121 +3936,9 @@ } if (!function_exists('gzdecode')) { - /* function gzdecode($string) { // no support for 2nd argument + function gzdecode($string) { // no support for 2nd argument return file_get_contents('compress.zlib://data:who/cares;base64,'. base64_encode($string)); - } */ - - - function gzdecode($data, &$filename = '', &$error = '', $maxlength = null) { - $len = strlen($data); - if ($len < 18 || strcmp(substr($data,0,2),"\x1f\x8b")) { - $error = "Not in GZIP format."; - return null; // Not GZIP format (See RFC 1952) - } - $method = ord(substr($data,2,1)); // Compression method - $flags = ord(substr($data,3,1)); // Flags - if ($flags & 31 != $flags) { - $error = "Reserved bits not allowed."; - return null; - } - // NOTE: $mtime may be negative (PHP integer limitations) - $mtime = unpack("V", substr($data,4,4)); - $mtime = $mtime[1]; - $xfl = substr($data,8,1); - $os = substr($data,8,1); - $headerlen = 10; - $extralen = 0; - $extra = ""; - if ($flags & 4) { - // 2-byte length prefixed EXTRA data in header - if ($len - $headerlen - 2 < 8) { - return false; // invalid - } - $extralen = unpack("v",substr($data,8,2)); - $extralen = $extralen[1]; - if ($len - $headerlen - 2 - $extralen < 8) { - return false; // invalid - } - $extra = substr($data,10,$extralen); - $headerlen += 2 + $extralen; - } - $filenamelen = 0; - $filename = ""; - if ($flags & 8) { - // C-style string - if ($len - $headerlen - 1 < 8) { - return false; // invalid - } - $filenamelen = strpos(substr($data,$headerlen),chr(0)); - if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 < 8) { - return false; // invalid - } - $filename = substr($data,$headerlen,$filenamelen); - $headerlen += $filenamelen + 1; - } - $commentlen = 0; - $comment = ""; - if ($flags & 16) { - // C-style string COMMENT data in header - if ($len - $headerlen - 1 < 8) { - return false; // invalid - } - $commentlen = strpos(substr($data,$headerlen),chr(0)); - if ($commentlen === false || $len - $headerlen - $commentlen - 1 < 8) { - return false; // Invalid header format - } - $comment = substr($data,$headerlen,$commentlen); - $headerlen += $commentlen + 1; - } - $headercrc = ""; - if ($flags & 2) { - // 2-bytes (lowest order) of CRC32 on header present - if ($len - $headerlen - 2 < 8) { - return false; // invalid - } - $calccrc = crc32(substr($data,0,$headerlen)) & 0xffff; - $headercrc = unpack("v", substr($data,$headerlen,2)); - $headercrc = $headercrc[1]; - if ($headercrc != $calccrc) { - $error = "Header checksum failed."; - return false; // Bad header CRC - } - $headerlen += 2; - } - // GZIP FOOTER - $datacrc = unpack("V",substr($data,-8,4)); - $datacrc = sprintf('%u',$datacrc[1] & 0xFFFFFFFF); - $isize = unpack("V",substr($data,-4)); - $isize = $isize[1]; - // decompression: - $bodylen = $len-$headerlen-8; - if ($bodylen < 1) { - // IMPLEMENTATION BUG! - return null; - } - $body = substr($data,$headerlen,$bodylen); - $data = ""; - if ($bodylen > 0) { - switch ($method) { - case 8: - // Currently the only supported compression method: - $data = gzinflate($body,$maxlength); - break; - default: - $error = "Unknown compression method."; - return false; - } - } // zero-byte body content is allowed - // Verifiy CRC32 - $crc = sprintf("%u",crc32($data)); - $crcOK = $crc == $datacrc; - $lenOK = $isize == strlen($data); - if (!$lenOK || !$crcOK) { - $error = ( $lenOK ? '' : 'Length check FAILED. ') . ( $crcOK ? '' : 'Checksum FAILED.'); - return false; - } - return $data; } } -- cgit v1.2.3-54-g00ecf From 4785420034aefcc9900c4646ce528676313f1a02 Mon Sep 17 00:00:00 2001 From: Daniel Andersson Date: Tue, 2 Apr 2013 09:05:17 +0200 Subject: Add hook to add explanations of hotkey actions via plugins. --- classes/pluginhost.php | 1 + include/functions.php | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 5b8a77fd6..a75027033 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -27,6 +27,7 @@ class PluginHost { const HOOK_TOOLBAR_BUTTON = 15; const HOOK_ACTION_ITEM = 16; const HOOK_HEADLINE_TOOLBAR_BUTTON = 17; + const HOOK_HOTKEY_INFO = 18; const KIND_ALL = 1; const KIND_SYSTEM = 2; diff --git a/include/functions.php b/include/functions.php index c04e6a81a..aea7618a8 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1934,6 +1934,11 @@ "help_dialog" => __("Show help dialog")) ); + global $pluginhost; + foreach ($pluginhost->get_hooks($pluginhost::HOOK_HOTKEY_INFO) as $plugin) { + $hotkeys = $plugin->hook_hotkey_info($hotkeys); + } + return $hotkeys; } -- cgit v1.2.3-54-g00ecf From 168680976f9678e2769b77324e8a80527c16d287 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 13:58:08 +0400 Subject: sessions: initialize connection on include, not in ttrss_open --- include/sessions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/sessions.php b/include/sessions.php index dd1ca663d..4923a05b7 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; } -- cgit v1.2.3-54-g00ecf From c35b6d8e14fd930128cd70c7dc46bef9e1c39d9d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:04:47 +0400 Subject: initialize session connection in ttrss_open but define session_connection in global context --- include/sessions.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/sessions.php b/include/sessions.php index 4923a05b7..539b81a06 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; } -- cgit v1.2.3-54-g00ecf From 8f2ad8e134e8d8110ec83ed4d14089549a63b5bb Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:29:11 +0400 Subject: 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(-) (limited to 'include') diff --git a/include/login_form.php b/include/login_form.php index 4fc08261a..7ac7111c8 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 6d90a9c8a..5815e60e5 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 86b0458be..780f6bfc7 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 17452d734..40fcc871b 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 { -- cgit v1.2.3-54-g00ecf From f17cac6b26c4df018e8fda97925411d8267c1310 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 15:32:47 +0400 Subject: retire DEFAULT_ARTICLE_LIMIT, infinite scrolling is fast enough to make it superfluous --- classes/feeds.php | 2 +- classes/pref/prefs.php | 11 ++--------- include/db-prefs.php | 4 ---- include/functions.php | 2 +- js/viewfeed.js | 2 +- 5 files changed, 5 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/classes/feeds.php b/classes/feeds.php index 713460e28..778850fc4 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -796,7 +796,7 @@ class Feeds extends Handler_Protected { $feed = db_escape_string($this->link, $_REQUEST["feed"]); $method = db_escape_string($this->link, $_REQUEST["m"]); $view_mode = db_escape_string($this->link, $_REQUEST["view_mode"]); - $limit = (int) get_pref($this->link, "DEFAULT_ARTICLE_LIMIT"); + $limit = 30; @$cat_view = $_REQUEST["cat"] == "true"; @$next_unread_feed = db_escape_string($this->link, $_REQUEST["nuf"]); @$offset = db_escape_string($this->link, $_REQUEST["skip"]); diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index cc523092f..fba9f70d8 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -120,7 +120,7 @@ class Pref_Prefs extends Handler_Protected { global $access_level_names; $prefs_blacklist = array("STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES", - "SORT_HEADLINES_BY_FEED_DATE"); + "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT"); /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */ @@ -498,13 +498,6 @@ class Pref_Prefs extends Handler_Protected { 'dojoType="dijit.form.Select"'); - } else if ($pref_name == "DEFAULT_ARTICLE_LIMIT") { - - $limits = array(15, 30, 45, 60); - - print_select($pref_name, $value, $limits, - 'dojoType="dijit.form.Select"'); - } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") { global $update_intervals_nodefault; @@ -528,7 +521,7 @@ class Pref_Prefs extends Handler_Protected { print ""; - } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', 'DEFAULT_ARTICLE_LIMIT', + } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) { $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; diff --git a/include/db-prefs.php b/include/db-prefs.php index f6a78939b..1ee3d609a 100644 --- a/include/db-prefs.php +++ b/include/db-prefs.php @@ -166,10 +166,6 @@ $value = sprintf("%d", $value); } - if ($pref_name == 'DEFAULT_ARTICLE_LIMIT' && $value == 0) { - $value = 30; - } - if ($pref_name == 'USER_TIMEZONE' && $value == '') { $value = 'UTC'; } diff --git a/include/functions.php b/include/functions.php index c04e6a81a..92690cfbb 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1840,7 +1840,7 @@ foreach (array("ON_CATCHUP_SHOW_NEXT_FEED", "HIDE_READ_FEEDS", "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP", - "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", "DEFAULT_ARTICLE_LIMIT", + "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) { $params[strtolower($param)] = (int) get_pref($link, $param); diff --git a/js/viewfeed.js b/js/viewfeed.js index 48137a136..c1163eab7 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -64,7 +64,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) { vgroup_last_feed = reply['headlines-info']['vgroup_last_feed']; - if (parseInt(headlines_count) < getInitParam("default_article_limit")) { + if (parseInt(headlines_count) < 30) { _infscroll_disable = 1; } else { _infscroll_disable = 0; -- cgit v1.2.3-54-g00ecf From 9eeb6d5e233006a35545917c9c9da95cbc53508a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 15:42:49 +0400 Subject: label_create: set default owner_uid --- include/labels.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/labels.php b/include/labels.php index 5ac8794d9..655b51555 100644 --- a/include/labels.php +++ b/include/labels.php @@ -173,7 +173,7 @@ db_query($link, "COMMIT"); } - function label_create($link, $caption, $fg_color = '', $bg_color = '', $owner_uid) { + function label_create($link, $caption, $fg_color = '', $bg_color = '', $owner_uid = false) { if (!$owner_uid) $owner_uid = $_SESSION['uid']; -- cgit v1.2.3-54-g00ecf From dfad9d7a36f1efeafd4e3b5bf1f38dac7aad8de4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 16:20:06 +0400 Subject: pref-prefs: don't use schema-defined help/desc/section names --- classes/pref/prefs.php | 102 +++++++++++++++++++++++++++++++----- include/localized_schema.php | 67 ----------------------- utils/update-schema-translations.sh | 23 -------- utils/update-translations.sh | 2 - 4 files changed, 88 insertions(+), 106 deletions(-) delete mode 100644 include/localized_schema.php delete mode 100755 utils/update-schema-translations.sh (limited to 'include') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index fba9f70d8..d4fad41ac 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1,12 +1,63 @@ pref_sections = array( + 1 => __('General'), + 2 => __('Interface'), + 3 => __('Advanced'), + 4 => __('Digest') + ); + + $this->pref_help = array( + "ALLOW_DUPLICATE_POSTS" => array(__("Allow duplicate posts")), + "AUTO_ASSIGN_LABELS" => array(__("Assign articles to labels automatically"), __("")), + "BLACKLISTED_TAGS" => array(__("Blacklisted tags"), __("When auto-detecting tags in articles these tags will not be applied (comma-separated list)")), + "CDM_AUTO_CATCHUP" => array(__("Automatically mark articles as read"), __("Mark articles as read automatically while you scroll article list.")), + "CDM_EXPANDED" => array(__("Automatically expand articles in combined mode"), __("")), + "COMBINED_DISPLAY_MODE" => array(__("Combined feed display"), __("Display expanded list of feed articles, instead of separate displays for headlines and article content")), + "CONFIRM_FEED_CATCHUP" => array(__("Confirm marking feed as read"), __("")), + "DEFAULT_ARTICLE_LIMIT" => array(__("Amount of articles to display at once"), __("")), + "DEFAULT_UPDATE_INTERVAL" => array(__("Default feed update interval"), __("")), + "DIGEST_CATCHUP" => array(__("Mark articles in e-mail digest as read"), __("")), + "DIGEST_ENABLE" => array(__("Enable email digest"), __("This option enables sending daily digest of new (and unread) headlines on your configured e-mail address")), + "DIGEST_PREFERRED_TIME" => array(__("Try to send digests around specified time"), __("Uses UTC timezone")), + "ENABLE_API_ACCESS" => array(__("Enable external API"), __("")), + "ENABLE_FEED_CATS" => array(__("Enable feed categories"), __("")), + "FEEDS_SORT_BY_UNREAD" => array(__("Sort feeds by unread articles count"), __("")), + "FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles (in hours)"), __("")), + "HIDE_READ_FEEDS" => array(__("Hide feeds with no unread articles"), __("")), + "HIDE_READ_SHOWS_SPECIAL" => array(__("Show special feeds and labels when hiding read feeds"), __("")), + "LONG_DATE_FORMAT" => array(__("Long date format"), __("")), + "ON_CATCHUP_SHOW_NEXT_FEED" => array(__("On catchup show next feed"), __("Automatically open next feed with unread articles after marking one as read")), + "PURGE_OLD_DAYS" => array(__("Purge articles after this number of days (0 - disables)"), __("")), + "PURGE_UNREAD_ARTICLES" => array(__("Purge unread articles"), __("")), + "REVERSE_HEADLINES" => array(__("Reverse headline order (oldest first)"), __("")), + "SHORT_DATE_FORMAT" => array(__("Short date format"), __("")), + "SHOW_CONTENT_PREVIEW" => array(__("Show content preview in headlines list"), __("")), + "SORT_HEADLINES_BY_FEED_DATE" => array(__("Sort headlines by feed date"), __("Use feed-specified date to sort headlines instead of local import date.")), + "SSL_CERT_SERIAL" => array(__("Login with an SSL certificate"), __("Click to register your SSL client certificate with tt-rss")), + "STRIP_IMAGES" => array(__("Do not embed images in articles"), __("")), + "STRIP_UNSAFE_TAGS" => array(__("Strip unsafe tags from articles"), __("Strip all but most common HTML tags when reading articles.")), + "USER_CSS_THEME" => array(__("Select theme"), __("Select one of the available CSS themes")), + "USER_STYLESHEET" => array(__("Customize stylesheet"), __("Customize CSS stylesheet to your liking")), + "USER_TIMEZONE" => array(__("User timezone"), __("")), + "VFEED_GROUP_BY_FEED" => array(__("Group headlines in virtual feeds"), __("When this option is enabled, headlines in Special feeds and Labels are grouped by feeds")) + ); + } + function changepassword() { $old_pw = $_POST["old_password"]; @@ -416,18 +467,17 @@ class Pref_Prefs extends Handler_Protected { $access_query = 'true'; $result = db_query($this->link, "SELECT DISTINCT - ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, + ttrss_user_prefs.pref_name,value,type_name, ttrss_prefs_sections.order_id, - section_name,def_value,section_id + def_value,section_id FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs WHERE type_id = ttrss_prefs_types.id AND $profile_qpart AND section_id = ttrss_prefs_sections.id AND ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND $access_query AND - short_desc != '' AND owner_uid = ".$_SESSION["uid"]." - ORDER BY ttrss_prefs_sections.order_id,short_desc"); + ORDER BY ttrss_prefs_sections.order_id,pref_name"); $lnum = 0; @@ -441,12 +491,22 @@ class Pref_Prefs extends Handler_Protected { continue; } + $type_name = $line["type_name"]; + $pref_name = $line["pref_name"]; + $section_name = $this->getSectionName($line["section_id"]); + $value = $line["value"]; + + $short_desc = $this->getShortDesc($pref_name); + $help_text = $this->getHelpText($pref_name); + + if (!$short_desc) continue; + if ($_SESSION["profile"] && in_array($line["pref_name"], $profile_blacklist)) { continue; } - if ($active_section != $line["section_name"]) { + if ($active_section != $line["section_id"]) { if ($active_section != "") { print ""; @@ -454,24 +514,18 @@ class Pref_Prefs extends Handler_Protected { print ""; - $active_section = $line["section_name"]; + $active_section = $line["section_id"]; - print ""; + print ""; $lnum = 0; } print ""; - $type_name = $line["type_name"]; - $pref_name = $line["pref_name"]; - $value = $line["value"]; - $def_value = $line["def_value"]; - $help_text = $line["help_text"]; - print "

".__($active_section)."

".$section_name."

"; print ""; if ($help_text) print "
".__($help_text)."
"; @@ -1007,6 +1061,26 @@ class Pref_Prefs extends Handler_Protected { } + private function getShortDesc($pref_name) { + if (isset($this->pref_help[$pref_name])) { + return $this->pref_help[$pref_name][0]; + } + return ""; + } + private function getHelpText($pref_name) { + if (isset($this->pref_help[$pref_name])) { + return $this->pref_help[$pref_name][1]; + } + return ""; + } + + private function getSectionName($id) { + if (isset($this->pref_sections[$id])) { + return $this->pref_sections[$id]; + } + + return ""; + } } ?> diff --git a/include/localized_schema.php b/include/localized_schema.php deleted file mode 100644 index 418c9d014..000000000 --- a/include/localized_schema.php +++ /dev/null @@ -1,67 +0,0 @@ - diff --git a/utils/update-schema-translations.sh b/utils/update-schema-translations.sh deleted file mode 100755 index d76fb03a4..000000000 --- a/utils/update-schema-translations.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -LC_ALL=C -LANG=C -LANGUAGE=C - -BASENAME=`basename $0` -TMPFILE="/tmp/$BASENAME-$$.tmp" -OUTFILE="include/localized_schema.php" - -cat schema/ttrss_schema_pgsql.sql | grep 'insert.*pref_name' | awk -F\' '{ print $8 }' > $TMPFILE -cat schema/ttrss_schema_pgsql.sql | grep 'insert.*pref_name' | awk -F\' '{ print $6 }' >> $TMPFILE - -echo " $OUTFILE -echo >> $OUTFILE -cat utils/localized_schema.txt >> $OUTFILE -echo >> $OUTFILE - -cat $TMPFILE | grep -v '^$' | sed "s/.*/__('&');/" >> $OUTFILE - -echo "?>" >> $OUTFILE - -rm $TMPFILE diff --git a/utils/update-translations.sh b/utils/update-translations.sh index c2e8ff54f..4b8dab6b9 100755 --- a/utils/update-translations.sh +++ b/utils/update-translations.sh @@ -1,8 +1,6 @@ #!/bin/sh TEMPLATE=messages.pot -./utils/update-schema-translations.sh - xgettext -kT_js_decl -kT_sprintf -kT_ngettext:1,2 -k__ -L PHP -o $TEMPLATE *.php include/*.php `find classes -iname '*.php'` `find plugins -iname '*.php'` xgettext --from-code utf-8 -k__ -knotify_info -knotify_progress -kngettext -L Java -j -o $TEMPLATE js/*.js `find plugins -iname '*.js'` -- cgit v1.2.3-54-g00ecf From 923b5c8b11cde506838a2f071a1c07892992fb70 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 16:34:08 +0400 Subject: schema: remove unused prefs help_text/short_desc/section_name --- include/functions.php | 2 +- schema/ttrss_schema_mysql.sql | 166 +++++++++++++++--------------------------- schema/ttrss_schema_pgsql.sql | 155 +++++++++++++-------------------------- schema/versions/mysql/115.sql | 9 +++ schema/versions/pgsql/115.sql | 9 +++ 5 files changed, 128 insertions(+), 213 deletions(-) create mode 100644 schema/versions/mysql/115.sql create mode 100644 schema/versions/pgsql/115.sql (limited to 'include') diff --git a/include/functions.php b/include/functions.php index 92690cfbb..9c58f807a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,6 +1,6 @@