mirror of
https://code.rocketnine.space/tslocum/tinyib.git
synced 2025-01-18 06:38:28 +01:00
Use file_get_contents if cURL isn't installed
This commit is contained in:
parent
6a26e32594
commit
ddcacf46b0
18
README.md
18
README.md
@ -28,10 +28,10 @@ Features
|
|||||||
Installing
|
Installing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
1. Verify the following requirements are met:
|
1. Verify the following are installed:
|
||||||
- [PHP](http://php.net) 4 or higher is installed.
|
- [PHP 4.3+](http://php.net)
|
||||||
- [GD Image Processing Library](http://php.net/gd) is installed.
|
- [GD Image Processing Library](http://php.net/gd)
|
||||||
- This library is installed by default on most hosts.
|
- 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.
|
- 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.
|
2. CD to the directory you wish to install TinyIB.
|
||||||
3. Run the command:
|
3. Run the command:
|
||||||
@ -76,9 +76,9 @@ Updating
|
|||||||
------------
|
------------
|
||||||
|
|
||||||
1. Obtain the latest release.
|
1. Obtain the latest release.
|
||||||
- If you installed via Git, run the following command in TinyIB's directory:
|
- If you installed via Git, run the following command in TinyIB's directory:
|
||||||
- `git pull`
|
- `git pull`
|
||||||
- Otherwise, [download](https://github.com/tslocum/TinyIB/archive/master.zip) and extract a zipped archive.
|
- Otherwise, [download](https://github.com/tslocum/TinyIB/archive/master.zip) and extract a zipped archive.
|
||||||
2. Note which files were modified.
|
2. Note which files were modified.
|
||||||
- If **settings.default.php** was updated, migrate the changes to **settings.php**
|
- 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.
|
- 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
|
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
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
13
imgboard.php
13
imgboard.php
@ -108,19 +108,6 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
|
|||||||
$post['file_hex'] = $service;
|
$post['file_hex'] = $service;
|
||||||
$temp_file = time() . substr(microtime(), 2, 3);
|
$temp_file = time() . substr(microtime(), 2, 3);
|
||||||
$file_location = "thumb/" . $temp_file;
|
$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_put_contents($file_location, url_get_contents($embed['thumbnail_url']));
|
||||||
|
|
||||||
$file_info = getimagesize($file_location);
|
$file_info = getimagesize($file_location);
|
||||||
|
@ -187,7 +187,7 @@ function writePage($filename, $contents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fixLinksInRes($html) {
|
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');
|
$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);
|
return str_replace($search, $replace, $html);
|
||||||
@ -529,6 +529,21 @@ function strallpos($haystack, $needle, $offset = 0) {
|
|||||||
return $result;
|
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) {
|
function isEmbed($file_hex) {
|
||||||
global $tinyib_embeds;
|
global $tinyib_embeds;
|
||||||
return in_array($file_hex, array_keys($tinyib_embeds));
|
return in_array($file_hex, array_keys($tinyib_embeds));
|
||||||
@ -538,16 +553,11 @@ function getEmbed($url) {
|
|||||||
global $tinyib_embeds;
|
global $tinyib_embeds;
|
||||||
foreach ($tinyib_embeds as $service => $service_url) {
|
foreach ($tinyib_embeds as $service => $service_url) {
|
||||||
$service_url = str_ireplace("TINYIBEMBED", urlencode($url), $service_url);
|
$service_url = str_ireplace("TINYIBEMBED", urlencode($url), $service_url);
|
||||||
$curl = curl_init($service_url);
|
$result = json_decode(url_get_contents($service_url), true);
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
|
||||||
$return = curl_exec($curl);
|
|
||||||
curl_close($curl);
|
|
||||||
$result = json_decode($return, true);
|
|
||||||
if (!empty($result)) {
|
if (!empty($result)) {
|
||||||
return array($service, $result);
|
return array($service, $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array('', array());
|
return array('', array());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user