??????????????? ??????????????? punbb115.inc.php000064400000013120152532121430007355 0ustar00 'PunBB v1.1.5', 'short_name' => 'punbb115', 'support_url' => 'http://www.punbb.org/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,config.php', 'use_post_based_groups_default' => '0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { // the vars that are used when bridgemgr is disabled // URL of your punbb $this->boardurl = 'http://www.yoursite.com/punbb'; // local path to your punbb config file require_once('../punbb/config.php'); } else { // the vars from the bridgemgr $this->boardurl = $BRIDGE['full_forum_url']; require_once($BRIDGE['relative_path_to_config_file'] . 'config.php'); $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } $this->multigroups = 0; $this->group_overrride = 0; // Database connection settings $this->db = array( 'name' => $db_name, 'host' => $db_host, 'user' => $db_username, 'password' => $db_password, 'prefix' =>$db_prefix ); // Board table names $this->table = array( 'users' => 'users', ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'id', // name of 'id' field in users table 'password' => 'password', // name of 'password' field in users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'registered', // name of 'registered' field in users table 'location' => 'location', // name of 'location' field in users table 'website' => 'url', // name of 'website' field in users table 'usertbl_group_id' => 'status', // name of 'group id' field in users table ); // Pages to redirect to $this->page = array( 'register' => '/register.php', 'editusers' => '/userlist.php', 'edituserprofile' => "/profile.php?id=" ); // Group ids $this->admingroups = array(2); $this->guestgroup = -1; // Cookie settings - used in following functions only $this->cookie_name = $cookie_name; // Connect to db $this->connect(); } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); $row = false; //array('id' => 0, 'username' => 'Guest', 'status' => -1); //if (isset($_COOKIE[$this->cookie_name])) { // list($username, $pass_hash) = unserialize($_COOKIE[$this->cookie_name]); if ($superCage->cookie->keyExists($this->cookie_name)) { list($username, $pass_hash) = unserialize($superCage->cookie->getRaw($this->cookie_name)); if (strcasecmp($username, 'Guest')) { $result = cpg_db_query("SELECT id, username, status+100 AS status FROM {$this->usertable} WHERE username = '$username' AND password = '$pass_hash'", $this->link_id); $row = mysql_fetch_assoc($result); } } return $row; } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { return false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; } // Login function login_page() { global $CONFIG; $this->redirect('/login.php?action=in&redir='.$CONFIG['site_url']); } // Logout function logout_page() { global $CONFIG; $this->redirect('/login.php?action=out&id='.USER_ID.'&redir='.$CONFIG['site_url']); } } // and go ! $cpg_udb = new cpg_udb; } ?>udb_base.inc.php000064400000072561152532121430007602 0ustar00can_join_tables = ($this->db['host'] == $CONFIG['dbserver'] && ($this->db['name'] == $CONFIG['dbname'] || $this->db['user'] == $CONFIG['dbuser'] || mysql_query("SELECT NULL FROM ".$this->usertable." LIMIT 1"))); if ($id){ $this->link_id = $id; } else { // Connect to udb database if necessary if (!$this->can_join_tables) { $this->link_id = mysql_connect($this->db['host'], $this->db['user'], $this->db['password']); if (!$this->link_id) { die("Coppermine critical error:
Unable to connect to UDB database !

MySQL said: " . mysql_error() . ""); } mysql_select_db ($this->db['name'], $this->link_id); } else { $this->link_id = 0; } } } // end function connect function authenticate() { global $USER_DATA; if (!($auth = $this->session_extraction()) && !($auth = $this->cookie_extraction()) && !($auth = $this->post_extraction())) { $this->load_guest_data(); } else { list ($id, $cookie_pass) = $auth; $f = $this->field; if (isset($this->usergroupstable)){ $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, {$f['password']} AS password, ug.{$f['usertbl_group_id']} AS group_id " . "FROM {$this->usertable} AS u, {$this->usergroupstable} AS ug " . "WHERE u.{$f['user_id']}=ug.{$f['user_id']} AND u.{$f['user_id']}='$id'"; } else { $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, {$f['password']} AS password, u.{$f['usertbl_group_id']} AS group_id " . "FROM {$this->usertable} AS u LEFT JOIN {$this->groupstable} AS g ON u.{$f['usertbl_group_id']}=g.{$f['grouptbl_group_id']} " . "WHERE u.{$f['user_id']}='$id'"; } $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)){ $row = mysql_fetch_assoc($result); mysql_free_result($result); $db_pass = $this->udb_hash_db($row['password']); if ($db_pass === $cookie_pass) { $this->load_user_data($row); } else { $this->load_guest_data(); } } else { $this->load_guest_data(); } } $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')'; $USER_DATA = array_merge($USER_DATA, $this->get_user_data($USER_DATA['groups'][0], $USER_DATA['groups'], $this->guestgroup)); if ($this->use_post_based_groups){ $USER_DATA['has_admin_access'] = (in_array($USER_DATA['groups'][0] - 100,$this->admingroups)) ? 1 : 0; } else { $USER_DATA['has_admin_access'] = ($USER_DATA['groups'][0] == 1) ? 1 : 0; } $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access']; // avoids a template error if (!$USER_DATA['user_id']) { $USER_DATA['can_create_albums'] = 0; } // For error checking $CONFIG['TABLE_USERS'] = '**ERROR**'; define('USER_ID', $USER_DATA['user_id']); define('USER_NAME', addslashes($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'] || (int)$USER_DATA['can_create_public_albums'])); define('USER_CAN_CREATE_PRIVATE_ALBUMS', (int)$USER_DATA['can_create_albums']); define('USER_CAN_CREATE_PUBLIC_ALBUMS', (int)$USER_DATA['can_create_public_albums']); define('USER_ACCESS_LEVEL', (int)$USER_DATA['access_level']); $this->session_update(); } // end function authenticate function load_guest_data() { global $USER_DATA, $CONFIG; $USER_DATA['user_id'] = 0; $USER_DATA['user_name'] = 'Guest'; $USER_DATA['groups'][0] = $this->use_post_based_groups ? ($this->guestgroup + 100) : 3; $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['access_level'] = $CONFIG['allow_unlogged_access']; } // end function load_guest_data function load_user_data($row) { global $USER_DATA; $USER_DATA['user_id'] = $row['id']; $USER_DATA['user_name'] = $row['username']; //changed to "row['group_id']" $group_id = $row[($this->usergroupstable)?$this->field['usertbl_group_id']:$this->field['grouptbl_group_id']]; if ($this->multigroups){ $USER_DATA['groups'] = $this->get_groups($row); } else { if ($this->use_post_based_groups){ $USER_DATA['groups'] = array(0 => $row['group_id']); } else { $USER_DATA['groups'] = array(0 => (in_array($row['group_id'], $this->admingroups)) ? 1 : 2); } } } // end function load_user_data /* * Prototype function needed for Mambo *maybe others* * Keeps the session alive */ function session_update() {} function get_user_count() { global $CONFIG; static $user_count = 0; if (!$user_count) { $result = cpg_db_query("SELECT count(*) FROM {$this->usertable} WHERE 1", $this->link_id); $nbEnr = mysql_fetch_array($result); $user_count = $nbEnr[0]; mysql_free_result($result); } return $user_count; } // end function get_user_count function get_users($options = array()) { global $CONFIG; // Copy UDB fields and config variables (just to make it easier to read) $f =& $this->field; $C =& $CONFIG; // Sort codes $sort_codes = array('name_a' => 'user_name ASC', 'name_d' => 'user_name DESC', 'group_a' => 'group_name ASC', 'group_d' => 'group_name DESC', 'reg_a' => 'user_regdate ASC', 'reg_d' => 'user_regdate DESC', 'pic_a' => 'pic_count ASC', 'pic_d' => 'pic_count DESC', 'disku_a' => 'disk_usage ASC', 'disku_d' => 'disk_usage DESC', 'lv_a' => 'user_lastvisit ASC', 'lv_d' => 'user_lastvisit DESC', ); // Fix the group id, if bridging is enabled if ($CONFIG['bridge_enable']) { $f['usertbl_group_id'] .= '+100'; } // Build WHERE clause, if this is a username search if ($options['search']) { $options['search'] = 'WHERE u.'.$f['username'].' LIKE "%'.$options['search'].'%" '; } // Build SQL table, should work with all bridges $sql = "SELECT {$f['user_id']} AS user_id, {$f['username']} AS user_name, {$f['email']} AS user_email, {$f['regdate']} AS user_regdate, {$f['lastvisit']} AS user_lastvisit, {$f['active']} AS user_active, " . "COUNT(pid) AS pic_count, ROUND(SUM(total_filesize)/1024) AS disk_usage, group_name, group_quota " . "FROM {$this->usertable} AS u " . "INNER JOIN `{$C['dbname']}`.{$C['TABLE_USERGROUPS']} AS g ON u.{$f['usertbl_group_id']} = g.group_id " . "LEFT JOIN `{$C['dbname']}`.{$C['TABLE_PICTURES']} AS p ON p.owner_id = u.{$f['user_id']} " . $options['search'] . "GROUP BY user_id " . "ORDER BY " . $sort_codes[$options['sort']] . " " . "LIMIT {$options['lower_limit']}, {$options['users_per_page']};"; $result = cpg_db_query($sql, $this->link_id); // If no records, return empty value if (!$result) { return array(); } // Extract user list to an array while ($user = mysql_fetch_assoc($result)) { $userlist[] = $user; } return $userlist; } // end function get_users function get_groups($row) {} // Retrieve the name of a user function get_user_name($uid) { static $cache = array(); if (!isset($cache[$uid])) { $sql = "SELECT {$this->field['username']} as user_name FROM {$this->usertable} WHERE {$this->field['user_id']} = '$uid'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $cache[$uid] = $row['user_name']; } else { $cache[$uid] = ''; } } return $cache[$uid]; } // end function get_user_name // Retrieve the id of a user function get_user_id($username) { $username = addslashes($username); $sql = "SELECT {$this->field['user_id']} AS user_id FROM {$this->usertable} WHERE {$this->field['username']} = '$username'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)) { $row = mysql_fetch_array($result); mysql_free_result($result); return $row['user_id']; } else { return ''; } } // end function get_user_id // Perform database queries to calculate user's privileges based on group membership function get_user_data($pri_group, $groups, $default_group_id = 3) { //Parameters : // $pri_group (scalar) : Group ID number of the user's 'main' group. This is the group that will be // the user's profile display. ($USER_DATA['group_id']) // // $groups (array) : List of group ids of all the groups that the user is a member of. IF this list // does not include the $pri_group, it will be added. // // $default_group_id (scalar) : The group used as a fall-back if no valid group ids are specified. // If this group also does not exist then CPG will abort with a critical // error. // // Returns an array containing most of the data to put into in $USER_DATA. global $CONFIG; foreach ($groups as $key => $val) { if (!is_numeric($val)) { unset ($groups[$key]); } } if (!in_array($pri_group, $groups)) { array_push($groups, $pri_group); } $result = cpg_db_query("SELECT MAX(group_quota) AS disk_max, MIN(group_quota) AS disk_min, " . "MAX(can_rate_pictures) AS can_rate_pictures, MAX(can_send_ecards) AS can_send_ecards, " . "MAX(can_post_comments) AS can_post_comments, MAX(can_upload_pictures) AS can_upload_pictures, " . "MAX(can_create_albums) AS can_create_albums, " . "MAX(has_admin_access) AS has_admin_access, " . "MAX(access_level) AS access_level, " . "MIN(pub_upl_need_approval) AS pub_upl_need_approval, MIN( priv_upl_need_approval) AS priv_upl_need_approval " . "FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id in (" . implode(",", $groups). ")"); if (mysql_num_rows($result)) { $USER_DATA = mysql_fetch_assoc($result); $result = cpg_db_query("SELECT group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id= " . $pri_group); $temp_arr = mysql_fetch_assoc($result); $USER_DATA["group_name"] = $temp_arr["group_name"]; } else { $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = $default_group_id"); if (!mysql_num_rows($result)) { $this->synchronize_groups(); die('Coppermine critical error:
The group table does not contain the Anonymous group !'); } $USER_DATA = mysql_fetch_assoc($result); } mysql_free_result($result); $result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_CATMAP']} WHERE group_id in (" . implode(",", $groups). ")"); if (mysql_result($result, 0) > 0) { $USER_DATA['can_create_public_albums'] = 1; } else { $USER_DATA['can_create_public_albums'] = 0; } mysql_free_result($result); $USER_DATA["group_quota"] = ($USER_DATA["disk_min"])?$USER_DATA["disk_max"]:0; $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access']; $USER_DATA["group_id"] = $pri_group; $USER_DATA['groups'] = $groups; if (get_magic_quotes_gpc() == 0) { $USER_DATA['group_name'] = mysql_escape_string($USER_DATA['group_name']); } return($USER_DATA); } // end function get_user_data // Redirect function redirect($target) { header('Location: '. $this->boardurl . $target); exit; } // end function redirect // Register function register_page() { $this->redirect($this->page['register']); } // end function register_page // View users function view_users() { $this->redirect($this->page['editusers']); } // end function view_users // Edit users function edit_users() { $this->redirect($this->page['editusers']); } // end function edit_users // View user profile function view_profile($uid) { $this->redirect($this->page['edituserprofile'].($uid ? $uid : USER_ID)); } // end function view_profile // Edit user profile function edit_profile($uid) { $this->redirect($this->page['edituserprofile'].$uid); } // end function edit_profile // Get user information function get_user_infos($uid) { global $lang_register_php; $sql = "SELECT *, {$this->field['username']} AS user_name, " . "{$this->field['email']} AS user_email, " . "{$this->field['regdate']} AS user_regdate, " . "{$this->field['location']} AS user_location, " . "{$this->field['website']} AS user_website " . "FROM {$this->usertable} WHERE {$this->field['user_id']} = '$uid'"; $result = cpg_db_query($sql, $this->link_id); if (!mysql_num_rows($result)) { cpg_die(ERROR, $lang_register_php['err_unk_user'], __FILE__, __LINE__); } $user_data = mysql_fetch_array($result); if (!isset($user_data['group_name'])) { $user_data['group_name'] = ''; } if (!isset($user_data['user_profile1'])) { $user_data['user_profile1'] = ''; } if (!isset($user_data['user_profile2'])) { $user_data['user_profile2'] = ''; } if (!isset($user_data['user_profile3'])) { $user_data['user_profile3'] = ''; } if (!isset($user_data['user_profile4'])) { $user_data['user_profile4'] = ''; } if (!isset($user_data['user_profile5'])) { $user_data['user_profile5'] = ''; } if (!isset($user_data['user_profile6'])) { $user_data['user_profile6'] = ''; } mysql_free_result($result); return $user_data; } // end function get_user_infos // Query used to list users function list_users_query(&$user_count) { global $CONFIG, $FORBIDDEN_SET, $PAGE; // Get the total number of users with albums $sql = "SELECT NULL " . "FROM {$CONFIG['TABLE_ALBUMS']} AS p " . " INNER JOIN {$CONFIG['TABLE_PICTURES']} AS pics ON pics.aid = p.aid " . "WHERE ( category > " . FIRST_USER_CAT . " $FORBIDDEN_SET) " . "GROUP BY category;"; $result = cpg_db_query($sql); $user_count = mysql_num_rows($result); mysql_free_result($result); if ($user_count == 0) { return false; } $users_per_page = $CONFIG['thumbcols'] * $CONFIG['thumbrows']; $totalPages = ceil($user_count / $users_per_page); if ($PAGE > $totalPages) $PAGE = 1; $lower_limit = ($PAGE-1) * $users_per_page; if ($this->can_join_tables) { $f =& $this->field; $sql = "SELECT {$f['user_id']} AS user_id," . "{$f['username']} AS user_name," . "COUNT(DISTINCT a.aid) AS alb_count," . "COUNT(DISTINCT pid) AS pic_count," . "MAX(pid) AS thumb_pid, " . "MAX(galleryicon) AS gallery_pid " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$this->usertable} AS u ON u.{$f['user_id']} = a.category - " . FIRST_USER_CAT . " " . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid " . "WHERE ((ISNULL(approved) OR approved='YES') AND category > " . FIRST_USER_CAT . ") $FORBIDDEN_SET GROUP BY user_id " . "ORDER BY category " . "LIMIT $lower_limit, $users_per_page "; $result = cpg_db_query($sql); while ($row = mysql_fetch_array($result)) { $users[] = $row; } mysql_free_result($result); } else { // This is the way we collect the data without a direct join to the forum's user table // This query determines which users we need to collect usernames of - ie just those which have albums with pics // and are on the page we are looking at $sql = "SELECT category - 10000 AS user_id " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid " . "WHERE ((ISNULL(approved) OR approved='YES') " . "AND category > " . FIRST_USER_CAT . ") $FORBIDDEN_SET " . "GROUP BY category " . "LIMIT $lower_limit, $users_per_page "; $result = cpg_db_query($sql); $user_ids = array(); while ($row = mysql_fetch_array($result)) { $user_ids[] = $row['user_id']; } mysql_free_result($result); $userlist = implode(',', $user_ids); // This query collects an array of user_id -> username mappings for the user ids collected above $result = cpg_db_query("SELECT {$this->field['user_id']} AS user_id, {$this->field['username']} AS user_name " . "FROM {$this->usertable} WHERE {$this->field['user_id']} IN ($userlist)", $this->link_id); $userdata = array(); while ($row = mysql_fetch_array($result)) { $userdata[$row['user_id']] = $row['user_name']; } mysql_free_result($result); // This is the main query, similar to the one in the join implementation above but without the join to the user table // We use the pic's owner_id field as the user_id instead of using category - 10000 as the user_id $sql = "SELECT owner_id AS user_id," . "COUNT(DISTINCT a.aid) AS alb_count," . "COUNT(DISTINCT pid) AS pic_count," . "MAX(pid) AS thumb_pid, " . "MAX(galleryicon) AS gallery_pid " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid " . "WHERE ((ISNULL(approved) OR approved='YES') AND category > " . FIRST_USER_CAT . ") $FORBIDDEN_SET " . "GROUP BY user_id " . "ORDER BY category " . "LIMIT $lower_limit, $users_per_page "; $result = cpg_db_query($sql); // Here we associate the username with the album details. while ($row = mysql_fetch_array($result)) { $users[] = array_merge($row, array('user_name' => $userdata[$row['user_id']])); } mysql_free_result($result); } return $users; } // end function list_users_query // Group table synchronization function synchronize_groups() { global $CONFIG ; if ($this->use_post_based_groups){ if ($this->group_overrride){ $udb_groups = $this->collect_groups(); } else { $sql = "SELECT * FROM {$this->groupstable} WHERE {$this->field['grouptbl_group_name']} <> ''"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']]+100] = $row[$this->field['grouptbl_group_name']]; } } } else { $udb_groups = array(1 =>'Administrators', 2=> 'Registered', 3=>'Guests'); } $result = cpg_db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE 1"); while ($row = mysql_fetch_array($result)) { $cpg_groups[$row['group_id']] = $row['group_name']; } mysql_free_result($result); // Scan Coppermine groups that need to be deleted foreach($cpg_groups as $c_group_id => $c_group_name) { if ((!isset($udb_groups[$c_group_id]))) { cpg_db_query("DELETE FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = '" . $c_group_id . "' LIMIT 1"); unset($cpg_groups[$c_group_id]); } } // Scan udb groups that need to be created inside Coppermine table foreach($udb_groups as $i_group_id => $i_group_name) { if ((!isset($cpg_groups[$i_group_id]))) { // add admin info $admin_access = in_array($i_group_id-100, $this->admingroups) ? '1' : '0'; cpg_db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} (group_id, group_name, has_admin_access) " . "VALUES ('$i_group_id', '" . addslashes($i_group_name) . "', '$admin_access')"); $cpg_groups[$i_group_id] = $i_group_name; } } // Update Group names foreach($udb_groups as $i_group_id => $i_group_name) { if ($cpg_groups[$i_group_id] != $i_group_name) { cpg_db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET group_name = '" . addslashes($i_group_name) . "' WHERE group_id = '$i_group_id' LIMIT 1"); } } // fix admin group if (!$this->use_post_based_groups) { cpg_db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET has_admin_access = '1' WHERE group_id = '1' LIMIT 1"); } } // end function synchronize_groups // Retrieve the album list used in gallery admin mode function get_admin_album_list() { global $CONFIG; if ($this->can_join_tables) { $sql = "SELECT aid, CONCAT('(', {$this->field['username']}, ') ', a.title) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$this->usertable} AS u " . "ON category = (" . FIRST_USER_CAT . " + {$this->field['user_id']}) " . "ORDER BY title"; } else { $sql = "SELECT aid, IF(category > " . FIRST_USER_CAT . ", CONCAT('* ', title), CONCAT(' ', title)) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} " . "ORDER BY title"; } return $sql; } // end function get_admin_album_list function util_filloptions() { global $lang_util_php, $CONFIG; echo '     (3)'; echo '    '; echo ' (4)'; } // end function util_filloptions // Taken from Mambo (com_registration.php) function make_password() { $makepass=""; $salt = "abchefghjkmnpqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; while ($i <= 7) { $num = rand() % 33; $tmp = substr($salt, $num, 1); $makepass = $makepass . $tmp; $i++; } return ($makepass); } // end function make_password function session_extraction() { return false; } // end function session_extraction function cookie_extraction() { return false; } // end function cookie_extraction /** * Function to extract auth info from POST * This is a special case used only on upload page (swfupload) * @return mixed Array with id and pass hash or false */ function post_extraction() { // Get the super cage instance $superCage = Inspekt::makeSuperCage(); // We will extract the auth info from post only on upload page. if (defined('UPLOAD_PHP') && ($superCage->post->keyExists('process') || $superCage->post->keyExists('plugin_process'))) { // Get the user id and password hash from post $user = unserialize(base64_decode($superCage->post->getRaw('user'))); if (is_array($user)) { return array((int)$user['user_id'], $user['pass_hash']); } } return false; } // end function post_extraction // Simple login by specified username and pass. // Used for xp publisher login // Needs override for any BBS that is more complex than straight md5(password) function login( $username = null, $password = null, $remember = false ) { $encpassword = md5($password); // Check for user in users table $sql = "SELECT {$this->field['user_id']} AS user_id, {$this->field['username']} AS user_name " . "FROM {$this->usertable} " . "WHERE {$this->field['username']} = '$username' AND BINARY {$this->field['password']} = '$encpassword'"; $results = cpg_db_query($sql); if (mysql_num_rows($results)) { $USER_DATA = mysql_fetch_assoc($results); mysql_free_result($results); return $USER_DATA; } else { return false; } } // end function login function adv_sort($a, $b) { if ($this->sortdir == 'ASC') { return strcmp($a[$this->sortfield], $b[$this->sortfield]); } else { return strcmp($b[$this->sortfield], $a[$this->sortfield]); } } // end function adv_sort function get_user_pass($user_id) { $sql = "SELECT {$this->field['user_id']} AS user_id, {$this->field['password']} AS pass_hash " . "FROM {$this->usertable} " . "WHERE {$this->field['user_id']} = '$user_id'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)) { $row = cpg_db_fetch_row($result); return array('user_id' => $row['user_id'], 'pass_hash' => $row['pass_hash']); } else { return array(); } } // end function get_user_pass } // end class core_udb ?> smf20.inc.php000064400000023666152532121430006767 0ustar00 'Simple Machines (SMF) 2.x', 'short_name' => 'smf20', 'support_url' => 'http://www.simplemachines.org/', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,Settings.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { require_once('../smf/Settings.php'); $boardurl = 'http://www.mysite.com/board'; } else { require_once($BRIDGE['relative_path_to_config_file'] . 'Settings.php'); } $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; $this->boardurl = $boardurl; $this->multigroups = 1; $this->group_overrride = 1; $this->cookie_name = $cookiename; // Board table names $this->table = array( 'users' => 'members', 'groups' => 'membergroups', 'sessions' => 'sessions' ); // Database connection settings $this->db = array( 'name' => $db_name, 'host' => $db_server ? $db_server : 'localhost', 'user' => $db_user, 'prefix' => $db_prefix, 'password' => $db_passwd, ); // Derived full table names if (strpos($db_prefix, '.') === false) { $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; } else { $this->usertable = $this->db['prefix'] . $this->table['users']; $this->groupstable = $this->db['prefix'] . $this->table['groups']; $this->sessionstable = $this->db['prefix'] . $this->table['sessions']; } // Table field names $this->field = array( 'username' => 'real_name', // name of 'username' field in users table 'user_id' => 'id_member', // name of 'id' field in users table 'password' => 'SHA1(CONCAT(passwd, password_salt))', // name of the password field in the users table 'email' => 'email_address', // name of 'email' field in users table 'regdate' => 'date_registered', // name of 'registered' field in users table 'lastvisit' => 'last_login', // last time user logged in 'active' => 'is_activated', // is user account active? 'location' => 'location', // name of 'location' field in users table 'website' => 'website_url', // name of 'website' field in users table 'usertbl_group_id' => 'id_post_group', // name of 'group id' field in users table 'grouptbl_group_id' => 'id_group', // name of 'group id' field in groups table 'grouptbl_group_name' => 'group_name', // name of 'group name' field in groups table 'postgroup' => 'id_post_group', // post group field 'additionals' => 'additional_groups', // additional groups, comma seperated ); // Pages to redirect to $this->page = array( 'register' => '/index.php?action=register', 'editusers' => '/index.php?action=mlist', 'edituserprofile' => '/index.php?action=profile;u=' ); // Group ids - admin and guest only. $this->admingroups = array(1); $this->guestgroup = 0; // Connect to db - or supply a connection id to be used instead of making own connection. $this->connect(); } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists($this->cookie_name)) { $data = unserialize($superCage->cookie->getRaw($this->cookie_name)); if (is_numeric($data[0]) && preg_match('/^[A-F0-9]{40}$/i', $data[1])) { return $data; } else { return false; } } } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { return false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; // unused } // Get groups of which user is member function get_groups($row) { $data = array(); $sql = "SELECT id_group, {$this->field['additionals']} AS additionals FROM {$this->usertable} WHERE {$this->field['user_id']} = {$row['id']}"; $result = cpg_db_query($sql, $this->link_id); $groupdata = mysql_fetch_assoc($result); if ($this->use_post_based_groups) { // the group is used as master group if ($groupdata['id_group']) { $data[] = $groupdata['id_group'] + 100; } // add in post based group as first additional group if ($row['group_id']) { $data[] = $row['group_id'] + 100; } // add in any additional groups if ($groupdata['additionals']) { $additionals = explode(',', $groupdata['additionals']); foreach ($additionals as $group) { $data[] = $group + 100; } } } else { $data[0] = in_array($groupdata['id_group'] , $this->admingroups) ? 1 : 2; } return $data; } function collect_groups() { // Use this version to exclude true post based groups //$sql ="SELECT * FROM {$this->groupstable} WHERE minposts=-1"; // Use this version to include all SMF groups $sql ="SELECT * FROM {$this->groupstable}"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(100 => 'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']]+100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; } function login_page() { global $CONFIG; if ($session = $this->_session_load()) { $session['old_url'] = $CONFIG['site_url'] . '?board=redirect'; $this->_session_save($session); } $this->redirect('/index.php?action=login'); } function _session_load() { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists('PHPSESSID')) { $session_id = $superCage->cookie->getEscaped('PHPSESSID'); $sql = "SELECT data FROM {$this->sessionstable} WHERE session_id = '$session_id'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)) { list($data) = mysql_fetch_row($result); session_name('CPG'); session_start(); session_decode($data); $session = $_SESSION; return $session; } } return false; } function _session_save($session) { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists('PHPSESSID')) { $session_id = $superCage->cookie->getEscaped('PHPSESSID'); $_SESSION = $session; $data = addslashes(session_encode()); $sql = "UPDATE {$this->sessionstable} SET data = '$data' WHERE session_id = '$session_id'"; cpg_db_query($sql, $this->link_id); } } function logout_page() { global $CONFIG; if ($session = $this->_session_load()) { $session['logout_url'] = $CONFIG['site_url']; $this->_session_save($session); $this->redirect('/index.php?action=logout;' . $session['session_var'] . '=' . $session['session_value']); } else { $this->redirect('/index.php?action=logout'); } } function view_users() { } function view_profile() { } } // and go ! $cpg_udb = new cpg_udb; } ?>coppermine.inc.php000064400000051714152532121430010174 0ustar00boardurl = 'http://localhost/coppermine'; include_once('../include/config.inc.php'); } else { $this->boardurl = $CONFIG['site_url']; $this->use_post_based_groups = @$BRIDGE['use_post_based_groups']; } // A hash that's a little specific to the client's configuration $this->client_id = md5($superCage->server->getRaw('HTTP_USER_AGENT').$CONFIG['site_url']); $this->multigroups = 1; $this->group_overrride = !$this->use_post_based_groups; // Database connection settings $this->db = array( 'name' => $CONFIG['dbname'], 'host' => $CONFIG['dbserver'] ? $CONFIG['dbserver'] : 'localhost', 'user' => $CONFIG['dbuser'], 'password' => $CONFIG['dbpass'], 'prefix' =>$CONFIG['TABLE_PREFIX'] ); // Board table names $this->table = array( 'users' => 'users', 'groups' => 'usergroups', 'sessions' => 'sessions' ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; // Table field names $this->field = array( 'username' => 'user_name', // name of 'username' field in users table 'user_id' => 'user_id', // name of 'id' field in users table 'password' => 'user_password', // name of 'password' field in users table 'email' => 'user_email', // name of 'email' field in users table 'regdate' => 'UNIX_TIMESTAMP(user_regdate)', // name of 'registered' field in users table 'lastvisit' => 'UNIX_TIMESTAMP(user_lastvisit)', // last time user logged in 'active' => 'user_active', // is user account active? 'location' => "''", // name of 'location' field in users table 'website' => "''", // name of 'website' field in users table 'usertbl_group_id' => 'user_group', // name of 'group id' field in users table 'grouptbl_group_id' => 'group_id', // name of 'group id' field in groups table 'grouptbl_group_name' => 'group_name' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => 'register.php', 'editusers' => 'usermgr.php', 'edituserprofile' => 'profile.php' ); // Group ids - admin and guest only. $this->admingroups = array(1); $this->guestgroup = 3; // Connect to db $this->connect($CONFIG['LINK_ID']); } // Login function function login( $username = null, $password = null, $remember = false ) { global $CONFIG; // Create the session_id from concat(cookievalue,client_id) $session_id = $this->session_id.$this->client_id; $encpassword = md5($password); // Check for user in users table $sql = "SELECT user_id, user_name, user_password FROM {$this->usertable} WHERE "; //Check the login method (username, email address or both) switch($CONFIG['login_method']){ case 'both': $sql .= "(user_name = '$username' OR user_email = '$username') AND BINARY user_password = '$encpassword' AND user_active = 'YES'"; break; case 'email': $sql .= "user_email = '$username' AND BINARY user_password = '$encpassword' AND user_active = 'YES'"; break; case 'username': default: $sql .= "user_name = '$username' AND BINARY user_password = '$encpassword' AND user_active = 'YES'"; break; } $results = cpg_db_query($sql); // If exists update lastvisit value, session, and login if (mysql_num_rows($results)) { // Update lastvisit value $sql = "UPDATE {$this->usertable} SET user_lastvisit = NOW() "; //Check the login method (username, email address or both) switch($CONFIG['login_method']){ case 'both': $sql .= "WHERE (user_name = '$username' OR user_email = '$username') AND BINARY user_password = '$encpassword' AND user_active = 'YES'"; break; case 'email': $sql .= "WHERE user_email = '$username' AND BINARY user_password = '$encpassword' AND user_active = 'YES'"; break; case 'username': default: $sql .= "WHERE user_name = '$username' AND BINARY user_password = '$encpassword' AND user_active = 'YES'"; break; } cpg_db_query($sql, $this->link_id); $USER_DATA = mysql_fetch_assoc($results); mysql_free_result($results); // If this is a 'remember me' login set the remember field to true if ($remember) { $remember_sql = ",remember = '1' "; // Change cookie life time to 2 weeks if (CPG_COOKIES_ALLOWED) { setcookie( $this->client_id, $this->session_id, time() + (CPG_WEEK*2), $CONFIG['cookie_path'] ); } } else { $remember_sql = ''; // Kill the cookie when closing the browser if (CPG_COOKIES_ALLOWED) { setcookie( $this->client_id, $this->session_id, 0, $CONFIG['cookie_path'] ); } } // Update guest session with user's information $sql = "UPDATE {$this->sessionstable} SET "; $sql .= "user_id = {$USER_DATA['user_id']} "; $sql .= $remember_sql; $sql .= "WHERE session_id = '" . md5($session_id) . "'"; cpg_db_query($sql, $this->link_id); return $USER_DATA; } else { return false; } } // Logout function function logout() { // Revert authenticated session to a guest session $session_id = $this->session_id.$this->client_id; $sql = "UPDATE {$this->sessionstable} SET user_id = 0, remember = 0 WHERE session_id = '" . md5($session_id) . "'"; cpg_db_query($sql, $this->link_id); } // Get groups of which user is member function get_groups( $user ) { $groups = array($user['group_id']); $sql = "SELECT user_group_list FROM {$this->usertable} AS u WHERE {$this->field['user_id']}='{$user['id']}' AND user_group_list <> ''"; $result = cpg_db_query($sql, $this->link_id); if ($row = mysql_fetch_array($result)){ $groups = array_merge($groups, explode(',', $row['user_group_list'])); } mysql_free_result($result); return $groups; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; } // definition of how to extract id, name, group from a session cookie function session_extraction() { global $CONFIG; $superCage = Inspekt::makeSuperCage(); // Default anonymous values $id = 0; $pass = ''; // Get the session cookie value $sessioncookie = $superCage->cookie->getEscaped($this->client_id); // Create the session id by concat(session_cookie_value, client_id) $session_id = $sessioncookie.$this->client_id; // Lifetime of 'remember me' session is 2 weeks $rememberme_life_time = time()-(CPG_WEEK*2); // Lifetime of normal session is 1 hour $session_life_time = time()-CPG_HOUR; // Clean up old sessions every 5 minutes at maximum if ($CONFIG['session_cleanup'] < time() - 300) { // Delete old sessions $sql = "DELETE FROM {$this->sessionstable} WHERE time < $session_life_time AND remember = 0"; cpg_db_query($sql, $this->link_id); // Delete stale 'remember me' sessions $sql = "DELETE FROM {$this->sessionstable} WHERE time < $rememberme_life_time"; cpg_db_query($sql, $this->link_id); // Update database entry $sql = "UPDATE {$CONFIG['TABLE_CONFIG']} SET value = ".time()." WHERE name = 'session_cleanup'"; cpg_db_query($sql, $this->link_id); } // Check for valid session if session_cookie_value exists if ($sessioncookie) { // Check for valid session $sql = "SELECT user_id, time FROM {$this->sessionstable} WHERE session_id = '" . md5($session_id) . "'"; $result = cpg_db_query($sql); // If session exists... if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $row['user_id'] = (int) $row['user_id']; $this->sessiontime = $row['time']; // Check if there's a user for this session $sql = "SELECT user_id, user_password FROM {$this->usertable} WHERE user_id = {$row['user_id']}"; $result = cpg_db_query($sql, $this->link_id); // If user exists, use the current session if ($result) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $pass = $row['user_password']; $id = (int) $row['user_id']; $this->session_id = $sessioncookie; // If the user doesn't exist, use default guest credentials } // If not a valid session exists, create a new session } else { $this->create_session(); } // No session exists; create one } else { $this->create_session(); } return ($id) ? array($id, $pass) : false; } // Function used to keep the session alive function session_update() { // don't update null sessions if (!isset($this->session_id) || !$this->session_id) { return false; } // only update session time once per minute at maximum if (!isset($this->sessiontime) || (time() - $this->sessiontime < 60)) { return false; } $session_id = $this->session_id.$this->client_id; $sql = "UPDATE {$this->sessionstable} SET time = ".time()." WHERE session_id = '" . md5($session_id) . "'"; cpg_db_query($sql); if (USER_ID > 0) { $sql = "UPDATE {$this->usertable} SET user_lastvisit = NOW() WHERE user_id = '".USER_ID."'"; cpg_db_query($sql); } } // Create a new session with the cookie lifetime set to 2 weeks function create_session() { global $CONFIG; $superCage = Inspekt::makeSuperCage(); // don't create sessions for people that don't accept cookies anyway if (!$superCage->cookie->keyExists($CONFIG['cookie_name'].'_data')) { return false; } // start session $this->session_id = $this->generateId(); $session_id = $this->session_id.$this->client_id; $sql = "INSERT INTO {$this->sessionstable} (session_id, time) VALUES ('" . md5($session_id) . "', ".time().")"; // insert the guest session cpg_db_query($sql, $this->link_id); // set the session cookie if (CPG_COOKIES_ALLOWED) { setcookie( $this->client_id, $this->session_id, time() + (CPG_WEEK*2), $CONFIG['cookie_path'] ); } } // Modified function taken from Mambo session class function generateId() { $failsafe = 20; $randnum = 0; while ($failsafe--) { $randnum = md5( uniqid( microtime(), 1 )); $session_id = $randnum.$this->client_id; if ($randnum != "") { $sql = "SELECT session_id FROM {$this->sessionstable} WHERE session_id = '" . md5($session_id) . "'"; $result = cpg_db_query($sql, $this->link_id); if (!mysql_num_rows($result)) { break; } mysql_free_result($result); } } return $randnum; } /* * Overidden functions !!DO NOT REMOVE OR CPG WILL NOT WORK CORRECTLY!! */ // definition of how to extract an id and password hash from a cookie function cookie_extraction() { return false; } // Register function register_page() { } // Edit users function edit_users() { } // View users function view_users() { } // View user profile function view_profile($uid) { } // Edit user profile function edit_profile($uid) { } function login_page() { } function logout_page() { $this->logout(); } /* Note : we don't want to overide this - the groups need to be resynced to coppermine default after un-integration * Rebuttal: without overriding and removing Coppermine group deletion (see below) its impossible to add new groups to a non-bridged install. */ function synchronize_groups() { global $CONFIG ; if ($this->use_post_based_groups){ if ($this->group_overrride){ $udb_groups = $this->collect_groups(); } else { $sql = "SELECT * FROM {$this->groupstable} WHERE {$this->field['grouptbl_group_name']} <> ''"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']]+100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } } } else { $udb_groups = array(1 =>'Administrators', 2=> 'Registered', 3=>'Guests'); } $result = cpg_db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE 1"); while ($row = mysql_fetch_array($result)) { $cpg_groups[$row['group_id']] = $row['group_name']; } mysql_free_result($result); /* Must be removed to allow new groups to be created in an unbridged install. // Scan Coppermine groups that need to be deleted foreach($cpg_groups as $c_group_id => $c_group_name) { if ((!isset($udb_groups[$c_group_id]))) { cpg_db_query("DELETE FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = '" . $c_group_id . "' LIMIT 1"); unset($cpg_groups[$c_group_id]); } } */ // Scan udb groups that need to be created inside Coppermine table foreach($udb_groups as $i_group_id => $i_group_name) { if ((!isset($cpg_groups[$i_group_id]))) { // add admin info $admin_access = in_array($i_group_id-100, $this->admingroups) ? '1' : '0'; cpg_db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} (group_id, group_name, has_admin_access) VALUES ('$i_group_id', '" . addslashes($i_group_name) . "', '$admin_access')"); $cpg_groups[$i_group_id] = $i_group_name; } } // Update Group names foreach($udb_groups as $i_group_id => $i_group_name) { if ($cpg_groups[$i_group_id] != $i_group_name) { cpg_db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET group_name = '" . addslashes($i_group_name) . "' WHERE group_id = '$i_group_id' LIMIT 1"); } } // fix admin grp if (!$this->use_post_based_groups) cpg_db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET has_admin_access = '1' WHERE group_id = '1' LIMIT 1"); } } // and go ! $cpg_udb = new coppermine_udb; } ?> phpbb2018.inc.php000064400000035730152532121430007441 0ustar00 'phpBB version 2.0.18 or better', 'short_name' => 'phpbb2018', 'support_url' => 'http://www.phpbb.com/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,config.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', 'cookie_prefix_default' => 'phpbb2mysql', 'cookie_prefix_used' => 'cookie', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class phpbb2018_udb extends core_udb { function phpbb2018_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { $this->boardurl = 'http://www.yousite.com/phpBB2'; require_once('../phpBB2/config.php'); } else { $this->boardurl = $BRIDGE['full_forum_url']; require_once($BRIDGE['relative_path_to_config_file'] . 'config.php'); $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } $this->use_post_based_groups = 0; $this->multigroups = 1; // Database connection settings $this->db = array( 'name' => $dbname, 'host' => $dbhost ? $dbhost : 'localhost', 'user' => $dbuser, 'password' => $dbpasswd, 'prefix' =>$table_prefix ); // Board table names $this->table = array( 'users' => 'users', 'groups' => 'groups', 'sessions' => 'sessions', 'usergroups' => 'user_group', 'sessionskeys' => 'sessions_keys' ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; $this->usergroupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['usergroups']; $this->sessionskeystable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessionskeys']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'user_id', // name of 'id' field in users table 'password' => 'user_password', // name of 'password' field in users table 'email' => 'user_email', // name of 'email' field in users table 'regdate' => 'user_regdate', // name of 'registered' field in users table 'active' => 'user_active', // is user account active? 'lastvisit' => 'user_lastvisit', // name of 'location' field in users table 'location' => 'user_from', // name of 'location' field in users table 'website' => 'user_website', // name of 'website' field in users table 'usertbl_group_id' => 'group_id', // name of 'group id' field in users table 'grouptbl_group_id' => 'group_id', // name of 'group id' field in groups table 'grouptbl_group_name' => 'group_name' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/profile.php?mode=register', 'editusers' => '/memberlist.php', 'edituserprofile' => "/profile.php?mode=viewprofile&u=", ); // Group ids - admin and guest only. $this->admingroups = array(2); $this->guestgroup = 3; // Use a special function to collect groups for cpg groups table $this->group_overrride = 1; // Cookie settings - used in following functions only $this->cookie_name = $BRIDGE['cookie_prefix']; // Connect to db $this->connect(); } function collect_groups() { $sql ="SELECT * FROM {$this->groupstable} WHERE group_single_user = 0"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(102 =>'Administrators', 2=> 'Registered', 3=>'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']]+100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); //if (isset($_COOKIE[$this->cookie_name . '_sid'])) { // $this->sid = addslashes($_COOKIE[$this->cookie_name . '_sid']); if ($superCage->cookie->keyExists($this->cookie_name . '_sid')) { $this->sid = addslashes($superCage->cookie->getRaw($this->cookie_name . '_sid')); $sql = "SELECT u.{$this->field['user_id']} AS user_id, u.{$this->field['password']} AS password, u.user_level FROM {$this->usertable} AS u, {$this->sessionstable} AS s WHERE u.{$this->field['user_id']}=s.session_user_id AND s.session_id = '{$this->sid}' AND u.user_id > 0"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)){ $row = mysql_fetch_array($result); $this->userlevel = $row['user_level']; return $row; } else { return false; } } } // Get groups of which user is member function get_groups($row) { $data = array(); if ($this->use_post_based_groups){ $sql = "SELECT ug.{$this->field['usertbl_group_id']}+100 AS group_id FROM {$this->usertable} AS u, {$this->usergroupstable} AS ug, {$this->groupstable} as g WHERE u.{$this->field['user_id']}=ug.{$this->field['user_id']} AND u.{$this->field['user_id']}='{$row['id']}' AND g.{$this->field['grouptbl_group_id']} = ug.{$this->field['grouptbl_group_id']}"; $result = cpg_db_query($sql, $this->link_id); while ($row2 = mysql_fetch_array($result)) { $data[] = $row2['group_id']; } if ($this->userlevel == 1 || in_array($row[$this->field['usertbl_group_id']] , $this->admingroups)) array_unshift($data, 102); if ($this->userlevel == 0) array_unshift($data, 2); } else { $data[0] = ($this->userlevel == 1 || in_array($row[$this->field['usertbl_group_id']] , $this->admingroups)) ? 1 : 2; } return $data; } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { $superCage = Inspekt::makeSuperCage(); $id = 0; $pass = ''; //if (isset($_COOKIE[$this->cookie_name.'_data'])){ // $sessiondata = unserialize($_COOKIE[$this->cookie_name.'_data']); if ($superCage->cookie->keyExists($this->cookie_name.'_data')){ $sessiondata = unserialize($superCage->cookie->getRaw($this->cookie_name.'_data')); $cookieid = $sessiondata['userid'] > 1 ? intval($sessiondata['userid']) : 0; $cookiepass = (isset($sessiondata['autologinid'])) ? addslashes($sessiondata['autologinid']) : ''; $sql = "SELECT u.user_id, u.user_password FROM {$this->sessionskeystable} AS s INNER JOIN {$this->usertable} AS u ON s.user_id = u.user_id WHERE u.user_id = '$cookieid' AND u.user_active = 1 AND s.key_id = MD5('$cookiepass')"; $result = cpg_db_query($sql, $this->link_id); list($id, $pass) = mysql_fetch_row($result); $this->sid = 0; } return ($id) ? array($id, $pass) : false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; // unused } function login_page() { global $CONFIG; $cpg = parse_url($CONFIG['site_url']); $bb = parse_url($this->boardurl); $levels = count(explode('/', $bb['path'])) - 1; $redirect = str_repeat('../', $levels) . trim($cpg['path'], '/') . '/'; $this->redirect("/login.php?redirect=$redirect"); } function logout_page() { global $CONFIG; $cpg = parse_url($CONFIG['site_url']); $bb = parse_url($this->boardurl); $levels = count(explode('/', $bb['path'])) - 1; $redirect = str_repeat('../', $levels) . trim($cpg['path'], '/') . '/'; $this->redirect("/login.php?logout=true&sid={$this->sid}&redirect=$redirect"); } function view_users() {} function view_profile() {} function get_users($options = array()) { global $CONFIG; // Copy UDB fields and config variables (just to make it easier to read) $f =& $this->field; $C =& $CONFIG; // Sort codes $sort_codes = array('name_a' => 'user_name ASC', 'name_d' => 'user_name DESC', 'group_a' => 'group_name ASC', 'group_d' => 'group_name DESC', 'reg_a' => 'user_regdate ASC', 'reg_d' => 'user_regdate DESC', 'pic_a' => 'pic_count ASC', 'pic_d' => 'pic_count DESC', 'disku_a' => 'disk_usage ASC', 'disku_d' => 'disk_usage DESC', 'lv_a' => 'user_lastvisit ASC', 'lv_d' => 'user_lastvisit DESC', ); if (in_array($options['sort'], array('group_a', 'group_d', 'pic_a', 'pic_d', 'disku_a', 'disku_d'))){ $sort = ''; list($this->sortfield, $this->sortdir) = explode(' ', $sort_codes[$options['sort']]); $this->adv_sort = true; } else { $sort = "ORDER BY " . $sort_codes[$options['sort']]; $this->adv_sort = false; } // Build WHERE clause, if this is a username search if ($options['search']) { $options['search'] = 'AND u.'.$f['username'].' LIKE "'.$options['search'].'" '; } $sql = "SELECT group_id, group_name, group_quota FROM {$C['TABLE_USERGROUPS']}"; $result = cpg_db_query($sql); $groups = array(); while ($row = mysql_fetch_assoc($result)) { $groups[$row['group_id']] = $row; } $sql ="SELECT group_id FROM {$this->groupstable} WHERE group_single_user = 0"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(); while ($row = mysql_fetch_assoc($result)) { $udb_groups[] = $row['group_id']; } $sql = "SELECT u.{$f['user_id']} as user_id, MIN(ug.{$f['grouptbl_group_id']}) AS user_group, {$f['username']} as user_name, {$f['email']} as user_email, {$f['regdate']} as user_regdate, {$f['lastvisit']} as user_lastvisit, '' as user_active, 0 as pic_count, 0 as disk_usage ". "FROM {$this->usertable} AS u ". "INNER JOIN {$this->usergroupstable} AS ug ON u.{$this->field['user_id']}=ug.{$this->field['user_id']} ". "WHERE u.{$f['user_id']} > 0 " . $options['search']. "GROUP BY ug.{$f['user_id']} " . $sort . " LIMIT {$options['lower_limit']}, {$options['users_per_page']};"; $result = cpg_db_query($sql, $this->link_id); // If no records, return empty value if (!mysql_num_rows($result)) { return array(); } // Extract user list to an array while ($user = mysql_fetch_assoc($result)) { $gid = 2; if ($this->use_post_based_groups){ if (in_array($user['user_group'], $udb_groups)){ $gid = $user['user_group'] + 100; } elseif ($user['user_level'] == 1 || in_array($user['user_group'], $this->admingroups)){ $gid = 102; } } else { if ($user['user_level'] == 1 || in_array($user['user_group'], $this->admingroups)){ $gid = 1; } } $userlist[$user['user_id']] = array_merge($user, $groups[$gid]); $users[] = $user['user_id']; } $user_list_string = implode(', ', $users); $sql = "SELECT owner_id, COUNT(pid) as pic_count, ROUND(SUM(total_filesize)/1024) as disk_usage FROM {$C['TABLE_PICTURES']} WHERE owner_id IN ($user_list_string) GROUP BY owner_id"; $result = cpg_db_query($sql); while ($owner = mysql_fetch_assoc($result)) { $userlist[$owner['owner_id']] = array_merge($userlist[$owner['owner_id']], $owner); } if ($this->adv_sort) usort($userlist, array('cpg_udb', 'adv_sort')); return $userlist; } function adv_sort($a, $b) { if ($this->sortdir == 'ASC'){ return strcmp($a[$this->sortfield], $b[$this->sortfield]); } else { return strcmp($b[$this->sortfield], $a[$this->sortfield]); } } } // and go ! $cpg_udb = new phpbb2018_udb; } ?>phorum.inc.php000064400000016737152532121430007353 0ustar00 'Phorum 5', 'short_name' => 'phorum', 'support_url' => 'http://www.phorum.org/', 'full_forum_url_default' => '', 'full_forum_url_used' => '', 'relative_path_to_config_file_default' => '../phorum/', 'relative_path_to_config_file_used' => 'lookfor,common.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; $dir = getcwd(); chdir($BRIDGE['relative_path_to_config_file']); if (!USE_BRIDGEMGR) { require_once('../phorum/common.php'); } else { require_once($BRIDGE['relative_path_to_config_file'] . 'common.php'); } chdir($dir); class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE, $CONFIG, $PHORUM; $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; $this->boardurl = $PHORUM['http_path']; $this->multigroups = 1; $this->group_overrride = 1; // Board table names $this->table = array( 'users' => 'users', 'groups' => 'groups', 'usergroups' => 'user_group_xref' ); // Database connection settings $this->db = array( 'name' => $PHORUM['DBCONFIG']['name'], 'host' => $PHORUM['DBCONFIG']['server'], 'user' => $PHORUM['DBCONFIG']['user'], 'password' => $PHORUM['DBCONFIG']['password'], 'prefix' =>$PHORUM['DBCONFIG']['table_prefix'] . '_' ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->usergroupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['usergroups']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'user_id', // name of 'id' field in users table 'password' => 'password', // name of the password field in the users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'date_added', // name of 'registered' field in users table 'lastvisit' => 'date_last_active', // last time user logged in 'active' => 'active', // is user account active? 'location' => "''", // name of 'location' field in users table 'website' => "''", // name of 'website' field in users table 'usertbl_group_id' => 'NOT_USED', // name of 'group id' field in users table 'grouptbl_group_id' => 'group_id', // name of 'group id' field in groups table 'grouptbl_group_name' => 'name' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/register.php?1', 'editusers' => '/admin.php?module=users', 'edituserprofile' => '/profile.php?1,', ); // Group ids - admin and guest only. $this->admingroups = array(1); $this->guestgroup = 3; // Connect to db - or supply a connection id to be used instead of making own connection. $this->connect(); } // Probably not a good idea to override this, come up with a better way later. function authenticate() { global $PHORUM, $USER_DATA; if (!$PHORUM['user']['user_id']){ $this->load_guest_data(); } else { $this->load_user_data(array('id' => $PHORUM['user']['user_id'], 'username' => $PHORUM['user']['username'])); $USER_DATA['groups'] = array(); if ($PHORUM['user']['admin']){ $USER_DATA['groups'][] = 1; } else { $USER_DATA['groups'][] = 2; } if ($this->use_post_based_groups){ foreach ($PHORUM['user']['groups'] as $group){ $USER_DATA['groups'][] = $group + 100; } } } $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')'; $USER_DATA = array_merge($USER_DATA, $this->get_user_data($USER_DATA['groups'][0], $USER_DATA['groups'], $this->guestgroup)); $USER_DATA['has_admin_access'] = (int) $PHORUM['user']['admin']; $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access']; // avoids a template error if (!$USER_DATA['user_id']) $USER_DATA['can_create_albums'] = 0; // For error checking $CONFIG['TABLE_USERS'] = '**ERROR**'; define('USER_ID', $USER_DATA['user_id']); define('USER_NAME', addslashes($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_ACCESS_LEVEL', (int)$USER_DATA['access_level']); $this->session_update(); } function collect_groups() { $sql ="SELECT * FROM {$this->groupstable}"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(1=>'Administrators', 2=>'Registered', 3 => 'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']]+100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; } function login_page() { global $CONFIG; $this->redirect('/login.php'); } function logout_page() { global $CONFIG; $this->redirect('/login.php,logout=1'); } //function view_users() {} function view_profile() {} } // and go ! $cpg_udb = new cpg_udb; } ?>xmb.inc.php000064400000023756152532121430006626 0ustar00 'XMB 1.9', 'short_name' => 'xmb', 'support_url' => 'http://www.xmbforum.com/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,config.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { // the vars that are used when bridgemgr is disabled // URL of your board $this->boardurl = 'http://localhost/XMB'; // local path to your board's config file require_once('../XMB/config.php'); $this->use_post_based_groups = 1; } else { // the vars from the bridgemgr $this->boardurl = $BRIDGE['full_forum_url']; require_once($BRIDGE['relative_path_to_config_file'] . 'config.php'); $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } // multiple groups are not actually supported, but need this set due to the unusual group implementation in XMB. $this->multigroups = 1; $this->group_overrride = 1; // Database connection settings $this->db = array( 'name' => $dbname, 'host' => $dbhost, 'user' => $dbuser, 'password' => $dbpw, 'prefix' =>$tablepre ); // Board table names $this->table = array( 'users' => 'members', 'groups' => 'ranks', ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'uid', // name of 'id' field in users table 'password' => 'password', // name of 'password' field in users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'regdate', // name of 'registered' field in users table 'location' => 'location', // name of 'location' field in users table 'website' => 'site', // name of 'website' field in users table 'usertbl_group_id' => 'status', // name of 'group id' field in users table 'grouptbl_group_id' => 'title', // name of 'group id' field in groups table 'grouptbl_group_name' => 'title', // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/register.php', 'editusers' => '/misc.php?action=list', 'edituserprofile' => '/member.php?action=viewpro&member=' ); // Group ids $this->admingroups = array(8,9); $this->guestgroup = 3; // Connect to db $this->connect(); } function collect_groups() { $sql = "SELECT * FROM {$this->groupstable}"; $result = cpg_db_query($sql, $this->link_id); // XMB has no guest group in groups table, so adding one here $udb_groups = array(3=>'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row['id']+100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; } function get_groups($row) { $id = $row['id']; $sql = "SELECT id FROM {$this->groupstable}, {$this->usertable} WHERE {$this->field['usertbl_group_id']} = {$this->field['grouptbl_group_id']} AND {$this->field['user_id']}='$id'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)){ $row = mysql_fetch_row($result); if ($this->use_post_based_groups){ $row = array($row[0] + 100); } else { if (in_array($row[0], $this->admingroups)){ $row = array(1); } else { $row = array(2); } } return $row; } else { return false; } } function get_users($options = array()) { global $CONFIG; // Copy UDB fields and config variables (just to make it easier to read) $f =& $this->field; $C =& $CONFIG; // Sort codes $sort_codes = array('name_a' => 'user_name ASC', 'name_d' => 'user_name DESC', 'group_a' => 'group_name ASC', 'group_d' => 'group_name DESC', 'reg_a' => 'user_regdate ASC', 'reg_d' => 'user_regdate DESC', 'pic_a' => 'pic_count ASC', 'pic_d' => 'pic_count DESC', 'disku_a' => 'disk_usage ASC', 'disku_d' => 'disk_usage DESC', 'lv_a' => 'user_lastvisit ASC', 'lv_d' => 'user_lastvisit DESC', ); $f['usertbl_group_id'] = 'id'; // Fix the group id, if bridging is enabled if ($CONFIG['bridge_enable']) { $f['usertbl_group_id'] .= '+100'; } // Build WHERE clause, if this is a username search if ($options['search']) { $options['search'] = 'WHERE u.'.$f['username'].' LIKE "'.$options['search'].'" '; } // Build SQL table, should work with all bridges $sql = "SELECT {$f['user_id']} as user_id, {$f['username']} as user_name, {$f['email']} as user_email, {$f['regdate']} as user_regdate, lastvisit as user_lastvisit, '' as user_active, ". "COUNT(pid) as pic_count, ROUND(SUM(total_filesize)/1024) as disk_usage, group_name, group_quota ". "FROM {$this->usertable} AS u ". "INNER JOIN {$this->groupstable} AS rank ON u.status = rank.title ". " INNER JOIN {$C['TABLE_USERGROUPS']} AS g ". "ON g.group_id = rank.{$f['usertbl_group_id']} LEFT JOIN {$C['TABLE_PICTURES']} AS p ON p.owner_id = u.{$f['user_id']} ". $options['search']. "GROUP BY user_id " . "ORDER BY " . $sort_codes[$options['sort']] . " ". "LIMIT {$options['lower_limit']}, {$options['users_per_page']};"; $result = cpg_db_query($sql); // If no records, return empty value if (!$result) { return array(); } // Extract user list to an array while ($user = mysql_fetch_assoc($result)) { $userlist[] = $user; } return $userlist; } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); //if (isset($_COOKIE['xmbpw']) && isset($_COOKIE['xmbuser'])){ // return array($this->get_user_id($_COOKIE['xmbuser']), $_COOKIE['xmbpw']); if ($superCage->cookie->keyExists('xmbpw') && $superCage->cookie->keyExists('xmbuser')){ return array($this->get_user_id($superCage->cookie->getRaw('xmbuser'), $superCage->cookie->getRaw('xmbpw'))); } else { return false; } } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { return false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; } // Login function login_page() { $this->redirect('/misc.php?action=login'); } // Logout function logout_page() { $this->redirect('/misc.php?action=logout'); } // View users function view_users() { } // View user profile function view_profile($uid) { } // Edit user profile function edit_profile($uid) { $this->redirect($this->page['edituserprofile'].$this->get_user_name($uid)); } } // and go ! $cpg_udb = new cpg_udb; } ?>phpbb3.inc.php000064400000017271152532121430007211 0ustar00 'phpBB version 3', 'short_name' => 'phpbb3', 'support_url' => 'http://www.phpbb.com/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,config.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', 'cookie_prefix_default' => '', 'cookie_prefix_used' => 'cookie', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { // the vars that are used when bridgemgr is disabled // URL of your punbb $this->boardurl = 'http://localhost/phpBB2'; // local path to your punbb config file require_once('../phpBB2/config.php'); } else { // the vars from the bridgemgr $this->boardurl = $BRIDGE['full_forum_url']; require_once($BRIDGE['relative_path_to_config_file'] . 'config.php'); $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } $this->multigroups = 1; // Database connection settings $this->db = array( 'name' => $dbname, 'host' => $dbhost ? $dbhost : 'localhost', 'user' => $dbuser, 'password' => $dbpasswd, 'prefix' => $table_prefix ); // Board table names $this->table = array( 'users' => 'users', 'groups' => 'groups', 'sessions' => 'sessions', 'usergroups' => 'user_group', ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; $this->usergroupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['usergroups']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'user_id', // name of 'id' field in users table 'password' => 'user_password', // name of 'password' field in users table 'email' => 'user_email', // name of 'email' field in users table 'regdate' => 'user_regdate', // name of 'registered' field in users table 'active' => 'user_active', // is user account active? 'lastvisit' => 'user_lastvisit', // name of 'location' field in users table 'location' => 'user_from', // name of 'location' field in users table 'website' => 'user_website', // name of 'website' field in users table 'usertbl_group_id' => 'group_id', // name of 'group id' field in users table 'grouptbl_group_id' => 'group_id', // name of 'group id' field in groups table 'grouptbl_group_name' => 'group_name' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/ucp.php?mode=register', 'editusers' => '/memberlist.php', 'edituserprofile' => "/memberlist.php?mode=viewprofile&u=", ); // Group ids $this->admingroups = $BRIDGE['admingroups_phpbb3'] ? explode(',', $BRIDGE['admingroups_phpbb3']) : array(5); // workaround - store admin and guest group IDs in bridge database in cpg1.6.x $this->guestgroup = 1; // Cookie settings - used in following functions only $this->cookie_name = $BRIDGE['cookie_prefix']; // Connect to db $this->connect(); } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists($this->cookie_name . '_sid')) { $this->session_id = $superCage->cookie->getEscaped($this->cookie_name . '_sid'); $sql = "SELECT user_id, user_password, group_id FROM {$this->sessionstable} INNER JOIN {$this->usertable} ON session_user_id = user_id WHERE session_id = '{$this->session_id}'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)){ $row = mysql_fetch_array($result); $this->primary_group = array_pop($row); return $row['user_id'] == 1 ? false : $row; } else { return false; } } } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { return false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; // unused } // Get groups of which user is member function get_groups($row) { $data = array(); if ($this->use_post_based_groups) { $data[] = $this->primary_group + 100; $sql = "SELECT group_id FROM {$this->usergroupstable} WHERE user_id = {$row['id']}"; $result = cpg_db_query($sql, $this->link_id); while ($group = mysql_fetch_assoc($result)) { $data[] = $group['group_id'] + 100; } $data = array_unique($data); } else { $data[0] = (in_array($this->primary_group, $this->admingroups)) ? 1 : 2; } return $data; } function login_page() { global $CONFIG; $redirect = urlencode($CONFIG['site_url']); $this->redirect("/ucp.php?mode=login&redirect=$redirect"); } function logout_page() { global $CONFIG; $redirect = urlencode($CONFIG['site_url']); $this->redirect("/ucp.php?mode=logout&redirect=$redirect&sid=" . $this->session_id); } function view_users() { $this->redirect($this->page['editusers']); } function get_users($options = array()) { } function view_profile($uid) { } } // and go ! $cpg_udb = new cpg_udb; } ?>vbulletin30.inc.php000064400000017712152532121430010202 0ustar00 'vBulletin 3.0', 'short_name' => 'vbulletin30', 'support_url' => 'http://www.vbulletin.com/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,includes/config.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { $this->boardurl = 'http://www.yousite.com/vb3'; require_once('../vb3/includes/config.php'); } else { $this->boardurl = $BRIDGE['full_forum_url']; require_once($BRIDGE['relative_path_to_config_file'] . 'includes/config.php'); $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } $this->multigroups = 1; // Database connection settings if (isset($config['Database']['dbname'])) { // Running on vBulletin 3.5.x $this->db = array( 'name' => $config['Database']['dbname'], 'host' => $config['MasterServer']['servername'] ? $config['MasterServer']['servername'] : 'localhost', 'user' => $config['MasterServer']['username'], 'password' => $config['MasterServer']['password'], 'prefix' => $config['Database']['tableprefix'] ); } else { // Running on vBulletin 3.0.x $this->db = array( 'name' => $dbname, 'host' => $servername ? $servername : 'localhost', 'user' => $dbusername, 'password' => $dbpassword, 'prefix' =>$tableprefix ); } // Board table names $this->table = array( 'users' => 'user', 'groups' => 'usergroup', 'sessions' => 'session' ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'userid', // name of 'id' field in users table 'password' => 'password', // name of 'password' field in users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'joindate', // name of 'registered' field in users table 'location' => "''", // name of 'location' field in users table 'website' => 'homepage', // name of 'website' field in users table 'usertbl_group_id' => 'usergroupid', // name of 'group id' field in users table 'grouptbl_group_id' => 'usergroupid', // name of 'group id' field in groups table 'grouptbl_group_name' => 'title' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/register.php', 'editusers' => '/memberlist.php', 'edituserprofile' => "/member.php?u=", ); // Group ids - admin and guest only. $this->admingroups = array(6); $this->guestgroup = 1; // Use a special function to collect groups for cpg groups table $this->group_overrride = 0; // Cookie settings - used in following functions only if (isset($config['Misc']['cookieprefix'])) { // get cookieprefix from vb3.5.x $this->cookie_name = $config['Misc']['cookieprefix']; } else { // get cookieprefix from vb3.0.x $this->cookie_name = $cookieprefix; } // Connect to db $this->connect(); } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists($this->cookie_name . 'sessionhash')) { $session_id = $superCage->cookie->getEscaped($this->cookie_name . 'sessionhash'); } elseif ($superCage->cookie->keyExists($this->cookie_name . '_sessionhash')) { $session_id = $superCage->cookie->getEscaped($this->cookie_name . '_sessionhash'); } $sql = "SELECT u.{$this->field['user_id']}, u.{$this->field['password']}, u.{$this->field['grouptbl_group_id']}+100 AS usergroupid FROM {$this->usertable} AS u, {$this->sessionstable} AS s WHERE s.{$this->field['user_id']}=u.{$this->field['user_id']} AND s.sessionhash='$session_id'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)){ $row = mysql_fetch_array($result); return $row; } else { return false; } } // Get groups of which user is member function get_groups($row) { $data[0] = in_array($row['group_id'] - 100, $this->admingroups) ? 1 : 2; if ($this->use_post_based_groups){ $sql = "SELECT g.{$this->field['usertbl_group_id']}+100 AS group_id, u.* FROM {$this->usertable} AS u, {$this->groupstable} as g WHERE g.{$this->field['grouptbl_group_id']} = u.{$this->field['usertbl_group_id']} AND u.{$this->field['user_id']} = '{$row['id']}'"; $result = cpg_db_query($sql, $this->link_id); $row = mysql_fetch_array($result); $data[0] = $row['group_id']; if ($row['membergroupids']){ $groups = explode(',', $row['membergroupids']); foreach ($groups as $id => $group){ $data[] = $group+100; } } } return $data; } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { return false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; // unused } function login_page() { $this->redirect("/index.php"); } function logout_page() { $this->redirect("/login.php?do=logout&u=".USER_ID); } } // and go ! $cpg_udb = new cpg_udb; } ?>invisionboard20.inc.php000064400000014271152532121430011040 0ustar00 'Invision Power Board 2.x', 'short_name' => 'invisionboard20', 'support_url' => 'http://forums.invisionpower.com/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,conf_global.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { $this->boardurl = 'http://localhost/ipb'; require_once('../ipb/conf_global.php'); $this->use_post_based_groups = 0; } else { require_once($BRIDGE['relative_path_to_config_file'] . '/conf_global.php'); $this->boardurl = $INFO['board_url']; $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } // Database connection settings $this->db = array( 'name' => $INFO['sql_database'], 'host' => $INFO['sql_host'] ? $INFO['sql_host'] : 'localhost', 'user' => $INFO['sql_user'], 'password' => $INFO['sql_pass'], 'prefix' => $INFO['sql_tbl_prefix'], ); // Board table names $this->table = array( 'users' => 'members', 'groups' => 'groups', 'sessions' => 'sessions', ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; // Table field names $this->field = array( 'username' => 'name', // name of 'username' field in users table 'user_id' => 'id', // name of 'id' field in users table 'password' => 'member_login_key', // name of 'password' field in users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'joined', // name of 'registered' field in users table 'location' => "''", // name of 'location' field in users table 'website' => "''", // name of 'website' field in users table 'usertbl_group_id' => 'mgroup', // name of 'group id' field in users table 'grouptbl_group_id' => 'g_id', // name of 'group id' field in groups table 'grouptbl_group_name' => 'g_title', // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/index.php?act=Reg&CODE=00', 'editusers' => '/admin.php', 'edituserprofile' => '/index.php?showuser=', ); // Group ids - admin and guest only. $this->admingroups = array($INFO['admin_group']); $this->guestgroup = $INFO['guest_group']; // Connect to db $this->connect(); } // definition of how to extract id, pass from session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists('session_id')) { $session_id = $superCage->cookie->getEscaped('session_id'); $sql = "SELECT member_id, member_login_key FROM {$this->sessionstable} AS s INNER JOIN {$this->usertable} AS u ON s.member_id = u.id WHERE s.id = '$session_id'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)) { $row = mysql_fetch_row($result); return $row; } } else { return false; } } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { $superCage = Inspekt::makeSuperCage(); $id = 0; $pass = ''; if ($superCage->cookie->keyExists('member_id') && $superCage->cookie->keyExists('pass_hash')) { $id = $superCage->cookie->getInt('member_id'); $pass = substr($superCage->cookie->getEscaped('pass_hash'), 0, 32); } return ($id) ? array($id, $pass) : false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; // unused } function login_page() { $this->redirect("/index.php?act=Login&CODE=00"); } function logout_page() { $this->redirect("/index.php?act=Login&CODE=03"); } } // and go ! $cpg_udb = new cpg_udb; } xoops.inc.php000064400000021165152532121430007200 0ustar00 'Xoops 2.0', 'short_name' => 'xoops', 'support_url' => 'http://www.xoops.org/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,mainfile.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; if (!USE_BRIDGEMGR) { require_once('../xoops/mainfile.php'); } else { require_once($BRIDGE['relative_path_to_config_file'] . 'mainfile.php'); } //print_r($_SESSION); //print_r($xoopsDB); // reset to cpg db mysql_select_db($CONFIG['dbname']); class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE, $xoopsDB; $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; $this->boardurl = XOOPS_URL; $this->multigroups = 1; $this->group_overrride = 0; // Board table names $this->table = array( 'users' => 'users', 'groups' => 'groups', 'usergroups' => 'groups_users_link' ); // Database connection settings $this->db = array( 'name' => XOOPS_DB_NAME, 'prefix' =>XOOPS_DB_PREFIX . '_', 'host' =>XOOPS_DB_HOST, 'user' => XOOPS_DB_USER ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->usergroupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['usergroups']; // Table field names $this->field = array( 'username' => 'uname', // name of 'username' field in users table 'user_id' => 'uid', // name of 'id' field in users table 'password' => 'pass', // name of the password field in the users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'user_regdate', // name of 'registered' field in users table 'lastvisit' => 'last_login', // last time user logged in 'active' => "''", // is user account active? 'location' => "''", // name of 'location' field in users table 'website' => 'url', // name of 'website' field in users table 'usertbl_group_id' => 'uid', // name of 'group id' field in users table 'grouptbl_group_id' => 'groupid', // name of 'group id' field in groups table 'grouptbl_group_name' => 'name' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/register.php', 'editusers' => '/index.php?action=mlist', 'edituserprofile' => '/userinfo.php?uid=' ); // Group ids - admin and guest only. $this->admingroups = array(XOOPS_GROUP_ADMIN); $this->guestgroup = XOOPS_GROUP_ANONYMOUS; // Connect to db - or supply a connection id to be used instead of making own connection. $this->connect($xoopsDB->conn); } function get_groups($row) { if ($this->use_post_based_groups){ //$groups = $_SESSION['xoopsUserGroups']; //foreach ($groups as $a => &$b) $b += 100; $groups = array(); foreach ($_SESSION['xoopsUserGroups'] as $a => $b) $groups[$a] = $b + 100; return $groups; } return array($_SESSION['xoopsUserGroups'][0]); } // definition of how to extract id, name, group from a session cookie function session_extraction() { return array($_SESSION['xoopsUserId'], 'fudge'); } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { return false; //unused } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return 'fudge'; } function login_page() { global $CONFIG; $parts = parse_url($CONFIG['site_url']); $path = $parts['path']; $this->redirect("/user.php?xoops_redirect=$path"); } function logout_page() { global $CONFIG; $parts = parse_url($CONFIG['site_url']); $path = $parts['path']; $this->redirect("/user.php?op=logout&xoops_redirect=$path"); } function view_users() { } function get_users($options = array()) { global $CONFIG; // Copy UDB fields and config variables (just to make it easier to read) $f =& $this->field; $C =& $CONFIG; // Sort codes $sort_codes = array('name_a' => 'user_name ASC', 'name_d' => 'user_name DESC', 'group_a' => 'group_name ASC', 'group_d' => 'group_name DESC', 'reg_a' => 'user_regdate ASC', 'reg_d' => 'user_regdate DESC', 'pic_a' => 'pic_count ASC', 'pic_d' => 'pic_count DESC', 'disku_a' => 'disk_usage ASC', 'disku_d' => 'disk_usage DESC', 'lv_a' => 'user_lastvisit ASC', 'lv_d' => 'user_lastvisit DESC', ); // Fix the group id, if bridging is enabled if ($CONFIG['bridge_enable']) { $f['usertbl_group_id'] .= '+100'; } // Build WHERE clause, if this is a username search if ($options['search']) { $options['search'] = 'WHERE u.'.$f['username'].' LIKE "'.$options['search'].'" '; } // Build SQL table, should work with all bridges $sql = "SELECT u.{$f['user_id']} as user_id, {$f['username']} as user_name, {$f['email']} as user_email, {$f['regdate']} as user_regdate, {$f['lastvisit']} as user_lastvisit, '' as user_active, ". "COUNT(pid) as pic_count, ROUND(SUM(total_filesize)/1024) as disk_usage, group_name, group_quota ". "FROM {$this->usertable} AS u ". "INNER JOIN {$this->usergroupstable} AS ug ON u.uid = ug.uid ". " INNER JOIN {$C['TABLE_USERGROUPS']} AS g ". "ON g.group_id = ug.{$f['grouptbl_group_id']} LEFT JOIN {$C['TABLE_PICTURES']} AS p ON p.owner_id = u.{$f['user_id']} ". $options['search']. "GROUP BY user_id " . "ORDER BY " . $sort_codes[$options['sort']] . " ". "LIMIT {$options['lower_limit']}, {$options['users_per_page']};"; $result = cpg_db_query($sql); // If no records, return empty value if (!$result) { return array(); } // Extract user list to an array while ($user = mysql_fetch_assoc($result)) { $userlist[] = $user; } return $userlist; } } // and go ! $cpg_udb = new cpg_udb; } ?>punbb12.inc.php000064400000023524152532121440007303 0ustar00 'PunBB v1.2', 'short_name' => 'punbb12', 'support_url' => 'http://www.punbb.org/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,config.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { // the vars that are used when bridgemgr is disabled // URL of your punbb $this->boardurl = 'http://www.yoursite.com/punbb'; // local path to your punbb config file require_once('../punbb/config.php'); } else { // the vars from the bridgemgr $this->boardurl = $BRIDGE['full_forum_url']; require_once($BRIDGE['relative_path_to_config_file'] . 'config.php'); $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } $this->multigroups = 0; $this->group_overrride = 0; // Database connection settings $this->db = array( 'name' => $db_name, 'host' => $db_host, 'user' => $db_username, 'password' => $db_password, 'prefix' =>$db_prefix ); // Board table names $this->table = array( 'users' => 'users', 'groups' => 'groups', ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'id', // name of 'id' field in users table 'password' => 'password', // name of 'password' field in users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'registered', // name of 'registered' field in users table 'location' => 'location', // name of 'location' field in users table 'website' => 'url', // name of 'website' field in users table 'lastvisit' => 'last_visit', // name of 'location' field in users table 'usertbl_group_id' => 'group_id', // name of 'group id' field in users table 'grouptbl_group_id' => 'g_id', // name of 'group id' field in groups table 'grouptbl_group_name' => 'g_title' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/register.php', 'editusers' => '/userlist.php', 'edituserprofile' => "/profile.php?id=" ); // Group ids $this->admingroups = array(1); $this->guestgroup = 3; // Cookie settings - used in following functions only $this->cookie_name = $cookie_name; $this->cookie_seed = $cookie_seed; // Connect to db $this->connect(); } // definition of how to extract id, name, group from a session cookie function session_extraction() { return false; // unused } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { $superCage = Inspekt::makeSuperCage(); $id = 0; $pass_hash = ''; //if (isset($_COOKIE[$this->cookie_name])){ // list($id, $pass_hash) = unserialize($_COOKIE[$this->cookie_name]); //} if ($superCage->cookie->keyExists($this->cookie_name)){ list($id, $pass_hash) = unserialize($superCage->cookie->getRaw($this->cookie_name)); } return ($id) ? array($id, $pass_hash) : false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return md5($this->cookie_seed.$password); } // Login function login_page() { global $CONFIG; $this->redirect('/login.php?action=login&redir='.$CONFIG['site_url']); } // Logout function logout_page() { global $CONFIG; $this->redirect('/login.php?action=out&id='.USER_ID.'&redir='.$CONFIG['site_url']); } function view_users() {} function view_profile($uid) {} function get_users($options = array()) { global $CONFIG; // Copy UDB fields and config variables (just to make it easier to read) $f =& $this->field; $C =& $CONFIG; // Sort codes $sort_codes = array('name_a' => 'user_name ASC', 'name_d' => 'user_name DESC', 'group_a' => 'group_name ASC', 'group_d' => 'group_name DESC', 'reg_a' => 'user_regdate ASC', 'reg_d' => 'user_regdate DESC', 'pic_a' => 'pic_count ASC', 'pic_d' => 'pic_count DESC', 'disku_a' => 'disk_usage ASC', 'disku_d' => 'disk_usage DESC', 'lv_a' => 'user_lastvisit ASC', 'lv_d' => 'user_lastvisit DESC', ); if (in_array($options['sort'], array('group_a', 'group_d', 'pic_a', 'pic_d', 'disku_a', 'disku_d'))){ $sort = ''; list($this->sortfield, $this->sortdir) = explode(' ', $sort_codes[$options['sort']]); $this->adv_sort = true; } else { $sort = "ORDER BY " . $sort_codes[$options['sort']]; $this->adv_sort = false; } // Build WHERE clause, if this is a username search if ($options['search']) { $options['search'] = 'AND u.'.$f['username'].' LIKE "'.$options['search'].'" '; } $sql = "SELECT group_id, group_name, group_quota FROM {$C['TABLE_USERGROUPS']}"; $result = cpg_db_query($sql); $groups = array(); while ($row = mysql_fetch_assoc($result)) { $groups[$row['group_id']] = $row; } $sql ="SELECT {$f['grouptbl_group_id']} FROM {$this->groupstable}"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(); while ($row = mysql_fetch_assoc($result)) { $udb_groups[] = $row['group_id']; } $sql = "SELECT u.{$f['user_id']} as user_id, u.{$f['usertbl_group_id']} AS user_group, {$f['username']} as user_name, {$f['email']} as user_email, {$f['regdate']} as user_regdate, {$f['lastvisit']} as user_lastvisit, '' as user_active, 0 AS pic_count ". "FROM {$this->usertable} AS u ". "WHERE u.{$f['user_id']} > 1 " . $options['search'] . $sort . " LIMIT {$options['lower_limit']}, {$options['users_per_page']}"; $result = cpg_db_query($sql, $this->link_id); // If no records, return empty value if (!mysql_num_rows($result)) { return array(); } // Extract user list to an array while ($user = mysql_fetch_assoc($result)) { if ($this->use_post_based_groups){ $gid = $user['user_group'] +100; } else { $gid = $user['user_group'] == $this->admingroups[0] ? 1 : 2; } $userlist[$user['user_id']] = array_merge($user, $groups[$gid]); $users[] = $user['user_id']; } $user_list_string = implode(', ', $users); $sql = "SELECT owner_id, COUNT(pid) as pic_count, ROUND(SUM(total_filesize)/1024) as disk_usage FROM {$C['TABLE_PICTURES']} WHERE owner_id IN ($user_list_string) GROUP BY owner_id"; $result = cpg_db_query($sql); while ($owner = mysql_fetch_assoc($result)) { $userlist[$owner['owner_id']] = array_merge($userlist[$owner['owner_id']], $owner); } if ($this->adv_sort) usort($userlist, array('cpg_udb', 'adv_sort')); return $userlist; } } // and go ! $cpg_udb = new cpg_udb; } ?>phpbb.inc.php000064400000033602152532121440007123 0ustar00 'phpBB versions prior to 2.0.18', 'short_name' => 'phpbb20', 'support_url' => 'http://www.phpbb.com/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,config.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', 'cookie_prefix_default' => 'phpbb2mysql', 'cookie_prefix_used' => 'cookie', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { $this->boardurl = 'http://www.yousite.com/phpBB2'; require_once('../phpBB2/config.php'); } else { $this->boardurl = $BRIDGE['full_forum_url']; require_once($BRIDGE['relative_path_to_config_file'] . 'config.php'); $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } $this->multigroups = 1; // Database connection settings $this->db = array( 'name' => $dbname, 'host' => $dbhost ? $dbhost : 'localhost', 'user' => $dbuser, 'password' => $dbpasswd, 'prefix' =>$table_prefix ); // Board table names $this->table = array( 'users' => 'users', 'groups' => 'groups', 'sessions' => 'sessions', 'usergroups' => 'user_group' ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; $this->usergroupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['usergroups']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'user_id', // name of 'id' field in users table 'password' => 'user_password', // name of 'password' field in users table 'email' => 'user_email', // name of 'email' field in users table 'regdate' => 'user_regdate', // name of 'registered' field in users table 'active' => 'user_active', // is user account active? 'lastvisit' => 'user_lastvisit', // name of 'location' field in users table 'location' => 'user_from', // name of 'location' field in users table 'website' => 'user_website', // name of 'website' field in users table 'usertbl_group_id' => 'group_id', // name of 'group id' field in users table 'grouptbl_group_id' => 'group_id', // name of 'group id' field in groups table 'grouptbl_group_name' => 'group_name' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/ucp.php?mode=register', 'editusers' => '/memberlist.php', 'edituserprofile' => "/memberlist.php?mode=viewprofile&u=", ); // Group ids - admin and guest only. $this->admingroups = array(2); $this->guestgroup = 3; // Use a special function to collect groups for cpg groups table $this->group_overrride = 1; // Cookie settings - used in following functions only $this->cookie_name = $BRIDGE['cookie_prefix']; // Connect to db $this->connect(); } function collect_groups() { $sql ="SELECT * FROM {$this->groupstable} WHERE group_single_user = 0"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(102 =>'Administrators', 2=> 'Registered', 3=>'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']]+100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); //if (isset($_COOKIE[$this->cookie_name . '_sid'])) { // $session_id = addslashes($_COOKIE[$this->cookie_name . '_sid']); if ($superCage->cookie->keyExists($this->cookie_name . '_sid')) { $session_id = $superCage->cookie->getEscaped($this->cookie_name . '_sid'); $sql = "SELECT u.{$this->field['user_id']} AS user_id, u.{$this->field['password']} AS password FROM {$this->usertable} AS u, {$this->sessionstable} AS s WHERE u.{$this->field['user_id']}=s.session_user_id AND s.session_id = '$session_id' AND u.user_id > 0"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)){ $row = mysql_fetch_array($result); return $row; } else { return false; } } } // Get groups of which user is member function get_groups($row) { if ($this->use_post_based_groups){ $sql = "SELECT ug.{$this->field['usertbl_group_id']}+100 AS group_id FROM {$this->usertable} AS u, {$this->usergroupstable} AS ug, {$this->groupstable} as g WHERE u.{$this->field['user_id']}=ug.{$this->field['user_id']} AND u.{$this->field['user_id']}='{$row['id']}' AND g.{$this->field['grouptbl_group_id']} = ug.{$this->field['grouptbl_group_id']}"; $result = cpg_db_query($sql, $this->link_id); while ($row = mysql_fetch_array($result)) { $data[] = $row['group_id']; } } else { $data[0] = in_array($row[$this->field['usertbl_group_id']] , $this->admingroups) ? 1 : 2; } return $data; } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { $superCage = Inspekt::makeSuperCage(); $id = 0; $pass = ''; //if (isset($_COOKIE[$this->cookie_name.'_data'])){ // $sessiondata = unserialize($_COOKIE[$this->cookie_name.'_data']); if ($superCage->cookie->keyExists($this->cookie_name.'_data')){ $sessiondata = unserialize($superCage->cookie->getRaw($this->cookie_name.'_data')); $id = $sessiondata['userid'] > 1 ? intval($sessiondata['userid']) : 0; $pass = (isset($sessiondata['autologinid'])) ? addslashes($sessiondata['autologinid']) : ''; } return ($id) ? array($id, $pass) : false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; // unused } function login_page() { global $CONFIG; $cpg = parse_url($CONFIG['site_url']); $bb = parse_url($this->boardurl); $levels = count(explode('/', $bb['path'])) - 1; $redirect = str_repeat('..', $levels) . rtrim($cpg['path'], '/') . '/'; $this->redirect("/login.php?redirect=$redirect"); } function logout_page() { global $CONFIG; $cpg = parse_url($CONFIG['site_url']); $bb = parse_url($this->boardurl); $levels = count(explode('/', $bb['path'])) - 1; $redirect = str_repeat('../', $levels) . trim($cpg['path'], '/') . '/'; $this->redirect("/login.php?logout=true&redirect=$redirect"); } function view_users() {} function view_profile() {} function get_users($options = array()) { global $CONFIG; // Copy UDB fields and config variables (just to make it easier to read) $f =& $this->field; $C =& $CONFIG; // Sort codes $sort_codes = array('name_a' => 'user_name ASC', 'name_d' => 'user_name DESC', 'group_a' => 'group_name ASC', 'group_d' => 'group_name DESC', 'reg_a' => 'user_regdate ASC', 'reg_d' => 'user_regdate DESC', 'pic_a' => 'pic_count ASC', 'pic_d' => 'pic_count DESC', 'disku_a' => 'disk_usage ASC', 'disku_d' => 'disk_usage DESC', 'lv_a' => 'user_lastvisit ASC', 'lv_d' => 'user_lastvisit DESC', ); if (in_array($options['sort'], array('group_a', 'group_d', 'pic_a', 'pic_d', 'disku_a', 'disku_d'))){ $sort = ''; list($this->sortfield, $this->sortdir) = explode(' ', $sort_codes[$options['sort']]); $this->adv_sort = true; } else { $sort = "ORDER BY " . $sort_codes[$options['sort']]; $this->adv_sort = false; } // Build WHERE clause, if this is a username search if ($options['search']) { $options['search'] = 'AND u.'.$f['username'].' LIKE "'.$options['search'].'" '; } $sql = "SELECT group_id, group_name, group_quota FROM {$C['TABLE_USERGROUPS']}"; $result = cpg_db_query($sql); $groups = array(); while ($row = mysql_fetch_assoc($result)) { $groups[$row['group_id']] = $row; } $sql ="SELECT group_id FROM {$this->groupstable} WHERE group_single_user = 0"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(); while ($row = mysql_fetch_assoc($result)) { $udb_groups[] = $row['group_id']; } $sql = "SELECT u.{$f['user_id']} as user_id, MIN(ug.{$f['grouptbl_group_id']}) AS user_group, {$f['username']} as user_name, {$f['email']} as user_email, {$f['regdate']} as user_regdate, {$f['lastvisit']} as user_lastvisit, '' as user_active, 0 as pic_count, 0 as disk_usage ". "FROM {$this->usertable} AS u ". "INNER JOIN {$this->usergroupstable} AS ug ON u.{$this->field['user_id']}=ug.{$this->field['user_id']} ". "WHERE u.{$f['user_id']} > 0 " . $options['search']. "GROUP BY ug.{$f['user_id']} " . $sort . " LIMIT {$options['lower_limit']}, {$options['users_per_page']};"; $result = cpg_db_query($sql, $this->link_id); // If no records, return empty value if (!mysql_num_rows($result)) { return array(); } // Extract user list to an array while ($user = mysql_fetch_assoc($result)) { $gid = 2; if ($this->use_post_based_groups){ if (in_array($user['user_group'], $udb_groups)){ $gid = $user['user_group'] + 100; } elseif (in_array($user['user_group'], $this->admingroups)){ $gid = 102; } } else { if (in_array($user['user_group'], $this->admingroups)){ $gid = 1; } } $userlist[$user['user_id']] = array_merge($user, $groups[$gid]); $users[] = $user['user_id']; } $user_list_string = implode(', ', $users); $sql = "SELECT owner_id, COUNT(pid) as pic_count, ROUND(SUM(total_filesize)/1024) as disk_usage FROM {$C['TABLE_PICTURES']} WHERE owner_id IN ($user_list_string) GROUP BY owner_id"; $result = cpg_db_query($sql); while ($owner = mysql_fetch_assoc($result)) { $userlist[$owner['owner_id']] = array_merge($userlist[$owner['owner_id']], $owner); } if ($this->adv_sort) usort($userlist, array('cpg_udb', 'adv_sort')); return $userlist; } function adv_sort($a, $b) { if ($this->sortdir == 'ASC'){ return strcmp($a[$this->sortfield], $b[$this->sortfield]); } else { return strcmp($b[$this->sortfield], $a[$this->sortfield]); } } } // and go ! $cpg_udb = new cpg_udb; } ?>mybb.inc.php000064400000016217152532121440006764 0ustar00 'MyBB 1.4', 'short_name' => 'mybb', 'support_url' => 'http://www.mybboard.net/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/inc/', 'relative_path_to_config_file_used' => 'lookfor,config.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { // the vars that are used when bridgemgr is disabled // URL of your punbb $this->boardurl = 'http://localhost/mybb'; // local path to your punbb config file require_once('../mybb/inc/config.php'); $this->use_post_based_groups = 1; } else { // the vars from the bridgemgr $this->boardurl = $BRIDGE['full_forum_url']; require_once($BRIDGE['relative_path_to_config_file'] . 'config.php'); $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } $this->multigroups = 1; $this->group_overrride = 0; // Database connection settings $this->db = array( 'name' => $config['database']['database'], 'host' => $config['database']['hostname'], 'user' => $config['database']['username'], 'password' => $config['database']['password'], 'prefix' => $config['database']['table_prefix'], ); // Board table names $this->table = array( 'users' => 'users', 'groups' => 'usergroups', 'sessions' => 'sessions', ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'uid', // name of 'id' field in users table 'password' => 'loginkey', // name of 'password' field in users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'regdate', // name of 'registered' field in users table 'location' => "''", // name of 'location' field in users table 'website' => 'website', // name of 'website' field in users table 'usertbl_group_id' => 'usergroup', // name of 'group id' field in users table 'grouptbl_group_id' => 'gid', // name of 'group id' field in groups table 'grouptbl_group_name' => 'title' // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/member.php?action=register', 'editusers' => '/memberlist.php', 'edituserprofile' => "/member.php?action=profile&uid=" ); // Group ids $this->admingroups = array(4); $this->guestgroup = 1; // Connect to db $this->connect(); } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); if (!$superCage->cookie->keyExists('sid')) { return false; } $this->sid = $superCage->cookie->getEscaped('sid'); if (!$this->sid) { return false; } $result = cpg_db_query("SELECT u.{$this->field['user_id']}, u.{$this->field['password']}, additionalgroups FROM {$this->sessionstable} AS s INNER JOIN {$this->usertable} AS u ON u.uid = s.uid WHERE sid = '" . $this->sid . "'", $this->link_id); if (!mysql_num_rows($result)) { return false; } $row = mysql_fetch_row($result); $this->additionalgroups = array_pop($row); $this->logoutkey = md5($row[1]); return $row; } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists('mybbuser')) { return array_map('addslashes', explode("_", $superCage->cookie->getRaw('mybbuser'), 2)); } else { return false; } } // Get groups of which user is member function get_groups($row) { $data = array(); if ($this->use_post_based_groups) { $data[] = $row['group_id'] + 100; $additionalgroups = explode(',', $this->additionalgroups); foreach ($additionalgroups as $g) { $data[] = $g + 100; } } else { $data[0] = (in_array($row['group_id'], $this->admingroups)) ? 1 : 2; } return $data; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; } // Login function login_page() { $this->redirect('/member.php?action=login'); } // Logout function logout_page() { $this->redirect('/member.php?action=logout&logoutkey=' . $this->logoutkey); } function view_users() { $this->redirect($this->page['editusers']); } function get_users($options = array()) { } function view_profile($uid) { } } // and go ! $cpg_udb = new cpg_udb; } ?>mambo.inc.php000064400000043176152532121440007132 0ustar00 'Mambo server', 'short_name' => 'mambo', 'support_url' => 'http://www.mamboserver.com/', 'full_forum_url_default' => 'http://www.yoursite.com/board', 'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,configuration.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE; if (!USE_BRIDGEMGR) { $this->boardurl = 'http://localhost/mambo'; include('../mambo/configuration.php'); include('../mambo/includes/version.php'); } else { include($BRIDGE['relative_path_to_config_file'] . 'configuration.php'); include($BRIDGE['relative_path_to_config_file'] . 'includes/version.php'); $this->boardurl = $mosConfig_live_site; $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; } $this->mambo_version = $_VERSION; $this->multigroups = 0; $this->group_overrride = !$this->use_post_based_groups; // Database connection settings $this->db = array( 'name' => $mosConfig_db, 'host' => $mosConfig_host ? $mosConfig_host : 'localhost', 'user' => $mosConfig_user, 'password' => $mosConfig_password, 'prefix' => $mosConfig_dbprefix, ); // Board table names $this->table = array( 'users' => 'users', 'groups' => 'core_acl_aro_groups', 'sessions' => 'session', ); // Derived full table names $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; // Table field names $this->field = array( 'username' => 'username', // name of 'username' field in users table 'user_id' => 'id', // name of 'id' field in users table 'password' => 'password', // name of 'password' field in users table 'email' => 'email', // name of 'email' field in users table 'regdate' => 'UNIX_TIMESTAMP(registerDate)', // name of 'registered' field in users table 'lastvisit' => 'UNIX_TIMESTAMP(lastvisitDate)', // last time user logged in 'active' => '1-block', // is user account active? 'location' => "''", // name of 'location' field in users table 'website' => "''", // name of 'website' field in users table 'usertbl_group_id' => 'gid', // name of 'group id' field in users table 'grouptbl_group_id' => 'group_id', // name of 'group id' field in groups table 'grouptbl_group_name' => 'name', // name of 'group name' field in groups table ); // Pages to redirect to $this->page = array( 'register' => '/index.php?option=com_registration&task=register', 'editusers' => '/administrator/index.php', 'edituserprofile' => '/index.php?option=com_user&task=UserDetails', ); // Group ids - admin and guest only. $this->admingroups = array(24, 25); $this->guestgroup = 1; // Connect to db $this->connect(); // Delete old sessions $past = time() - $mosConfig_lifetime; $sql = "DELETE FROM {$this->sessionstable} WHERE time < $past"; cpg_db_query($sql, $this->link_id); } function session_update() { $sql = 'update '.$this->sessionstable.' set time="'.time().'" '. 'where session_id=md5("'.$this->session_id.'");'; $result = cpg_db_query($sql, $this->link_id); } function collect_groups() { $sql ="SELECT * FROM {$this->groupstable}"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(1 => 'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']] + 100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { global $CONFIG, $raw_ip; $superCage = Inspekt::makeSuperCage(); // Default anonymous values $id = 0; $pass = ''; $f = $this->field; $mambo_version =& $this->mambo_version; //$sessioncookie = $_COOKIE['sessioncookie']; $sessioncookie = $superCage->cookie->getRaw('sessioncookie'); // 4.5.1 and 4.5.2 compatibility if (($mambo_version->RELEASE == '4.5' && $mambo_version->DEV_LEVEL != '1.0.9') && $sessioncookie) { //$sessioncookie .= $_SERVER['REMOTE_ADDR']; $sessioncookie .= $raw_ip; } //$usercookie = $_COOKIE['usercookie']; $usercookie = $superCage->cookie->getRaw('usercookie'); $result = false; // Query database for session, if cookie exists if ($sessioncookie) { $sql = 'select userid from '.$this->sessionstable.' where session_id=md5("'.$sessioncookie.'");'; $result = cpg_db_query($sql, $this->link_id); } // If session exists, check if user exists if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $row['userid'] = (int) $row['userid']; $sql = 'select id, password '; $sql .= 'from '.$this->usertable.' '; $sql .= 'where id='.$row['userid']; $result = cpg_db_query($sql, $this->link_id); // If user exists, use the current session if ($result) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $pass = $row['password']; $id = (int) $row['id']; $this->session_id = $sessioncookie; // If the user doesn't exist, use default guest credentials } // No session exists, so create a session and check for remember me cookie } else { $this->create_session(); // remember me cookie exists; login with user creditials if ($usercookie) { $username = (isset($usercookie['username'])) ? addslashes($usercookie['username']) : ''; $password = (isset($usercookie['password'])) ? addslashes($usercookie['password']) : ''; // Grab id from Mambo database, if a cookie exists if ($username) { $sql = 'select u.'.$f['user_id'].' as id, u.'.$f['password'].' as password, u.'. $f['username'].' as username, u.'.$f['usertbl_group_id'].' as usertbl_group_id, '. 'g.'.$f['grouptbl_group_id'].' as grouptbl_group_id, g.'.$f['grouptbl_group_name'].' as grouptbl_group_name '; $sql .= 'from '.$this->usertable.' as u '; $sql .= 'inner join '.$this->groupstable.' as g '; $sql .= 'on gid=group_id '; $sql .= 'where u.'.$f['username'].'="'.$username.'" and u.'.$f['password'].'="'.$password.'" and u.block=0;'; $result = cpg_db_query($sql, $this->link_id); // the user exists; finalize login procedures if ($result) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $gid = 1; if ($this->is_group_child_of($row['grouptbl_group_name'], 'Registered') || $this->is_group_child_of($row['grouptbl_group_name'], 'Administrator')) { $gid = 2; } // update session information in session table $sql = 'update '.$this->sessionstable.' set '. 'userid='.$row['id']. ',username="'.$row['username'].'"'. ',guest=0 '. ',gid='.$gid.' '. ',usertype="'.$row['grouptbl_group_name'].'" '. 'where session_id=md5("'.$this->session_id.'");'; cpg_db_query($sql, $this->link_id); // update last visit date $currentDate = date("Y-m-d\TH:i:s"); $sql = 'update '.$this->usertable.' set '. 'lastvisitDate="'.$currentDate.'" '. 'where id='.$row['id']; cpg_db_query($sql, $this->link_id); $pass = $password; $id = $row['id']; } } } } return ($id) ? array($id, $pass) : false; } function login($username = null, $password = null) { $this->create_session(); if (is_null($username) || is_null($password)) { return false; } // Grab id from Mambo database, if a cookie exists if ($username) { $sql = 'select u.'.$f['user_id'].' as id, u.'.$f['password'].' as password, u.'. $f['username'].' as username, u.'.$f['usertbl_group_id'].' as usertbl_group_id, '. 'g.'.$f['grouptbl_group_id'].' as grouptbl_group_id, g.'.$f['grouptbl_group_name'].' as grouptbl_group_name '; $sql .= 'from '.$this->usertable.' as u '; $sql .= 'inner join '.$this->groupstable.' as g '; $sql .= 'on gid=group_id '; $sql .= 'where u.'.$f['username'].'="'.$username.'" and u.'.$f['password'].'="'.$password.'" and u.block=0;'; $result = cpg_db_query($sql, $this->link_id); // the user exists; finalize login procedures if ($result) { $row = mysql_fetch_assoc($result); mysql_free_result($result); $gid = 1; if ($this->is_group_child_of($row['grouptbl_group_name'], 'Registered') || $this->is_group_child_of($row['grouptbl_group_name'], 'Administrator')) { $gid = 2; } // update session information in session table $sql = 'update '.$this->sessionstable.' set '. 'userid='.$row['id']. ',username="'.$row['username'].'"'. ',guest=0 '. ',gid='.$gid.' '. ',usertype="'.$row['grouptbl_group_name'].'" '. 'where session_id=md5("'.$this->session_id.'");'; cpg_db_query($sql, $this->link_id); // update last visit date $currentDate = date("Y-m-d\TH:i:s"); $sql = 'update '.$this->usertable.' set '. 'lastvisitDate="'.$currentDate.'" '. 'where id='.$row['id']; cpg_db_query($sql, $this->link_id); $pass = $password; $id = $row['id']; } } } /** create a guest session */ function create_session() { global $raw_ip; // alias the Mambo version object $mambo_version =& $this->mambo_version; // start session $this->session_id = $this->generateId(); $sessioncookie = $this->session_id; // 4.5.1 and 4.5.2 compatibility if ($mambo_version->RELEASE == '4.5' && $mambo_version->DEV_LEVEL != '1.0.9') { //$this->session_id .= $_SERVER['REMOTE_ADDR']; $this->session_id .= $raw_ip; } $sql = 'insert into '.$this->sessionstable.' (session_id, username, guest, time, gid) values '; $sql .= '("'.md5($this->session_id).'", "", 1, "'.time().'",0)'; // insert the guest session cpg_db_query($sql); // set the session cookie if (CPG_COOKIES_ALLOWED) { setcookie("sessioncookie", $sessioncookie, time() + (CPG_DAY*0.5), "/"); } } /** taken from Mambo session class */ function generateId() { $failsafe = 20; $randnum = 0; while ($failsafe--) { $randnum = md5(uniqid(microtime(), 1)); if ($randnum != "") { $sql = "SELECT session_id FROM {$this->sessionstable} WHERE session_id=MD5('$randnum')"; if (!$result = cpg_db_query($sql, $this->link_id)) { break; } } } return $randnum; } /** taken from Mambo acl api class */ /*======================================================================*\ Function: has_group_parent Purpose: Checks whether the 'source' group is a child of the 'target' \*======================================================================*/ function is_group_child_of($grp_src, $grp_tgt, $group_type = 'ARO') { $table = &$this->groupstable; if (is_int($grp_src) && is_int($grp_tgt)) { $sql = "SELECT COUNT(*)". "\nFROM $table AS g1". "\nLEFT JOIN $table AS g2 ON g1.lft > g2.lft AND g1.lft < g2.rgt". "\nWHERE g1.group_id=$grp_src AND g2.group_id=$grp_tgt"; } else if (is_string($grp_src) && is_string($grp_tgt)) { $sql = "SELECT COUNT(*)". "\nFROM $table AS g1". "\nLEFT JOIN $table AS g2 ON g1.lft > g2.lft AND g1.lft < g2.rgt". "\nWHERE g1.name='$grp_src' AND g2.name='$grp_tgt'"; } else if (is_int($grp_src) && is_string($grp_tgt)) { $sql = "SELECT COUNT(*)". "\nFROM $table AS g1". "\nLEFT JOIN $table AS g2 ON g1.lft > g2.lft AND g1.lft < g2.rgt". "\nWHERE g1.group_id='$grp_src' AND g2.name='$grp_tgt'"; } else { $sql = "SELECT COUNT(*)". "\nFROM $table AS g1". "\nLEFT JOIN $table AS g2 ON g1.lft > g2.lft AND g1.lft < g2.rgt". "\nWHERE g1.name=$grp_src AND g2.group_id='$grp_tgt'"; } $result = cpg_db_query($sql, $this->link_id); $count = mysql_num_rows($result); if ($count) { mysql_free_result($result); } return ($count > 0); } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; // unused } function login_page() { $this->redirect("/index.php"); } function logout_page() { global $CONFIG; $this->redirect("/index.php?option=logout"); } function edit_profile() { $this->redirect("/index.php?option=com_user&task=UserDetails&Itemid=21"); } function view_users() { } function view_profile() { } function session_extraction($cookie_id) { } } // and go ! $cpg_udb = new cpg_udb; } ?>smf10.inc.php000064400000025437152532121440006765 0ustar00 'Simple Machines (SMF) 1.x', 'short_name' => 'smf10', 'support_url' => 'http://www.simplemachines.org/', 'relative_path_to_config_file_default' => '../board/', 'relative_path_to_config_file_used' => 'lookfor,Settings.php', 'use_post_based_groups_default' => '0', 'use_post_based_groups_used' => 'radio,1,0', ); } else { // Switch that allows overriding the bridge manager with hard-coded values define('USE_BRIDGEMGR', 1); require_once 'bridge/udb_base.inc.php'; if (!USE_BRIDGEMGR) { require_once('../smf/Settings.php'); $boardurl = 'http://www.mysite.com/board'; } else { require_once($BRIDGE['relative_path_to_config_file'] . 'Settings.php'); } class cpg_udb extends core_udb { function cpg_udb() { global $BRIDGE, $CONFIG, $boardurl, $db_prefix, $db_server, $db_name, $db_user, $db_passwd, $cookiename; $this->use_post_based_groups = $BRIDGE['use_post_based_groups']; $this->boardurl = $boardurl; $this->multigroups = 1; $this->group_overrride = 1; $this->cookie_name = $cookiename; // Board table names $this->table = array( 'users' => 'members', 'groups' => 'membergroups', 'sessions' => 'sessions' ); // Database connection settings $this->db = array( 'name' => $db_name, 'host' => $db_server ? $db_server : 'localhost', 'user' => $db_user, 'prefix' => $db_prefix, 'password' => $db_passwd ); // Derived full table names if (strpos($db_prefix, '.') === false) { $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users']; $this->groupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups']; $this->sessionstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions']; } else { $this->usertable = $this->db['prefix'] . $this->table['users']; $this->groupstable = $this->db['prefix'] . $this->table['groups']; $this->sessionstable = $this->db['prefix'] . $this->table['sessions']; } // Table field names $this->field = array( 'username' => 'realName', // name of 'username' field in users table 'user_id' => 'ID_MEMBER', // name of 'id' field in users table 'password' => 'SHA1(CONCAT(passwd, passwordSalt))', // name of the password field in the users table 'email' => 'emailAddress', // name of 'email' field in users table 'regdate' => 'dateRegistered', // name of 'registered' field in users table 'lastvisit' => 'UNIX_TIMESTAMP(lastLogin)', // last time user logged in 'active' => 'is_activated', // is user account active? 'location' => 'location', // name of 'location' field in users table 'website' => 'websiteUrl', // name of 'website' field in users table 'usertbl_group_id' => 'ID_GROUP', // name of 'group id' field in users table 'grouptbl_group_id' => 'ID_GROUP', // name of 'group id' field in groups table 'grouptbl_group_name' => 'groupName', // name of 'group name' field in groups table 'postgroup' => 'ID_POST_GROUP', // post group field 'additionals' => 'additionalGroups', // additional groups, comma seperated ); // Pages to redirect to $this->page = array( 'register' => '/index.php?action=register', 'editusers' => '/index.php?action=mlist', 'edituserprofile' => '/index.php?action=profile;u=' ); // Group ids - admin and guest only. $this->admingroups = array(1); $this->guestgroup = 3; // Connect to db - or supply a connection id to be used instead of making own connection. $this->connect(); } // definition of how to extract id, name, group from a session cookie function session_extraction() { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists($this->cookie_name)) { $data = unserialize($superCage->cookie->getRaw($this->cookie_name)); if (is_numeric($data[0]) && preg_match('/^[A-F0-9]{40}$/i', $data[1])) { return $data; } else { return false; } } } // definition of how to extract an id and password hash from a cookie function cookie_extraction() { return false; } // definition of actions required to convert a password from user database form to cookie form function udb_hash_db($password) { return $password; // unused } // Get groups of which user is member function get_groups($row) { $data = array(); if ($this->use_post_based_groups) { $data[0] = $row['group_id'] + 100; $sql = "SELECT {$this->field['postgroup']} AS postgroup, {$this->field['additionals']} AS additionals FROM {$this->usertable} WHERE {$this->field['user_id']} = {$row['id']}"; $result = cpg_db_query($sql, $this->link_id); $groupdata = mysql_fetch_assoc($result); // add in post group $data[] = $groupdata['postgroup'] + 100; // now add in any additional groups if ($groupdata['additionals']) { $additionals = explode(',', $groupdata['additionals']); foreach ($additionals as $group) { $data[] = $group + 100; } } } else { $data[0] = in_array($row['group_id'] , $this->admingroups) ? 1 : 2; } return $data; } function collect_groups() { // Use this version to exclude true post based groups //$sql ="SELECT * FROM {$this->groupstable} WHERE minposts=-1"; // Use this version to include all SMF groups $sql ="SELECT * FROM {$this->groupstable}"; $result = cpg_db_query($sql, $this->link_id); $udb_groups = array(3 => 'Guests'); while ($row = mysql_fetch_assoc($result)) { $udb_groups[$row[$this->field['grouptbl_group_id']]+100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']])); } return $udb_groups; } function login_page() { global $CONFIG; if ($session = $this->_session_load()) { $session['old_url'] = $CONFIG['site_url'] . '?board=redirect'; $this->_session_save($session); } $this->redirect('/index.php?action=login'); } function _session_load() { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists('PHPSESSID')) { $session_id = $superCage->cookie->getEscaped('PHPSESSID'); $sql = "SELECT data FROM {$this->sessionstable} WHERE session_id = '$session_id'"; $result = cpg_db_query($sql, $this->link_id); if (mysql_num_rows($result)) { list($data) = mysql_fetch_row($result); session_name('CPG'); session_start(); session_decode($data); $session = $_SESSION; return $session; } } return false; } function _session_save($session) { $superCage = Inspekt::makeSuperCage(); if ($superCage->cookie->keyExists('PHPSESSID')) { $session_id = $superCage->cookie->getEscaped('PHPSESSID'); $_SESSION = $session; $data = addslashes(session_encode()); $sql = "UPDATE {$this->sessionstable} SET data = '$data' WHERE session_id = '$session_id'"; cpg_db_query($sql, $this->link_id); } } function logout_page() { global $CONFIG; if ($session = $this->_session_load()) { $sesc = $session['rand_code']; $session['logout_url'] = $CONFIG['site_url']; $this->_session_save($session); } else { $sesc = ''; } $this->redirect('/index.php?action=logout&sesc=' . $sesc); } function view_users() {} function view_profile() {} } // and go ! $cpg_udb = new cpg_udb; } ?>