} $db->sql_freeresult($result); if (sizeof($group_user)) { $sql = "UPDATE " . USERS_TABLE . " \n\t\t\t\tSET user_level = " . USER . " \n\t\t\t\tWHERE user_id IN (" . implode(', ', $group_user) . ") AND user_level = " . MOD; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql); } } message_die(GENERAL_MESSAGE, $message); } } else { if ($mode == 'user' && (isset($_POST['username']) || $user_id) || $mode == 'group' && $group_id) { if (isset($_POST['username'])) { // Begin PNphpBB2 Module // $this_userdata = get_userdata($_POST['username'], true); $this_userdata = phpbb_get_userdata($_POST['username'], true); // End PNphpBB2 Module if (!is_array($this_userdata)) { message_die(GENERAL_MESSAGE, $lang['No_such_user']); } $user_id = $this_userdata['user_id']; } // // Front end // // Begin PNphpBB2 Categories Hierarchie Mod // $sql = "SELECT f.* // FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c // WHERE f.cat_id = c.cat_id // ORDER BY c.cat_order, f.forum_order ASC"; // get cat ids
// Start session management $userdata = session_pagestart($user_ip, PAGE_PROFILE); init_userprefs($userdata); // session id check if ($sid == '' || $sid != $userdata['session_id']) { //message_die(GENERAL_ERROR, 'Invalid_session'); message_die(GENERAL_ERROR, 'Invalid_session:<br >' . $sid . '<br />' . $userdata['session_id']); } // Obtain initial var settings $user_id = get_var(POST_USERS_URL, 0); if (!$user_id) { message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } // Begin PNphpBB2 Module // $profiledata = get_userdata($user_id); $profiledata = phpbb_get_userdata($user_id); // End PNphpBB2 Module if ($profiledata['user_id'] != $userdata['user_id'] && $userdata['user_level'] != ADMIN) { message_die(GENERAL_MESSAGE, $lang['Not_Authorised']); } $page_title = $lang['User_acp_title']; include $phpbb_root_path . 'includes/page_header.' . $phpEx; $language = $board_config['default_lang']; if (!file_exists($phpbb_root_path . 'language/lang_' . $language . '/lang_admin_attach.' . $phpEx)) { $language = $attach_config['board_lang']; } include $phpbb_root_path . 'language/lang_' . $language . '/lang_admin_attach.' . $phpEx; $start = get_var('start', 0); $sort_order = get_var('order', 'ASC'); $sort_order = $sort_order == 'ASC' ? 'ASC' : 'DESC'; $mode = get_var('mode', '');
} else { $group_type = isset($_POST['group_type']) ? intval($_POST['group_type']) : GROUP_OPEN; $group_name = isset($_POST['group_name']) ? htmlspecialchars(trim($_POST['group_name'])) : ''; $group_description = isset($_POST['group_description']) ? trim($_POST['group_description']) : ''; $group_moderator = isset($_POST['username']) ? $_POST['username'] : ''; $delete_old_moderator = isset($_POST['delete_old_moderator']) ? true : false; if ($group_name == '') { message_die(GENERAL_MESSAGE, $lang['No_group_name']); } else { if ($group_moderator == '') { message_die(GENERAL_MESSAGE, $lang['No_group_moderator']); } } // Begin PNphpBB2 Module // $this_userdata = get_userdata($group_moderator, true); $this_userdata = phpbb_get_userdata($group_moderator, true); // End PNphpBB2 Module $group_moderator = $this_userdata['user_id']; if (!$group_moderator) { message_die(GENERAL_MESSAGE, $lang['No_group_moderator']); } if ($mode == "editgroup") { $sql = "SELECT *\n\t\t\t\tFROM " . GROUPS_TABLE . "\n\t\t\t\tWHERE group_single_user <> " . TRUE . "\n\t\t\t\tAND group_id = " . $group_id; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql); } if (!($group_info = $db->sql_fetchrow($result))) { message_die(GENERAL_MESSAGE, $lang['Group_not_exist']); } if ($group_info['group_moderator'] != $group_moderator) { if ($delete_old_moderator) {
/** * Upload an Attachment to Filespace (intern) */ function upload_attachment() { global $_FILES, $db, $_POST, $error, $error_msg, $lang, $attach_config, $userdata, $upload_dir, $forum_id; $this->post_attach = $this->filename != '' ? TRUE : FALSE; if ($this->post_attach) { $r_file = trim(basename(htmlspecialchars($this->filename))); $file = $_FILES['fileupload']['tmp_name']; $this->type = $_FILES['fileupload']['type']; if (isset($_FILES['fileupload']['size']) && $_FILES['fileupload']['size'] == 0) { message_die(GENERAL_ERROR, 'Tried to upload empty file'); } // Opera add the name to the mime type $this->type = strstr($this->type, '; name') ? str_replace(strstr($this->type, '; name'), '', $this->type) : $this->type; $this->type = strtolower($this->type); $this->extension = strtolower(get_extension($this->filename)); $this->filesize = @filesize($file); $this->filesize = intval($this->filesize); $sql = 'SELECT g.allow_group, g.max_filesize, g.cat_id, g.forum_permissions FROM ' . EXTENSION_GROUPS_TABLE . ' g, ' . EXTENSIONS_TABLE . " e\n\t\t\t\tWHERE g.group_id = e.group_id\n\t\t\t\t\tAND e.extension = '" . attach_mod_sql_escape($this->extension) . "'\n\t\t\t\tLIMIT 1"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query Extensions.', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $allowed_filesize = $row['max_filesize'] ? $row['max_filesize'] : $attach_config['max_filesize']; $cat_id = intval($row['cat_id']); $auth_cache = trim($row['forum_permissions']); // check Filename if (preg_match("#[\\/:*?\"<>|]#i", $this->filename)) { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['Invalid_filename'], htmlspecialchars($this->filename)); } // check php upload-size if (!$error && $file == 'none') { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $ini_val = phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; $max_size = @$ini_val('upload_max_filesize'); if ($max_size == '') { $error_msg .= $lang['Attachment_php_size_na']; } else { $error_msg .= sprintf($lang['Attachment_php_size_overrun'], $max_size); } } // Check Extension if (!$error && intval($row['allow_group']) == 0) { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['Disallowed_extension'], htmlspecialchars($this->extension)); } // Check Forum Permissions if (!$error && $this->page != PAGE_PRIVMSGS && $userdata['user_level'] != ADMIN && !is_forum_authed($auth_cache, $forum_id) && trim($auth_cache) != '') { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['Disallowed_extension_within_forum'], htmlspecialchars($this->extension)); } // Upload File $this->thumbnail = 0; if (!$error) { // Prepare Values $this->filetime = time(); $this->filename = $r_file; // physical filename $this->attach_filename = strtolower($this->filename); // To re-add cryptic filenames, change this variable to true $cryptic = false; if (!$cryptic) { $this->attach_filename = html_entity_decode(trim(stripslashes($this->attach_filename))); $this->attach_filename = delete_extension($this->attach_filename); $this->attach_filename = str_replace(array(' ', '-'), array('_', '_'), $this->attach_filename); $this->attach_filename = str_replace('__', '_', $this->attach_filename); $this->attach_filename = str_replace(array(',', '.', '!', '?', 'ü', 'Ü', 'ö', 'Ö', 'ä', 'Ä', ';', ':', '@', "'", '"', '&'), array('', '', '', '', 'ue', 'ue', 'oe', 'oe', 'ae', 'ae', '', '', '', '', '', 'and'), $this->attach_filename); $this->attach_filename = str_replace(array('$', 'ß', '>', '<', '§', '%', '=', '/', '(', ')', '#', '*', '+', "\\", '{', '}', '[', ']'), array('dollar', 'ss', 'greater', 'lower', 'paragraph', 'percent', 'equal', '', '', '', '', '', '', '', '', '', '', ''), $this->attach_filename); // Remove non-latin characters $this->attach_filename = preg_replace("/([ÂÃ])([€-¿])/e", "chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)", $this->attach_filename); $this->attach_filename = rawurlencode($this->attach_filename); $this->attach_filename = preg_replace("/(%[0-9A-F]{1,2})/i", '', $this->attach_filename); $this->attach_filename = trim($this->attach_filename); $new_filename = $this->attach_filename; if (!$new_filename) { $u_id = intval($userdata['user_id']) == ANONYMOUS ? 0 : intval($userdata['user_id']); $new_filename = $u_id . '_' . $this->filetime . '.' . $this->extension; } do { $this->attach_filename = $new_filename . '_' . substr(rand(), 0, 3) . '.' . $this->extension; } while (physical_filename_already_stored($this->attach_filename)); unset($new_filename); } else { $u_id = intval($userdata['user_id']) == ANONYMOUS ? 0 : intval($userdata['user_id']); $this->attach_filename = $u_id . '_' . $this->filetime . '.' . $this->extension; } // Do we have to create a thumbnail ? if ($cat_id == IMAGE_CAT && intval($attach_config['img_create_thumbnail'])) { $this->thumbnail = 1; } } if ($error) { $this->post_attach = FALSE; return; } // Upload Attachment if (!$error) { if (!intval($attach_config['allow_ftp_upload'])) { // Descide the Upload method $ini_val = phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; $safe_mode = @$ini_val('safe_mode'); if (@$ini_val('open_basedir')) { if (@phpversion() < '4.0.3') { $upload_mode = 'copy'; } else { $upload_mode = 'move'; } } else { if (@$ini_val('safe_mode')) { $upload_mode = 'move'; } else { $upload_mode = 'copy'; } } } else { $upload_mode = 'ftp'; } // Ok, upload the Attachment if (!$error) { $this->move_uploaded_attachment($upload_mode, $file); } } // Now, check filesize parameters if (!$error) { if ($upload_mode != 'ftp' && !$this->filesize) { $this->filesize = intval(@filesize($upload_dir . '/' . $this->attach_filename)); } } // Check Image Size, if it's an image if (!$error && $userdata['user_level'] != ADMIN && $cat_id == IMAGE_CAT) { list($width, $height) = image_getdimension($upload_dir . '/' . $this->attach_filename); if ($width != 0 && $height != 0 && intval($attach_config['img_max_width']) != 0 && intval($attach_config['img_max_height']) != 0) { if ($width > intval($attach_config['img_max_width']) || $height > intval($attach_config['img_max_height'])) { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['Error_imagesize'], intval($attach_config['img_max_width']), intval($attach_config['img_max_height'])); } } } // check Filesize if (!$error && $allowed_filesize != 0 && $this->filesize > $allowed_filesize && $userdata['user_level'] != ADMIN) { $size_lang = $allowed_filesize >= 1048576 ? $lang['MB'] : ($allowed_filesize >= 1024 ? $lang['KB'] : $lang['Bytes']); if ($allowed_filesize >= 1048576) { $allowed_filesize = round($allowed_filesize / 1048576 * 100) / 100; } else { if ($allowed_filesize >= 1024) { $allowed_filesize = round($allowed_filesize / 1024 * 100) / 100; } } $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['Attachment_too_big'], $allowed_filesize, $size_lang); } // Check our complete quota if ($attach_config['attachment_quota']) { $sql = 'SELECT sum(filesize) as total FROM ' . ATTACHMENTS_DESC_TABLE; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query total filesize', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $total_filesize = $row['total']; if ($total_filesize + $this->filesize > $attach_config['attachment_quota']) { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= $lang['Attach_quota_reached']; } } $this->get_quota_limits($userdata); // Check our user quota if ($this->page != PAGE_PRIVMSGS) { if ($attach_config['upload_filesize_limit']) { $sql = 'SELECT attach_id FROM ' . ATTACHMENTS_TABLE . ' WHERE user_id_1 = ' . (int) $userdata['user_id'] . ' AND privmsgs_id = 0 GROUP BY attach_id'; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Couldn\'t query attachments', '', __LINE__, __FILE__, $sql); } $attach_ids = $db->sql_fetchrowset($result); $num_attach_ids = $db->sql_numrows($result); $db->sql_freeresult($result); $attach_id = array(); for ($i = 0; $i < $num_attach_ids; $i++) { $attach_id[] = intval($attach_ids[$i]['attach_id']); } if ($num_attach_ids > 0) { // Now get the total filesize $sql = 'SELECT sum(filesize) as total FROM ' . ATTACHMENTS_DESC_TABLE . ' WHERE attach_id IN (' . implode(', ', $attach_id) . ')'; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query total filesize', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $total_filesize = $row['total']; } else { $total_filesize = 0; } if ($total_filesize + $this->filesize > $attach_config['upload_filesize_limit']) { $upload_filesize_limit = $attach_config['upload_filesize_limit']; $size_lang = $upload_filesize_limit >= 1048576 ? $lang['MB'] : ($upload_filesize_limit >= 1024 ? $lang['KB'] : $lang['Bytes']); if ($upload_filesize_limit >= 1048576) { $upload_filesize_limit = round($upload_filesize_limit / 1048576 * 100) / 100; } else { if ($upload_filesize_limit >= 1024) { $upload_filesize_limit = round($upload_filesize_limit / 1024 * 100) / 100; } } $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['User_upload_quota_reached'], $upload_filesize_limit, $size_lang); } } } // If we are at Private Messaging, check our PM Quota if ($this->page == PAGE_PRIVMSGS) { if ($attach_config['pm_filesize_limit']) { $total_filesize = get_total_attach_pm_filesize('from_user', $userdata['user_id']); if ($total_filesize + $this->filesize > $attach_config['pm_filesize_limit']) { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= $lang['Attach_quota_sender_pm_reached']; } } $to_user = isset($_POST['username']) ? $_POST['username'] : ''; // Check Receivers PM Quota if (!empty($to_user) && $userdata['user_level'] != ADMIN) { // Begin PNphpBB2 Module // $u_data = get_userdata($to_user, true); $u_data = phpbb_get_userdata($user_id, true); // End PNphpBB2 Module $user_id = (int) $u_data['user_id']; $this->get_quota_limits($u_data, $user_id); if ($attach_config['pm_filesize_limit']) { $total_filesize = get_total_attach_pm_filesize('to_user', $user_id); if ($total_filesize + $this->filesize > $attach_config['pm_filesize_limit']) { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['Attach_quota_receiver_pm_reached'], $to_user); } } } } if ($error) { unlink_attach($this->attach_filename); unlink_attach($this->attach_filename, MODE_THUMBNAIL); $this->post_attach = FALSE; } } }
* it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ***************************************************************************/ if (!defined('IN_PHPBB')) { die("Hacking attempt"); exit; } if (empty($_GET[POST_USERS_URL]) || $_GET[POST_USERS_URL] == ANONYMOUS) { message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } // Begin PNphpBB2 Module // $profiledata = get_userdata($_GET[POST_USERS_URL]); $profiledata = phpbb_get_userdata($_GET[POST_USERS_URL]); $uid = $_GET['u']; if ($uid) { $userVars = UserUtil::getVars($uid); if (!$profiledata['user_from']) { $profiledata['user_from'] = $userVars['_YLOCATION']; } if (!$profiledata['url']) { $profiledata['url'] = $userVars['_YOURHOMEPAGE']; } if (!$profiledata['user_avatar']) { $profiledata['user_avatar'] = $userVars['_YOURAVATAR']; } if (!$profiledata['user_icq']) { $profiledata['user_icq'] = $userVars['_YICQ']; }
/** * 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, $_POST, $_GET, $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($_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) { 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 // Begin PNphpBB2 Module // $this_userdata = get_userdata($_POST['username'], true); $this_userdata = phpbb_get_userdata($_POST['username'], true); // End PNphpBB2 Module } $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 && $_POST['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($_POST['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($_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); } } }