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
'.$upload_code_form.' - '.$this->translate(4).':
+ '.$this->translate(4).':
+

+ '.$this->translate(22).':

@@ -662,6 +664,42 @@ class PictshareModel extends Model } } + if($_REQUEST['picurl']) + { + $url = $_REQUEST['picurl']; + if(startsWith($url,'http://') || startsWith($url,'https://')) + { + $size_mb = remote_filesize($url)*0.000001; + $maxsize = (int)(ini_get('upload_max_filesize')); + if(endswith($maxsize,'MB')) + { + $maxsize = substr($maxsize,0,strpos($maxsize,'MB')); + } + else $maxsize = 20; + if($size_mb <= $maxsize) //if the file is within maxsize lets download it + { + $name = basename($url);//md5(rand(1,9999)*rand(1,99999)); + file_put_contents(ROOT.DS.'tmp'.DS.$name, file_get_contents($url)); + $data = $this->uploadImageFromURL(ROOT.DS.'tmp'.DS.$name); + if($data['status']=='OK') + { + if($data['deletecode']) + $deletecode = '
Delete image'; + else $deletecode = ''; + if($data['type']=='mp4') + $o.= '

'.$this->translate(4).' '.++$i.'

'.$data['hash'].''.$deletecode.'
'; + else + $o.= '

'.$this->translate(4).' '.++$i.'

'.$deletecode.'
'; + + $hashes[] = $data['hash']; + } + unlink(ROOT.DS.'tmp'.DS.$name); + } + else + $o.= '

Error

File '.$url.' is too large. Max upload size: '.$maxsize.'MB
'; + } + } + if(count($hashes)>1) { $albumlink = DOMAINPATH.PATH.implode('/',$hashes); @@ -735,6 +773,7 @@ class PictshareModel extends Model $words[19] = $params[0].' Aufrufe aus '.$params[1]; $words[20] = 'Upload-Code'; $words[21] = 'Falscher Upload Code eingegeben. Upload abgebrochen'; + $words[22] = 'URL für den Upload'; break; @@ -761,6 +800,7 @@ class PictshareModel extends Model $words[19] = $params[0].' views from '.$params[1]; $words[20] = 'Upload code'; $words[21] = 'Invalid upload code provided'; + $words[22] = 'URL to upload'; } return $words[$index];