summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-02-23 12:07:46 +0400
committerAndrew Dolgov <[email protected]>2013-02-23 12:07:46 +0400
commite02555c1b8efad4fdc918e8245624e0b641ac6df (patch)
treefc30ca23ff7b1b82359cd7bb03b3a1fc808ceac4 /plugins
parent389859b5d459f3b6ce3c09755b2d15069a77334a (diff)
add af_* plugin workaround for already processed article
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_buttersafe/init.php38
-rw-r--r--plugins/af_explosm/init.php38
-rw-r--r--plugins/af_gocomics/init.php39
-rw-r--r--plugins/af_pennyarcade/init.php38
-rw-r--r--plugins/af_unburn/init.php58
5 files changed, 112 insertions, 99 deletions
diff --git a/plugins/af_buttersafe/init.php b/plugins/af_buttersafe/init.php
index 0715be3aa..12833540b 100644
--- a/plugins/af_buttersafe/init.php
+++ b/plugins/af_buttersafe/init.php
@@ -20,35 +20,37 @@ class Af_Buttersafe extends Plugin {
function hook_article_filter($article) {
$owner_uid = $article["owner_uid"];
- if (strpos($article["guid"], "buttersafe.com") !== FALSE &&
- strpos($article["plugin_data"], "buttersafe,$owner_uid:") === FALSE) {
+ if (strpos($article["guid"], "buttersafe.com") !== FALSE) {
+ if (strpos($article["plugin_data"], "buttersafe,$owner_uid:") === FALSE) {
- $doc = new DOMDocument();
- @$doc->loadHTML(fetch_file_contents($article["link"]));
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
- $basenode = false;
+ $basenode = false;
- if ($doc) {
- $xpath = new DOMXPath($doc);
- $entries = $xpath->query('(//img[@src])');
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query('(//img[@src])');
- $matches = array();
+ $matches = array();
- foreach ($entries as $entry) {
+ foreach ($entries as $entry) {
- if (preg_match("/(http:\/\/buttersafe.com\/comics\/\d{4}.*)/i", $entry->getAttribute("src"), $matches)) {
+ if (preg_match("/(http:\/\/buttersafe.com\/comics\/\d{4}.*)/i", $entry->getAttribute("src"), $matches)) {
- $basenode = $entry;
- break;
+ $basenode = $entry;
+ break;
+ }
}
- }
- if ($basenode) {
- $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
+ $article["plugin_data"] = "buttersafe,$owner_uid:" . $article["plugin_data"];
+ }
}
+ } else if (isset($article["stored"]["content"])) {
+ $article["content"] = $article["stored"]["content"];
}
-
- $article["plugin_data"] = "buttersafe,$owner_uid:" . $article["plugin_data"];
}
return $article;
diff --git a/plugins/af_explosm/init.php b/plugins/af_explosm/init.php
index b848bb0fb..701eafeeb 100644
--- a/plugins/af_explosm/init.php
+++ b/plugins/af_explosm/init.php
@@ -20,35 +20,37 @@ class Af_Explosm extends Plugin {
function hook_article_filter($article) {
$owner_uid = $article["owner_uid"];
- if (strpos($article["link"], "explosm.net/comics") !== FALSE &&
- strpos($article["plugin_data"], "explosm,$owner_uid:") === FALSE) {
+ if (strpos($article["link"], "explosm.net/comics") !== FALSE) {
+ if (strpos($article["plugin_data"], "explosm,$owner_uid:") === FALSE) {
- $doc = new DOMDocument();
- @$doc->loadHTML(fetch_file_contents($article["link"]));
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
- $basenode = false;
+ $basenode = false;
- if ($doc) {
- $xpath = new DOMXPath($doc);
- $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
- $matches = array();
+ $matches = array();
- foreach ($entries as $entry) {
+ foreach ($entries as $entry) {
- if (preg_match("/(http:\/\/.*\/db\/files\/Comics\/.*)/i", $entry->getAttribute("src"), $matches)) {
+ if (preg_match("/(http:\/\/.*\/db\/files\/Comics\/.*)/i", $entry->getAttribute("src"), $matches)) {
- $basenode = $entry;
- break;
+ $basenode = $entry;
+ break;
+ }
}
- }
- if ($basenode) {
- $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
+ $article["plugin_data"] = "explosm,$owner_uid:" . $article["plugin_data"];
+ }
}
+ } else if (isset($article["stored"]["content"])) {
+ $article["content"] = $article["stored"]["content"];
}
-
- $article["plugin_data"] = "explosm,$owner_uid:" . $article["plugin_data"];
}
return $article;
diff --git a/plugins/af_gocomics/init.php b/plugins/af_gocomics/init.php
index 829dda999..da5242595 100644
--- a/plugins/af_gocomics/init.php
+++ b/plugins/af_gocomics/init.php
@@ -20,34 +20,37 @@ class Af_GoComics extends Plugin {
function hook_article_filter($article) {
$owner_uid = $article["owner_uid"];
- if (strpos($article["guid"], "gocomics.com") !== FALSE && strpos($article["plugin_data"], "gocomics,$owner_uid:") === FALSE) {
- $doc = new DOMDocument();
- @$doc->loadHTML(fetch_file_contents($article["link"]));
+ if (strpos($article["guid"], "gocomics.com") !== FALSE) {
+ if (strpos($article["plugin_data"], "gocomics,$owner_uid:") === FALSE) {
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
- $basenode = false;
+ $basenode = false;
- if ($doc) {
- $xpath = new DOMXPath($doc);
- $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
- $matches = array();
+ $matches = array();
- foreach ($entries as $entry) {
+ foreach ($entries as $entry) {
- if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
+ if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
- $entry->setAttribute("src", $matches[0]);
- $basenode = $entry;
- break;
+ $entry->setAttribute("src", $matches[0]);
+ $basenode = $entry;
+ break;
+ }
}
- }
- if ($basenode) {
- $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
+ $article["plugin_data"] = "gocomics,$owner_uid:" . $article["plugin_data"];
+ }
}
+ } else if (isset($article["stored"]["content"])) {
+ $article["content"] = $article["stored"]["content"];
}
-
- $article["plugin_data"] = "gocomics,$owner_uid:" . $article["plugin_data"];
}
return $article;
diff --git a/plugins/af_pennyarcade/init.php b/plugins/af_pennyarcade/init.php
index 5ac629914..bf07b94a7 100644
--- a/plugins/af_pennyarcade/init.php
+++ b/plugins/af_pennyarcade/init.php
@@ -20,35 +20,37 @@ class Af_PennyArcade extends Plugin {
function hook_article_filter($article) {
$owner_uid = $article["owner_uid"];
- if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE &&
- strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
+ if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
+ if (strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
- $doc = new DOMDocument();
- @$doc->loadHTML(fetch_file_contents($article["link"]));
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
- $basenode = false;
+ $basenode = false;
- if ($doc) {
- $xpath = new DOMXPath($doc);
- $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
- $matches = array();
+ $matches = array();
- foreach ($entries as $entry) {
+ foreach ($entries as $entry) {
- if (preg_match("/(http:\/\/art.penny-arcade.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
+ if (preg_match("/(http:\/\/art.penny-arcade.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
- $basenode = $entry;
- break;
+ $basenode = $entry;
+ break;
+ }
}
- }
- if ($basenode) {
- $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
+ $article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"];
+ }
}
+ } else if (isset($article["stored"]["content"])) {
+ $article["content"] = $article["stored"]["content"];
}
-
- $article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"];
}
return $article;
diff --git a/plugins/af_unburn/init.php b/plugins/af_unburn/init.php
index 5adbda391..b68796fb4 100644
--- a/plugins/af_unburn/init.php
+++ b/plugins/af_unburn/init.php
@@ -25,46 +25,50 @@ class Af_Unburn extends Plugin {
if ((strpos($article["link"], "feedproxy.google.com") !== FALSE ||
strpos($article["link"], "/~r/") !== FALSE ||
- strpos($article["link"], "feedsportal.com") !== FALSE) &&
- strpos($article["plugin_data"], "unburn,$owner_uid:") === FALSE) {
+ strpos($article["link"], "feedsportal.com") !== FALSE)) {
- $ch = curl_init($article["link"]);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT);
+ if (strpos($article["plugin_data"], "unburn,$owner_uid:") === FALSE) {
- $contents = @curl_exec($ch);
+ $ch = curl_init($article["link"]);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HEADER, true);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT);
- $real_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
+ $contents = @curl_exec($ch);
- curl_close($ch);
+ $real_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
- if ($real_url) {
- /* remove the rest of it */
+ curl_close($ch);
- $query = parse_url($real_url, PHP_URL_QUERY);
+ if ($real_url) {
+ /* remove the rest of it */
- if ($query && strpos($query, "utm_source") !== FALSE) {
- $args = array();
- parse_str($query, $args);
+ $query = parse_url($real_url, PHP_URL_QUERY);
- foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) {
- if (isset($args[$param])) unset($args[$param]);
- }
+ if ($query && strpos($query, "utm_source") !== FALSE) {
+ $args = array();
+ parse_str($query, $args);
+
+ foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) {
+ if (isset($args[$param])) unset($args[$param]);
+ }
- $new_query = http_build_query($args);
+ $new_query = http_build_query($args);
- if ($new_query != $query) {
- $real_url = str_replace("?$query", "?$new_query", $real_url);
+ if ($new_query != $query) {
+ $real_url = str_replace("?$query", "?$new_query", $real_url);
+ }
}
- }
- $real_url = preg_replace("/\?$/", "", $real_url);
+ $real_url = preg_replace("/\?$/", "", $real_url);
- $article["plugin_data"] = "unburn,$owner_uid:" . $article["plugin_data"];
- $article["link"] = $real_url;
+ $article["plugin_data"] = "unburn,$owner_uid:" . $article["plugin_data"];
+ $article["link"] = $real_url;
+ }
+ } else if (isset($article["stored"]["link"])) {
+ $article["link"] = $article["stored"]["link"];
}
}