PDA

View Full Version : Looking for force attachment


Vishaaldesiking
07-20-2012, 06:21 AM
Hi,

I'm looking for like in forum 2,3,4,5 if members need to create a thread they must have 1 attachment for some special file like .torrent?
Is that possible in vb4?

Simon Lloyd
07-20-2012, 08:17 AM
Maybe something like this using hook attachdata_presaveif (in_array($foruminfo['forumid'], array(1,2,3,4,5,6)))
{
$file_type = $_FILES['foreign_character_upload']['type']; //returns the mimetype

$allowed = array('torrent', 'zip','TORRENT', 'ZIP');
if(!in_array($file_type, $allowed)) {
$error_message = 'Only zip or torrent files are allowed.';
$error = 'yes';
}
}

Vishaaldesiking
07-20-2012, 11:29 AM
i mean it must check if there is .torrent file then it must submit other it must give a error message like please add your .torrent file

Other files must be allowed also but the .torrent must be attachted

Simon Lloyd
07-20-2012, 01:28 PM
Isn't that what the code above does?

Vishaaldesiking
07-20-2012, 06:48 PM
^ no that allowed only 'torrent', 'zip','TORRENT', 'ZIP'

I need a mod that allowed everyfile but there must be 1 .torrent file also other it must give error message

So it must just check if == .torrent is true then no error.
if its =- then it must come a error

Sample:
1.jpg = error

Sample 2:
2.jpg + sd.torrent = good (because there is a .torrent file)

Simon Lloyd
07-21-2012, 04:38 AM
the code i gave cn be expanded very easily, have a go at making it do what you need, use the AND operator to check if the upload is an $allowed file AND has a torrent file, you will not be able to check if the zip contains the torrent though.

Vishaaldesiking
08-06-2012, 09:52 AM
^ i have add the script inside plugin manager its not working.

what i can see in this plugin is that only zip and torrent file is allowed!.
but i want everyfile must allowed just .torrent file required.

without a torrent file they must get error message. but they are also allowed to upload other files like jpg, zip etc.

Simon Lloyd
08-06-2012, 10:54 AM
For more files just add to the list following what i've done, you need to COUNT the number of attachments and you need to make sure that there is at least a count of 1 for a torrent file before allowing the upload.

Vishaaldesiking
08-06-2012, 06:13 PM
^ how can i do it??