Commit 7d39e540 authored by Sebastian Reichel's avatar Sebastian Reichel

Imported Upstream version 1.7.3+dfsg

parent 748e1df1
......@@ -100,3 +100,7 @@ div.articleNote {
border-style : dashed none dashed none;
}
div.cdmHeader span.hlFeed {
float : right;
font-weight : normal;
}
......@@ -309,7 +309,7 @@ class API extends Handler {
"published" => sql_bool_to_bool($line["published"]),
"comments" => $line["comments"],
"author" => $line["author"],
"updated" => strtotime($line["updated"]),
"updated" => (int) strtotime($line["updated"]),
"content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"],
"feed_id" => $line["feed_id"],
"attachments" => $attachments
......@@ -563,7 +563,7 @@ class API extends Handler {
"unread" => (int)$unread,
"has_icon" => $has_icon,
"cat_id" => (int)$line["cat_id"],
"last_updated" => strtotime($line["last_updated"]),
"last_updated" => (int) strtotime($line["last_updated"]),
"order_id" => (int) $line["order_id"],
);
......@@ -604,7 +604,7 @@ class API extends Handler {
"unread" => sql_bool_to_bool($line["unread"]),
"marked" => sql_bool_to_bool($line["marked"]),
"published" => sql_bool_to_bool($line["published"]),
"updated" => strtotime($line["updated"]),
"updated" => (int) strtotime($line["updated"]),
"is_updated" => $is_updated,
"title" => $line["title"],
"link" => $line["link"],
......
......@@ -39,18 +39,19 @@ class Backend extends Handler {
foreach ($hotkeys as $action => $description) {
foreach ($omap[$action] as $sequence) {
if (strpos($sequence, "|") !== FALSE) {
$sequence = substr($sequence,
strpos($sequence, "|")+1,
strlen($sequence));
if (is_array($omap[$action])) {
foreach ($omap[$action] as $sequence) {
if (strpos($sequence, "|") !== FALSE) {
$sequence = substr($sequence,
strpos($sequence, "|")+1,
strlen($sequence));
}
print "<li>";
print "<span class='hksequence'>$sequence</span>";
print $description;
print "</li>";
}
print "<li>";
print "<span class='hksequence'>$sequence</span>";
print $description;
print "</li>";
}
}
}
......
<?php
abstract class Db_Abstract implements Db_Interface
{
private $dbconn;
protected static $instance;
private function __construct() { }
public static function instance()
{
if (is_null(static::$instance)) {
static::$instance = new static();
}
return static::$instance;
}
public function connect($host, $user, $pass, $db) { }
public function getLink()
{
return $this->dbconn;
}
public function init() { }
public function escape_string($s, $strip_tags = true) { }
public function query($query, $die_on_error = true) { }
public function fetch_assoc($result) { }
public function num_rows($result) { }
public function fetch_result($result, $row, $param) { }
public function unescape_string($str)
{
$tmp = str_replace("\\\"", "\"", $str);
$tmp = str_replace("\\'", "'", $tmp);
return $tmp;
}
public function close() { }
public function affected_rows($result) { }
public function last_error() { }
public function quote($str)
{
return("'$str'");
}
}
\ No newline at end of file
<?php
interface Db_Interface
{
public function connect($host, $user, $pass, $db);
public function getLink();
public function init();
public function escape_string($s, $strip_tags = true);
public function query($query, $die_on_error = true);
public function fetch_assoc($result);
public function num_rows($result);
public function fetch_result($result, $row, $param);
public function unescape_string($str);
public function close();
public function affected_rows($result);
public function last_error();
public function quote($str);
}
<?php
class Db_Mysql extends Db_Abstract
{
public function connect($host, $user, $pass, $db)
{
$link = mysql_connect($host, $user, $pass);
if ($link) {
$result = mysql_select_db($db, $link);
if (!$result) {
die("Can't select DB: " . mysql_error($link));
}
$this->dbconn = $link;
return $link;
} else {
die("Unable to connect to database (as $user to $host, database $db): " . mysql_error());
}
}
public function init()
{
db_query($this->dbconn, "SET time_zone = '+0:0'");
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
db_query($this->dbconn, "SET NAMES " . MYSQL_CHARSET);
}
}
public function escape_string($s, $strip_tags = true)
{
if ($strip_tags) $s = strip_tags($s);
return mysql_real_escape_string($s);
}
public function query($query, $die_on_error = true)
{
$result = mysql_query($query, $this->dbconn);
if (!$result) {
$query = htmlspecialchars($query);
if ($die_on_error) {
die("Query <i>$query</i> failed: " . ($this->dbconn ? mysql_error($this->dbconn) : "No connection"));
}
}
return $result;
}
public function fetch_assoc($result) {
return mysql_fetch_assoc($result);
}
public function num_rows($result) {
return mysql_num_rows($result);
}
public function fetch_result($result, $row, $param) {
// I hate incoherent naming of PHP functions
return mysql_result($result, $row, $param);
}
public function close() {
return mysql_close($this->dbconn);
}
public function affected_rows($result) {
return mysql_affected_rows($this->dbconn);
}
public function last_error() {
return mysql_error($this->dbconn);
}
}
<?php
class Db_Pgsql extends Db_Abstract
{
public function connect($host, $user, $pass, $db)
{
$string = "dbname=$db user=$user";
if ($pass) {
$string .= " password=$pass";
}
if ($host) {
$string .= " host=$host";
}
if (defined('DB_PORT')) {
$string = "$string port=" . DB_PORT;
}
$link = pg_connect($string);
if (!$link) {
die("Unable to connect to database (as $user to $host, database $db):" . pg_last_error());
}
$this->dbconn = $link;
return $link;
}
public function init()
{
pg_query($this->dbconn, "set client_encoding = 'UTF-8'");
pg_set_client_encoding("UNICODE");
pg_query($this->dbconn, "set datestyle = 'ISO, european'");
pg_query($this->dbconn, "set TIME ZONE 0");
}
public function escape_string($s, $strip_tags = true)
{
if ($strip_tags) $s = strip_tags($s);
return pg_escape_string($s);
}
public function query($query, $die_on_error = true)
{
$result = pg_query($this->dbconn, $query);
if (!$result) {
$query = htmlspecialchars($query); // just in case
if ($die_on_error) {
die("Query <i>$query</i> failed [$result]: " . ($this->dbconn ? pg_last_error($this->dbconn) : "No connection"));
}
}
return $result;
}
public function fetch_assoc($result) {
return pg_fetch_assoc($result);
}
public function num_rows($result) {
return pg_num_rows($result);
}
public function fetch_result($result, $row, $param) {
return pg_fetch_result($result, $row, $param);
}
public function close() {
return pg_close($this->dbconn);
}
public function affected_rows($result) {
return pg_affected_rows($result);
}
public function last_error() {
return pg_last_error($this->dbconn);
}
}
......@@ -544,12 +544,11 @@ class Feeds extends Handler_Protected {
$reply['content'] .= $labels_str;
if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&
defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
if (@$line["feed_title"]) {
$reply['content'] .= "<span class=\"hlFeed\">
(<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
$line["feed_title"]."</a>)
<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
$line["feed_title"]."</a>
</span>";
}
}
......
<?php
class SanitizeDummy extends SimplePie_Sanitize {
function sanitize($data, $type, $base) {
function sanitize($data, $type, $base = '') {
return $data;
}
}
......
<?php
function __autoload($class) {
$class_file1 = str_replace("_", "/", basename($class)); // PSR-0
$class_file2 = str_replace("_", "/", strtolower(basename($class)));
$file1 = dirname(__FILE__)."/../classes/$class_file1.php";
$file2 = dirname(__FILE__)."/../classes/$class_file2.php";
if (file_exists($file1)) {
require $file1;
} elseif (file_exists($file2)) {
require $file2;
}
}
?>
<?php
require_once "config.php";
require_once "classloader.php";
function db_connect($host, $user, $pass, $db) {
if (DB_TYPE == "pgsql") {
$db_class = 'db_'.lcfirst(DB_TYPE);
$string = "dbname=$db user=$user";
$db = $db_class::instance(); // call_user_func(array($db_class, 'instance'));
if ($pass) {
$string .= " password=$pass";
}
if ($host) {
$string .= " host=$host";
}
if (defined('DB_PORT')) {
$string = "$string port=" . DB_PORT;
}
$link = pg_connect($string);
if (!$link) {
die("Unable to connect to database (as $user to $host, database $db):" . pg_last_error());
}
return $link;
} else if (DB_TYPE == "mysql") {
$link = mysql_connect($host, $user, $pass);
if ($link) {
$result = mysql_select_db($db, $link);
if (!$result) {
die("Can't select DB: " . mysql_error($link));
}
return $link;
} else {
die("Unable to connect to database (as $user to $host, database $db): " . mysql_error());
}
}
function db_connect($host, $user, $pass, $db_name) {
global $db;
return $db->connect($host, $user, $pass, $db_name);
}
function db_escape_string($s, $strip_tags = true) {
if ($strip_tags) $s = strip_tags($s);
if (DB_TYPE == "pgsql") {
return pg_escape_string($s);
} else {
return mysql_real_escape_string($s);
}
global $db;
return $db->escape_string($s, $strip_tags);
}
function db_query($link, $query, $die_on_error = true) {
if (DB_TYPE == "pgsql") {
$result = pg_query($link, $query);
if (!$result) {
$query = htmlspecialchars($query); // just in case
if ($die_on_error) {
die("Query <i>$query</i> failed [$result]: " . ($link ? pg_last_error($link) : "No connection"));
}
}
return $result;
} else if (DB_TYPE == "mysql") {
$result = mysql_query($query, $link);
if (!$result) {
$query = htmlspecialchars($query);
if ($die_on_error) {
die("Query <i>$query</i> failed: " . ($link ? mysql_error($link) : "No connection"));
}
}
return $result;
}
global $db;
return $db->query($query, $die_on_error);
}
function db_fetch_assoc($result) {
if (DB_TYPE == "pgsql") {
return pg_fetch_assoc($result);
} else if (DB_TYPE == "mysql") {
return mysql_fetch_assoc($result);
}
global $db;
return $db->fetch_assoc($result);
}
function db_num_rows($result) {
if (DB_TYPE == "pgsql") {
return pg_num_rows($result);
} else if (DB_TYPE == "mysql") {
return mysql_num_rows($result);
}
global $db;
return $db->num_rows($result);
}
function db_fetch_result($result, $row, $param) {
if (DB_TYPE == "pgsql") {
return pg_fetch_result($result, $row, $param);
} else if (DB_TYPE == "mysql") {
// I hate incoherent naming of PHP functions
return mysql_result($result, $row, $param);
}
global $db;
return $db->fetch_result($result, $row, $param);
}
function db_unescape_string($str) {
$tmp = str_replace("\\\"", "\"", $str);
$tmp = str_replace("\\'", "'", $tmp);
return $tmp;
global $db;
return $db->unescape_string($str);
}
function db_close($link) {
if (DB_TYPE == "pgsql") {
return pg_close($link);
} else if (DB_TYPE == "mysql") {
return mysql_close($link);
}
global $db;
return $db->close();
}
function db_affected_rows($link, $result) {
if (DB_TYPE == "pgsql") {
return pg_affected_rows($result);
} else if (DB_TYPE == "mysql") {
return mysql_affected_rows($link);
}
global $db;
return $db->affected_rows($result);
}
function db_last_error($link) {
if (DB_TYPE == "pgsql") {
return pg_last_error($link);
} else if (DB_TYPE == "mysql") {
return mysql_error($link);
}
global $db;
return $db->last_error();
}
function db_quote($str){
return("'$str'");
global $db;
return $db->quote($str);
}
?>
<?php
define('EXPECTED_CONFIG_VERSION', 26);
define('SCHEMA_VERSION', 103);
define('SCHEMA_VERSION', 104);
$fetch_last_error = false;
$pluginhost = false;
function __autoload($class) {
$class_file = str_replace("_", "/", strtolower(basename($class)));
$file = dirname(__FILE__)."/../classes/$class_file.php";
if (file_exists($file)) {
require $file;
}
}
require_once "classloader.php";
mb_internal_encoding("UTF-8");
date_default_timezone_set('UTC');
......@@ -199,8 +190,6 @@
ttrss_entries.date_updated < NOW() - INTERVAL '$purge_interval days'");
}
$rows = pg_affected_rows($result);
} else {
/* $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
......@@ -216,9 +205,8 @@
$query_limit
ttrss_entries.date_updated < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
$rows = mysql_affected_rows($link);
}
$rows = db_affected_rows($link, $result);
ccache_update($link, $feed_id, $owner_uid);
......@@ -952,7 +940,7 @@
}
function sql_random_function() {
if (DB_TYPE == "mysql") {
if (DB_TYPE == "mysql") {
return "RAND()";
} else {
return "RANDOM()";
......@@ -1895,7 +1883,8 @@
"feed_reverse" => __("Reverse headlines"),
"feed_debug_update" => __("Debug feed update"),
"catchup_all" => __("Mark all feeds as read"),
"cat_toggle_collapse" => __("Un/collapse current category")),
"cat_toggle_collapse" => __("Un/collapse current category"),
"toggle_combined_mode" => __("Toggle combined mode")),
__("Go to") => array(
"goto_all" => __("All articles"),
"goto_fresh" => __("Fresh"),
......@@ -1955,6 +1944,7 @@
"f q" => "feed_catchup",
"f x" => "feed_reverse",
"f D" => "feed_debug_update",
"f C" => "toggle_combined_mode",
"Q" => "catchup_all",
"x" => "cat_toggle_collapse",
// "goto" => array(
......@@ -3206,24 +3196,13 @@
}
function init_connection($link) {
if ($link) {
if (DB_TYPE == "pgsql") {
pg_query($link, "set client_encoding = 'UTF-8'");
pg_set_client_encoding("UNICODE");
pg_query($link, "set datestyle = 'ISO, european'");
pg_query($link, "set TIME ZONE 0");
} else {
db_query($link, "SET time_zone = '+0:0'");
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
db_query($link, "SET NAMES " . MYSQL_CHARSET);
}
}
global $db;
if ($db) {
$db->init();
global $pluginhost;
$pluginhost = new PluginHost($link);
$pluginhost = new PluginHost($db->getLink());
$pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
return true;
......
<?php
define('VERSION', "1.7.2");
define('VERSION', "1.7.3");
?>
......@@ -5,6 +5,13 @@
exit;
}
// we need a separate check here because functions.php might get parsed
// incorrectly before 5.3 because of :: syntax.
if (version_compare("5.3.0", phpversion()) == 1) {
print "<b>Fatal Error</b>: PHP version 5.3.0 or newer required.\n";
exit;
}
set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
get_include_path());
......
......@@ -775,6 +775,19 @@ function hotkey_handler(e) {
return false;
case "help_dialog":
helpDialog("main");
return false;
case "toggle_combined_mode":
notify_progress("Loading, please wait...");
var value = isCdmMode() ? "false" : "true";
var query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value;
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
window.location.reload();
} });
return false;
default:
console.log("unhandled action: " + hotkey_action + "; hotkey: " + hotkey);
......
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -20,8 +20,10 @@ class Af_RedditImgur extends Plugin {
function hook_article_filter($article) {
$owner_uid = $article["owner_uid"];
$force = false;
if (strpos($article["link"], "reddit.com/r/") !== FALSE) {
if (strpos($article["plugin_data"], "redditimgur,$owner_uid:") === FALSE) {
if (strpos($article["plugin_data"], "redditimgur,$owner_uid:") === FALSE || $force) {
$doc = new DOMDocument();
@$doc->loadHTML($article["content"]);
......@@ -29,6 +31,8 @@ class Af_RedditImgur extends Plugin {
$xpath = new DOMXPath($doc);
$entries = $xpath->query('(//a[@href]|//img[@src])');
$found = false;
foreach ($entries as $entry) {
if ($entry->hasAttribute("href")) {
if (preg_match("/\.(jpg|jpeg|gif|png)$/i", $entry->getAttribute("href"))) {
......@@ -37,6 +41,64 @@ class Af_RedditImgur extends Plugin {
$img->setAttribute("src", $entry->getAttribute("href"));
$entry->parentNode->replaceChild($img, $entry);
$found = true;
}
// links to imgur pages
$matches = array();
if (preg_match("/^http:\/\/imgur.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
$token = $matches[1];
$album_content = fetch_file_contents($entry->getAttribute("href"),
false, false, false, false, 10);
if ($album_content && $token) {
$adoc = new DOMDocument();
@$adoc->loadHTML($album_content);
if ($adoc) {
$axpath = new DOMXPath($adoc);
$aentries = $axpath->query('(//img[@src])');
foreach ($aentries as $aentry) {
if (preg_match("/^http:\/\/i.imgur.com\/$token\./", $aentry->getAttribute("src"))) {
$img = $doc->createElement('img');
$img->setAttribute("src", $aentry->getAttribute("src"));
$entry->parentNode->insertBefore($img, $entry);
$found = true;
break;
}
}
}
}
}
// linked albums, ffs
if (preg_match("/^http:\/\/imgur.com\/a\/[^\.]+$/", $entry->getAttribute("href"), $matches)) {
$album_content = fetch_file_contents($entry->getAttribute("href"),
false, false, false, false, 10);
if ($album_content) {
$adoc = new DOMDocument();
@$adoc->loadHTML($album_content);
if ($adoc) {
$axpath = new DOMXPath($adoc);
$aentries = $axpath->query("//div[@class='image']//a[@href and @class='zoom']");
foreach ($aentries as $aentry) {
$img = $doc->createElement('img');
$img->setAttribute("src", $aentry->getAttribute("href"));
$entry->parentNode->insertBefore($doc->createElement('br'), $entry);
$entry->parentNode->insertBefore($img, $entry);
$found = true;
}
}
}
}
}
......@@ -50,9 +112,9 @@ class Af_RedditImgur extends Plugin {
$node = $doc->getElementsByTagName('body')->item(0);
if ($node) {
if ($node && $found) {
$article["content"] = $doc->saveXML($node, LIBXML_NOEMPTYTAG);