forked from GithubBackups/tinyib
Use cURL instead of file_get_contents, mime_content_type instead of shell_exec (#38)
This commit is contained in:
parent
58d9922bd4
commit
6a26e32594
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ settings.php
|
|||||||
.project
|
.project
|
||||||
.settings/
|
.settings/
|
||||||
.idea/
|
.idea/
|
||||||
|
*error_log
|
||||||
|
21
imgboard.php
21
imgboard.php
@ -108,10 +108,23 @@ 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;
|
||||||
file_put_contents($file_location, file_get_contents($embed['thumbnail_url']));
|
|
||||||
|
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);
|
$file_info = getimagesize($file_location);
|
||||||
$file_mime = $file_info['mime'];
|
$file_mime = mime_content_type($file_location);
|
||||||
$post['image_width'] = $file_info[0];
|
$post['image_width'] = $file_info[0];
|
||||||
$post['image_height'] = $file_info[1];
|
$post['image_height'] = $file_info[1];
|
||||||
|
|
||||||
@ -159,7 +172,7 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
|
|||||||
|
|
||||||
checkDuplicateFile($post['file_hex']);
|
checkDuplicateFile($post['file_hex']);
|
||||||
|
|
||||||
$file_mime_split = explode(' ', trim(@shell_exec('file --mime-type ' . $_FILES['file']['tmp_name'])));
|
$file_mime_split = explode(' ', trim(mime_content_type($_FILES['file']['tmp_name'])));
|
||||||
if (count($file_mime_split) > 0) {
|
if (count($file_mime_split) > 0) {
|
||||||
$file_mime = strtolower(array_pop($file_mime_split));
|
$file_mime = strtolower(array_pop($file_mime_split));
|
||||||
} else {
|
} else {
|
||||||
@ -168,7 +181,7 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$file_info = getimagesize($_FILES['file']['tmp_name']);
|
$file_info = getimagesize($_FILES['file']['tmp_name']);
|
||||||
$file_mime = $file_info['mime'];
|
$file_mime = mime_content_type($file_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($file_mime) || !isset($tinyib_uploads[$file_mime])) {
|
if (empty($file_mime) || !isset($tinyib_uploads[$file_mime])) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user