
05-03-2005, 02:59 PM
|
 |
|
|
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили:
0 раз(а) в 0 сообщениях
|
|
Quote:
Originally Posted by Trigunflame
Yes he is using curl.
This can be done much easier with fopen.
I have not Installed this hack, or tested my file change.. It should work though.
Replace the Code he gives in the install file with this.
PHP Code:
if (is_array($_POST['attachmenturl'])) { foreach ($_POST['attachmenturl'] AS $key => $url) { // attempt to fetch the filename from the url preg_match('/\/([A-z0-9]*)([\.]{1})([A-z0-9]{2,6})$/si', $url, $matches); $filename['original'] = str_replace("/", "", $matches[0]); // did we retrieve a valid filename? $validurl = iif(!empty($url) AND !empty($filename['original']), true, false); /* * FOPEN Modification By Trigunflame */ // valid url if ($validurl) { // init $data = ''; // cancel the file that might have been uploaded unset($_FILES["attachment{$key}"]); // attempt opening of remote file if ($fileOpen = @fopen($url, "rb")) { while (!feof($fileOpen)) { $data = @fread($fileOpen, 4096); } @fclose($fileOpen); } // empty if (empty($data)) { $error = construct_phrase($vbphrase['error_cannot_retrieve_url'], $url); $errors[] = array( 'filename' => htmlspecialchars_uni($url), 'error' => $error ); } // save file else { $tmp_name = 'vbupload' . substr(TIMENOW, -4); $filesize = strlen($data); // write file to temporary directory... if ($vboptions['safeupload']) { // ... in safe mode $filename['temp'] = $vboptions['tmppath'] . "/$tmp_name"; $filenum = @fopen($filename['temp'], 'wb'); @fwrite($filenum, $data); @fclose($filenum); } else { // ... in normal mode $filename['temp'] = tempnam(ini_get('upload_tmp_dir'), 'vbupload'); $fp = @fopen($filename['temp'], 'wb'); @fwrite($fp, $data); @fclose($fp); } $_FILES["attachment$key"]['name'] = $filename['original']; $_FILES["attachment$key"]['type'] = ''; $_FILES["attachment$key"]['size'] = $filesize; $_FILES["attachment$key"]['tmp_name'] = $filename['temp']; $_FILES["attachment$key"]['error'] = 0; $_FILES["attachment$key"]['url_upload_by_curl'] = 1; } } } }
|
I get a filesize stats failed error with this code.
|