PDA

View Full Version : Choose which filetypes to moderate


MrNase
04-26-2005, 10:00 PM
Hello,

This one is a really quick one. You may take this as a base for another, better hack but you have to credit me :)

Support:
The most important thing first: I'll give full support but Iam not responsible for any damaged caused by this mini mod.
Please use this thread for any questions you have.

What does this hack do:
My members recently uploaded some .pdf which were 'stolen' and used without credit. As my members attach images regularly I searched for an option to restrict the attachment moderation only to .pdf so that won't happen again.

What files are modified:
/includes/functions_file.php - only ~ 2 minutes


Notes and explanations:
You'll find the following array when you successfully installed this mini mod:

$moderatethisattachments = array(
'pdf',
'txt',
'doc',
'xls'
);


Here you can select which files should be moderated. The code above tell the script to moderate: pdf, txt, doc and xls (which I do on my forums).

You can add more extensions quite easily.. Here's another example which only moderates .avi:

$moderatethisattachments = array(
'avi'
);




I hope you like this mini mod. Hopefully one of the advanced coders takes up this idea and makes a nice hack out of this one (please contact me first via PM) :)

Oblivion Knight
04-27-2005, 09:03 AM
Some instructions may be useful? Just a thought.. ;)

MrNase
04-27-2005, 09:08 AM
Oops sorry.. I had to add the url to this thread and I totally forgot to add the file afterwards :D

Marco van Herwaarden
04-27-2005, 09:50 AM
Your avi-only example has a comma too much on the end. ;)

Marco van Herwaarden
04-27-2005, 09:55 AM
This hack will fully override the basic permissions. So if a usergroup is set to always moderate, it won't be moderated if you also upload a non-moderated attachment............i think ;)

i think the following would be better:
$visible = iif($moderate, 0, 1);

if ($visible)
{
$attachment_name2 = strtolower($attachment_name);
$extension = file_extension($attachment_name2);
$moderatethisattachments = array(
'pdf',
'txt',
'doc',
'xls'
);
if(in_array($extension, $moderatethisattachments)) {
$visible = '0';
}
}

MrNase
04-27-2005, 09:56 AM
Have a look at the $globaltemplates-array() in various vB-files.. there's also a comma at the end :)

Thank you, I updated the hack and I also updated the code I have installed ;)

Marco van Herwaarden
04-27-2005, 10:10 AM
Have a look at the $globaltemplates-array() in various vB-files.. there's also a comma at the end :)

Thank you, I updated the hack and I also updated the code I have installed ;)True, it is allowed, but not nice coding if you ask me. I guess it is done because it happened too many times that someone added a line and forgot to add a comma to the previous (copying the last line, and only changing names).

This is also why i don't like the layout of the coding. Instead of:
$myarray = array(
'aa',
'bb',
'cc'
);I personally prefer:
$myarray = array(
'aa'
, 'bb'
, 'cc'
);

And for hacks adding new entries to these tables, i would suggest a new line instead of editing the existing code.

So instead of instructions to change:
$myarray = array(
'aa',
'bb',
'cc'
);Into:
$myarray = array(
'aa',
'bb',
'cc' ,
'mynewhackvalue'
);

Just instruct to add the following line immediate after the original:
$myarray[] = 'mynewhackvalue';

But now we are hijacking a thread. :D

jugo
04-27-2005, 01:34 PM
This is very helpful stuff though....Thanks for AAAALLLLL The info and for the hack.

MrNase
04-30-2005, 10:43 PM
Thanks, Iam glad you like it :)