summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-09-22 09:04:33 +0300
committerAndrew Dolgov <[email protected]>2020-09-22 09:04:33 +0300
commit74568df4ff7b7788991636f6fb2ed62012f85c3b (patch)
tree673bcb01157b38e4b38f8f4c8227012e8a750e18 /plugins
parentd04ac399ff284e9747e3fb55e87d05e0a5b8d85f (diff)
remove a lot of stuff from global context (functions.php), add a few helper classes instead
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_comics/filters/af_comics_cad.php2
-rw-r--r--plugins/af_comics/filters/af_comics_comicclass.php2
-rwxr-xr-xplugins/af_comics/filters/af_comics_comicpress.php4
-rw-r--r--plugins/af_comics/filters/af_comics_darklegacy.php2
-rw-r--r--plugins/af_comics/filters/af_comics_dilbert.php2
-rw-r--r--plugins/af_comics/filters/af_comics_explosm.php2
-rw-r--r--plugins/af_comics/filters/af_comics_gocomics.php2
-rw-r--r--plugins/af_comics/filters/af_comics_gocomics_farside.php2
-rw-r--r--plugins/af_comics/filters/af_comics_pa.php4
-rw-r--r--plugins/af_comics/filters/af_comics_pvp.php2
-rw-r--r--plugins/af_comics/filters/af_comics_tfd.php4
-rw-r--r--plugins/af_comics/filters/af_comics_twp.php2
-rw-r--r--plugins/af_comics/filters/af_comics_whomp.php2
-rw-r--r--plugins/af_proxy_http/init.php6
-rwxr-xr-xplugins/af_readability/init.php8
-rwxr-xr-xplugins/af_redditimgur/init.php10
-rwxr-xr-xplugins/cache_starred_images/init.php8
-rw-r--r--plugins/no_iframes/init.php4
18 files changed, 34 insertions, 34 deletions
diff --git a/plugins/af_comics/filters/af_comics_cad.php b/plugins/af_comics/filters/af_comics_cad.php
index cbd9ae3fb..5da82ae3f 100644
--- a/plugins/af_comics/filters/af_comics_cad.php
+++ b/plugins/af_comics/filters/af_comics_cad.php
@@ -13,7 +13,7 @@ class Af_Comics_Cad extends Af_ComicFilter {
$doc = new DOMDocument();
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
diff --git a/plugins/af_comics/filters/af_comics_comicclass.php b/plugins/af_comics/filters/af_comics_comicclass.php
index 07b4be712..ff32375d3 100644
--- a/plugins/af_comics/filters/af_comics_comicclass.php
+++ b/plugins/af_comics/filters/af_comics_comicclass.php
@@ -11,7 +11,7 @@ class Af_Comics_ComicClass extends Af_ComicFilter {
// lol at people who block clients by user agent
// oh noes my ad revenue Q_Q
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
diff --git a/plugins/af_comics/filters/af_comics_comicpress.php b/plugins/af_comics/filters/af_comics_comicpress.php
index 6a2036645..29b064612 100755
--- a/plugins/af_comics/filters/af_comics_comicpress.php
+++ b/plugins/af_comics/filters/af_comics_comicpress.php
@@ -18,7 +18,7 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
// lol at people who block clients by user agent
// oh noes my ad revenue Q_Q
- $res = fetch_file_contents(["url" => $article["link"],
+ $res = UrlHelper::fetch(["url" => $article["link"],
"useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
$doc = new DOMDocument();
@@ -37,7 +37,7 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
if ($webtoon_link) {
- $res = fetch_file_contents(["url" => $webtoon_link->getAttribute("href"),
+ $res = UrlHelper::fetch(["url" => $webtoon_link->getAttribute("href"),
"useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
if (@$doc->loadHTML($res)) {
diff --git a/plugins/af_comics/filters/af_comics_darklegacy.php b/plugins/af_comics/filters/af_comics_darklegacy.php
index ee9ce2d77..978545431 100644
--- a/plugins/af_comics/filters/af_comics_darklegacy.php
+++ b/plugins/af_comics/filters/af_comics_darklegacy.php
@@ -9,7 +9,7 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter {
if (strpos($article["guid"], "darklegacycomics.com") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
diff --git a/plugins/af_comics/filters/af_comics_dilbert.php b/plugins/af_comics/filters/af_comics_dilbert.php
index 6b194960c..31a72d88d 100644
--- a/plugins/af_comics/filters/af_comics_dilbert.php
+++ b/plugins/af_comics/filters/af_comics_dilbert.php
@@ -10,7 +10,7 @@ class Af_Comics_Dilbert extends Af_ComicFilter {
if (strpos($article["link"], "dilbert.com") !== false ||
strpos($article["link"], "/DilbertDailyStrip") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
diff --git a/plugins/af_comics/filters/af_comics_explosm.php b/plugins/af_comics/filters/af_comics_explosm.php
index dd1c8e723..bfe38e53b 100644
--- a/plugins/af_comics/filters/af_comics_explosm.php
+++ b/plugins/af_comics/filters/af_comics_explosm.php
@@ -11,7 +11,7 @@ class Af_Comics_Explosm extends Af_ComicFilter {
$doc = new DOMDocument();
- if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('(//img[@id="main-comic"])')->item(0);
diff --git a/plugins/af_comics/filters/af_comics_gocomics.php b/plugins/af_comics/filters/af_comics_gocomics.php
index 2cb49b9bc..949b7a235 100644
--- a/plugins/af_comics/filters/af_comics_gocomics.php
+++ b/plugins/af_comics/filters/af_comics_gocomics.php
@@ -29,7 +29,7 @@ class Af_Comics_Gocomics extends Af_ComicFilter {
$article_link = $site_url . date('/Y/m/d');
- $body = fetch_file_contents(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false));
+ $body = UrlHelper::fetch(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false));
$feed_title = htmlspecialchars($comic[1]);
$site_url = htmlspecialchars($site_url);
diff --git a/plugins/af_comics/filters/af_comics_gocomics_farside.php b/plugins/af_comics/filters/af_comics_gocomics_farside.php
index 71c5e0059..9663da8f9 100644
--- a/plugins/af_comics/filters/af_comics_gocomics_farside.php
+++ b/plugins/af_comics/filters/af_comics_gocomics_farside.php
@@ -37,7 +37,7 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter {
$tpl->setVariable('FEED_URL', htmlspecialchars($url), true);
$tpl->setVariable('SELF_URL', htmlspecialchars($url), true);
- $body = fetch_file_contents(['url' => $article_link, 'type' => 'text/html', 'followlocation' => false]);
+ $body = UrlHelper::fetch(['url' => $article_link, 'type' => 'text/html', 'followlocation' => false]);
if ($body) {
$doc = new DOMDocument();
diff --git a/plugins/af_comics/filters/af_comics_pa.php b/plugins/af_comics/filters/af_comics_pa.php
index c70a39f6e..380e84596 100644
--- a/plugins/af_comics/filters/af_comics_pa.php
+++ b/plugins/af_comics/filters/af_comics_pa.php
@@ -10,7 +10,7 @@ class Af_Comics_Pa extends Af_ComicFilter {
$doc = new DOMDocument();
- if ($doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if ($doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0);
@@ -25,7 +25,7 @@ class Af_Comics_Pa extends Af_ComicFilter {
if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) {
$doc = new DOMDocument();
- if ($doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if ($doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXPath($doc);
$entries = $xpath->query('(//div[@class="post"])');
diff --git a/plugins/af_comics/filters/af_comics_pvp.php b/plugins/af_comics/filters/af_comics_pvp.php
index e3a92de6b..105d3f490 100644
--- a/plugins/af_comics/filters/af_comics_pvp.php
+++ b/plugins/af_comics/filters/af_comics_pvp.php
@@ -8,7 +8,7 @@ class Af_Comics_Pvp extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["guid"], "pvponline.com") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
diff --git a/plugins/af_comics/filters/af_comics_tfd.php b/plugins/af_comics/filters/af_comics_tfd.php
index 38ac054c0..e0216705c 100644
--- a/plugins/af_comics/filters/af_comics_tfd.php
+++ b/plugins/af_comics/filters/af_comics_tfd.php
@@ -8,7 +8,7 @@ class Af_Comics_Tfd extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["link"], "toothpastefordinner.com") !== false ||
strpos($article["link"], "marriedtothesea.com") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
@@ -16,7 +16,7 @@ class Af_Comics_Tfd extends Af_ComicFilter {
$doc = new DOMDocument();
- if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//img[contains(@src, ".gif")]')->item(0);
diff --git a/plugins/af_comics/filters/af_comics_twp.php b/plugins/af_comics/filters/af_comics_twp.php
index 84e5ce428..38a8ca32b 100644
--- a/plugins/af_comics/filters/af_comics_twp.php
+++ b/plugins/af_comics/filters/af_comics_twp.php
@@ -11,7 +11,7 @@ class Af_Comics_Twp extends Af_ComicFilter {
$doc = new DOMDocument();
- if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXpath($doc);
$basenode = $xpath->query("//td/center/img")->item(0);
diff --git a/plugins/af_comics/filters/af_comics_whomp.php b/plugins/af_comics/filters/af_comics_whomp.php
index ddd80a0ee..021a2952a 100644
--- a/plugins/af_comics/filters/af_comics_whomp.php
+++ b/plugins/af_comics/filters/af_comics_whomp.php
@@ -8,7 +8,7 @@ class Af_Comics_Whomp extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["guid"], "whompcomic.com") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php
index 7cb9355f3..2d9ae59b5 100644
--- a/plugins/af_proxy_http/init.php
+++ b/plugins/af_proxy_http/init.php
@@ -48,7 +48,7 @@ class Af_Proxy_Http extends Plugin {
}
public function imgproxy() {
- $url = validate_url(clean($_REQUEST["url"]));
+ $url = UrlHelper::validate(clean($_REQUEST["url"]));
// called without user context, let's just redirect to original URL
if (!$_SESSION["uid"] || $_REQUEST['af_proxy_http_token'] != $_SESSION['af_proxy_http_token']) {
@@ -62,7 +62,7 @@ class Af_Proxy_Http extends Plugin {
header("Location: " . $this->cache->getUrl($local_filename));
return;
} else {
- $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
+ $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
if ($data) {
if ($this->cache->put($local_filename, $data)) {
@@ -125,7 +125,7 @@ class Af_Proxy_Http extends Plugin {
foreach (explode(" " , $this->ssl_known_whitelist) as $host) {
if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) {
$parts['scheme'] = 'https';
- $url = build_url($parts);
+ $url = UrlHelper::build_url($parts);
if ($all_remote && $is_remote) {
break;
} else {
diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php
index ce8f8d2a4..111462c4b 100755
--- a/plugins/af_readability/init.php
+++ b/plugins/af_readability/init.php
@@ -176,7 +176,7 @@ class Af_Readability extends Plugin {
global $fetch_effective_url;
- $tmp = fetch_file_contents([
+ $tmp = UrlHelper::fetch([
"url" => $url,
"http_accept" => "text/*",
"type" => "text/html"]);
@@ -235,7 +235,7 @@ class Af_Readability extends Plugin {
$extracted_content = $this->extract_content($article["link"]);
# let's see if there's anything of value in there
- $content_test = trim(strip_tags(sanitize($extracted_content)));
+ $content_test = trim(strip_tags(Sanitizer::sanitize($extracted_content)));
if ($content_test) {
$article["content"] = $extracted_content;
@@ -264,7 +264,7 @@ class Af_Readability extends Plugin {
$extracted_content = $this->extract_content($link);
# let's see if there's anything of value in there
- $content_test = trim(strip_tags(sanitize($extracted_content)));
+ $content_test = trim(strip_tags(Sanitizer::sanitize($extracted_content)));
if ($content_test) {
return $extracted_content;
@@ -303,7 +303,7 @@ class Af_Readability extends Plugin {
$ret = [];
if ($row = $sth->fetch()) {
- $ret["content"] = sanitize($this->extract_content($row["link"]));
+ $ret["content"] = Sanitizer::sanitize($this->extract_content($row["link"]));
}
print json_encode($ret);
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index b332ec588..2c213c10b 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -103,7 +103,7 @@ class Af_RedditImgur extends Plugin {
if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE);
- $oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
+ $oembed_result = UrlHelper::fetch("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
if ($oembed_result) {
$oembed_result = json_decode($oembed_result, true);
@@ -165,7 +165,7 @@ class Af_RedditImgur extends Plugin {
$source_stream = false;
if ($source_article_url) {
- $j = json_decode(fetch_file_contents($source_article_url.".json"), true);
+ $j = json_decode(UrlHelper::fetch($source_article_url.".json"), true);
if ($j) {
foreach ($j as $listing) {
@@ -195,7 +195,7 @@ class Af_RedditImgur extends Plugin {
Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE);
- $tmp = fetch_file_contents($entry->getAttribute("href"));
+ $tmp = UrlHelper::fetch($entry->getAttribute("href"));
if ($tmp) {
$tmpdoc = new DOMDocument();
@@ -285,7 +285,7 @@ class Af_RedditImgur extends Plugin {
Debug::log("handling as imgur page/whatever", Debug::$LOG_VERBOSE);
- $content = fetch_file_contents(["url" => $entry->getAttribute("href"),
+ $content = UrlHelper::fetch(["url" => $entry->getAttribute("href"),
"http_accept" => "text/*"]);
if ($content) {
@@ -331,7 +331,7 @@ class Af_RedditImgur extends Plugin {
if (!$found) {
Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE);
- $content = fetch_file_contents(["url" => $entry->getAttribute("href"),
+ $content = UrlHelper::fetch(["url" => $entry->getAttribute("href"),
"http_accept" => "text/*"]);
if ($content) {
diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php
index ae369f56e..5fe963e32 100755
--- a/plugins/cache_starred_images/init.php
+++ b/plugins/cache_starred_images/init.php
@@ -40,16 +40,16 @@ class Cache_Starred_Images extends Plugin {
Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "...");
- $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title,
+ $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title,
ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data
FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON
(ttrss_user_entries.feed_id = ttrss_feeds.id)
WHERE ref_id = ttrss_entries.id AND
marked = true AND
- site_url != '' AND
+ site_url != '' AND
ttrss_user_entries.owner_uid = ? AND
plugin_data NOT LIKE '%starred_cache_images%'
- ORDER BY ".sql_random_function()." LIMIT 100");
+ ORDER BY ".Db::sql_random_function()." LIMIT 100");
if ($sth->execute([$this->host->get_owner_uid()])) {
@@ -139,7 +139,7 @@ class Cache_Starred_Images extends Plugin {
if (!$this->cache->exists($local_filename)) {
Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE);
- $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
+ $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
if ($data)
return $this->cache->put($local_filename, $data);;
diff --git a/plugins/no_iframes/init.php b/plugins/no_iframes/init.php
index 18cc3ba17..9711eeb24 100644
--- a/plugins/no_iframes/init.php
+++ b/plugins/no_iframes/init.php
@@ -23,7 +23,7 @@ class No_Iframes extends Plugin {
$entries = $xpath->query('//iframe');
foreach ($entries as $entry) {
- if (!iframe_whitelisted($entry))
+ if (!Sanitizer::iframe_whitelisted($entry))
$entry->parentNode->removeChild($entry);
}
@@ -34,4 +34,4 @@ class No_Iframes extends Plugin {
return 2;
}
-} \ No newline at end of file
+}