Version: 1.00, by akanevsky
Developer Last Online: Feb 2016
Version: 3.0.7
Rating:
Released: 04-30-2005
Last Update: 06-19-2005
Installs: 11
No support by the author.
/*================================================= =====================*\
|| Attachment Upload by URL
|| Author : Psionic Vision
|| Works on : vBulletin 3.0.7 Only
\*================================================ ======================*/
There have been some requests for attachment upload by URL option... So here it is - my atttempt to create something like this. I am not sure that the way I did it is completely valid, but it does work. That is why I put it in beta releases. The code is fairly short, so it will not take more than one minute to install or remove it.
What this does is, it allows a user to upload an attachment from an URL rather than directly from user's computer. Sometime it is very useful.
Please test it out and comment and/or criticize. Thanks.
from the looks of it this hack requires curl which is not a standard library, you should mention this in the first post
pretty cool though, i may look into it
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);
}
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); }