View Single Post
  #131  
Old 05-30-2004, 05:56 AM
KevinM KevinM is offline
 
Join Date: Dec 2002
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

These code changes use vb's attachment permissions (extensions only) before inserting attachments into the database - so no more .scr files :squareeyed:

If the file extension is not set up in the 'Attachment Manager' 'Extensions and Sizes' section of the control panel then the attachment is ignored.

I have tested it on version 2.1.0. All changes are to 'gateway.php'. There are 6 additions or changes to the script to be made to 'gateway.php'.

Find

PHP Code:
require_once("global.php"); 
CHANGE it to:

PHP Code:
$specialtemplates = array(
    
'attachmentcache'
);
require_once(
"global.php");
$attachtypes unserialize($datastore['attachmentcache']); 
Find:

PHP Code:
function process_attachments ($date$postid$threadid) {
    global 
$message$DB_site
AFTER it put:

PHP Code:
global $attachtypes
Find:

PHP Code:
$attachcount 0
AFTER it put:

PHP Code:
$attaches 0
Find:

PHP Code:
for ($i 1$i <= $message['attachments']; $i++) { 
AFTER it put:

PHP Code:
// now we check the file extension against the vb settings to check that it exists, and if it does, check it is enabled.
        
$attachment_name2 strtolower($message['attachment' $i]['headers']['filename']);
                
$extension file_extension($attachment_name2);
        
    if (!
$attachtypes["$extension"] OR !$attachtypes["$extension"]['enabled'])
    {
        
// invalid extension
        
logging($extension " extensions are not accepted, as currently set up in the control panel \n");
    }
    else { 
Find:

PHP Code:
fclose($handle);
        
unlink($tempfile); 
CHANGE to:

PHP Code:
$attaches++;
        
fclose($handle);
        
unlink($tempfile);
        } 
Find:

PHP Code:
$DB_site->query("UPDATE " TABLE_PREFIX "post 
    SET attach = attach + " 
$attachcount " WHERE postid = $postid");
    
$DB_site->query("UPDATE " TABLE_PREFIX "thread
    SET attach = attach + " 
$attachcount " WHERE threadid = $threadid");
    
logging("Inserted " $attachcount " attachment(s).");

CHANGE to:

PHP Code:
$DB_site->query("UPDATE " TABLE_PREFIX "post 
    SET attach = attach + " 
$attaches " WHERE postid = $postid");
    
$DB_site->query("UPDATE " TABLE_PREFIX "thread
    SET attach = attach + " 
$attaches " WHERE threadid = $threadid");
    
logging("Inserted " $attaches " attachment(s)."); 
And that is it :nervous:

This script doesn't check against the maximum file size or image dimensions permissions, but it would be fairly easy to add on however I'm not sure of how useful this would be, as people posting to newsgroups would be unaware of your boards limits.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01279 seconds
  • Memory Usage 1,818KB
  • 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
  • (12)bbcode_php
  • (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