/** * Called from admin_users.php and admin_groups.php in order to process Quota Settings (admin/admin_users.php:admin/admin_groups.php) */ function attachment_quota_settings($admin_mode, $submit = false, $mode) { global $template, $db, $HTTP_POST_VARS, $HTTP_GET_VARS, $lang, $lang, $phpbb_root_path, $phpEx, $attach_config; // Make sure constants got included include_once $phpbb_root_path . 'attach_mod/includes/constants.' . $phpEx; if (!intval($attach_config['allow_ftp_upload'])) { if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') { $upload_dir = $attach_config['upload_dir']; } else { $upload_dir = $phpbb_root_path . $attach_config['upload_dir']; } } else { $upload_dir = $attach_config['download_path']; } include_once $phpbb_root_path . 'attach_mod/includes/functions_selects.' . $phpEx; include_once $phpbb_root_path . 'attach_mod/includes/functions_admin.' . $phpEx; $user_id = 0; if ($admin_mode == 'user') { // We overwrite submit here... to be sure $submit = isset($HTTP_POST_VARS['submit']) ? true : false; if (!$submit && $mode != 'save') { $user_id = get_var(POST_USERS_URL, 0); $u_name = get_var('username', ''); if (!$user_id && !$u_name) { message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } if ($user_id) { $this_userdata['user_id'] = $user_id; } else { // Get userdata is handling the sanitizing of username $this_userdata = get_userdata($HTTP_POST_VARS['username'], true); } $user_id = (int) $this_userdata['user_id']; } else { $user_id = get_var('id', 0); if (!$user_id) { message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } } } if ($admin_mode == 'user' && !$submit && $mode != 'save') { // Show the contents $sql = 'SELECT quota_limit_id, quota_type FROM ' . QUOTA_TABLE . ' WHERE user_id = ' . (int) $user_id; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Unable to get Quota Settings', '', __LINE__, __FILE__, $sql); } $pm_quota = $upload_quota = 0; if ($row = $db->sql_fetchrow($result)) { do { if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { $upload_quota = $row['quota_limit_id']; } else { if ($row['quota_type'] == QUOTA_PM_LIMIT) { $pm_quota = $row['quota_limit_id']; } } } while ($row = $db->sql_fetchrow($result)); } else { // Set Default Quota Limit $upload_quota = $attach_config['default_upload_quota']; $pm_quota = $attach_config['default_pm_quota']; } $db->sql_freeresult($result); $template->assign_vars(array('S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota), 'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota), 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota'])); } if ($admin_mode == 'user' && $submit && $HTTP_POST_VARS['deleteuser']) { process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, 0); process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, 0); } else { if ($admin_mode == 'user' && $submit && $mode == 'save') { // Get the contents $upload_quota = get_var('user_upload_quota', 0); $pm_quota = get_var('user_pm_quota', 0); process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota); process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota); } } if ($admin_mode == 'group' && $mode == 'newgroup') { return; } if ($admin_mode == 'group' && !$submit && isset($HTTP_POST_VARS['edit'])) { // Get group id again, we do not trust phpBB here, Mods may be installed ;) $group_id = get_var(POST_GROUPS_URL, 0); // Show the contents $sql = 'SELECT quota_limit_id, quota_type FROM ' . QUOTA_TABLE . ' WHERE group_id = ' . (int) $group_id; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Unable to get Quota Settings', '', __LINE__, __FILE__, $sql); } $pm_quota = $upload_quota = 0; if ($row = $db->sql_fetchrow($result)) { do { if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { $upload_quota = $row['quota_limit_id']; } else { if ($row['quota_type'] == QUOTA_PM_LIMIT) { $pm_quota = $row['quota_limit_id']; } } } while ($row = $db->sql_fetchrow($result)); } else { // Set Default Quota Limit $upload_quota = $attach_config['default_upload_quota']; $pm_quota = $attach_config['default_pm_quota']; } $db->sql_freeresult($result); $template->assign_vars(array('S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota), 'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota), 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota'])); } if ($admin_mode == 'group' && $submit && isset($HTTP_POST_VARS['group_delete'])) { $group_id = get_var(POST_GROUPS_URL, 0); process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, 0); process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, 0); } else { if ($admin_mode == 'group' && $submit) { $group_id = get_var(POST_GROUPS_URL, 0); // Get the contents $upload_quota = get_var('group_upload_quota', 0); $pm_quota = get_var('group_pm_quota', 0); process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota); process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota); } } }
function attachment_quota_settings($admin_mode, $submit = FALSE, $mode) { global $template, $db, $HTTP_POST_VARS, $HTTP_GET_VARS, $lang, $group_id, $lang, $phpbb_root_path, $phpEx, $attach_config; @(include_once $phpbb_root_path . 'attach/includes/constants.' . $phpEx); if (!intval($attach_config['allow_ftp_upload'])) { if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') { $upload_dir = $attach_config['upload_dir']; } else { $upload_dir = '../' . $attach_config['upload_dir']; } } else { $upload_dir = $attach_config['download_path']; } include $phpbb_root_path . 'attach/includes/functions_selects.' . $phpEx; include $phpbb_root_path . 'attach/includes/functions_admin.' . $phpEx; if ($admin_mode == 'user') { $submit = isset($HTTP_POST_VARS['submit']) ? TRUE : FALSE; if (!$submit && $mode != 'save') { if (isset($HTTP_GET_VARS[POST_USERS_URL]) || isset($HTTP_POST_VARS[POST_USERS_URL])) { $user_id = isset($HTTP_POST_VARS[POST_USERS_URL]) ? intval($HTTP_POST_VARS[POST_USERS_URL]) : intval($HTTP_GET_VARS[POST_USERS_URL]); $this_userdata['user_id'] = $user_id; if (empty($user_id)) { message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } } else { $u_name = isset($HTTP_POST_VARS['username']) ? htmlspecialchars(trim($HTTP_POST_VARS['username'])) : htmlspecialchars(trim($HTTP_GET_VARS['username'])); $this_userdata = get_userdata($u_name); if (!$this_userdata) { message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } } $user_id = intval($this_userdata['user_id']); } else { $user_id = isset($HTTP_POST_VARS['id']) ? intval($HTTP_POST_VARS['id']) : intval($HTTP_GET_VARS['id']); if (empty($user_id)) { message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } } } if ($admin_mode == 'user' && !$submit && $mode != 'save') { // Show the contents $sql = "SELECT quota_limit_id, quota_type FROM " . QUOTA_TABLE . " WHERE user_id = " . $user_id; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Unable to get Quota Settings', '', __LINE__, __FILE__, $sql); } $pm_quota = -1; $upload_quota = -1; while ($row = $db->sql_fetchrow($result)) { if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { $upload_quota = $row['quota_limit_id']; } else { if ($row['quota_type'] == QUOTA_PM_LIMIT) { $pm_quota = $row['quota_limit_id']; } } } $template->assign_vars(array('S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota), 'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota), 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota'])); } if ($admin_mode == 'user' && $submit && $HTTP_POST_VARS['deleteuser']) { process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, -1); process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, -1); } else { if ($admin_mode == 'user' && $submit && $mode == 'save') { // Get the contents $upload_quota = intval($HTTP_POST_VARS['user_upload_quota']); $pm_quota = intval($HTTP_POST_VARS['user_pm_quota']); if ($upload_quota <= 0) { process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, -1); } else { process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota); } if ($pm_quota <= 0) { process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, -1); } else { process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota); } } } if ($admin_mode == 'group' && $mode == 'newgroup') { return; } else { if ($admin_mode == 'group') { // Get group id again, we do not trust phpBB here, Mods may be installed ;) if (isset($HTTP_POST_VARS[POST_GROUPS_URL]) || isset($HTTP_GET_VARS[POST_GROUPS_URL])) { $group_id = isset($HTTP_POST_VARS[POST_GROUPS_URL]) ? intval($HTTP_POST_VARS[POST_GROUPS_URL]) : intval($HTTP_GET_VARS[POST_GROUPS_URL]); } else { // This should not occur :( $group_id = ''; } } } if ($admin_mode == 'group' && !$submit && isset($HTTP_POST_VARS['edit'])) { // Show the contents $sql = "SELECT quota_limit_id, quota_type FROM " . QUOTA_TABLE . " WHERE group_id = " . $group_id; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Unable to get Quota Settings', '', __LINE__, __FILE__, $sql); } $pm_quota = -1; $upload_quota = -1; while ($row = $db->sql_fetchrow($result)) { if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { $upload_quota = $row['quota_limit_id']; } else { if ($row['quota_type'] == QUOTA_PM_LIMIT) { $pm_quota = $row['quota_limit_id']; } } } $template->assign_vars(array('S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota), 'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota), 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota'])); } if ($admin_mode == 'group' && $submit && isset($HTTP_POST_VARS['group_delete'])) { process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, -1); process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, -1); } else { if ($admin_mode == 'group' && $submit) { // Get the contents $upload_quota = intval($HTTP_POST_VARS['group_upload_quota']); $pm_quota = intval($HTTP_POST_VARS['group_pm_quota']); if ($upload_quota <= 0) { process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, -1); } else { process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota); } if ($pm_quota <= 0) { process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, -1); } else { process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota); } } } }
/** * Called from admin_users.php and admin_groups.php in order to process Quota Settings (admin/admin_users.php:admin/admin_groups.php) */ function attachment_quota_settings($admin_mode, $submit = false, $mode) { global $template, $db, $lang, $lang, $config; // Make sure constants got included include_once IP_ROOT_PATH . ATTACH_MOD_PATH . 'includes/constants.' . PHP_EXT; if (!intval($config['allow_ftp_upload'])) { if ($config['upload_dir'][0] == '/' || $config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':') { $upload_dir = $config['upload_dir']; } else { $upload_dir = IP_ROOT_PATH . $config['upload_dir']; } } else { $upload_dir = $config['download_path']; } $user_id = 0; if ($admin_mode == 'user') { // We overwrite submit here... to be sure $submit = isset($_POST['submit']) ? true : false; if (!$submit && $mode != 'save') { $user_id = request_var(POST_USERS_URL, 0); $u_name = request_var('username', ''); if (!$user_id && !$u_name) { if (!defined('STATUS_404')) { define('STATUS_404', true); } message_die(GENERAL_MESSAGE, 'NO_USER'); } if ($user_id) { $this_userdata['user_id'] = $user_id; } else { // Get userdata is handling the sanitizing of username $this_userdata = get_userdata($_POST['username'], true); } $user_id = (int) $this_userdata['user_id']; } else { $user_id = request_var('id', 0); if (!$user_id) { if (!defined('STATUS_404')) { define('STATUS_404', true); } message_die(GENERAL_MESSAGE, 'NO_USER'); } } } if ($admin_mode == 'user' && !$submit && $mode != 'save') { // Show the contents $sql = 'SELECT quota_limit_id, quota_type FROM ' . QUOTA_TABLE . ' WHERE user_id = ' . (int) $user_id; $result = $db->sql_query($sql); $pm_quota = $upload_quota = 0; if ($row = $db->sql_fetchrow($result)) { do { if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { $upload_quota = $row['quota_limit_id']; } elseif ($row['quota_type'] == QUOTA_PM_LIMIT) { $pm_quota = $row['quota_limit_id']; } } while ($row = $db->sql_fetchrow($result)); } else { // Set Default Quota Limit $upload_quota = $config['default_upload_quota']; $pm_quota = $config['default_pm_quota']; } $db->sql_freeresult($result); $template->assign_vars(array('S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota), 'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota), 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota'])); } if ($admin_mode == 'user' && $submit && $_POST['deleteuser']) { process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, 0); process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, 0); } elseif ($admin_mode == 'user' && $submit && $mode == 'save') { // Get the contents $upload_quota = request_var('user_upload_quota', 0); $pm_quota = request_var('user_pm_quota', 0); process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota); process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota); } if ($admin_mode == 'group' && $mode == 'newgroup') { return; } if ($admin_mode == 'group' && !$submit && (isset($_POST['edit']) || isset($_GET['edit']))) { // Get group id again, we do not trust phpBB here, Mods may be installed ;) $group_id = request_var(POST_GROUPS_URL, 0); // Show the contents $sql = 'SELECT quota_limit_id, quota_type FROM ' . QUOTA_TABLE . ' WHERE group_id = ' . (int) $group_id; $result = $db->sql_query($sql); $pm_quota = $upload_quota = 0; if ($row = $db->sql_fetchrow($result)) { do { if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { $upload_quota = $row['quota_limit_id']; } elseif ($row['quota_type'] == QUOTA_PM_LIMIT) { $pm_quota = $row['quota_limit_id']; } } while ($row = $db->sql_fetchrow($result)); } else { // Set Default Quota Limit $upload_quota = $config['default_upload_quota']; $pm_quota = $config['default_pm_quota']; } $db->sql_freeresult($result); $template->assign_vars(array('S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota), 'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota), 'L_UPLOAD_QUOTA' => $lang['Upload_quota'], 'L_PM_QUOTA' => $lang['Pm_quota'])); } if ($admin_mode == 'group' && $submit && isset($_POST['group_delete'])) { $group_id = request_var(POST_GROUPS_URL, 0); process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, 0); process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, 0); } elseif ($admin_mode == 'group' && $submit) { $group_id = request_var(POST_GROUPS_URL, 0); // Get the contents $upload_quota = request_var('group_upload_quota', 0); $pm_quota = request_var('group_pm_quota', 0); process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota); process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota); } }
/** * Called from admin_users.php and admin_groups.php in order to process Quota Settings (admin/admin_users.php:admin/admin_groups.php) */ function attachment_quota_settings($admin_mode, $submit = false, $mode) { global $template, $lang, $attach_config; if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') { $upload_dir = $attach_config['upload_dir']; } else { $upload_dir = BB_ROOT . $attach_config['upload_dir']; } include ATTACH_DIR . 'includes/functions_selects.php'; if (!function_exists("process_quota_settings")) { include ATTACH_DIR . 'includes/functions_admin.php'; } $user_id = 0; if ($admin_mode == 'user') { // We overwrite submit here... to be sure $submit = isset($_POST['submit']) ? true : false; if (!$submit && $mode != 'save') { $user_id = get_var(POST_USERS_URL, 0); $u_name = get_var('username', ''); if (!$user_id && !$u_name) { bb_die($lang['NO_USER_ID_SPECIFIED']); } if ($user_id) { $this_userdata['user_id'] = $user_id; } else { // Get userdata is handling the sanitizing of username $this_userdata = get_userdata($_POST['username'], true); } $user_id = (int) $this_userdata['user_id']; } else { $user_id = get_var('id', 0); if (!$user_id) { bb_die($lang['NO_USER_ID_SPECIFIED']); } } } if ($admin_mode == 'user' && !$submit && $mode != 'save') { // Show the contents $sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE user_id = ' . (int) $user_id; if (!($result = DB()->sql_query($sql))) { bb_die('Unable to get quota settings #1'); } $pm_quota = $upload_quota = 0; if ($row = DB()->sql_fetchrow($result)) { do { if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { $upload_quota = $row['quota_limit_id']; } else { if ($row['quota_type'] == QUOTA_PM_LIMIT) { $pm_quota = $row['quota_limit_id']; } } } while ($row = DB()->sql_fetchrow($result)); } else { // Set Default Quota Limit $upload_quota = $attach_config['default_upload_quota']; $pm_quota = $attach_config['default_pm_quota']; } DB()->sql_freeresult($result); $template->assign_vars(array('S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota), 'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota))); } if ($admin_mode == 'user' && $submit && @$_POST['delete_user']) { process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, 0); process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, 0); } else { if ($admin_mode == 'user' && $submit && $mode == 'save') { // Get the contents $upload_quota = get_var('user_upload_quota', 0); $pm_quota = get_var('user_pm_quota', 0); process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota); process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota); } } if ($admin_mode == 'group' && $mode == 'newgroup') { return; } if ($admin_mode == 'group' && !$submit && isset($_POST['edit'])) { // Get group id again $group_id = get_var(POST_GROUPS_URL, 0); // Show the contents $sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE group_id = ' . (int) $group_id; if (!($result = DB()->sql_query($sql))) { bb_die('Unable to get quota settings #2'); } $pm_quota = $upload_quota = 0; if ($row = DB()->sql_fetchrow($result)) { do { if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { $upload_quota = $row['quota_limit_id']; } else { if ($row['quota_type'] == QUOTA_PM_LIMIT) { $pm_quota = $row['quota_limit_id']; } } } while ($row = DB()->sql_fetchrow($result)); } else { // Set Default Quota Limit $upload_quota = $attach_config['default_upload_quota']; $pm_quota = $attach_config['default_pm_quota']; } DB()->sql_freeresult($result); $template->assign_vars(array('S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota), 'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota))); } if ($admin_mode == 'group' && $submit && isset($_POST['group_delete'])) { $group_id = get_var(POST_GROUPS_URL, 0); process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, 0); process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, 0); } else { if ($admin_mode == 'group' && $submit) { $group_id = get_var(POST_GROUPS_URL, 0); // Get the contents $upload_quota = get_var('group_upload_quota', 0); $pm_quota = get_var('group_pm_quota', 0); process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota); process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota); } } }