forked from GithubBackups/tinyib
Fix missing error message when embedding fails
This commit is contained in:
parent
74540e68b3
commit
91c137b264
@ -338,8 +338,9 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name'])
|
|||||||
if (!TINYIB_UPLOADVIAURL) {
|
if (!TINYIB_UPLOADVIAURL) {
|
||||||
fancyDie(sprintf(__('Invalid embed URL. Only %s URLs are supported.'), implode('/', array_keys($tinyib_embeds))));
|
fancyDie(sprintf(__('Invalid embed URL. Only %s URLs are supported.'), implode('/', array_keys($tinyib_embeds))));
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = get_headers(trim($_POST['embed']), true);
|
$headers = get_headers(trim($_POST['embed']), true);
|
||||||
if (TINYIB_MAXKB > 0 && intval($headers['Content-Length']) > (TINYIB_MAXKB * 1024)) {
|
if (TINYIB_MAXKB > 0 && isset($headers['Content-Length']) && intval($headers['Content-Length']) > (TINYIB_MAXKB * 1024)) {
|
||||||
fancyDie(sprintf(__('That file is larger than %s.'), TINYIB_MAXKBDESC));
|
fancyDie(sprintf(__('That file is larger than %s.'), TINYIB_MAXKBDESC));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +349,10 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name'])
|
|||||||
fancyDie(__('Failed to download file at specified URL.'));
|
fancyDie(__('Failed to download file at specified URL.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TINYIB_MAXKB > 0 && strlen($data) > (TINYIB_MAXKB * 1024)) {
|
||||||
|
fancyDie(sprintf(__('That file is larger than %s.'), TINYIB_MAXKBDESC));
|
||||||
|
}
|
||||||
|
|
||||||
$filepath = 'src/' . time() . substr(microtime(), 2, 3) . rand(1000, 9999) . '.txt';
|
$filepath = 'src/' . time() . substr(microtime(), 2, 3) . rand(1000, 9999) . '.txt';
|
||||||
if (!file_put_contents($filepath, $data)) {
|
if (!file_put_contents($filepath, $data)) {
|
||||||
@unlink($filepath);
|
@unlink($filepath);
|
||||||
|
@ -574,9 +574,15 @@ function url_get_contents($url) {
|
|||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
$output = curl_exec($ch);
|
$output = curl_exec($ch);
|
||||||
|
$responsecode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
|
if (intval($responsecode) != 200) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,9 +595,12 @@ 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);
|
||||||
$result = json_decode(url_get_contents($service_url), true);
|
$data = url_get_contents($service_url);
|
||||||
if (!empty($result)) {
|
if ($data != '') {
|
||||||
return array($service, $result);
|
$result = json_decode($data, true);
|
||||||
|
if (!empty($result)) {
|
||||||
|
return array($service, $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user