$db->sql_freeresult($result);
    for ($i = 0; $i < $num_extension_group; $i++) {
        // Format the filesize
        if (!$extension_group[$i]['max_filesize']) {
            $extension_group[$i]['max_filesize'] = $attach_config['max_filesize'];
        }
        $size_format = $extension_group[$i]['max_filesize'] >= 1048576 ? 'mb' : ($extension_group[$i]['max_filesize'] >= 1024 ? 'kb' : 'b');
        if ($extension_group[$i]['max_filesize'] >= 1048576) {
            $extension_group[$i]['max_filesize'] = round($extension_group[$i]['max_filesize'] / 1048576 * 100) / 100;
        } else {
            if ($extension_group[$i]['max_filesize'] >= 1024) {
                $extension_group[$i]['max_filesize'] = round($extension_group[$i]['max_filesize'] / 1024 * 100) / 100;
            }
        }
        $s_allowed = $extension_group[$i]['allow_group'] == 1 ? 'checked="checked"' : '';
        $template->assign_block_vars('grouprow', array('GROUP_ID' => $extension_group[$i]['group_id'], 'EXTENSION_GROUP' => $extension_group[$i]['group_name'], 'UPLOAD_ICON' => $extension_group[$i]['upload_icon'], 'S_ALLOW_SELECTED' => $s_allowed, 'S_SELECT_CAT' => category_select('category_list[]', $extension_group[$i]['group_id']), 'S_DOWNLOAD_MODE' => download_select('download_mode_list[]', $extension_group[$i]['group_id']), 'S_FILESIZE' => size_select('size_select_list[]', $size_format), 'MAX_FILESIZE' => $extension_group[$i]['max_filesize'], 'CAT_BOX' => $viewgroup == $extension_group[$i]['group_id'] ? $lang['Decollapse'] : $lang['Collapse'], 'U_VIEWGROUP' => $viewgroup == $extension_group[$i]['group_id'] ? append_sid("admin_extensions.{$phpEx}?mode=groups") : append_sid("admin_extensions.{$phpEx}?mode=groups&" . POST_GROUPS_URL . "=" . $extension_group[$i]['group_id']), 'U_FORUM_PERMISSIONS' => append_sid("admin_extensions.{$phpEx}?mode={$mode}&amp;e_mode=perm&amp;e_group=" . $extension_group[$i]['group_id'])));
        if ($viewgroup && $viewgroup == $extension_group[$i]['group_id']) {
            $sql = 'SELECT comment, extension 
				FROM ' . EXTENSIONS_TABLE . '
				WHERE group_id = ' . (int) $viewgroup;
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Couldn\'t get Extension informations', '', __LINE__, __FILE__, $sql);
            }
            $extension = $db->sql_fetchrowset($result);
            $num_extension = $db->sql_numrows($result);
            $db->sql_freeresult($result);
            for ($j = 0; $j < $num_extension; $j++) {
                $template->assign_block_vars('grouprow.extensionrow', array('EXPLANATION' => $extension[$j]['comment'], 'EXTENSION' => $extension[$j]['extension']));
            }
        }
    }
    } elseif ($max_add_filesize >= 1024) {
        $max_add_filesize = round($max_add_filesize / 1024 * 100) / 100;
    }
    $template->assign_vars(array('L_MANAGE_QUOTAS_TITLE' => $lang['Manage_quotas'], 'L_MANAGE_QUOTAS_EXPLAIN' => $lang['Manage_quotas_explain'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_EDIT' => $lang['Edit'], 'L_VIEW' => $lang['View'], 'L_DESCRIPTION' => $lang['Description'], 'L_SIZE' => $lang['Max_filesize_attach'], 'L_ADD_NEW' => $lang['Add_new'], 'L_DELETE' => $lang['Delete'], 'MAX_FILESIZE' => $max_add_filesize, 'S_FILESIZE' => size_select('add_size_select', $size), 'L_REMOVE_SELECTED' => $lang['Remove_selected'], 'S_ATTACH_ACTION' => append_sid('admin_attachments.' . PHP_EXT . '?mode=quota')));
    $sql = "SELECT * FROM " . QUOTA_LIMITS_TABLE . " ORDER BY quota_limit DESC";
    $result = $db->sql_query($sql);
    $rows = $db->sql_fetchrowset($result);
    $db->sql_freeresult($result);
    for ($i = 0; $i < sizeof($rows); $i++) {
        $size_format = $rows[$i]['quota_limit'] >= 1048576 ? 'mb' : ($rows[$i]['quota_limit'] >= 1024 ? 'kb' : 'b');
        if ($rows[$i]['quota_limit'] >= 1048576) {
            $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1048576 * 100) / 100;
        } elseif ($rows[$i]['quota_limit'] >= 1024) {
            $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1024 * 100) / 100;
        }
        $template->assign_block_vars('limit_row', array('QUOTA_NAME' => $rows[$i]['quota_desc'], 'QUOTA_ID' => $rows[$i]['quota_limit_id'], 'S_FILESIZE' => size_select('size_select_list[]', $size_format), 'U_VIEW' => append_sid('admin_attachments.' . PHP_EXT . '?mode=' . $mode . '&amp;e_mode=view_quota&amp;quota_id=' . $rows[$i]['quota_limit_id']), 'MAX_FILESIZE' => $rows[$i]['quota_limit']));
    }
}
if ($mode == 'quota' && $e_mode == 'view_quota') {
    $quota_id = request_var('quota_id', 0);
    if (!$quota_id) {
        message_die(GENERAL_MESSAGE, 'Invalid Call');
    }
    $template->assign_block_vars('switch_quota_limit_desc', array());
    $sql = "SELECT * FROM " . QUOTA_LIMITS_TABLE . " WHERE quota_limit_id = " . (int) $quota_id . " LIMIT 1";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    $template->assign_vars(array('L_QUOTA_LIMIT_DESC' => $row['quota_desc'], 'L_ASSIGNED_USERS' => $lang['Assigned_users'], 'L_ASSIGNED_GROUPS' => $lang['Assigned_groups'], 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota']));
    $sql = 'SELECT q.user_id, u.username, q.quota_type
		FROM ' . QUOTA_TABLE . ' q, ' . USERS_TABLE . ' u
				<td class="row2"><?php echo download_select('download_mode', $group_id); ?></td>
			</tr>
			<tr>
				<td class="row1" width="35%"><b><?php echo $_CLASS['core_user']->lang['UPLOAD_ICON']; ?>: </b></td>
				<td class="row2" align="left">
					<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td align="center"><select name="upload_icon" onChange="update_image(this.options[selectedIndex].value);"><option value="no_image"<?php echo (($no_image_select) ? ' selected="selected"' : ''); ?>><?php echo $_CLASS['core_user']->lang['NO_IMAGE']; ?></option><?php echo $filename_list ?></select></td>
						<td width="50" align="center" valign="middle">&nbsp;<img src="<?php echo (($no_image_select) ? 'images/spacer.gif' : $img_path . '/' . $upload_icon) ?>" name="image" border="0" alt="" title="" />&nbsp;</td>
					</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td class="row1" width="35%"><b><?php echo $_CLASS['core_user']->lang['MAX_EXTGROUP_FILESIZE']; ?>: </b></td>
				<td class="row2"><input type="text" size="3" maxlength="15" name="max_filesize" class="post" value="<?php echo $max_filesize; ?>" /> <?php echo size_select('size_select', $size_format); ?></td>
			</tr>
			<tr>
				<td class="row1" width="35%" valign="top"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td colspan="2"><b><?php echo $_CLASS['core_user']->lang['ASSIGNED_EXTENSIONS']; ?>: </b></td></tr>
					<tr><td class="row1" width="20"> &#187; &nbsp;</td>
					<td class="row1"><div id="ext" style="margin:0px; width:200px">&nbsp;<?php
							$i = 0;
							foreach ($extensions as $num => $row)
							{
								if ($row['group_id'] == $group_id && $group_id)
								{
									echo ($i) ? ', ' . $row['extension'] : $row['extension'];
									$i++;
								}
							}
					?></div></td></tr>
Example #4
0
             $max_add_filesize = round($max_add_filesize / 1024 * 100) / 100;
         }
     }
     $template->assign_vars(array('L_MANAGE_QUOTAS_TITLE' => $lang['Manage_quotas'], 'L_MANAGE_QUOTAS_EXPLAIN' => $lang['Manage_quotas_explain'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_EDIT' => $lang['Edit'], 'L_VIEW' => $lang['View'], 'L_DESCRIPTION' => $lang['Description'], 'L_SIZE' => $lang['Max_filesize_attach'], 'L_ADD_NEW' => $lang['Add_new'], 'L_DELETE' => $lang['Delete'], 'MAX_FILESIZE' => $max_add_filesize, 'QUOTA_LIMIT_SETTINGS' => '', 'S_FILESIZE' => size_select('add_size_select', $size), 'L_REMOVE_SELECTED' => $lang['Remove_selected'], 'S_HIDDEN_FIELDS' => '', 'S_ATTACH_ACTION' => URL::admin("&amp;do=attachments&amp;mode=quota")));
     $result = $db->sql_query("SELECT * FROM " . QUOTA_LIMITS_TABLE . " ORDER BY quota_limit DESC");
     $rows = $db->sql_fetchrowset($result);
     for ($i = 0; $i < count($rows); $i++) {
         $size_format = $rows[$i]['quota_limit'] >= 1048576 ? 'mb' : ($rows[$i]['quota_limit'] >= 1024 ? 'kb' : 'b');
         if ($rows[$i]['quota_limit'] >= 1048576) {
             $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1048576 * 100) / 100;
         } else {
             if ($rows[$i]['quota_limit'] >= 1024) {
                 $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1024 * 100) / 100;
             }
         }
         $template->assign_block_vars('limit_row', array('QUOTA_NAME' => $rows[$i]['quota_desc'], 'QUOTA_ID' => $rows[$i]['quota_limit_id'], 'S_FILESIZE' => size_select('size_select_list[]', $size_format), 'U_VIEW' => URL::admin("&amp;do=attachments&amp;mode={$mode}&amp;e_mode=view_quota&amp;quota_id=" . $rows[$i]['quota_limit_id']), 'MAX_FILESIZE' => $rows[$i]['quota_limit']));
     }
 } else {
     if ($mode == 'quota' && $e_mode == 'view_quota') {
         if (isset($_POST['quota_id']) || isset($_GET['quota_id'])) {
             $quota_id = isset($_POST['quota_id']) ? intval($_POST['quota_id']) : intval($_GET['quota_id']);
         } else {
             message_die(GENERAL_MESSAGE, 'Invalid Call');
             return;
         }
         $template->assign_block_vars('switch_quota_limit_desc', array());
         $result = $db->sql_query("SELECT * FROM " . QUOTA_LIMITS_TABLE . " WHERE quota_limit_id = " . $quota_id . " LIMIT 1");
         $row = $db->sql_fetchrow($result);
         $template->assign_vars(array('L_QUOTA_LIMIT_DESC' => $row['quota_desc'], 'L_ASSIGNED_USERS' => $lang['Assigned_users'], 'L_ASSIGNED_GROUPS' => $lang['Assigned_groups'], 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota']));
         $sql = "SELECT q.user_id, u.username, q.quota_type\n\tFROM " . QUOTA_TABLE . " q, " . USERS_TABLE . " u\n\tWHERE q.quota_limit_id = " . $quota_id . " AND q.user_id <> 0 AND q.user_id = u.user_id";
         $result = $db->sql_query($sql);
    $template->assign_vars(array('L_MANAGE_QUOTAS_TITLE' => $lang['Manage_quotas'], 'L_MANAGE_QUOTAS_EXPLAIN' => $lang['Manage_quotas_explain'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_EDIT' => $lang['Edit'], 'L_VIEW' => $lang['View'], 'L_DESCRIPTION' => $lang['Description'], 'L_SIZE' => $lang['Max_filesize_attach'], 'L_ADD_NEW' => $lang['Add_new'], 'L_DELETE' => $lang['Delete'], 'MAX_FILESIZE' => $max_add_filesize, 'S_FILESIZE' => size_select('add_size_select', $size), 'L_REMOVE_SELECTED' => $lang['Remove_selected'], 'S_ATTACH_ACTION' => append_sid('admin_attachments.php?mode=quota')));
    $sql = "SELECT * FROM " . QUOTA_LIMITS_TABLE . " ORDER BY quota_limit DESC";
    if (!($result = DB()->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not get quota limits', '', __LINE__, __FILE__, $sql);
    }
    $rows = DB()->sql_fetchrowset($result);
    for ($i = 0; $i < count($rows); $i++) {
        $size_format = $rows[$i]['quota_limit'] >= 1048576 ? 'mb' : ($rows[$i]['quota_limit'] >= 1024 ? 'kb' : 'b');
        if ($rows[$i]['quota_limit'] >= 1048576) {
            $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1048576 * 100) / 100;
        } else {
            if ($rows[$i]['quota_limit'] >= 1024) {
                $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1024 * 100) / 100;
            }
        }
        $template->assign_block_vars('limit_row', array('QUOTA_NAME' => stripslashes($rows[$i]['quota_desc']), 'QUOTA_ID' => $rows[$i]['quota_limit_id'], 'S_FILESIZE' => size_select('size_select_list[]', $size_format), 'U_VIEW' => append_sid("admin_attachments.php?mode={$mode}&amp;e_mode=view_quota&amp;quota_id=" . $rows[$i]['quota_limit_id']), 'MAX_FILESIZE' => $rows[$i]['quota_limit']));
    }
}
if ($mode == 'quota' && $e_mode == 'view_quota') {
    if (isset($HTTP_POST_VARS['quota_id']) || isset($HTTP_GET_VARS['quota_id'])) {
        $quota_id = isset($HTTP_POST_VARS['quota_id']) ? intval($HTTP_POST_VARS['quota_id']) : intval($HTTP_GET_VARS['quota_id']);
    } else {
        message_die(GENERAL_MESSAGE, 'Invalid Call');
    }
    $template->assign_block_vars('switch_quota_limit_desc', array());
    $sql = "SELECT * FROM " . QUOTA_LIMITS_TABLE . " WHERE quota_limit_id = " . $quota_id . " LIMIT 1";
    if (!($result = DB()->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not get quota limits', '', __LINE__, __FILE__, $sql);
    }
    $row = DB()->sql_fetchrow($result);
    $template->assign_vars(array('L_QUOTA_LIMIT_DESC' => $row['quota_desc'], 'L_ASSIGNED_USERS' => $lang['Assigned_users'], 'L_ASSIGNED_GROUPS' => $lang['Assigned_groups'], 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota']));