vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Beta Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=34)
-   -   Attachment Upload by URL (https://vborg.vbsupport.ru/showthread.php?t=80833)

Zachery 05-01-2005 08:18 PM

Quote:

Originally Posted by reminder
Not working. Error "Please select a file to attach using the "Browse..." button."

Please do not report a post if its not working for you. You should contact the author or uninstall the hack

Reminder 05-01-2005 08:39 PM

Quote:

Originally Posted by Zachery
Please do not report a post if its not working for you. You should contact the author or uninstall the hack

Oppps. Sory. Ok. :)

Lionel 05-01-2005 09:08 PM

Your problem is in the javascript in template that checks for a value in upload field.

akanevsky 05-01-2005 09:25 PM

Sorry, I forgot to include that into the instructions. Will update them in a minute.

The fix is as follows:

In template 'newattachment', find:

Code:

if (elm.type == 'file')
and replace with:

Code:

if ((elm.type == 'file') || (elm.type == 'text'))

AN-net 05-01-2005 10:50 PM

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;)

Trigunflame 05-01-2005 11:17 PM

Quote:

Originally Posted by AN-net
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']), truefalse);

                
/*
                 * 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($fileOpen4096);
                        }
                        @
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;
                    }
                }
            }
        } 


Allan 05-02-2005 12:18 AM

screenshot please, just for looking ?

Reminder 05-02-2005 06:20 AM

Quote:

Originally Posted by Dark Visor
Then you did not install it correctly. What is your vB version?

Vbulletin Version 3.0.7

Boofo 05-03-2005 02:59 PM

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']), truefalse);
 
                
/*
                 * 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($fileOpen4096);
                        }
                        @
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. ;)

Lionel 05-03-2005 05:12 PM

Can't get the fopen() code to work either.


All times are GMT. The time now is 12:21 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01298 seconds
  • Memory Usage 1,851KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete