Hi!
Valid file extension for Upload, separate for every Category.
with this modification you can set the valid file extension for upload, seperate for every category.
1.) copy the file "install_mediatypes.php" from the attachment in your root and call it to.
2.) search in admin/categories.php section: ($action == "savecat")
$cat_order = (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;
insert below:
//############# Allowed Mediatypes in Categories ###############
$cat_mediatypes = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_mediatypes']));
//############# Allowed Mediatypes in Categories ###############
search:
$sql = "INSERT INTO ".CATEGORIES_TABLE."
(cat_name, cat_description, cat_parent_id, cat_order, cat_mediatypes, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
VALUES
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, '$cat_mediatypes', $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
$result = $site_db->query($sql);
and replace:
$sql = "INSERT INTO ".CATEGORIES_TABLE."
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
VALUES
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
$result = $site_db->query($sql);
2.1) search in admin/categories.php section: ($action == "addcat")
$permission_headline = $lang['permissions'];
insert above:
//############## Allowed Mediatypes in Categories ###############
show_input_row($lang['cat_mediatypes'], "cat_mediatypes", "", $textinput_size);
//############## Allowed Mediatypes in Categories ###############
search:
$sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_parent_id";
$row = $site_db->query_firstrow($sql);
and replace:
$sql = "SELECT cat_name, cat_mediatypes, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_parent_id";
$row = $site_db->query_firstrow($sql);
search:
$permission_headline .= "<span class=\"smalltext\"><br>".$lang['permissions_inherited']." (".format_text($row['cat_name'], 2).")</span>";
insert below:
//############## Allowed Mediatypes in Categories ###############
show_input_row($lang['cat_mediatypes'], "cat_mediatypes", $row['cat_mediatypes'], $textinput_size);
//############## Allowed Mediatypes in Categories ###############
2.2) search in admin/categories.php section: ($action == "updatecat")
$cat_order = (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;
insert below:
//############### Allowed Mediatypes in Categories ###############
$cat_mediatypes = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_mediatypes']));
//############### Allowed Mediatypes in Categories ###############
search:
$sql = "UPDATE ".CATEGORIES_TABLE."
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
WHERE cat_id = $cat_id";
$result = $site_db->query($sql);
and replace:
$sql = "UPDATE ".CATEGORIES_TABLE."
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_mediatypes = '$cat_mediatypes', cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
WHERE cat_id = $cat_id";
$result = $site_db->query($sql);
2.3) search in admin/categories.php section: ($action == "editcat")
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_id";
$cat_row = $site_db->query_firstrow($sql);
and replace:
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, cat_mediatypes, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_id";
$cat_row = $site_db->query_firstrow($sql);
search:
show_input_row($lang['field_hits'], "cat_hits", $cat_row['cat_hits'], 5);
insert below:
//################ Allowed Mediatypes in Categories ###############
show_input_row($lang['cat_mediatypes'], "cat_mediatypes", $cat_row['cat_mediatypes'], $textinput_size);
//################ Allowed Mediatypes in Categories ###############
3.) search in includes/upload.php:
function set_allowed_filetypes() {
global $config;
and replace:
function set_allowed_filetypes() {
global $config,$cat_cache,$cat_id;
search:
$this->accepted_extensions['media'] = $config['allowed_mediatypes_array'];
and replace:
$allowed_mediatypes = (!empty($cat_cache[$cat_id]['cat_mediatypes'])) ? explode(",",$cat_cache[$cat_id]['cat_mediatypes']) : $config['allowed_mediatypes_array'];
$this->accepted_extensions['media'] = $allowed_mediatypes;
4.) search in lang/your lang/admin.php:
//--- Categories --------------------------------------
//-----------------------------------------------------
(deutsch:)
//############# Allowed Mediatypes in Categories ###############
$lang['cat_mediatypes'] = "Erlaubte Dateitypen<br><span class=\"smalltext\">Durch ein Komma getrennt, ohne Leerzeichen.</span>";
//############# Allowed Mediatypes in Categories ###############
(english)
//############# Allowed Mediatypes in Categories ###############
$lang['cat_mediatypes'] = "Valid file extensions<br /><span class=\"smalltext\">Delimit with comma, not with spaces..</span>";
//############# Allowed Mediatypes in Categories ###############
5.) search in member.php:
"allowed_media_types" => str_replace(",",", ",$config['allowed_mediatypes']),
and replace:
"allowed_media_types" => (!empty($cat_cache[$cat_id]['cat_mediatypes'])) ? "<b class=\"new\">".str_replace(",",", ",$cat_cache[$cat_id]['cat_mediatypes'])."</b>" : str_replace(",",", ",$config['allowed_mediatypes']),
6.) search in global.php:
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
FROM ".CATEGORIES_TABLE."
ORDER BY ".$config['cat_order']." " .$config['cat_sort'];
$result = $site_db->query($sql);
and replace:
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order,cat_mediatypes, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
FROM ".CATEGORIES_TABLE."
ORDER BY ".$config['cat_order']." " .$config['cat_sort'];
$result = $site_db->query($sql);
mfg Andi