summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorwn_ <[email protected]>2017-09-17 13:56:57 -0500
committerwn_ <[email protected]>2017-09-17 13:56:57 -0500
commitb4b5236ec469bfc4b59d73b202864a6fa0c2c61e (patch)
tree085835bdb14d1bfc666336980e2f9b3b866607e7 /plugins
parent8352d7c6cb88637073b50422a9c4708c48ec4572 (diff)
af_redditimgur: use common header retrieval function
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/af_redditimgur/init.php29
1 files changed, 9 insertions, 20 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index 3a34b5d8c..8074894fd 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -479,8 +479,8 @@ class Af_RedditImgur extends Plugin {
}
}
- private function get_content_type($url, $useragent = SELF_USER_AGENT) {
- $content_type = false;
+ private function get_header($url, $useragent = SELF_USER_AGENT, $header) {
+ $ret = false;
if (function_exists("curl_init") && !defined("NO_CURL")) {
$ch = curl_init($url);
@@ -492,29 +492,18 @@ class Af_RedditImgur extends Plugin {
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
@curl_exec($ch);
- $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
+ $ret = curl_getinfo($ch, $header);
}
- return $content_type;
+ return $ret;
}
- private function get_location($url, $useragent = SELF_USER_AGENT) {
- $location = false;
-
- if (function_exists("curl_init") && !defined("NO_CURL")) {
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_NOBODY, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
- curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
-
- @curl_exec($ch);
- $location = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
- }
+ private function get_content_type($url, $useragent = SELF_USER_AGENT) {
+ return $this->get_header($url, $useragent, CURLINFO_CONTENT_TYPE);
+ }
- return $location;
+ private function get_location($url, $useragent = SELF_USER_AGENT) {
+ return $this->get_header($url, $useragent, CURLINFO_EFFECTIVE_URL);
}
/**