Merge branch 'master' into german-translation

master
Heiko Adams 8 years ago
commit 2842cf6e45

@ -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);

@ -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"]),

@ -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 "<div class=\"dlgSec\">".__("User")."</div>";
print "<div class=\"dlgSecCont\">";

@ -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')");
}
}

@ -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();
}
}
}

@ -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];
}
?>

@ -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", "");
}
?>

@ -1,5 +1,5 @@
<?php
define('VERSION_STATIC', '16.3');
define('VERSION_STATIC', '16.8');
function get_version() {
date_default_timezone_set('UTC');

@ -88,6 +88,15 @@
<link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" />
<script>
dojoConfig = {
async: true,
packages: [
{ name: "fox", location: "../../js" },
]
};
</script>
<?php
foreach (array("lib/prototype.js",
"lib/scriptaculous/scriptaculous.js?load=effects,controls",
@ -105,11 +114,16 @@
require_once 'lib/jshrink/Minifier.php';
print get_minified_js(array("tt-rss",
"functions", "feedlist", "viewfeed", "FeedTree", "PluginHost"));
"functions", "feedlist", "viewfeed", "PluginHost"));
foreach (PluginHost::getInstance()->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 @@
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="referrer" content="no-referrer"/>
<script type="text/javascript">
Event.observe(window, 'load', function() {

@ -1,10 +1,6 @@
dojo.provide("fox.FeedTree");
dojo.provide("fox.FeedStoreModel");
require(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) {
dojo.require("dijit.Tree");
dojo.require("dijit.Menu");
dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
return declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
getItemsInCategory: function (id) {
if (!this.store._itemsByIdentity) return undefined;
@ -95,9 +91,13 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
else
return false;
},
});
});
dojo.declare("fox.FeedTree", dijit.Tree, {
require(["dojo/_base/declare", "dijit/Tree", "dijit/Menu"], function (declare) {
return declare("fox.FeedTree", dijit.Tree, {
_onKeyPress: function(/* Event */ e) {
return; // Stop dijit.Tree from interpreting keystrokes
},
@ -587,3 +587,5 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
}
},
});
});

@ -1,10 +1,6 @@
dojo.provide("fox.PrefFeedTree");
dojo.provide("fox.PrefFeedStore");
require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
dojo.require("lib.CheckBoxTree");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
newFileContentString) {
@ -19,7 +15,11 @@ dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
});
dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
});
require(["dojo/_base/declare", "lib/CheckBoxTree"], function (declare) {
return declare("fox.PrefFeedTree", lib.CheckBoxTree, {
_createTreeNode: function(args) {
var tnode = this.inherited(arguments);
@ -122,4 +122,5 @@ dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
}
},
});
});

@ -1,24 +1,27 @@
dojo.provide("fox.PrefFilterTree");
require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
dojo.require("lib.CheckBoxTree");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
return declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
_saveEverything: function (saveCompleteCallback, saveFailedCallback,
newFileContentString) {
dojo.xhrPost({
url: "backend.php",
content: {op: "pref-filters", method: "savefilterorder",
payload: newFileContentString},
content: {
op: "pref-filters", method: "savefilterorder",
payload: newFileContentString
},
error: saveFailedCallback,
load: saveCompleteCallback});
load: saveCompleteCallback
});
},
});
});
dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, {
require(["dojo/_base/declare", "lib/CheckBoxTree"], function (declare) {
return declare("fox.PrefFilterTree", lib.CheckBoxTree, {
_createTreeNode: function(args) {
var tnode = this.inherited(arguments);
@ -94,3 +97,6 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, {
},
});
});

@ -1,9 +1,6 @@
dojo.provide("fox.PrefLabelTree");
require(["dojo/_base/declare", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare) {
dojo.require("lib.CheckBoxTree");
dojo.require("dijit.form.DropDownButton");
dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, {
return declare("fox.PrefLabelTree", lib.CheckBoxTree, {
setNameById: function (id, name) {
var item = this.model.store._itemsByIdentity['LABEL:' + id];
@ -41,3 +38,6 @@ dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, {
},
});
});

@ -889,7 +889,6 @@ function init_second_stage() {
loading_set_progress(50);
notify("");
dojo.addOnLoad(function() {
var tab = getURLParam('tab');
if (tab) {
@ -904,7 +903,6 @@ function init_second_stage() {
window.setTimeout('editFeed(' + param + ')', 100);
}
});
setTimeout("hotkey_prefix_timeout()", 5*1000);
@ -916,42 +914,43 @@ function init_second_stage() {
function init() {
try {
dojo.registerModulePath("lib", "..");
dojo.registerModulePath("fox", "../../js/");
dojo.require("dijit.ColorPalette");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.DropDownButton");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.Form");
dojo.require("dijit.form.RadioButton");
dojo.require("dijit.form.Select");
dojo.require("dijit.form.SimpleTextarea");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.InlineEditBox");
dojo.require("dijit.layout.AccordionContainer");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.Menu");
dojo.require("dijit.ProgressBar");
dojo.require("dijit.ProgressBar");
dojo.require("dijit.Toolbar");
dojo.require("dijit.Tree");
dojo.require("dijit.tree.dndSource");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("lib.CheckBoxTree");
dojo.require("fox.PrefFeedTree");
dojo.require("fox.PrefFilterTree");
dojo.require("fox.PrefLabelTree");
dojo.parser.parse();
dojo.addOnLoad(function() {
require(["dojo/_base/kernel",
"dojo/ready",
"dojo/parser",
"dojo/_base/loader",
"dijit/ColorPalette",
"dijit/Dialog",
"dijit/form/Button",
"dijit/form/CheckBox",
"dijit/form/DropDownButton",
"dijit/form/FilteringSelect",
"dijit/form/Form",
"dijit/form/RadioButton",
"dijit/form/ComboButton",
"dijit/form/Select",
"dijit/form/SimpleTextarea",
"dijit/form/TextBox",
"dijit/form/ValidationTextBox",
"dijit/InlineEditBox",
"dijit/layout/AccordionContainer",
"dijit/layout/AccordionPane",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/Menu",
"dijit/ProgressBar",
"dijit/Toolbar",
"dijit/Tree",
"dijit/tree/dndSource",
"dojo/data/ItemFileWriteStore",
"fox/PrefFeedTree",
"fox/PrefFilterTree",
"fox/PrefLabelTree" ], function (dojo, ready, parser) {
ready(function() {
parser.parse();
loading_set_progress(50);
var clientTzOffset = new Date().getTimezoneOffset() * 60;
@ -963,6 +962,7 @@ function init() {
backend_sanity_check_callback(transport);
} });
});
});
} catch (e) {
exception_error("init", e);

@ -218,35 +218,42 @@ function init() {
try {
//dojo.registerModulePath("fox", "../../js/");
dojo.require("fox.FeedTree");
dojo.require("dijit.ColorPalette");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.DropDownButton");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.Form");
dojo.require("dijit.form.RadioButton");
dojo.require("dijit.form.Select");
dojo.require("dijit.form.SimpleTextarea");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.InlineEditBox");
dojo.require("dijit.layout.AccordionContainer");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.Menu");
dojo.require("dijit.ProgressBar");
dojo.require("dijit.ProgressBar");
dojo.require("dijit.Toolbar");
dojo.require("dijit.Tree");
dojo.require("dijit.tree.dndSource");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.parser.parse();
require(["dojo/_base/kernel",
"dojo/ready",
"dojo/parser",
"dojo/_base/loader",
"dijit/ProgressBar",
"dijit/ColorPalette",
"dijit/Dialog",
"dijit/form/Button",
"dijit/form/ComboButton",
"dijit/form/CheckBox",
"dijit/form/DropDownButton",
"dijit/form/FilteringSelect",
"dijit/form/Form",
"dijit/form/RadioButton",
"dijit/form/Select",
"dijit/form/SimpleTextarea",
"dijit/form/TextBox",
"dijit/form/ComboBox",
"dijit/form/ValidationTextBox",
"dijit/InlineEditBox",
"dijit/layout/AccordionContainer",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/PopupMenuItem",
"dijit/Menu",
"dijit/Toolbar",
"dijit/Tree",
"dijit/tree/dndSource",
"dijit/tree/ForestStoreModel",
"dojo/data/ItemFileWriteStore",
"fox/FeedTree" ], function (dojo, ready, parser) {
ready(function() {
parser.parse();
if (!genericSanityCheck())
return false;
@ -260,6 +267,8 @@ function init() {
var hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
var clientTzOffset = new Date().getTimezoneOffset() * 60;
init_hotkey_actions();
new Ajax.Request("backend.php", {
parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
hasMp3: hasMp3,
@ -269,6 +278,18 @@ function init() {
backend_sanity_check_callback(transport);
} });
});
});
} catch (e) {
exception_error("init", e);
}
}
function init_hotkey_actions() {
hotkey_actions["next_feed"] = function() {
var rv = dijit.byId("feedTree").getNextFeed(
getActiveFeedId(), activeFeedIsCat());
@ -441,6 +462,16 @@ function init() {
hotkey_actions["feed_reverse"] = function() {
reverseHeadlineOrder();
};
hotkey_actions["feed_toggle_vgroup"] = function() {
var query_str = "?op=rpc&method=togglepref&key=VFEED_GROUP_BY_FEED";
new Ajax.Request("backend.php", {
parameters: query_str,
onComplete: function(transport) {
viewCurrentFeed();
} });
};
hotkey_actions["catchup_all"] = function() {
catchupAllFeeds();
};
@ -548,17 +579,11 @@ function init() {
viewCurrentFeed();
} });
};
} catch (e) {
exception_error("init", e);
}
}
function init_second_stage() {
try {
dojo.addOnLoad(function() {
updateFeedList();
closeArticlePanel();
@ -584,8 +609,6 @@ function init_second_stage() {
}
});
});
delCookie("ttrss_test");
var toolbar = document.forms["main_toolbar_form"];

@ -1,15 +1,17 @@
dojo.provide("lib.CheckBoxTree");
dojo.provide("lib.CheckBoxStoreModel");
//dojo.provide("lib.CheckBoxTree");
//dojo.provide("lib.CheckBoxStoreModel");
// THIS WIDGET IS BASED ON DOJO/DIJIT 1.4.0 AND WILL NOT WORK WITH PREVIOUS VERSIONS
//
// Release date: 02/05/2010
//
dojo.require("dijit.Tree");
dojo.require("dijit.form.CheckBox");
//dojo.require("dijit.Tree");
//dojo.require("dijit.form.CheckBox");
dojo.declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel,
require(["dojo/_base/declare", "dijit/tree/TreeStoreModel"], function (declare) {
return declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel,
{
// checkboxAll: Boolean
// If true, every node in the tree will receive a checkbox regardless if the 'checkbox' attribute
@ -334,7 +336,11 @@ dojo.declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel,
});
dojo.declare( "lib._CheckBoxTreeNode", dijit._TreeNode,
});
require(["dojo/_base/declare", "dijit/Tree"], function (declare) {
return declare("lib._CheckBoxTreeNode", dijit._TreeNode,
{
// _checkbox: [protected] dojo.doc.element
// Local reference to the dojo.doc.element of type 'checkbox'
@ -371,8 +377,11 @@ dojo.declare( "lib._CheckBoxTreeNode", dijit._TreeNode,
}
});
});
dojo.declare( "lib.CheckBoxTree", dijit.Tree,
require(["dojo/_base/declare", "dijit/Tree"], function (declare) {
return declare( "lib.CheckBoxTree", dijit.Tree,
{
onNodeChecked: function(/*dojo.data.Item*/ storeItem, /*treeNode*/ treeNode) {
@ -472,3 +481,6 @@ dojo.declare( "lib.CheckBoxTree", dijit.Tree,
}
});
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -274,7 +274,7 @@ class Af_Psql_Trgm extends Plugin {
$result = db_query("SELECT COUNT(id) AS nequal
FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id AND
date_entered >= NOW() - interval '1 day' AND
date_entered >= NOW() - interval '3 days' AND
title = '$title_escaped' AND
guid != '$entry_guid' AND
owner_uid = $owner_uid");

@ -159,7 +159,7 @@ class Af_Readability extends Plugin {
$tmp = fetch_file_contents($url);
if ($tmp && mb_strlen($tmp) < 65535 * 4) {
if ($tmp && mb_strlen($tmp) < 1024 * 500) {
$tmpdoc = new DOMDocument("1.0", "UTF-8");
if (!$tmpdoc->loadHTML($tmp))

@ -95,11 +95,38 @@ class Af_RedditImgur extends Plugin {
$matches = array();
if (preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
if (preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
_debug("handling as twitter: " . $matches[1] . " " . $matches[2], $debug);
$oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
if ($oembed_result) {
$oembed_result = json_decode($oembed_result, true);
if ($oembed_result && isset($oembed_result["html"])) {
$tmp = new DOMDocument();
if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) {
$p = $doc->createElement("p");
$p->appendChild($doc->importNode(
$tmp->getElementsByTagName("blockquote")->item(0), TRUE));
$br = $doc->createElement('br');
$entry->parentNode->insertBefore($p, $entry);
$entry->parentNode->insertBefore($br, $entry);
$found = 1;
}
}
}
}
if (!$found && preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
$entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]);
}
if (preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
if (!$found && preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
_debug("Handling as Gfycat", $debug);
@ -111,17 +138,12 @@ class Af_RedditImgur extends Plugin {
if (@$tmpdoc->loadHTML($tmp)) {
$tmpxpath = new DOMXPath($tmpdoc);
$source_meta = $tmpxpath->query("//meta[@name='twitter:player:stream' and contains(@content, '.mp4')]")->item(0);
$poster_meta = $tmpxpath->query("//meta[@property='og:image' and contains(@content,'thumbs.gfycat.com')]")->item(0);
if ($source_meta) {
$source_stream = $source_meta->getAttribute("content");
$poster_url = false;
$source_node = $tmpxpath->query("//video[contains(@class,'share-video')]//source[contains(@src, '.mp4')]")->item(0);
$poster_node = $tmpxpath->query("//video[contains(@class,'share-video') and @poster]")->item(0);
if ($source_stream) {
if ($poster_meta)
$poster_url = $poster_meta->getAttribute("content");
if ($source_node && $poster_node) {
$source_stream = $source_node->getAttribute("src");
$poster_url = $poster_node->getAttribute("poster");
$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
$found = 1;
@ -130,22 +152,20 @@ class Af_RedditImgur extends Plugin {
}
}
}
// imgur .gif -> .gifv
if (preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
_debug("Handling as imgur gif (->gifv)", $debug);
$entry->setAttribute("href",
str_replace(".gif", ".gifv", $entry->getAttribute("href")));
}
if (preg_match("/\.(gifv)$/i", $entry->getAttribute("href"))) {
if (!$found && preg_match("/\.(gifv|mp4)$/i", $entry->getAttribute("href"))) {
_debug("Handling as imgur gifv", $debug);
$source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
if (strpos($source_stream, "i.imgur.com") !== FALSE)
if (strpos($source_stream, "imgur.com") !== FALSE)
$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
$this->handle_as_video($doc, $entry, $source_stream, $poster_url, $debug);
@ -154,7 +174,7 @@ class Af_RedditImgur extends Plugin {
}
$matches = array();
if (preg_match("/youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
if (!$found && preg_match("/youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
preg_match("/youtube\.com\/.*?[\&\?]v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
preg_match("/youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) {
@ -179,7 +199,10 @@ class Af_RedditImgur extends Plugin {
$found = true;
}
if (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href"))) {
if (!$found && preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) ||
mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE ||
mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== FALSE) {
_debug("Handling as a picture", $debug);
$img = $doc->createElement('img');
@ -194,7 +217,7 @@ class Af_RedditImgur extends Plugin {
// linked albums & pages
if (preg_match("/^https?:\/\/(m\.)?imgur.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches) ||
if (!$found && preg_match("/^https?:\/\/(m\.)?imgur.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches) ||
preg_match("/^https?:\/\/(m\.)?imgur.com\/(a|album|gallery)\/[^\.]+$/", $entry->getAttribute("href"), $matches)) {
_debug("Handling as an imgur page/album/gallery", $debug);
@ -208,18 +231,17 @@ class Af_RedditImgur extends Plugin {
if (@$adoc->loadHTML($album_content)) {
$axpath = new DOMXPath($adoc);
/*$aentries = $axpath->query("//meta[@property='og:image']");
$urls = array();
$aentries = $axpath->query("(//div[@class='post-image']/img[@src] | //a[@class='zoom']/img[@src] | //div[@class='video-elements']/source)");
$urls = [];
foreach ($aentries as $aentry) {
_debug("og:image content=" . $aentry->getAttribute("content"), $debug);
$url = $aentry->getAttribute("src");
if (!in_array($url, $urls)) {
$url = str_replace("?fb", "", $aentry->getAttribute("content"));
$check_url = basename($url);
$check_url = mb_substr($check_url, 0, strrpos($check_url, "."));
if ($aentry->tagName == "img") {
if (!in_array($check_url, $urls)) {
$img = $doc->createElement('img');
$img->setAttribute("src", $url);
$entry->parentNode->insertBefore($doc->createElement('br'), $entry);
@ -228,31 +250,16 @@ class Af_RedditImgur extends Plugin {
$entry->parentNode->insertBefore($img, $entry);
$entry->parentNode->insertBefore($br, $entry);
} else if ($aentry->tagName == "source") {
array_push($urls, $check_url);
$found = true;
}
} */
//if ($debug) print_r($album_content);
$aentries = $axpath->query("(//div[@class='post-image']/img[@src] | //a[@class='zoom']/img[@src])");
$urls = [];
foreach ($aentries as $aentry) {
$url = $aentry->getAttribute("src");
if (!in_array($url, $urls)) {
$img = $doc->createElement('img');
$img->setAttribute("src", $url);
$entry->parentNode->insertBefore($doc->createElement('br'), $entry);
if (strpos($url, "imgur.com") !== FALSE)
$poster_url = str_replace(".mp4", "h.jpg", $url);
else
$poster_url = "";
$br = $doc->createElement('br');
$this->handle_as_video($doc, $entry, $url, $poster_url);
$entry->parentNode->insertBefore($img, $entry);
$entry->parentNode->insertBefore($br, $entry);
}
array_push($urls, $url);
@ -267,7 +274,7 @@ class Af_RedditImgur extends Plugin {
}
// wtf is this even
if (preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
$img_id = $matches[1];
_debug("handling as gyazo: $img_id", $debug);
@ -301,9 +308,10 @@ class Af_RedditImgur extends Plugin {
@$doc->loadHTML($article["content"]);
$xpath = new DOMXPath($doc);
if ($this->host->get($this, "enable_content_dupcheck")) {
$content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0);
if ($this->host->get($this, "enable_content_dupcheck")) {
if ($content_link) {
$content_href = db_escape_string($content_link->getAttribute("href"));
$entry_guid = db_escape_string($article["guid_hashed"]);
@ -333,81 +341,12 @@ class Af_RedditImgur extends Plugin {
$found = $this->inline_stuff($article, $doc, $xpath);
if (!defined('NO_CURL') && function_exists("curl_init") && !$found && $this->host->get($this, "enable_readability") &&
mb_strlen(strip_tags($article["content"])) <= 150) {
if (!class_exists("Readability")) require_once(dirname(dirname(__DIR__)). "/lib/readability/Readability.php");
if ($content_link &&
strpos($content_link->getAttribute("href"), "twitter.com") === FALSE &&
strpos($content_link->getAttribute("href"), "youtube.com") === FALSE &&
strpos($content_link->getAttribute("href"), "reddit.com") === FALSE) {
/* link may lead to a huge video file or whatever, we need to check content type before trying to
parse it which p much requires curl */
$ch = curl_init($content_link->getAttribute("href"));
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT);
@$result = curl_exec($ch);
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
if ($content_type && strpos($content_type, "text/html") !== FALSE) {
$tmp = fetch_file_contents($content_link->getAttribute("href"));
//_debug("tmplen: " . mb_strlen($tmp));
if ($tmp && mb_strlen($tmp) < 65535 * 4) {
$r = new Readability($tmp, $content_link->getAttribute("href"));
if ($r->init()) {
$tmpxpath = new DOMXPath($r->dom);
$entries = $tmpxpath->query('(//a[@href]|//img[@src])');
foreach ($entries as $entry) {
if ($entry->hasAttribute("href")) {
$entry->setAttribute("href",
rewrite_relative_url($content_link->getAttribute("href"), $entry->getAttribute("href")));
}
if ($entry->hasAttribute("src")) {
$entry->setAttribute("src",
rewrite_relative_url($content_link->getAttribute("href"), $entry->getAttribute("src")));
}
}
$article["content"] = $r->articleContent->innerHTML . "<hr/>" . $article["content"];
// prob not a very good idea (breaks wikipedia pages, etc) -
// inliner currently is not really fit for any random web content
//$doc = new DOMDocument();
//@$doc->loadHTML($article["content"]);
//$xpath = new DOMXPath($doc);
//$found = $this->inline_stuff($article, $doc, $xpath);
}
}
}
}
}
$node = $doc->getElementsByTagName('body')->item(0);
if ($node && $found) {
$article["content"] = $doc->saveXML($node);
} else if ($content_link) {
$article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath);
}
}
@ -457,12 +396,101 @@ class Af_RedditImgur extends Plugin {
@$doc->loadHTML("<html><body><a href=\"$url\">[link]</a></body>");
$xpath = new DOMXPath($doc);
print "Inline result: " . $this->inline_stuff([], $doc, $xpath, true) . "\n";
$found = $this->inline_stuff([], $doc, $xpath, true);
print "Inline result: $found\n";
if (!$found) {
print "\nReadability result:\n";
$article = $this->readability([], $url, $doc, $xpath, true);
print_r($article);
} else {
print "\nResulting HTML:\n";
print $doc->saveHTML();
}
}
private function get_content_type($url, $useragent = SELF_USER_AGENT) {
$content_type = false;
if (function_exists("curl_init") && !defined("NO_CURL")) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
@$result = curl_exec($ch);
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
}
return $content_type;
}
private function readability($article, $url, $doc, $xpath, $debug = false) {
if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") &&
mb_strlen(strip_tags($article["content"])) <= 150) {
if (!class_exists("Readability")) require_once(dirname(dirname(__DIR__)). "/lib/readability/Readability.php");
if ($url &&
strpos($url, "twitter.com") === FALSE &&
strpos($url, "youtube.com") === FALSE &&
strpos($url, "reddit.com") === FALSE) {
/* link may lead to a huge video file or whatever, we need to check content type before trying to
parse it which p much requires curl */
$useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
$content_type = $this->get_content_type($url, $useragent_compat);
if ($content_type && strpos($content_type, "text/html") !== FALSE) {
$tmp = fetch_file_contents(array("url" => $url,
"useragent" => $useragent_compat));
if ($debug) _debug("tmplen: " . mb_strlen($tmp));
if ($tmp && mb_strlen($tmp) < 1024 * 500) {
$r = new Readability($tmp, $url);
if ($r->init()) {
$tmpxpath = new DOMXPath($r->dom);
$entries = $tmpxpath->query('(//a[@href]|//img[@src])');
foreach ($entries as $entry) {
if ($entry->hasAttribute("href")) {
$entry->setAttribute("href",
rewrite_relative_url($url, $entry->getAttribute("href")));
}
if ($entry->hasAttribute("src")) {
$entry->setAttribute("src",
rewrite_relative_url($url, $entry->getAttribute("src")));
}
}
$article["content"] = $r->articleContent->innerHTML . "<hr/>" . $article["content"];
}
}
}
}
}
return $article;
}
}
?>

@ -1,4 +1,5 @@
dojo.addOnLoad(function() {
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
ready(function () {
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) {
if (row) {
console.log("af_zz_noautoplay!");
@ -36,5 +37,5 @@ dojo.addOnLoad(function() {
return true;
});
});
});

@ -425,10 +425,10 @@ class Import_Export extends Plugin implements IHandler {
print "<div style='text-align : center'>";
if ($_FILES['export_file']['error'] != 0) {
print_error(T_sprintf("Upload failed with error code %d",
$_FILES['export_file']['error']));
return;
}
print_error(T_sprintf("Upload failed with error code %d (%s)",
$_FILES['export_file']['error'],
get_upload_error_message($_FILES['export_file']['error'])));
} else {
$tmp_file = false;
@ -454,6 +454,7 @@ class Import_Export extends Plugin implements IHandler {
print_error(__('No file uploaded.'));
return;
}
}
print "<button dojoType=\"dijit.form.Button\"
onclick=\"dijit.byId('dataImportDlg').hide()\">".

@ -1,5 +1,7 @@
dojo.addOnLoad(function() {
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
ready(function () {
updateTitle = function () {
document.title = "Tiny Tiny RSS";
};
});
});

@ -1,4 +1,9 @@
dojo.addOnLoad(function() {
hash_set = function() { };
hash_get = function() { };
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
ready(function () {
hash_set = function () {
};
hash_get = function () {
};
});
});

@ -22,7 +22,9 @@ function expandSizeWrapper(id) {
}
dojo.addOnLoad(function() {
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
ready(function() {
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
if (getInitParam('cdm_expanded')) {
@ -45,3 +47,5 @@ dojo.addOnLoad(function() {
return true;
});
});
});

@ -54,6 +54,16 @@
<link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" />
<script>
dojoConfig = {
async: true,
packages: [
{ name: "lib", location: "../" },
{ name: "fox", location: "../../js" },
]
};
</script>
<?php
foreach (array("lib/prototype.js",
"lib/scriptaculous/scriptaculous.js?load=effects,controls",
@ -72,11 +82,16 @@
foreach (PluginHost::getInstance()->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();
?>

@ -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;

Loading…
Cancel
Save