Changeset 165536
- Timestamp:
- 10/21/2009 07:22:30 PM (16 years ago)
- Location:
- phpbb-single-sign-on/trunk
- Files:
-
- 6 edited
-
connect-phpbb.php (modified) (5 diffs)
-
files/auth_op.php (modified) (9 diffs)
-
files/common.php (modified) (2 diffs)
-
module.phpbb.php (modified) (4 diffs)
-
module.wp.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
phpbb-single-sign-on/trunk/connect-phpbb.php
r163762 r165536 2 2 /* 3 3 Plugin Name: PHPBB Single Sign On 4 Version: 0. 4.64 Version: 0.5 5 5 Plugin URI: http://www.onigoetz.ch/plugins/wordpress-phpbb-plugin/ 6 6 Description: Connecte un site wordpress à PHPBB … … 50 50 add_action('wp_authenticate_user','op_login',10,2); 51 51 function op_login(&$userdata,$password){ 52 53 global $op_credentials;54 $op_credentials = array('username'=>strtolower($userdata->user_login),'password'=>$password); // Set credentials55 52 56 53 if(file_exists(ABSPATH.'/'.PHPBBPATH.'config.php')){ // check to see if phpBB exists … … 59 56 } 60 57 op_phpBB3::getIdentity(); 61 $result = op_phpBB3::login( );58 $result = op_phpBB3::login(strtolower($userdata->user_login),$password); 62 59 } 63 60 … … 96 93 } 97 94 98 95 /* 99 96 add_action('register_post', 'op_wp_userExists',10,3); 100 97 //??? … … 152 149 } 153 150 } 151 152 */ -
phpbb-single-sign-on/trunk/files/auth_op.php
r163762 r165536 6 6 * 7 7 * @package login 8 * @version 0. 4.68 * @version 0.5 9 9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 10 10 * … … 15 15 include(dirname(__FILE__).'/auth_db.php'); 16 16 } 17 17 18 18 19 /** … … 29 30 30 31 // Provide option for WordPress path 31 function acp_op(&$new)32 /*function acp_op(&$new) 32 33 { 33 34 // These are fields required in the config table … … 43 44 'config' => array('op_path') 44 45 ); 45 } 46 }*/ 46 47 47 48 /** … … 52 53 global $db, $config; 53 54 55 //Still needed ? 54 56 if(defined('SECOND_RUN')){ 55 57 return array( … … 67 69 68 70 global $current_user; 69 71 72 73 /* 74 ** Exists in PHPBB ? 75 */ 76 //TODO :: Replace by generic function op_PHPBB 77 $sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts 78 FROM ' . USERS_TABLE . " 79 WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; 80 $result = $db->sql_query($sql); 81 $phpBB_user = $db->sql_fetchrow($result); 82 83 //$phpBB_user = op_phpBB3::getUserByNameClean($name); 84 85 /* 86 ** Exists in WP ? 87 */ 70 88 //Loaded from within WP ? 71 89 if(!function_exists('censor_text')){ 72 //use another function, maybe this one is not available at this point of the execution73 //$wp_user = wp_get_current_user();74 90 $wp_user = op_Wordpress::getIdByName($username); 75 91 $in_wp = $wp_user == 0 ? FALSE : TRUE; 76 92 } else { 77 93 94 //SYNC to WP 95 op_WordPress::loadAdminAPI(); 96 op_WordPress::changePassword($username, $password); 97 78 98 if(isset($current_user)){ 79 99 wp_clear_auth_cookie(); … … 97 117 } 98 118 99 //TODO :: Replace by generic function op_PHPBB 100 //Exists in PHPBB ? 101 $sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts 102 FROM ' . USERS_TABLE . " 103 WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; 104 $result = $db->sql_query($sql); 105 $phpBB_user = $db->sql_fetchrow($result); 106 107 //$phpBB_user = op_phpBB3::getUserByNameClean($name); 108 109 //password ? 110 /*if($phpBB_user){ 111 //Doit faire la mise à jour du mot de passe ? 112 if(defined('FROM_WP')){ 113 //op_phpBB3::changePassword($username,$password); 114 115 $hashed = md5($password); 116 $sql = 'UPDATE ' . USERS_TABLE . ' SET user_password="'.$hashed.'",user_pass_convert=1,user_last_search=1 WHERE username = "' . $username . '"'; 117 118 $hashed = phpbb_hash($password); 119 //op_phpBB3::changePassword($username,$password); 120 $sql = 'UPDATE ' . USERS_TABLE . ' SET user_password="'.$hashed.'",user_pass_convert=0,user_last_search=1 WHERE username = "' . $username . '"'; 121 122 123 $result = $db->sql_query($sql); 124 125 $phpBB_user['user_password'] = $hashed; 126 //echo 'did pass update !'; 127 } 128 129 130 131 $phpBB_authed = phpbb_check_hash($password, $phpBB_user['user_password']); 132 } 133 else{ 134 $phpBB_authed = false; 135 }*/ 136 137 //WP 1 BB 0 ? 138 if(!$phpBB_user && $in_wp){ 139 //echo 'not in phpbb'; 140 141 $email = $wp_user->user_email ? $wp_user->user_email : ''; 142 143 // since group IDs may change, use a query to make sure it is the right default group. 144 $sql = 'SELECT group_id 145 FROM ' . GROUPS_TABLE . " 146 WHERE group_name = '" . $db->sql_escape(REGISTERED) . "' 147 AND group_type = " . GROUP_SPECIAL; 119 //Checking existence of users 120 if(!function_exists('censor_text')){ 121 //WP 1 BB 0 ? 122 if(!$phpBB_user && $in_wp){ 123 //echo 'not in phpbb'; 124 125 $email = $wp_user->user_email ? $wp_user->user_email : ''; 126 127 // since group IDs may change, use a query to make sure it is the right default group. 128 $sql = 'SELECT group_id 129 FROM ' . GROUPS_TABLE . " 130 WHERE group_name = '" . $db->sql_escape(REGISTERED) . "' 131 AND group_type = " . GROUP_SPECIAL; 132 $result = $db->sql_query($sql); 133 $row = $db->sql_fetchrow($result); 134 $group_id = $row['group_id']; 135 136 $user_row = array( 137 'username' => $username, 138 'user_password' => phpbb_hash($password), 139 'group_id' => $group_id, 140 'user_email' => $email, 141 'user_type' => 0 142 ); 143 144 $id = op_phpBB3::addUser($user_row); 145 $phpBB_user = op_phpBB3::getUserById($id); 146 } 147 } else { 148 //WP 0 BB 1 ? 149 if($phpBB_user && !$in_wp){ 150 //echo 'not in wordpress'; 151 152 $username = $phpBB_user['username']; 153 154 $user_row = array( 155 'username' => $username, 156 'email' => $phpBB_user['user_email'] ? $phpBB_user['user_email'] : '', 157 'password' => html_entity_decode($password) 158 ); 159 160 $wp_user = op_WordPress::addUser($user_row); 161 162 $wp_user = wp_signon(array( 163 'user_login' => $username, 164 'user_password' => html_entity_decode($password) 165 ), $secure_cookie); 166 167 mysql_select_db($db->db_name); // Select phpBB database 168 } 169 } 170 171 //SYNC PHPBB Password 172 if(!function_exists('censor_text')){ 173 //$hashed = md5($password); 174 //$sql = 'UPDATE ' . USERS_TABLE . ' SET user_password="'.$hashed.'",user_pass_convert=1,user_last_search=1 WHERE username = "' . $username . '"'; 175 176 $hashed = phpbb_hash($password); 177 $sql = 'UPDATE ' . USERS_TABLE . ' SET user_password="'.$hashed.'",user_pass_convert=0,user_last_search=1 WHERE username = "' . $username . '"'; 178 148 179 $result = $db->sql_query($sql); 149 $row = $db->sql_fetchrow($result); 150 $group_id = $row['group_id']; 151 152 $user_row = array( 153 'username' => $username, 154 'user_password' => phpbb_hash($password), 155 'group_id' => $group_id, 156 'user_email' => $email, 157 'user_type' => 0 158 ); 159 160 $id = op_phpBB3::addUser($user_row); 161 $phpBB_user = op_phpBB3::getUserById($id); 162 } 163 164 //BUG :: user creates duplicata on every connection !!! 165 //WP 0 BB 1 ? 166 if($phpBB_user && !$in_wp){ 167 //echo 'not in wordpress'; 168 169 $username = $phpBB_user['username']; 170 171 $user_row = array( 172 'username' => $username, 173 'email' => $phpBB_user['user_email'] ? $phpBB_user['user_email'] : '', 174 'password' => html_entity_decode($password) 175 ); 176 177 $wp_user = op_WordPress::addUser($user_row); 178 179 $wp_user = wp_signon(array( 180 'user_login' => $username, 181 'user_password' => html_entity_decode($password) 182 ), $secure_cookie); 183 184 mysql_select_db($db->db_name); // Select phpBB database 180 181 //$phpBB_user['user_password'] = $hashed; 182 //$phpBB_authed = phpbb_check_hash($password, $phpBB_user['user_password']); 185 183 } 186 184 … … 194 192 } 195 193 196 197 // TODO -- Make sure they are not in all modules active198 //if ((!$phpBB_user || !$phpBB_authed) && !$in_wp)199 194 if ((!$phpBB_user || !$phpBB_authed) && !$in_wp) 200 195 { … … 222 217 } 223 218 224 //TODO :: Load only when wp is loaded225 219 function logout_op($data, $new_session){ 226 220 227 221 //if WP is loaded 228 if(function_exists('wp_ signon')){222 if(function_exists('wp_clear_auth_cookie')){ 229 223 wp_clear_auth_cookie(); 230 224 } -
phpbb-single-sign-on/trunk/files/common.php
r163762 r165536 6 6 * 7 7 * @package login 8 * @version 0. 4.68 * @version 0.5 9 9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 10 10 * … … 68 68 $include_common_contents = str_replace($original_get_cookie,$new_get_cookie,$include_common_contents); 69 69 70 //Include de la version modifi ée de common.php70 //Include de la version modifi�e de common.php 71 71 eval($include_common_contents); 72 72 73 //Include Wordpress 73 74 include($root_path.'/'.$extra_path.'wp-blog-header.php'); 74 75 -
phpbb-single-sign-on/trunk/module.phpbb.php
r162729 r165536 63 63 $identity = array(); 64 64 } 65 66 67 65 } 68 66 69 function login( ){67 function login($uname, $passwd){ 70 68 define('IN_PHPBB',TRUE); 71 69 72 global $op_credentials;73 70 global $auth; 74 75 71 76 $username = $ op_credentials['username']=='' ? request_var('username', '', true) : $op_credentials['username'];77 $password = $ op_credentials['password']=='' ? request_var('password', '', true) : $op_credentials['password'];72 $username = $uname=='' ? request_var('username', '', true) : $uname; 73 $password = $passwd=='' ? request_var('password', '', true) : $passwd; 78 74 79 75 $result = $auth->login($username, $password); … … 96 92 require($phpbb_root_path.'config.php'); 97 93 98 $dbr = mysql_connect($dbhost,$dbuser,$dbpasswd); 99 mysql_select_db($dbname); 100 define('USERS_TABLE', 'phpbb_users'); 94 //$dbr = mysql_connect($dbhost,$dbuser,$dbpasswd); 95 //mysql_select_db($dbname); 101 96 102 97 // set user_pass_convert to 1 so user's pass will be hashed under phpBB rules when logging in after pass is changed in WordPress … … 119 114 120 115 function addUser($user){ 121 global $phpbb_root_path, $phpEx;116 global $phpbb_root_path, $phpEx; 122 117 123 118 // Use the user_add function, this code is from auth.php line 864-869 … … 174 169 175 170 function getUserByNameClean($name){ 176 177 171 return op_phpBB3::getUserByName($name, true); 178 172 } -
phpbb-single-sign-on/trunk/module.wp.php
r162742 r165536 67 67 68 68 wp_update_user(get_object_vars($user)); 69 } 70 71 function changePassword($username, $password){ 72 $user = array(); 73 $user['ID'] = op_WordPress::getIdByName($username); 74 $user['user_pass'] = $password; 75 76 wp_update_user($user); 69 77 } 70 78 -
phpbb-single-sign-on/trunk/readme.txt
r163762 r165536 18 18 characters, nor special ones. Check directly in the DB if in doubt. 19 19 20 !IMPORTANT! 21 PHPBB and Wordpress need to run on the same database. 22 otherwise it won't work 20 23 21 24 == Changelog == … … 23 26 = Roadmap = 24 27 * API to create logons on other CMS's 25 * Hook for password change 26 * Profile sync 28 * Make it work on multiple db's 29 30 = 0.5 = 31 * Enabled synchronisation 27 32 28 33 = 0.4.6 =
Note: See TracChangeset
for help on using the changeset viewer.