diff --git a/api/index.php b/api/index.php index a8484ef0e..d451a3ac8 100644 --- a/api/index.php +++ b/api/index.php @@ -57,6 +57,20 @@ if (!init_plugins()) return; + if ($_SESSION["uid"]) { + if (!validate_session()) { + header("Content-Type: text/json"); + + print json_encode(array("seq" => -1, + "status" => 1, + "content" => array("error" => "NOT_LOGGED_IN"))); + + return; + } + + load_user_plugins( $_SESSION["uid"]); + } + $method = strtolower($_REQUEST["op"]); $handler = new API($_REQUEST); diff --git a/classes/api.php b/classes/api.php index 9be04cff9..35c5d5f38 100644 --- a/classes/api.php +++ b/classes/api.php @@ -330,7 +330,7 @@ class API extends Handler { if ($article_id) { - $query = "SELECT id,title,link,content,feed_id,comments,int_id, + $query = "SELECT id,guid,title,link,content,feed_id,comments,int_id, marked,unread,published,score,note,lang, ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title, @@ -352,6 +352,7 @@ class API extends Handler { $article = array( "id" => $line["id"], + "guid" => $line["guid"], "title" => $line["title"], "link" => $line["link"], "labels" => get_article_labels($line['id']), @@ -753,6 +754,7 @@ class API extends Handler { $headline_row = array( "id" => (int)$line["id"], + "guid" => $line["guid"], "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), diff --git a/classes/pref/users.php b/classes/pref/users.php index a10404d0a..164935b23 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -37,7 +37,7 @@ class Pref_Users extends Handler_Protected { $access_level = $this->dbh->fetch_result($result, 0, "access_level"); $email = $this->dbh->fetch_result($result, 0, "email"); - $sel_disabled = ($id == $_SESSION["uid"]) ? "disabled" : ""; + $sel_disabled = ($id == $_SESSION["uid"] || $login == "admin") ? "disabled" : ""; print "
".__("User")."
"; print "
"; diff --git a/classes/rpc.php b/classes/rpc.php index 617c7a22b..9eb8dbd70 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -438,7 +438,7 @@ class RPC extends Handler_Protected { if ($this->dbh->num_rows($result) == 0) { $result = $this->dbh->query("INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id,site_url) - VALUES ('$id','".$_SESSION["uid"]."', + VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL, '$site_url')"); } } diff --git a/include/functions.php b/include/functions.php index d6bd5fb73..3902ac45a 100755 --- a/include/functions.php +++ b/include/functions.php @@ -16,7 +16,9 @@ libxml_disable_entity_loader(true); - mb_internal_encoding("UTF-8"); + // separate test because this is included before sanity checks + if (function_exists("mb_internal_encoding")) mb_internal_encoding("UTF-8"); + date_default_timezone_set('UTC'); if (defined('E_DEPRECATED')) { error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); @@ -831,14 +833,17 @@ return $csrf_token == $_SESSION['csrf_token']; } - function load_user_plugins($owner_uid) { + function load_user_plugins($owner_uid, $pluginhost = false) { + + if (!$pluginhost) $pluginhost = PluginHost::getInstance(); + if ($owner_uid && SCHEMA_VERSION >= 100) { $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); - PluginHost::getInstance()->load($plugins, PluginHost::KIND_USER, $owner_uid); + $pluginhost->load($plugins, PluginHost::KIND_USER, $owner_uid); if (get_schema_version() > 100) { - PluginHost::getInstance()->load_data(); + $pluginhost->load_data(); } } } diff --git a/include/functions2.php b/include/functions2.php index 0a4f4309e..7e1171b7d 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -89,6 +89,7 @@ "feed_edit" => __("Edit feed"), "feed_catchup" => __("Mark as read"), "feed_reverse" => __("Reverse headlines"), + "feed_toggle_vgroup" => __("Toggle headline grouping"), "feed_debug_update" => __("Debug feed update"), "feed_debug_viewfeed" => __("Debug viewfeed()"), "catchup_all" => __("Mark all feeds as read"), @@ -158,6 +159,7 @@ "f e" => "feed_edit", "f q" => "feed_catchup", "f x" => "feed_reverse", + "f g" => "feed_toggle_vgroup", "f *d" => "feed_debug_update", "f *g" => "feed_debug_viewfeed", "f *c" => "toggle_combined_mode", @@ -1062,6 +1064,10 @@ array_push($attrs_to_remove, $attr); } + if ($attr->nodeName == 'href' && stripos($attr->value, 'javascript:') === 0) { + array_push($attrs_to_remove, $attr); + } + if (in_array($attr->nodeName, $disallowed_attributes)) { array_push($attrs_to_remove, $attr); } @@ -2443,4 +2449,20 @@ return $tmp; } + + function get_upload_error_message($code) { + + $errors = array( + 0 => __('There is no error, the file uploaded with success'), + 1 => __('The uploaded file exceeds the upload_max_filesize directive in php.ini'), + 2 => __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'), + 3 => __('The uploaded file was only partially uploaded'), + 4 => __('No file was uploaded'), + 6 => __('Missing a temporary folder'), + 7 => __('Failed to write file to disk.'), + 8 => __('A PHP extension stopped the file upload.'), + ); + + return $errors[$code]; + } ?> diff --git a/include/rssfuncs.php b/include/rssfuncs.php old mode 100755 new mode 100644 index c01e703d1..cbd011e5c --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -179,6 +179,8 @@ $nf = 0; $bstarted = microtime(true); + $batch_owners = array(); + // For each feed, we call the feed update function. foreach ($feeds_to_update as $feed) { if($debug) _debug("Base feed: $feed"); @@ -204,6 +206,9 @@ while ($tline = db_fetch_assoc($tmp_result)) { if($debug) _debug(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]); + if (array_search($tline["owner_uid"], $batch_owners) === FALSE) + array_push($batch_owners, $tline["owner_uid"]); + $fstarted = microtime(true); $rss = update_rss_feed($tline["id"], true, false); _debug_suppress(false); @@ -220,6 +225,12 @@ microtime(true) - $bstarted, (microtime(true) - $bstarted) / $nf)); } + foreach ($batch_owners as $owner_uid) { + _debug("Running housekeeping tasks for user $owner_uid..."); + + housekeeping_user($owner_uid); + } + require_once "digest.php"; // Send feed digests by email if needed. @@ -726,7 +737,8 @@ "language" => $entry_language, "feed" => array("id" => $feed, "fetch_url" => $fetch_url, - "site_url" => $site_url) + "site_url" => $site_url, + "cache_images" => $cache_images) ); $entry_plugin_data = ""; @@ -778,7 +790,7 @@ foreach ($article as $k => $v) { // i guess we'll have to take the risk of 4byte unicode labels & tags here - if (!is_array($article[$k])) { + if (is_string($article[$k])) { $article[$k] = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $v); } } @@ -1501,6 +1513,14 @@ _debug("Removed $frows (feeds) $crows (cats) orphaned counter cache entries."); } + function housekeeping_user($owner_uid) { + $tmph = new PluginHost(); + + load_user_plugins($owner_uid, $tmph); + + $tmph->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", ""); + } + function housekeeping_common($debug) { expire_cached_files($debug); expire_lock_files($debug); @@ -1516,6 +1536,5 @@ //_debug("Cleaned $rc cached tags."); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", ""); - } ?> diff --git a/include/version.php b/include/version.php index 3169ff222..6ca1b7fc4 100644 --- a/include/version.php +++ b/include/version.php @@ -1,5 +1,5 @@ + + get_plugins() as $n => $p) { if (method_exists($p, "get_js")) { + echo "try {"; echo JShrink\Minifier::minify($p->get_js()); + echo "} catch (e) { + console.warn('failed to initialize plugin JS: $n'); + console.warn(e); + }"; } } @@ -118,6 +132,7 @@ + + get_plugins() as $n => $p) { if (method_exists($p, "get_prefs_js")) { + echo "try {"; echo JShrink\Minifier::minify($p->get_prefs_js()); + echo "} catch (e) { + console.warn('failed to initialize plugin JS: $n'); + console.warn(e); + }"; } } - print get_minified_js(array("../lib/CheckBoxTree","functions", "deprecated", "prefs", "PrefFeedTree", "PrefFilterTree", "PrefLabelTree")); + print get_minified_js(array("functions", "deprecated", "prefs")); init_js_translations(); ?> diff --git a/schema/versions/mysql/128.sql b/schema/versions/mysql/128.sql index 0a4d7ab7c..281379bb0 100644 --- a/schema/versions/mysql/128.sql +++ b/schema/versions/mysql/128.sql @@ -1,5 +1,8 @@ BEGIN; +update ttrss_feeds set last_updated = NULL; +alter table ttrss_feeds modify column last_updated datetime DEFAULT NULL; + alter table ttrss_feeds add column feed_language varchar(100); update ttrss_feeds set feed_language = ''; alter table ttrss_feeds change feed_language feed_language varchar(100) not null;