function udb_authenticate() { global $HTTP_COOKIE_VARS, $USER_DATA, $UDB_DB_LINK_ID, $UDB_DB_NAME_PREFIX, $CONFIG; // For error checking $CONFIG['TABLE_USERS'] = '**ERROR**'; $default_group = array('group_id' => PHPBB_GUEST_GROUP, 'group_name' => 'Unknown', 'has_admin_access' => 0, 'can_send_ecards' => 0, 'can_rate_pictures' => 0, 'can_post_comments' => 0, 'can_upload_pictures' => 0, 'can_create_albums' => 0, 'pub_upl_need_approval' => 1, 'priv_upl_need_approval' => 1, 'upload_form_config' => 0, 'custom_user_upload' => 0, 'num_file_upload' => 0, 'num_URI_upload' => 0, 'has_admin_access' => 0, 'can_see_all_albums' => 0, 'groups' => array(PHPBB_GUEST_GROUP)); // Retrieve cookie stored login information if (!isset($HTTP_COOKIE_VARS[PHPBB_COOKIE_PREFIX . '_data'])) { $cookie_uid = 0; $cookie_pass = '******'; } else { $sessiondata = unserialize($HTTP_COOKIE_VARS[PHPBB_COOKIE_PREFIX . '_data']); if (is_array($sessiondata)) { $cookie_uid = isset($sessiondata['userid']) ? intval($sessiondata['userid']) : 0; $cookie_pass = isset($sessiondata['autologinid']) ? addslashes($sessiondata['autologinid']) : '*'; } else { $cookie_uid = 0; $cookie_pass = '******'; } } // If autologin was not selected, we need to use the sessions table if ($cookie_uid && !$cookie_pass && isset($HTTP_COOKIE_VARS[PHPBB_COOKIE_PREFIX . '_sid'])) { $session_id = addslashes($HTTP_COOKIE_VARS[PHPBB_COOKIE_PREFIX . '_sid']); $sql = "SELECT user_id, username as user_name, user_level " . "FROM " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_SESSION_TABLE . " " . "INNER JOIN " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_USER_TABLE . " ON session_user_id = user_id " . "WHERE session_id='{$session_id}' AND session_user_id ='{$cookie_uid}' AND user_active='1'"; } else { $sql = "SELECT user_id, username as user_name, user_level " . "FROM " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_USER_TABLE . " " . "WHERE user_id='{$cookie_uid}' AND user_password='******' AND user_active='1'"; } $result = db_query($sql, $UDB_DB_LINK_ID); if (mysql_num_rows($result)) { $USER_DATA = mysql_fetch_array($result); mysql_free_result($result); $USER_DATA['groups'] = array(); if ($USER_DATA['user_id'] == "-1") { define('USER_ID', 0); } else { define('USER_ID', (int) $USER_DATA['user_id']); } define('USER_NAME', $USER_DATA['user_name']); // Define the basic groups if ($USER_DATA['user_id'] == "-1") { array_push($USER_DATA['groups'], PHPBB_GUEST_GROUP); } else { if ($USER_DATA['user_level'] == 1) { array_push($USER_DATA['groups'], PHPBB_ADMIN_GROUP); } array_push($USER_DATA['groups'], PHPBB_MEMBERS_GROUP); } // Retrieve the groups the user is a member of $sql = "SELECT (ug.group_id + 5) as group_id " . "FROM " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_UGROUP_TABLE . " as ug " . "LEFT JOIN " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_GROUP_TABLE . " as g ON ug.group_id = g.group_id " . "WHERE user_id = " . USER_ID . " AND user_pending = 0 AND group_single_user = 0"; $result = db_query($sql, $UDB_DB_LINK_ID); while ($row = mysql_fetch_array($result)) { array_push($USER_DATA['groups'], $row['group_id']); } mysql_free_result($result); $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')'; // Default group data $USER_DATA['group_quota'] = 1; $USER_DATA['can_rate_pictures'] = 0; $USER_DATA['can_send_ecards'] = 0; $USER_DATA['can_post_comments'] = 0; $USER_DATA['can_upload_pictures'] = 0; $USER_DATA['can_create_albums'] = 0; $USER_DATA['pub_upl_need_approval'] = 1; $USER_DATA['priv_upl_need_approval'] = 1; $USER_DATA['upload_form_config'] = 0; $USER_DATA['num_file_upload'] = 0; $USER_DATA['num_URI_upload'] = 0; $USER_DATA['custom_user_upload'] = 0; $USER_DATA = array_merge($USER_DATA, cpgGetUserData($USER_DATA['groups'][0], $USER_DATA['groups'], PHPBB_GUEST_GROUP)); define('USER_GROUP', ''); define('USER_GROUP_SET', $user_group_set); define('USER_IS_ADMIN', $USER_DATA['user_level'] == 1); define('USER_CAN_SEND_ECARDS', (int) $USER_DATA['can_send_ecards']); define('USER_CAN_RATE_PICTURES', (int) $USER_DATA['can_rate_pictures']); define('USER_CAN_POST_COMMENTS', (int) $USER_DATA['can_post_comments']); define('USER_CAN_UPLOAD_PICTURES', (int) $USER_DATA['can_upload_pictures']); define('USER_CAN_CREATE_ALBUMS', (int) $USER_DATA['can_create_albums']); define('USER_UPLOAD_FORM', (int) $USER_DATA['upload_form_config']); define('CUSTOMIZE_UPLOAD_FORM', (int) $USER_DATA['custom_user_upload']); define('NUM_FILE_BOXES', (int) $USER_DATA['num_file_upload']); define('NUM_URI_BOXES', (int) $USER_DATA['num_URI_upload']); } else { $USER_DATA = cpgGetUserData(PHPBB_GUEST_GROUP, array(), PHPBB_GUEST_GROUP); define('USER_ID', 0); define('USER_NAME', 'Anonymous'); define('USER_GROUP_SET', '(' . PHPBB_GUEST_GROUP . ')'); define('USER_IS_ADMIN', 0); define('USER_CAN_SEND_ECARDS', (int) $USER_DATA['can_send_ecards']); define('USER_CAN_RATE_PICTURES', (int) $USER_DATA['can_rate_pictures']); define('USER_CAN_POST_COMMENTS', (int) $USER_DATA['can_post_comments']); define('USER_CAN_UPLOAD_PICTURES', (int) $USER_DATA['can_upload_pictures']); define('USER_CAN_CREATE_ALBUMS', 0); define('USER_UPLOAD_FORM', (int) $USER_DATA['upload_form_config']); define('CUSTOMIZE_UPLOAD_FORM', (int) $USER_DATA['custom_user_upload']); define('NUM_FILE_BOXES', (int) $USER_DATA['num_file_upload']); define('NUM_URI_BOXES', (int) $USER_DATA['num_URI_upload']); mysql_free_result($result); } }
function udb_authenticate() { global $HTTP_COOKIE_VARS, $USER_DATA, $UDB_DB_LINK_ID, $UDB_DB_NAME_PREFIX, $CONFIG; global $HTTP_SERVER_VARS, $HTTP_X_FORWARDED_FOR, $HTTP_PROXY_USER, $REMOTE_ADDR; global $password, $username, $pwseed, $settings, $ID_MEMBER, $realname, $txt, $user_info, $user_settings; $pwseed = SMF_PASSWD_SEED; session_start(); reloadSettings(); LoadUserSettings(); // For error checking $CONFIG['TABLE_USERS'] = '**ERROR**'; // get first 50 chars $HTTP_USER_AGENT = substr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 0, 50); $REMOTE_ADDR = substr($HTTP_SERVER_VARS['REMOTE_ADDR'], 0, 50); /* If the user is a guest, initialize all the critial user settings */ if (!$ID_MEMBER) { $USER_DATA = cpgGetUserData(SMF_GUEST_GROUP, array(SMF_GUEST_GROUP), SMF_GUEST_GROUP); define('USER_ID', 0); define('USER_NAME', 'Anonymous'); define('USER_GROUP_SET', '(' . SMF_GUEST_GROUP . ')'); define('USER_IS_ADMIN', 0); define('USER_CAN_SEND_ECARDS', (int) $USER_DATA['can_send_ecards']); define('USER_CAN_RATE_PICTURES', (int) $USER_DATA['can_rate_pictures']); define('USER_CAN_POST_COMMENTS', (int) $USER_DATA['can_post_comments']); define('USER_CAN_UPLOAD_PICTURES', (int) $USER_DATA['can_upload_pictures']); define('USER_CAN_CREATE_ALBUMS', 0); define('USER_UPLOAD_FORM', (int) $USER_DATA['upload_form_config']); define('CUSTOMIZE_UPLOAD_FORM', (int) $USER_DATA['custom_user_upload']); define('NUM_FILE_BOXES', (int) $USER_DATA['num_file_upload']); define('NUM_URI_BOXES', (int) $USER_DATA['num_URI_upload']); } else { if ($user_settings['ID_GROUP']) { $cm_group_id = $user_settings['ID_GROUP']; } else { if ($user_settings['ID_POST_GROUP'] && defined('USE_POST_GROUPS')) { $cm_group_id = $user_settings['ID_POST_GROUP']; } else { $cm_group_id = SMF_MEMBERS_GROUP; } } // Retrieve group information $USER_DATA = cpgGetUserData($cm_group_id, $user_info['groups'], SMF_GUEST_GROUP); $USER_DATA['has_admin_access'] = $user_info['is_admin']; $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access'] | in_array(SMF_GMOD_GROUP, $user_info['groups']); define('USER_ID', $ID_MEMBER); define('USER_NAME', $user_info['name']); define('SMF_USER_NAME', $user_info['username']); define('USER_GROUP', $USER_DATA['group_name']); define('USER_GROUP_SET', '(' . implode(",", $USER_DATA['groups']) . ')'); define('USER_IS_ADMIN', $user_info['is_admin']); define('USER_CAN_SEND_ECARDS', (int) $USER_DATA['can_send_ecards']); define('USER_CAN_RATE_PICTURES', (int) $USER_DATA['can_rate_pictures']); define('USER_CAN_POST_COMMENTS', (int) $USER_DATA['can_post_comments']); define('USER_CAN_UPLOAD_PICTURES', (int) $USER_DATA['can_upload_pictures']); define('USER_CAN_CREATE_ALBUMS', (int) $USER_DATA['can_create_albums']); define('USER_UPLOAD_FORM', (int) $USER_DATA['upload_form_config']); define('CUSTOMIZE_UPLOAD_FORM', (int) $USER_DATA['custom_user_upload']); define('NUM_FILE_BOXES', (int) $USER_DATA['num_file_upload']); define('NUM_URI_BOXES', (int) $USER_DATA['num_URI_upload']); } }
function udb_authenticate() { global $USER_DATA, $CONFIG, $cookie_name, $UDB_DB_LINK_ID, $UDB_DB_NAME_PREFIX; // For error checking $CONFIG['TABLE_USERS'] = '**ERROR**'; function unescape($str) { return get_magic_quotes_gpc() == 1 ? stripslashes($str) : $str; } // Retrieve cookie stored login information // default user info $USER_DATA['user_id'] = 0; $USER_DATA['status'] = -1; $USER_DATA['user_name'] = 'Guest'; if (isset($_COOKIE[$cookie_name])) { list($cookie['username'], $cookie['password_hash']) = unserialize(unescape($_COOKIE[$cookie_name])); if (strcasecmp($cookie['username'], 'Guest')) { $result = db_query("SELECT id AS user_id, username AS user_name, status FROM " . $UDB_DB_NAME_PREFIX . PUNBB_TABLE_PREFIX . PUNBB_USER_TABLE . " WHERE username='******'username']) . "' AND password='******'password_hash']) . "'", $UDB_DB_LINK_ID); $USER_DATA = mysql_fetch_assoc($result); } } $USER_DATA['groups'] = array(); // Define the basic groups switch ($USER_DATA['status']) { case 0: $USER_DATA['groups'][0] = PUNBB_MEMBERS_GROUP; break; case 1: $USER_DATA['groups'][0] = PUNBB_MOD_GROUP; break; case 2: $USER_DATA['groups'][0] = PUNBB_ADMIN_GROUP; break; default: $USER_DATA['groups'][0] = PUNBB_GUEST_GROUP; break; } if ($USER_DATA['status'] == -1) { define('USER_ID', 0); } else { define('USER_ID', (int) $USER_DATA['user_id']); } $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')'; // Default group data $USER_DATA['group_quota'] = 1; $USER_DATA['can_rate_pictures'] = 0; $USER_DATA['can_send_ecards'] = 0; $USER_DATA['can_post_comments'] = 0; $USER_DATA['can_upload_pictures'] = 0; $USER_DATA['can_create_albums'] = 0; $USER_DATA['pub_upl_need_approval'] = 1; $USER_DATA['priv_upl_need_approval'] = 1; $USER_DATA['upload_form_config'] = 0; $USER_DATA['num_file_upload'] = 0; $USER_DATA['num_URI_upload'] = 0; $USER_DATA['custom_user_upload'] = 0; $USER_DATA = array_merge($USER_DATA, cpgGetUserData($USER_DATA['groups'][0], $USER_DATA['groups'], PUNBB_GUEST_GROUP)); $USER_DATA['has_admin_access'] = $USER_DATA['status'] == 2 || $USER_DATA['status'] == 1 && MOD_IS_ADMIN ? 1 : 0; $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access']; define('USER_NAME', $USER_DATA['user_name']); define('USER_GROUP', $USER_DATA['group_name']); define('USER_GROUP_SET', $user_group_set); define('USER_IS_ADMIN', $USER_DATA['has_admin_access']); define('USER_CAN_SEND_ECARDS', (int) $USER_DATA['can_send_ecards']); define('USER_CAN_RATE_PICTURES', (int) $USER_DATA['can_rate_pictures']); define('USER_CAN_POST_COMMENTS', (int) $USER_DATA['can_post_comments']); define('USER_CAN_UPLOAD_PICTURES', (int) $USER_DATA['can_upload_pictures']); define('USER_CAN_CREATE_ALBUMS', (int) $USER_DATA['can_create_albums']); define('USER_UPLOAD_FORM', (int) $USER_DATA['upload_form_config']); define('CUSTOMIZE_UPLOAD_FORM', (int) $USER_DATA['custom_user_upload']); define('NUM_FILE_BOXES', (int) $USER_DATA['num_file_upload']); define('NUM_URI_BOXES', (int) $USER_DATA['num_URI_upload']); }
define('USER_NAME', $USER_DATA['user_name']); define('USER_GROUP', $USER_DATA['group_name']); define('USER_GROUP_SET', '(' . implode(',', $USER_DATA['groups']) . ')'); define('USER_IS_ADMIN', (int) $USER_DATA['has_admin_access']); define('USER_CAN_SEND_ECARDS', (int) $USER_DATA['can_send_ecards']); define('USER_CAN_RATE_PICTURES', (int) $USER_DATA['can_rate_pictures']); define('USER_CAN_POST_COMMENTS', (int) $USER_DATA['can_post_comments']); define('USER_CAN_UPLOAD_PICTURES', (int) $USER_DATA['can_upload_pictures']); define('USER_CAN_CREATE_ALBUMS', (int) $USER_DATA['can_create_albums']); define('USER_UPLOAD_FORM', (int) $USER_DATA['upload_form_config']); define('CUSTOMIZE_UPLOAD_FORM', (int) $USER_DATA['custom_user_upload']); define('NUM_FILE_BOXES', (int) $USER_DATA['num_file_upload']); define('NUM_URI_BOXES', (int) $USER_DATA['num_URI_upload']); mysql_free_result($results); } else { $USER_DATA = cpgGetUserData(3, array(3)); define('USER_ID', 0); define('USER_NAME', 'Anonymous'); define('USER_GROUP', $USER_DATA['group_name']); define('USER_GROUP_SET', '(' . $USER_DATA['group_id'] . ')'); define('USER_IS_ADMIN', 0); define('USER_CAN_SEND_ECARDS', (int) $USER_DATA['can_send_ecards']); define('USER_CAN_RATE_PICTURES', (int) $USER_DATA['can_rate_pictures']); define('USER_CAN_POST_COMMENTS', (int) $USER_DATA['can_post_comments']); define('USER_CAN_UPLOAD_PICTURES', (int) $USER_DATA['can_upload_pictures']); define('USER_CAN_CREATE_ALBUMS', 0); define('USER_UPLOAD_FORM', (int) $USER_DATA['upload_form_config']); define('CUSTOMIZE_UPLOAD_FORM', (int) $USER_DATA['custom_user_upload']); define('NUM_FILE_BOXES', (int) $USER_DATA['num_file_upload']); define('NUM_URI_BOXES', (int) $USER_DATA['num_URI_upload']); mysql_free_result($results);