Add image proxy to avoid https mixed content warnings
This commit is contained in:
parent
a648b06a68
commit
7d4d4e0193
@ -45,6 +45,7 @@ Features
|
||||
- Themes
|
||||
- Auto-update from the user interface
|
||||
- Multiple databases (each user has his own database)
|
||||
- Image proxy to avoid mixed content warnings with HTTPS
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
@ -38,10 +38,10 @@ PicoDb\Database::bootstrap('db', function() {
|
||||
|
||||
$db = new PicoDb\Database(array(
|
||||
'driver' => 'sqlite',
|
||||
'filename' => \Model\Database\get_path(),
|
||||
'filename' => Model\Database\get_path(),
|
||||
));
|
||||
|
||||
if ($db->schema()->check(Model\Config\DB_VERSION)) {
|
||||
if ($db->schema()->check(Schema\VERSION)) {
|
||||
return $db;
|
||||
}
|
||||
else {
|
||||
|
@ -17,6 +17,7 @@
|
||||
"models/user.php",
|
||||
"models/feed.php",
|
||||
"models/item.php",
|
||||
"models/proxy.php",
|
||||
"models/schema.php",
|
||||
"models/auto_update.php",
|
||||
"models/database.php",
|
||||
|
@ -78,3 +78,15 @@ Router\get_action('select-db', function() {
|
||||
|
||||
Response\redirect('?action=login');
|
||||
});
|
||||
|
||||
// Image proxy (avoid SSL mixed content warnings)
|
||||
Router\get_action('proxy', function() {
|
||||
list($content, $type) = Model\Proxy\download(urldecode(Request\param('url')));
|
||||
|
||||
if (empty($content)) {
|
||||
Response\text('Not Found', 404);
|
||||
}
|
||||
|
||||
Response\content_type($type);
|
||||
echo $content;
|
||||
});
|
||||
|
@ -134,7 +134,7 @@ Router\get_action('config', function() {
|
||||
// Update preferences
|
||||
Router\post_action('config', function() {
|
||||
|
||||
$values = Request\values() + array('nocontent' => 0);
|
||||
$values = Request\values() + array('nocontent' => 0, 'image_proxy' => 0);
|
||||
Model\Config\check_csrf_values($values);
|
||||
list($valid, $errors) = Model\Config\validate_modification($values);
|
||||
|
||||
|
@ -71,7 +71,8 @@ Router\get_action('show', function() {
|
||||
'feed' => $feed,
|
||||
'item_nav' => isset($nav) ? $nav : null,
|
||||
'menu' => $menu,
|
||||
'title' => $item['title']
|
||||
'title' => $item['title'],
|
||||
'image_proxy_enabled' => (bool) Model\Config\get('image_proxy'),
|
||||
)));
|
||||
});
|
||||
|
||||
|
@ -227,4 +227,9 @@ return array(
|
||||
// 'Instapaper' => '',
|
||||
// 'Pinboard' => '',
|
||||
// 'Send bookmarks to Instapaper' => '',
|
||||
// 'Authentication' => '',
|
||||
// 'Reading' => '',
|
||||
// 'Application' => '',
|
||||
// 'Enable image proxy' => '',
|
||||
// 'Avoid mixed content warnings with HTTPS' => '',
|
||||
);
|
||||
|
@ -227,4 +227,9 @@ return array(
|
||||
// 'Instapaper' => '',
|
||||
// 'Pinboard' => '',
|
||||
// 'Send bookmarks to Instapaper' => '',
|
||||
// 'Authentication' => '',
|
||||
// 'Reading' => '',
|
||||
// 'Application' => '',
|
||||
// 'Enable image proxy' => '',
|
||||
// 'Avoid mixed content warnings with HTTPS' => '',
|
||||
);
|
||||
|
@ -227,4 +227,9 @@ return array(
|
||||
// 'Instapaper' => '',
|
||||
// 'Pinboard' => '',
|
||||
// 'Send bookmarks to Instapaper' => '',
|
||||
// 'Authentication' => '',
|
||||
// 'Reading' => '',
|
||||
// 'Application' => '',
|
||||
// 'Enable image proxy' => '',
|
||||
// 'Avoid mixed content warnings with HTTPS' => '',
|
||||
);
|
||||
|
@ -227,4 +227,9 @@ return array(
|
||||
'Instapaper' => 'Instapaper',
|
||||
'Pinboard' => 'Pinboard',
|
||||
'Send bookmarks to Instapaper' => 'Envoyer les favoris vers Instapaper',
|
||||
'Authentication' => 'Authentification',
|
||||
'Reading' => 'Lecture',
|
||||
'Application' => 'Application',
|
||||
'Enable image proxy' => 'Activer le proxy pour les images',
|
||||
'Avoid mixed content warnings with HTTPS' => 'Évite les alertes du navigateur web en HTTPS',
|
||||
);
|
||||
|
@ -227,4 +227,9 @@ return array(
|
||||
// 'Instapaper' => '',
|
||||
// 'Pinboard' => '',
|
||||
// 'Send bookmarks to Instapaper' => '',
|
||||
// 'Authentication' => '',
|
||||
// 'Reading' => '',
|
||||
// 'Application' => '',
|
||||
// 'Enable image proxy' => '',
|
||||
// 'Avoid mixed content warnings with HTTPS' => '',
|
||||
);
|
||||
|
@ -227,4 +227,9 @@ return array(
|
||||
// 'Instapaper' => '',
|
||||
// 'Pinboard' => '',
|
||||
// 'Send bookmarks to Instapaper' => '',
|
||||
// 'Authentication' => '',
|
||||
// 'Reading' => '',
|
||||
// 'Application' => '',
|
||||
// 'Enable image proxy' => '',
|
||||
// 'Avoid mixed content warnings with HTTPS' => '',
|
||||
);
|
||||
|
@ -227,4 +227,9 @@ return array(
|
||||
// 'Instapaper' => '',
|
||||
// 'Pinboard' => '',
|
||||
// 'Send bookmarks to Instapaper' => '',
|
||||
// 'Authentication' => '',
|
||||
// 'Reading' => '',
|
||||
// 'Application' => '',
|
||||
// 'Enable image proxy' => '',
|
||||
// 'Avoid mixed content warnings with HTTPS' => '',
|
||||
);
|
||||
|
@ -9,7 +9,6 @@ use PicoDb\Database;
|
||||
use PicoFeed\Config\Config as ReaderConfig;
|
||||
use PicoFeed\Logging\Logger;
|
||||
|
||||
const DB_VERSION = 32;
|
||||
const HTTP_USER_AGENT = 'Miniflux (http://miniflux.net)';
|
||||
|
||||
// Get PicoFeed config
|
||||
@ -32,6 +31,10 @@ function get_reader_config()
|
||||
// Filter
|
||||
$config->setFilterIframeWhitelist(get_iframe_whitelist());
|
||||
|
||||
if ((bool) get('image_proxy')) {
|
||||
$config->setFilterImageProxyUrl('?action=proxy&url=%s');
|
||||
}
|
||||
|
||||
// Parser
|
||||
$config->setParserHashAlgo('crc32b');
|
||||
|
||||
@ -306,7 +309,8 @@ function get_all()
|
||||
'pinboard_tags',
|
||||
'instapaper_enabled',
|
||||
'instapaper_username',
|
||||
'instapaper_password'
|
||||
'instapaper_password',
|
||||
'image_proxy'
|
||||
)
|
||||
->findOne();
|
||||
}
|
||||
|
@ -557,12 +557,6 @@ function download_content_url($url)
|
||||
$content = $grabber->getFilteredcontent();
|
||||
}
|
||||
|
||||
if (! empty($content)) {
|
||||
$filter = Filter::html($content, $url);
|
||||
$filter->setConfig(Config\get_reader_config());
|
||||
$content = $filter->execute();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
24
models/proxy.php
Normal file
24
models/proxy.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Model\Proxy;
|
||||
|
||||
use Model\Config;
|
||||
use PicoFeed\Client\Client;
|
||||
use PicoFeed\Client\ClientException;
|
||||
|
||||
function download($url)
|
||||
{
|
||||
try {
|
||||
$client = Client::getInstance();
|
||||
$client->setUserAgent(Config\HTTP_USER_AGENT);
|
||||
$client->execute($url);
|
||||
|
||||
return array(
|
||||
$client->getContent(),
|
||||
$client->getContentType(),
|
||||
);
|
||||
}
|
||||
catch (ClientException $e) {
|
||||
return array(false, false);
|
||||
}
|
||||
}
|
@ -5,6 +5,13 @@ namespace Schema;
|
||||
use PDO;
|
||||
use Model\Config;
|
||||
|
||||
const VERSION = 33;
|
||||
|
||||
function version_33($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE config ADD COLUMN image_proxy INTEGER DEFAULT 0');
|
||||
}
|
||||
|
||||
function version_32($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE config ADD COLUMN instapaper_enabled INTEGER DEFAULT 0');
|
||||
|
@ -11,8 +11,9 @@
|
||||
<section>
|
||||
<form method="post" action="?action=config" autocomplete="off">
|
||||
|
||||
<?= Helper\form_hidden('csrf', $values) ?>
|
||||
<h3><?= t('Authentication') ?></h3>
|
||||
|
||||
<?= Helper\form_hidden('csrf', $values) ?>
|
||||
<?= Helper\form_label(t('Username'), 'username') ?>
|
||||
<?= Helper\form_text('username', $values, $errors, array('required')) ?><br/>
|
||||
|
||||
@ -22,12 +23,25 @@
|
||||
<?= Helper\form_label(t('Confirmation'), 'confirmation') ?>
|
||||
<?= Helper\form_password('confirmation', $values, $errors) ?><br/>
|
||||
|
||||
<h3><?= t('Application') ?></h3>
|
||||
<?= Helper\form_label(t('Timezone'), 'timezone') ?>
|
||||
<?= Helper\form_select('timezone', $timezones, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Language'), 'language') ?>
|
||||
<?= Helper\form_select('language', $languages, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Theme'), 'theme') ?>
|
||||
<?= Helper\form_select('theme', $theme_options, $values, $errors) ?><br/>
|
||||
|
||||
<?php if (ENABLE_AUTO_UPDATE): ?>
|
||||
<?= Helper\form_label(t('Auto-Update URL'), 'auto_update_url') ?>
|
||||
<?= Helper\form_text('auto_update_url', $values, $errors, array('required')) ?><br/>
|
||||
<?php endif ?>
|
||||
|
||||
<?= Helper\form_checkbox('image_proxy', t('Enable image proxy'), 1, isset($values['image_proxy']) && $values['image_proxy'] == 1) ?>
|
||||
<div class="form-help"><?= t('Avoid mixed content warnings with HTTPS') ?></div>
|
||||
|
||||
<h3><?= t('Reading') ?></h3>
|
||||
<?= Helper\form_label(t('Remove automatically read items'), 'autoflush') ?>
|
||||
<?= Helper\form_select('autoflush', $autoflush_read_options, $values, $errors) ?><br/>
|
||||
|
||||
@ -46,15 +60,7 @@
|
||||
<?= Helper\form_label(t('When there is nothing to read, redirect me to this page'), 'redirect_nothing_to_read') ?>
|
||||
<?= Helper\form_select('redirect_nothing_to_read', $redirect_nothing_to_read_options, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Theme'), 'theme') ?>
|
||||
<?= Helper\form_select('theme', $theme_options, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_checkbox('nocontent', t('Do not fetch the content of articles'), 1, isset($values['nocontent']) ? $values['nocontent'] : false) ?><br />
|
||||
|
||||
<?php if (ENABLE_AUTO_UPDATE): ?>
|
||||
<?= Helper\form_label(t('Auto-Update URL'), 'auto_update_url') ?>
|
||||
<?= Helper\form_text('auto_update_url', $values, $errors, array('required')) ?><br/>
|
||||
<?php endif ?>
|
||||
<?= Helper\form_checkbox('nocontent', t('Do not fetch the content of articles'), 1, isset($values['nocontent']) && $values['nocontent'] == 1) ?><br />
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
|
@ -85,8 +85,12 @@
|
||||
<source src="<?= $item['enclosure'] ?>" type="<?= $item['enclosure_type'] ?>">
|
||||
</video>
|
||||
<?php elseif (strpos($item['enclosure_type'], 'image') !== false): ?>
|
||||
<?php if ($image_proxy_enabled): ?>
|
||||
<img src="?action=proxy&url=<?= urlencode($item['enclosure']) ?>" alt="enclosure"/>
|
||||
<?php else: ?>
|
||||
<img src="<?= $item['enclosure'] ?>" alt="enclosure"/>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInite2d22b082480fbe8c7c1ceae6d7cbe85::getLoader();
|
||||
return ComposerAutoloaderInit2e47cecea56754de3b457018a8eee985::getLoader();
|
||||
|
1
vendor/composer/autoload_files.php
vendored
1
vendor/composer/autoload_files.php
vendored
@ -12,6 +12,7 @@ return array(
|
||||
$baseDir . '/models/user.php',
|
||||
$baseDir . '/models/feed.php',
|
||||
$baseDir . '/models/item.php',
|
||||
$baseDir . '/models/proxy.php',
|
||||
$baseDir . '/models/schema.php',
|
||||
$baseDir . '/models/auto_update.php',
|
||||
$baseDir . '/models/database.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInite2d22b082480fbe8c7c1ceae6d7cbe85
|
||||
class ComposerAutoloaderInit2e47cecea56754de3b457018a8eee985
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -19,9 +19,9 @@ class ComposerAutoloaderInite2d22b082480fbe8c7c1ceae6d7cbe85
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInite2d22b082480fbe8c7c1ceae6d7cbe85', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit2e47cecea56754de3b457018a8eee985', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite2d22b082480fbe8c7c1ceae6d7cbe85', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit2e47cecea56754de3b457018a8eee985', 'loadClassLoader'));
|
||||
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
@ -42,14 +42,14 @@ class ComposerAutoloaderInite2d22b082480fbe8c7c1ceae6d7cbe85
|
||||
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach ($includeFiles as $file) {
|
||||
composerRequiree2d22b082480fbe8c7c1ceae6d7cbe85($file);
|
||||
composerRequire2e47cecea56754de3b457018a8eee985($file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequiree2d22b082480fbe8c7c1ceae6d7cbe85($file)
|
||||
function composerRequire2e47cecea56754de3b457018a8eee985($file)
|
||||
{
|
||||
require $file;
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -162,18 +162,18 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fguillot/picoFeed.git",
|
||||
"reference": "eefd3f78268627e07ccf31c71cadd4c5ec0955bd"
|
||||
"reference": "b3f2202845be5895ce818f1393cdd28b0aa1b8cb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/eefd3f78268627e07ccf31c71cadd4c5ec0955bd",
|
||||
"reference": "eefd3f78268627e07ccf31c71cadd4c5ec0955bd",
|
||||
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/b3f2202845be5895ce818f1393cdd28b0aa1b8cb",
|
||||
"reference": "b3f2202845be5895ce818f1393cdd28b0aa1b8cb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2014-12-24 18:41:58",
|
||||
"time": "2014-12-24 20:46:58",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -185,7 +185,7 @@ class Grabber
|
||||
*/
|
||||
public function getFilteredContent()
|
||||
{
|
||||
$filter = Filter::html($this->content, $this->url);
|
||||
$filter = Filter::html($this->content, Url::base($this->url));
|
||||
$filter->setConfig($this->config);
|
||||
return $filter->execute();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user