Use file_get_contents if cURL isn't installed

This commit is contained in:
Trevor Slocum 2017-12-14 14:36:57 -08:00
parent 6a26e32594
commit ddcacf46b0
3 changed files with 28 additions and 29 deletions

View File

@ -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:
@ -76,9 +76,9 @@ Updating
------------
1. Obtain the latest release.
- If you installed via Git, run the following command in TinyIB's directory:
- `git pull`
- Otherwise, [download](https://github.com/tslocum/TinyIB/archive/master.zip) and extract a zipped archive.
- If you installed via Git, run the following command in TinyIB's directory:
- `git pull`
- Otherwise, [download](https://github.com/tslocum/TinyIB/archive/master.zip) and extract a zipped archive.
2. Note which files were modified.
- If **settings.default.php** was updated, migrate the changes to **settings.php**
- Take care to not change the value of **TINYIB_TRIPSEED**, as it would result in different secure tripcodes.
@ -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
------------

View File

@ -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);

View File

@ -187,7 +187,7 @@ function writePage($filename, $contents) {
}
function fixLinksInRes($html) {
$search = array(' href="css/', ' src="js/', ' href="src/', ' href="thumb/', ' href="res/', ' href="imgboard.php', ' href="favicon.ico', 'src="thumb/', 'src="inc/', 'src="sticky.png', ' action="imgboard.php');
$search = array(' href="css/', ' src="js/', ' href="src/', ' href="thumb/', ' href="res/', ' href="imgboard.php', ' href="favicon.ico', 'src="thumb/', 'src="inc/', 'src="sticky.png', ' action="imgboard.php');
$replace = array(' href="../css/', ' src="../js/', ' href="../src/', ' href="../thumb/', ' href="../res/', ' href="../imgboard.php', ' href="../favicon.ico', 'src="../thumb/', 'src="../inc/', 'src="../sticky.png', ' action="../imgboard.php');
return str_replace($search, $replace, $html);
@ -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,16 +553,11 @@ 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);
}
}
return array('', array());
return array('', array());
}