View Single Post
  #17  
Old 05-01-2005, 11:17 PM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;
                    }
                }
            }
        } 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01285 seconds
  • Memory Usage 1,834KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete