| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
if (defined('IN_PHPBB')) |
|---|
| 14 |
{ |
|---|
| 15 |
die('Hacking attempt'); |
|---|
| 16 |
exit; |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
define('IN_PHPBB', TRUE); |
|---|
| 20 |
$phpbb_root_path = './'; |
|---|
| 21 |
include($phpbb_root_path . 'extension.inc'); |
|---|
| 22 |
include($phpbb_root_path . 'common.'.$phpEx); |
|---|
| 23 |
|
|---|
| 24 |
$forum_id = get_var('f', 0); |
|---|
| 25 |
$privmsg = (!$forum_id) ? true : false; |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
$userdata = session_pagestart($user_ip, PAGE_INDEX); |
|---|
| 29 |
init_userprefs($userdata); |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
if ($privmsg) |
|---|
| 33 |
{ |
|---|
| 34 |
$auth['auth_attachments'] = ($userdata['user_level'] != ADMIN) ? intval($attach_config['allow_pm_attach']) : true; |
|---|
| 35 |
$auth['auth_view'] = true; |
|---|
| 36 |
$_max_filesize = $attach_config['max_filesize_pm']; |
|---|
| 37 |
} |
|---|
| 38 |
else |
|---|
| 39 |
{ |
|---|
| 40 |
$auth = auth(AUTH_ALL, $forum_id, $userdata); |
|---|
| 41 |
$_max_filesize = $attach_config['max_filesize']; |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
if (!($auth['auth_attachments'] && $auth['auth_view'])) |
|---|
| 45 |
{ |
|---|
| 46 |
message_die(GENERAL_ERROR, 'You are not allowed to call this file (ID:2)'); |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
$template->set_filenames(array( |
|---|
| 50 |
'body' => 'posting_attach_rules.tpl') |
|---|
| 51 |
); |
|---|
| 52 |
|
|---|
| 53 |
$sql = 'SELECT group_id, group_name, max_filesize, forum_permissions |
|---|
| 54 |
FROM ' . EXTENSION_GROUPS_TABLE . ' |
|---|
| 55 |
WHERE allow_group = 1 |
|---|
| 56 |
ORDER BY group_name ASC'; |
|---|
| 57 |
|
|---|
| 58 |
if (!($result = $db->sql_query($sql))) |
|---|
| 59 |
{ |
|---|
| 60 |
message_die(GENERAL_ERROR, 'Could not query Extension Groups.', '', __LINE__, __FILE__, $sql); |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
$allowed_filesize = array(); |
|---|
| 64 |
$rows = $db->sql_fetchrowset($result); |
|---|
| 65 |
$num_rows = $db->sql_numrows($result); |
|---|
| 66 |
$db->sql_freeresult($result); |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
$nothing = true; |
|---|
| 70 |
for ($i = 0; $i < $num_rows; $i++) |
|---|
| 71 |
{ |
|---|
| 72 |
$auth_cache = trim($rows[$i]['forum_permissions']); |
|---|
| 73 |
|
|---|
| 74 |
$permit = ($privmsg) ? true : ((is_forum_authed($auth_cache, $forum_id)) || trim($rows[$i]['forum_permissions']) == ''); |
|---|
| 75 |
|
|---|
| 76 |
if ($permit) |
|---|
| 77 |
{ |
|---|
| 78 |
$nothing = false; |
|---|
| 79 |
$group_name = $rows[$i]['group_name']; |
|---|
| 80 |
$f_size = intval(trim($rows[$i]['max_filesize'])); |
|---|
| 81 |
$det_filesize = (!$f_size) ? $_max_filesize : $f_size; |
|---|
| 82 |
$size_lang = ($det_filesize >= 1048576) ? $lang['MB'] : (($det_filesize >= 1024) ? $lang['KB'] : $lang['Bytes']); |
|---|
| 83 |
|
|---|
| 84 |
if ($det_filesize >= 1048576) |
|---|
| 85 |
{ |
|---|
| 86 |
$det_filesize = round($det_filesize / 1048576 * 100) / 100; |
|---|
| 87 |
} |
|---|
| 88 |
else if ($det_filesize >= 1024) |
|---|
| 89 |
{ |
|---|
| 90 |
$det_filesize = round($det_filesize / 1024 * 100) / 100; |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
$max_filesize = ($det_filesize == 0) ? $lang['Unlimited'] : $det_filesize . ' ' . $size_lang; |
|---|
| 94 |
|
|---|
| 95 |
$template->assign_block_vars('group_row', array( |
|---|
| 96 |
'GROUP_RULE_HEADER' => sprintf($lang['Group_rule_header'], $group_name, $max_filesize)) |
|---|
| 97 |
); |
|---|
| 98 |
|
|---|
| 99 |
$sql = 'SELECT extension |
|---|
| 100 |
FROM ' . EXTENSIONS_TABLE . " |
|---|
| 101 |
WHERE group_id = " . (int) $rows[$i]['group_id'] . " |
|---|
| 102 |
ORDER BY extension ASC"; |
|---|
| 103 |
|
|---|
| 104 |
if (!($result = $db->sql_query($sql))) |
|---|
| 105 |
{ |
|---|
| 106 |
message_die(GENERAL_ERROR, 'Could not query Extensions.', '', __LINE__, __FILE__, $sql); |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
$e_rows = $db->sql_fetchrowset($result); |
|---|
| 110 |
$e_num_rows = $db->sql_numrows($result); |
|---|
| 111 |
$db->sql_freeresult($result); |
|---|
| 112 |
|
|---|
| 113 |
for ($j = 0; $j < $e_num_rows; $j++) |
|---|
| 114 |
{ |
|---|
| 115 |
$template->assign_block_vars('group_row.extension_row', array( |
|---|
| 116 |
'EXTENSION' => $e_rows[$j]['extension']) |
|---|
| 117 |
); |
|---|
| 118 |
} |
|---|
| 119 |
} |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
$gen_simple_header = TRUE; |
|---|
| 123 |
$page_title = $lang['Attach_rules_title']; |
|---|
| 124 |
include($phpbb_root_path . 'includes/page_header.' . $phpEx); |
|---|
| 125 |
|
|---|
| 126 |
$template->assign_vars(array( |
|---|
| 127 |
'L_RULES_TITLE' => $lang['Attach_rules_title'], |
|---|
| 128 |
'L_CLOSE_WINDOW' => $lang['Close_window'], |
|---|
| 129 |
'L_EMPTY_GROUP_PERMS' => $lang['Note_user_empty_group_permissions']) |
|---|
| 130 |
); |
|---|
| 131 |
|
|---|
| 132 |
if ($nothing) |
|---|
| 133 |
{ |
|---|
| 134 |
$template->assign_block_vars('switch_nothing', array()); |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
$template->pparse('body'); |
|---|
| 138 |
|
|---|
| 139 |
?> |
|---|