/** * Send email validation request */ public function sendEmailValidationRequest($h) { // check username $username = $h->cage->post->testUsername('username'); $userid = $h->getUserIdFromName($username); if ($userid) { // send email validation request $us = new UserSignin(); $us->sendConfirmationEmail($h, $userid); $h->messages[$h->lang['user_man_email_validation_request_sent']] = 'green'; } else { $h->vars['user_man_username_3'] = $username; // to fill the username field $h->messages[$h->lang['user_man_user_not_found']] = 'red'; } }
/** * Show a login with RPX link */ public function theme_index_top($h) { // get the token if available. If not, stop executing this function // also stop here if there's no apiKey $token = $h->cage->post->sanitizeAll('token'); if (!$token || !$this->apiKey) { return false; } // get the functions file: require_once PLUGINS . 'rpx/libs/RpxFunctions.php'; $rpxFuncs = new RpxFunctions(); // get the profile: $rpx_profile = $rpxFuncs->getProfile($token, $this->apiKey); // If adding a provider to an existing non-RPX user... if ($h->isPage('account') && $this->account == 'basic') { // add the rpx ID and profile info (serialized) into the users table $sql = "UPDATE " . TABLE_USERS . " SET user_rpx_id = %s, user_rpx = %s WHERE user_id = %d"; $h->db->query($h->db->prepare($sql, $rpx_profile['identifier'], serialize($rpx_profile), $h->currentUser->id)); return false; // gets us out of here and loads the rest of the page. } // If adding another provider, map it then get out of here. if ($h->isPage('account') && $this->account != 'basic') { // update the database with this user's RPX identifier IF EMPTY: $sql = "UPDATE " . TABLE_USERS . " SET user_rpx_id = %s WHERE user_id = %d AND user_rpx_id IS NULL"; $h->db->query($h->db->prepare($sql, $rpx_profile['identifier'], $h->currentUser->id)); // update the database with this user's RPX profile IF EMPTY: $sql = "UPDATE " . TABLE_USERS . " SET user_rpx = %s WHERE user_id = %d AND user_rpx IS NULL"; $h->db->query($h->db->prepare($sql, serialize($rpx_profile), $h->currentUser->id)); // map this provider with the user's existing account: $status = $rpxFuncs->map($h->currentUser->id, $rpx_profile['identifier'], $this->apiKey); if ($status == 'ok') { return false; // gets us out of here and loads the rest of the page. } else { die("Error: Unable to map with RPX. Please contact a site administrator"); exit; } } if (isset($rpx_profile['primaryKey']) && $this->account != 'basic') { //get username from database for this primarykey $sql = "SELECT user_username FROM " . TABLE_USERS . " WHERE user_id = %d"; $username = $h->db->get_var($h->db->prepare($sql, $rpx_profile['primaryKey'])); $login_result = $h->currentUser->loginCheck($h, $username, ''); // no password necessary if ($login_result) { //success $h->currentUser->name = $username; $remember = 1; // keep them logged in for 30 days (not optional) require_once PLUGINS . 'user_signin/user_signin.php'; $user_signin = new UserSignin(); $user_signin->loginSuccess($h, $remember); $return = $h->cage->get->testUri('return'); // so that we don't return to the register page: if (strpos($return, urlencode('register')) !== false) { $return = BASEURL; } if ($return) { header("Location: " . $return); exit; } else { header("Location: " . BASEURL); exit; } } } if ($rpx_profile['identifier'] && $this->account == 'basic') { //get username from database for this identifier $sql = "SELECT user_username FROM " . TABLE_USERS . " WHERE user_rpx_id = %s"; $username = $h->db->get_var($h->db->prepare($sql, $rpx_profile['identifier'])); if ($username) { $login_result = $h->currentUser->loginCheck($h, $username, ''); // no password necessary } if (isset($login_result) && $login_result != false) { //success $h->currentUser->name = $username; $remember = 1; // keep them logged in for 30 days (not optional) require_once PLUGINS . 'user_signin/user_signin.php'; $user_signin = new UserSignin(); $user_signin->loginSuccess($h, $remember); $return = $h->cage->get->testUri('return'); // so that we don't return to the register page: if (strpos($return, urlencode('register')) !== false) { $return = BASEURL; } if ($return) { header("Location: " . $return); exit; } else { header("Location: " . BASEURL); exit; } } } $rpx_profile['preferredUsername'] = str_replace(" ", "", $rpx_profile['preferredUsername']); // strip spaces from username; // Let's temporarily store the user's profile info in the databse since that would be safer than embedding it in the registration form: // first find out if it already exists: $sql = "SELECT miscdata_value FROM " . TABLE_MISCDATA . " WHERE miscdata_value = %s"; $ident_exists = $h->db->get_var($h->db->prepare($sql, $rpx_profile['identifier'])); // insert it if it doesn't exist, update it if it does. if (!$ident_exists) { $sql = "INSERT INTO " . TABLE_MISCDATA . " SET miscdata_key = %s, miscdata_value = %s, miscdata_default = %s"; $h->db->query($h->db->prepare($sql, 'rpx_identifier', $rpx_profile['identifier'], serialize($rpx_profile))); } else { $sql = "UPDATE " . TABLE_MISCDATA . " SET miscdata_key = %s, miscdata_value = %s, miscdata_default = %s WHERE miscdata_value = %s"; $h->db->query($h->db->prepare($sql, 'rpx_identifier', $rpx_profile['identifier'], serialize($rpx_profile), $rpx_profile['identifier'])); } // Assign $prx_profile to $h to be used in the registration form, $h->vars['rpx_profile'] = $rpx_profile; // set blank if not present: if (!isset($h->vars['rpx_profile']['email'])) { $h->vars['rpx_profile']['email'] = ''; } if (!isset($h->vars['rpx_profile']['preferredUsername'])) { $h->vars['rpx_profile']['preferredUsername'] = ''; } /* falls through to theme_main_index in Users plugin, where we hook in with the function "user_signin_pre_display_register_template" below */ }