"; openid_help(); exit;} // error_reporting(E_ALL); function openid() { global $openid_options, $bb_current_user, $bbdb; openid_remove(); // check for request to remove session or attached account if (bb_get_location()=="register-page") { if (!empty($_POST) && function_exists('instant_password')) { // means we are on register page and instant password is running - need password if (empty($_POST['password']) || empty($_POST['pass2'])) { $length=rand(12,16); $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $password = ''; for ( $i = 0; $i < $length; $i++ ) {$password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);} $_POST['password']=$_POST['pass2']=$password; } } // openid_session(); } if (isset($_POST['openid_url'])) {$openid_url=$_POST['openid_url'];} elseif (isset($_GET['openid_url'])) {$openid_url=$_GET['openid_url'];} if (!empty($openid_url)){ // helpers for the services that don't recognize partial words if (preg_match("/^(https?\:\/\/)?google(\.com)?\/?/simU",$openid_url)) {$openid_url="google.com/accounts/o8/id";} // elseif (preg_match("/^(https?\:\/\/)?aol(\.com)?\/?/simU",$openid_url)) {$openid_url="openid.aol.com";} @require_once('class.openid.php'); $openid = new OpenIDService; $openid->SetIdentity($openid_url); $openid->SetTrustRoot($openid_options['root']); $openid->SetRequiredFields(array('email')); // $openid->SetOptionalFields(array('fullname','dob','gender','postcode','country','language','timezone')); if ($openid->GetOpenIDServer()){ $openid_approve="http://".$_SERVER['HTTP_HOST'].remove_query_arg('openid_url'); // add_query_arg( 're',urlencode("http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"].(empty($_SERVER["QUERY_STRING"]) ? "" : '?'.$_SERVER["QUERY_STRING"]))); $openid->SetApprovedURL($openid_approve); $openid->Redirect(); // This will redirect user to OpenID Server exit; }else{ $error = $openid->GetError(); $error ="ERROR CODE: " . $error['code'] . "
". "ERROR DESCRIPTION: " . $error['description'] . "
"; openid_redirect($error); } } elseif (isset($_GET['openid_mode'])) { if ($_GET['openid_mode'] == 'cancel') {openid_redirect(__("USER CANCELED REQUEST"));} elseif ($_GET['openid_mode'] != 'id_res') {openid_redirect(__("INVALID OPENID REQUEST"));} @require_once('class.openid.php'); $openid = new OpenIDService; $openid->SetIdentity($_GET['openid_identity']); $openid_result = $openid->ValidateWithServer(); if ($openid->IsError() == true) { $error = $openid->GetError(); $error="ERROR CODE: " . $error['code'] . "
". "ERROR DESCRIPTION: " . $error['description'] . "
"; openid_redirect($error); } elseif (empty($openid_result)===true || empty($_GET['openid_identity'])===true) {openid_redirect(__("INVALID AUTHORIZATION"));} else { // valid result $openid=addslashes(substr($_GET['openid_identity'],0,256)); // openid_assoc_handle $openid_user_id=$bbdb->get_var("SELECT user_id FROM $bbdb->usermeta WHERE meta_key='openid' AND meta_value LIKE '%:\"$openid\";%' LIMIT 1"); if (!$bb_current_user) { if ($openid_user_id) { // we found a user, give them a cookie if ($openid_options['debug']) {bb_update_usermeta($openid_user_id,'openid_debug',$_GET);} wp_set_auth_cookie( (int) $openid_user_id, 0 ); // 0 = don't remember, short login, todo: use form value do_action('bb_user_login', (int) $openid_user_id ); openid_redirect(); } else { // openid is valid but no user_id, we need to create a user // $error="Sorry, account creation is not supported yet.
The following OpenID is not attached to any forum account:
$openid"; // openid_redirect($error); openid_session(); $_SESSION['OPENID']=$_GET['openid_identity']; bb_safe_redirect(bb_get_option('uri')."register.php"); } } elseif (!empty($bb_current_user->ID) && bb_get_location()=="profile-page" && isset($_GET['tab']) && $_GET['tab']=="edit") { if (!$openid_user_id) { // no one owns this ID $user = bb_get_user($bb_current_user->ID); (array) $user->openid[]=$openid; bb_update_usermeta($bb_current_user->ID,'openid',(array) $user->openid); openid_redirect(); } else { if ($openid_user_id==$bb_current_user->ID) {openid_redirect(__("THIS PROVIDER IS ALREADY ON YOUR ACCOUNT"));} else {openid_redirect(__("THIS PROVIDER IS OWNED BY ANOTHER ACCOUNT"));} } } } // valid result } // openid_mode } function openid_session() { if (!isset($_SESSION)) { @ini_set('session.use_trans_sid', false); @ini_set("url_rewriter.tags",""); @session_start(); // sent with headers } } function openid_register_success($user_id=0) { if (!$user_id) {return;} openid_session(); if (empty($_SESSION['OPENID'])) {return;} else {$openid[]=$_SESSION['OPENID']; $_SESSION['OPENID']=""; unset($_SESSION['OPENID']);} global $bbdb; $bbdb->query("UPDATE $bbdb->users SET user_status=0 WHERE ID=$user_id LIMIT 1"); // 0.9 has a typo bug in update_user_status function bb_update_usermeta($user_id,'openid',$openid); wp_set_auth_cookie( (int) $user_id, 0 ); do_action('bb_user_login', (int) $user_id ); if (isset($_REQUEST['re'])) {$re=$_REQUEST['re'];} else {$re=bb_get_option('uri');} bb_safe_redirect($re); } function openid_profile_edit() { global $bbdb,$user_id,$openid_options; if (!bb_get_location()=="register-page") {echo '';} echo '
'.$openid_options['profile_text'].''; if (!empty($_SESSION['OPENID'])) { openid_session(); $url=$_SESSION['OPENID']; remove_action( 'extra_profile_info', 'instant_password',9); remove_action('register_user', 'instant_password_success',9999); $instructions=$openid_options['approved_text']; echo '

'.$instructions.'

'; } else { $value=""; if (bb_is_user_logged_in()) {$instructions=$openid_options['add_text'];} else {$instructions=$openid_options['register_text']; } if (isset($_GET['openid_error'])) {echo "
".substr(addslashes(strip_tags($_GET['openid_error'],"
")),0,200)."
";} echo '

'.$instructions.'

'.$url.'
'; echo ''; if (bb_is_user_logged_in()) { $user = bb_get_user( $user_id ); if (!empty($user->openid)) { foreach ((array) $user->openid as $url ) { echo ''; } } } } // session else echo '
[help]'; if ($session_id=session_id()) { $session_name=session_name(); echo ''; } openid_help(); echo '
'.$url.'
'; } function openid_login() { global $openid_options; ?>

".substr(addslashes(strip_tags($_GET['openid_error'],"
")),0,200)."";} ?>
[help]
function openid_help() { var e=document.getElementById('openid_help'); if (e.style.visibility == 'hidden') {e.style.visibility = 'visible';} else {e.style.visibility = 'hidden';} setTimeout(\"document.getElementById('openid_url').focus()\",1000); return false; } "; } function openid_remove() { if (isset($_GET['remove_openid'])) { if (!bb_is_user_logged_in()) { openid_session(); if (!empty($_SESSION['OPENID'])) { $_SESSION['OPENID']=""; unset($_SESSION['OPENID']); } } else { bb_repermalink(); global $bbdb,$user_id,$bb_current_user,$openid_options; $user = bb_get_user( $user_id ); if ($user_id==$bb_current_user->ID || bb_current_user_can('administrate')) { $remove_openid=intval($_GET['remove_openid']); $user->openid=(array) $user->openid; $key=array_search($remove_openid,$user->openid); if ($key!==false) {unset($user->openid[$key]); bb_update_usermeta($user_id,'openid',(array) $user->openid);} } } } } function openid_redirect($error="") { global $openid_options; if (isset($_POST['openid_return_to'])) {$re=$_POST['openid_return_to'];} elseif (isset($_GET['openid_return_to'])) {$re=$_GET['openid_return_to'];} else {$re=$_SERVER['REQUEST_URI'];} // else {$re =$openid_options['root'];} $re=remove_query_arg('openid_mode',$re); $re=remove_query_arg('openid_url',$re); if ($error) {$re=add_query_arg('openid_error',urlencode($error),$re);} // if ($error) {echo "$error"; exit;} bb_safe_redirect($re); exit; } ?>