mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-19 06:28:01 +00:00
added url input in upload form closes #69
This commit is contained in:
14
inc/core.php
14
inc/core.php
@@ -518,4 +518,18 @@ function endswith($string, $test) {
|
||||
$testlen = strlen($test);
|
||||
if ($testlen > $strlen) return false;
|
||||
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
|
||||
}
|
||||
|
||||
function remote_filesize($url) {
|
||||
static $regex = '/^Content-Length: *+\K\d++$/im';
|
||||
if (!$fp = @fopen($url, 'rb')) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
isset($http_response_header) &&
|
||||
preg_match($regex, implode("\n", $http_response_header), $matches)
|
||||
) {
|
||||
return (int)$matches[0];
|
||||
}
|
||||
return strlen(stream_get_contents($fp));
|
||||
}
|
||||
Reference in New Issue
Block a user