From b552abb3327f09baa1c0f4e821dc9f6bd6ef738e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 1 May 2018 17:02:11 +0200 Subject: JSON column for feeds (#1838) * Draft of JSON column for feeds https://github.com/FreshRSS/FreshRSS/issues/1654 * Add some per-feed options * Feed cURL timeout * Mark updated articles as read https://github.com/FreshRSS/FreshRSS/issues/891 * Mark as read upon reception https://github.com/FreshRSS/FreshRSS/issues/1702 * Ignore SSL (unsafe) https://github.com/FreshRSS/FreshRSS/issues/1811 * Try PHPCS workaround While waiting for a better syntax support --- lib/Minz/ModelPdo.php | 4 ++-- lib/Minz/Request.php | 13 +++++++++++++ lib/lib_rss.php | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index d769e0ff4..6928a2857 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -69,7 +69,7 @@ class Minz_ModelPdo { case 'sqlite': $string = 'sqlite:' . join_path(DATA_PATH, 'users', $currentUser, 'db.sqlite'); $this->prefix = ''; - $this->bd = new MinzPDOMSQLite($string, $db['user'], $db['password'], $driver_options); + $this->bd = new MinzPDOSQLite($string, $db['user'], $db['password'], $driver_options); $this->bd->exec('PRAGMA foreign_keys = ON;'); break; case 'pgsql': @@ -160,7 +160,7 @@ class MinzPDOMySql extends MinzPDO { } } -class MinzPDOMSQLite extends MinzPDO { +class MinzPDOSQLite extends MinzPDO { public function lastInsertId($name = null) { return parent::lastInsertId(); //We discard the name, only used by PostgreSQL } diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index a43509ded..e21697e42 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -39,6 +39,19 @@ class Minz_Request { return $default; } } + public static function paramTernary($key) { + if (isset(self::$params[$key])) { + $p = self::$params[$key]; + $tp = trim($p); + if ($p === null || $tp === '' || $tp === 'null') { + return null; + } elseif ($p == false || $tp == '0' || $tp === 'false' || $tp === 'no') { + return false; + } + return true; + } + return null; + } public static function defaultControllerName() { return self::$default_controller_name; } diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 215c4c362..9dfca385d 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -175,7 +175,7 @@ function html_only_entity_decode($text) { return strtr($text, $htmlEntitiesOnly); } -function customSimplePie() { +function customSimplePie($attributes = array()) { $system_conf = Minz_Configuration::get('system'); $limits = $system_conf->limits; $simplePie = new SimplePie(); @@ -183,8 +183,17 @@ function customSimplePie() { $simplePie->set_syslog($system_conf->simplepie_syslog_enabled); $simplePie->set_cache_location(CACHE_PATH); $simplePie->set_cache_duration($limits['cache_duration']); - $simplePie->set_timeout($limits['timeout']); - $simplePie->set_curl_options($system_conf->curl_options); + + $feed_timeout = empty($attributes['timeout']) ? 0 : intval($attributes['timeout']); + $simplePie->set_timeout($feed_timeout > 0 ? $feed_timeout : $limits['timeout']); + + $curl_options = $system_conf->curl_options; + if (isset($attributes['ssl_verify'])) { + $curl_options[CURLOPT_SSL_VERIFYHOST] = $attributes['ssl_verify'] ? 2 : 0; + $curl_options[CURLOPT_SSL_VERIFYPEER] = $attributes['ssl_verify'] ? true : false; + } + $simplePie->set_curl_options($curl_options); + $simplePie->strip_htmltags(array( 'base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', -- cgit v1.2.3