diff --git a/inc/core.php b/inc/core.php index c7675d0..2c3ad40 100644 --- a/inc/core.php +++ b/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)); } \ No newline at end of file diff --git a/models/pictsharemodel.php b/models/pictsharemodel.php index ad7edc2..2792db9 100644 --- a/models/pictsharemodel.php +++ b/models/pictsharemodel.php @@ -371,7 +371,9 @@ class PictshareModel extends Model