vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Allow only one file (of an extension) to be uploaded in a post (https://vborg.vbsupport.ru/showthread.php?t=75878)

Aurous 02-07-2005 01:04 AM

Allow only one file (of an extension) to be uploaded in a post
 
Here's what I am trying to achieve:


  • When a user starts a new post, he can only attach one zip file and multiple images. Most users ignore the rules and attach multiple zip files in the post, which makes the thread very unorganized.
I have made a few changes to /includes/functions_file.php to achieve that. Heres the code I use:

PHP Code:

    //check for number of zip files

    
$zipattaches $DB_site->query_first("
        SELECT COUNT(*) AS count
        FROM " 
TABLE_PREFIX "attachment
        WHERE posthash = '
$posthash'
        AND userid = 
$bbuserinfo[userid] AND filename LIKE '%.zip'
        "
);
    
$zipcount $zipattaches['count'];

    if(
$extension == zip AND $zipcount 0)
    {
            eval(
'$error="' fetch_phrase('onlyonezip'PHRASETYPEID_ERROR).'";');
        
$errors[] = array(
            
'filename' => $attachment_name,
            
'error' => $error
        
);
        return 
false;
    } 

The problem with this is that it will detect the number of zip files when a user is creating new post. But if he edits the post, he can by pass the check and upload one more zip file. So basically I need to make a join to see how many zip files are already attached to that particular post,and I am really confused as how to go about it. Any help??

Thanks

Aurous

Aurous 02-09-2005 01:12 AM

*bump*

Aurous 02-15-2005 11:09 PM

*bump*

Aurous 02-24-2005 03:07 AM

bump

Aurous 02-25-2005 10:39 PM

*bump*


All times are GMT. The time now is 08:16 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.00937 seconds
  • Memory Usage 1,720KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete