Aurous
02-07-2005, 01:04 AM
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:
//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
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:
//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