forked from GithubBackups/tinyib
Use file_get_contents if cURL isn't installed
This commit is contained in:
parent
6a26e32594
commit
ddcacf46b0
12
README.md
12
README.md
@ -28,10 +28,10 @@ Features
|
||||
Installing
|
||||
------------
|
||||
|
||||
1. Verify the following requirements are met:
|
||||
- [PHP](http://php.net) 4 or higher is installed.
|
||||
- [GD Image Processing Library](http://php.net/gd) is installed.
|
||||
- This library is installed by default on most hosts.
|
||||
1. Verify the following are installed:
|
||||
- [PHP 4.3+](http://php.net)
|
||||
- [GD Image Processing Library](http://php.net/gd)
|
||||
- This library is usually installed by default.
|
||||
- If you plan on disabling image uploads to use TinyIB as a text board only, this library is not required.
|
||||
2. CD to the directory you wish to install TinyIB.
|
||||
3. Run the command:
|
||||
@ -112,7 +112,9 @@ If there was a warning about AUTO_INCREMENT not being updated, you'll need to up
|
||||
Support
|
||||
------------
|
||||
|
||||
Contact tslocum@gmail.com
|
||||
1. Ensure you are running the latest version of TinyIB.
|
||||
2. Review the [open issues](https://github.com/tslocum/TinyIB/issues).
|
||||
3. Open a [new issue](https://github.com/tslocum/TinyIB/issues/new).
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
13
imgboard.php
13
imgboard.php
@ -108,19 +108,6 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
|
||||
$post['file_hex'] = $service;
|
||||
$temp_file = time() . substr(microtime(), 2, 3);
|
||||
$file_location = "thumb/" . $temp_file;
|
||||
|
||||
function url_get_contents ($url) {
|
||||
if (!function_exists('curl_init')){
|
||||
die('CURL is not installed!');
|
||||
}
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $output;
|
||||
}
|
||||
|
||||
file_put_contents($file_location, url_get_contents($embed['thumbnail_url']));
|
||||
|
||||
$file_info = getimagesize($file_location);
|
||||
|
@ -529,6 +529,21 @@ function strallpos($haystack, $needle, $offset = 0) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function url_get_contents($url) {
|
||||
if (!function_exists('curl_init')) {
|
||||
return file_get_contents($url);
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function isEmbed($file_hex) {
|
||||
global $tinyib_embeds;
|
||||
return in_array($file_hex, array_keys($tinyib_embeds));
|
||||
@ -538,12 +553,7 @@ function getEmbed($url) {
|
||||
global $tinyib_embeds;
|
||||
foreach ($tinyib_embeds as $service => $service_url) {
|
||||
$service_url = str_ireplace("TINYIBEMBED", urlencode($url), $service_url);
|
||||
$curl = curl_init($service_url);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
$return = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$result = json_decode($return, true);
|
||||
$result = json_decode(url_get_contents($service_url), true);
|
||||
if (!empty($result)) {
|
||||
return array($service, $result);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user