Move model proxy to handlers

This commit is contained in:
Frederic Guillot 2016-08-18 22:41:39 -04:00
parent 46bc8cfd71
commit 2b71bbf126
No known key found for this signature in database
GPG Key ID: 92D77191BA7FBC99
6 changed files with 9 additions and 10 deletions

View File

@ -66,6 +66,6 @@ Router\get_action('more', function () {
// Image proxy (avoid SSL mixed content warnings) // Image proxy (avoid SSL mixed content warnings)
Router\get_action('proxy', function () { Router\get_action('proxy', function () {
Model\Proxy\download(rawurldecode(Request\param('url'))); Handler\Proxy\download(rawurldecode(Request\param('url')));
exit; exit;
}); });

View File

@ -80,10 +80,10 @@ Router\get_action('show', function () {
$image_proxy = (bool) Model\Config\get('image_proxy'); $image_proxy = (bool) Model\Config\get('image_proxy');
// add the image proxy if requested and required // add the image proxy if requested and required
$item['content'] = Model\Proxy\rewrite_html($item['content'], $item['url'], $image_proxy, $feed['cloak_referrer']); $item['content'] = Handler\Proxy\rewrite_html($item['content'], $item['url'], $image_proxy, $feed['cloak_referrer']);
if ($image_proxy && strpos($item['enclosure_type'], 'image') === 0) { if ($image_proxy && strpos($item['enclosure_type'], 'image') === 0) {
$item['enclosure'] = Model\Proxy\rewrite_link($item['enclosure']); $item['enclosure'] = Handler\Proxy\rewrite_link($item['enclosure']);
} }
Response\html(Template\layout('show_item', array( Response\html(Template\layout('show_item', array(
@ -133,7 +133,7 @@ Router\post_action('download-item', function () {
$feed = Model\Feed\get($item['feed_id']); $feed = Model\Feed\get($item['feed_id']);
$download = Model\Item\download_contents($id); $download = Model\Item\download_contents($id);
$download['content'] = Model\Proxy\rewrite_html($download['content'], $item['url'], Model\Config\get('image_proxy'), $feed['cloak_referrer']); $download['content'] = Handler\Proxy\rewrite_html($download['content'], $item['url'], Model\Config\get('image_proxy'), $feed['cloak_referrer']);
Response\json($download); Response\json($download);
}); });

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Model\Proxy; namespace Handler\Proxy;
use Helper; use Helper;
use Model\Config; use Model\Config;
@ -59,8 +59,7 @@ function download($url)
$client->setUserAgent(Config\HTTP_USER_AGENT); $client->setUserAgent(Config\HTTP_USER_AGENT);
$client->enablePassthroughMode(); $client->enablePassthroughMode();
$client->execute($url); $client->execute($url);
} catch (ClientException $e) { } catch (ClientException $e) {}
}
Config\write_debug(); Config\write_debug();
} }

View File

@ -39,6 +39,7 @@
"app/core/session.php", "app/core/session.php",
"app/core/template.php", "app/core/template.php",
"app/handlers/scraper.php", "app/handlers/scraper.php",
"app/handlers/proxy.php",
"app/models/config.php", "app/models/config.php",
"app/models/service.php", "app/models/service.php",
"app/models/search.php", "app/models/search.php",
@ -48,7 +49,6 @@
"app/models/item_feed.php", "app/models/item_feed.php",
"app/models/item_group.php", "app/models/item_group.php",
"app/models/bookmark.php", "app/models/bookmark.php",
"app/models/proxy.php",
"app/models/auto_update.php", "app/models/auto_update.php",
"app/models/database.php", "app/models/database.php",
"app/models/remember_me.php", "app/models/remember_me.php",

View File

@ -20,6 +20,7 @@ return array(
'98faa6699f100c5ddb2013d85f9dfabb' => $baseDir . '/app/core/session.php', '98faa6699f100c5ddb2013d85f9dfabb' => $baseDir . '/app/core/session.php',
'93228d441890e5962b0566344884332c' => $baseDir . '/app/core/template.php', '93228d441890e5962b0566344884332c' => $baseDir . '/app/core/template.php',
'9de087554be89ca71a2ed558a4e35fde' => $baseDir . '/app/handlers/scraper.php', '9de087554be89ca71a2ed558a4e35fde' => $baseDir . '/app/handlers/scraper.php',
'081a26ac825aa2a7e4cb00c18e0510d5' => $baseDir . '/app/handlers/proxy.php',
'bc98222aedc910930f5b76b8c84f334e' => $baseDir . '/app/models/config.php', 'bc98222aedc910930f5b76b8c84f334e' => $baseDir . '/app/models/config.php',
'c3080c7edf4a590ce36fc4f3561968dc' => $baseDir . '/app/models/service.php', 'c3080c7edf4a590ce36fc4f3561968dc' => $baseDir . '/app/models/service.php',
'b59348c9973f21f2c58eb493d9fea5be' => $baseDir . '/app/models/search.php', 'b59348c9973f21f2c58eb493d9fea5be' => $baseDir . '/app/models/search.php',
@ -29,7 +30,6 @@ return array(
'c0f7d31e45ab3b885f3f3567be6b8cda' => $baseDir . '/app/models/item_feed.php', 'c0f7d31e45ab3b885f3f3567be6b8cda' => $baseDir . '/app/models/item_feed.php',
'c9e2906d32a129f63c98d210037c227b' => $baseDir . '/app/models/item_group.php', 'c9e2906d32a129f63c98d210037c227b' => $baseDir . '/app/models/item_group.php',
'546998ee103e300ad614144f30a1de8e' => $baseDir . '/app/models/bookmark.php', '546998ee103e300ad614144f30a1de8e' => $baseDir . '/app/models/bookmark.php',
'0bdc342df97b8a477df96dbb288b21bf' => $baseDir . '/app/models/proxy.php',
'd06207bd4580f7e9250cf39d0d648fc5' => $baseDir . '/app/models/auto_update.php', 'd06207bd4580f7e9250cf39d0d648fc5' => $baseDir . '/app/models/auto_update.php',
'6a19d5803b084354df8269801d4e98e4' => $baseDir . '/app/models/database.php', '6a19d5803b084354df8269801d4e98e4' => $baseDir . '/app/models/database.php',
'ee585b658e324609d721bc6f959e85c8' => $baseDir . '/app/models/remember_me.php', 'ee585b658e324609d721bc6f959e85c8' => $baseDir . '/app/models/remember_me.php',

View File

@ -21,6 +21,7 @@ class ComposerStaticInitfd7e8d436e1dc450edc3153ac8bc31b4
'98faa6699f100c5ddb2013d85f9dfabb' => __DIR__ . '/../..' . '/app/core/session.php', '98faa6699f100c5ddb2013d85f9dfabb' => __DIR__ . '/../..' . '/app/core/session.php',
'93228d441890e5962b0566344884332c' => __DIR__ . '/../..' . '/app/core/template.php', '93228d441890e5962b0566344884332c' => __DIR__ . '/../..' . '/app/core/template.php',
'9de087554be89ca71a2ed558a4e35fde' => __DIR__ . '/../..' . '/app/handlers/scraper.php', '9de087554be89ca71a2ed558a4e35fde' => __DIR__ . '/../..' . '/app/handlers/scraper.php',
'081a26ac825aa2a7e4cb00c18e0510d5' => __DIR__ . '/../..' . '/app/handlers/proxy.php',
'bc98222aedc910930f5b76b8c84f334e' => __DIR__ . '/../..' . '/app/models/config.php', 'bc98222aedc910930f5b76b8c84f334e' => __DIR__ . '/../..' . '/app/models/config.php',
'c3080c7edf4a590ce36fc4f3561968dc' => __DIR__ . '/../..' . '/app/models/service.php', 'c3080c7edf4a590ce36fc4f3561968dc' => __DIR__ . '/../..' . '/app/models/service.php',
'b59348c9973f21f2c58eb493d9fea5be' => __DIR__ . '/../..' . '/app/models/search.php', 'b59348c9973f21f2c58eb493d9fea5be' => __DIR__ . '/../..' . '/app/models/search.php',
@ -30,7 +31,6 @@ class ComposerStaticInitfd7e8d436e1dc450edc3153ac8bc31b4
'c0f7d31e45ab3b885f3f3567be6b8cda' => __DIR__ . '/../..' . '/app/models/item_feed.php', 'c0f7d31e45ab3b885f3f3567be6b8cda' => __DIR__ . '/../..' . '/app/models/item_feed.php',
'c9e2906d32a129f63c98d210037c227b' => __DIR__ . '/../..' . '/app/models/item_group.php', 'c9e2906d32a129f63c98d210037c227b' => __DIR__ . '/../..' . '/app/models/item_group.php',
'546998ee103e300ad614144f30a1de8e' => __DIR__ . '/../..' . '/app/models/bookmark.php', '546998ee103e300ad614144f30a1de8e' => __DIR__ . '/../..' . '/app/models/bookmark.php',
'0bdc342df97b8a477df96dbb288b21bf' => __DIR__ . '/../..' . '/app/models/proxy.php',
'd06207bd4580f7e9250cf39d0d648fc5' => __DIR__ . '/../..' . '/app/models/auto_update.php', 'd06207bd4580f7e9250cf39d0d648fc5' => __DIR__ . '/../..' . '/app/models/auto_update.php',
'6a19d5803b084354df8269801d4e98e4' => __DIR__ . '/../..' . '/app/models/database.php', '6a19d5803b084354df8269801d4e98e4' => __DIR__ . '/../..' . '/app/models/database.php',
'ee585b658e324609d721bc6f959e85c8' => __DIR__ . '/../..' . '/app/models/remember_me.php', 'ee585b658e324609d721bc6f959e85c8' => __DIR__ . '/../..' . '/app/models/remember_me.php',