本文整理匯總了PHP中IPSMember::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSMember::create方法的具體用法?PHP IPSMember::create怎麽用?PHP IPSMember::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSMember
的用法示例。
在下文中一共展示了IPSMember::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createUser
public function createUser($api_key, $api_module, $username, $email, $display_name, $md5_passwordHash)
{
//-----------------------------------------
// INIT
//-----------------------------------------
$api_key = IPSText::md5Clean($api_key);
$api_module = IPSText::parseCleanValue($api_module);
//-----------------------------------------
// Authenticate
//-----------------------------------------
if ($this->__authenticate($api_key, $api_module, 'createUser') !== FALSE) {
//-----------------------------------------
// Add log
//-----------------------------------------
$this->addLogging($api_key);
//-----------------------------------------
// Create a user
//-----------------------------------------
$test = IPSMember::create(array('core' => array('email' => $email, 'md5_hash_password' => $md5_passwordHash, 'name' => $username, 'members_display_name' => $display_name)));
//-----------------------------------------
// The way IPSMember::create function works is it can't fail.. It always returns true unless all data isn't provided.
// However it will still create a partial record. So in essence never fails
//-----------------------------------------
$this->classApiServer->apiSendReply(array('result' => 'success'));
exit;
}
}
示例2: __create_user_account
/**
* Converge_Server::__create_user_account()
*
* Routine to create a local user account
*
* @access public
* @param string $email_address Email address of user logged in
* @param string $md5_once_password The plain text password, hashed once
* @param string $ip_address IP Address of registree
* @param string $unix_join_date The member's join date in unix format
* @param string $timezone The member's timezone
* @param string $dst_autocorrect The member's DST autocorrect settings
* @param string $username The member's username
* @return array $member Newly created member array
*
* @deprecated Doesn't seem to be used anymore, need to verify properly for the next major revision
*/
protected function __create_user_account($email_address = '', $md5_once_password, $ip_address, $unix_join_date, $timezone = 0, $dst_autocorrect = 0, $username = '')
{
//-----------------------------------------
// Check to make sure there's not already
// a member registered.
//-----------------------------------------
$member = IPSMember::load($email_address);
if ($member['member_id']) {
return $member;
}
//-----------------------------------------
// INIT
//-----------------------------------------
$unix_join_date = $unix_join_date ? $unix_join_date : time();
$ip_address = $ip_address ? $ip_address : $this->member->ip_address;
//-----------------------------------------
// Create member
//-----------------------------------------
$member = IPSMember::create(array('members' => array('email' => $email_address, 'password' => $md5_once_password, 'name' => $username, 'members_display_name' => $username, 'joined' => $unix_join_date, 'ip_address' => $ip_address, 'members_created_remote' => true)), false, true, false);
return $member;
}
示例3: number
/**
* Register a new account
*
* @param string Key - this can be anything which is known only to the applications. Never reveal this key publically.
* For IPS Community Suite installs, this key can be obtained in the Login Management page in the ACP
* @param string Username
* @param string Display name
* @param string The password, md5 encoded
* @param string Email address
* @return void Outputs to screen JSON object with 2 parameters
'status' One of the following values:
BAD_KEY The key provided was invalid
SUCCESS Account created
EMAIL_IN_USE Email is already in use
USERNAME_IN_USE Username is already in use
BAD_KEY Key was invalid
MISSING_DATA Not all data was provided
FAIL Other error
'id' with master ID number (0 if fail) - if user already exists, will provide ID of existing user
*/
public function register($key, $username, $displayname, $md5Password, $email, $revalidateUrl)
{
//-----------------------------------------
// Checks
//-----------------------------------------
/* Key is good */
if ($key != $this->masterKey) {
echo json_encode(array('status' => 'BAD_KEY', 'id' => 0));
exit;
}
/* We have the data */
if (!$email or !$md5Password) {
echo json_encode(array('status' => 'MISSING_DATA', 'id' => 0));
exit;
}
/* Email/Username is not in use */
$member = IPSMember::load($email, 'none', 'email');
if ($member['member_id']) {
echo json_encode(array('status' => 'EMAIL_IN_USE', 'id' => $member['member_id']));
exit;
}
if ($username) {
$member = IPSMember::load($username, 'none', 'username');
if ($member['member_id']) {
echo json_encode(array('status' => 'USERNAME_IN_USE', 'id' => $member['member_id']));
exit;
}
}
//-----------------------------------------
// Create
//-----------------------------------------
/* Set basic data */
$tables = array('members' => array('email' => $email, 'md5_hash_password' => $md5Password));
if ($displayname and !$username) {
$username = $displayname;
}
/* Are we validating? */
if ($revalidateUrl) {
$tables['members']['member_group_id'] = ipsRegistry::$settings['auth_group'];
$tables['members']['ipsconnect_revalidate_url'] = base64_decode($revalidateUrl);
}
/* Create */
if ($username) {
$tables['members']['name'] = $username;
if ($displayname) {
$tables['members']['members_display_name'] = $displayname;
}
$member = IPSMember::create($tables, TRUE, TRUE);
} else {
$member = IPSMember::create($tables, FALSE, TRUE, FALSE);
}
//-----------------------------------------
// Return
//-----------------------------------------
if ($member['member_id']) {
echo json_encode(array('status' => 'SUCCESS', 'id' => $member['member_id']));
exit;
} else {
echo json_encode(array('status' => 'FAIL', 'id' => 0));
exit;
}
}
示例4: finishLogin
/**
* Completes the connection
*
* @access public
* @return redirect
*/
public function finishLogin()
{
/* From reg flag */
if ($_REQUEST['code']) {
/* Load oAuth */
require_once IPS_KERNEL_PATH . 'facebook/facebookoauth.php';
/*noLibHook*/
$this->_oauth = new FacebookOAuth(FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, FACEBOOK_CALLBACK, $this->extendedPerms);
/* Load API */
require_once IPS_KERNEL_PATH . 'facebook/facebook.php';
/*noLibHook*/
$this->_api = new Facebook(array('appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_APP_SECRET, 'cookie' => true));
/* Ensure URL is correct */
$_urlExtra = '';
if ($_REQUEST['key']) {
$_urlExtra .= '&key=' . $_REQUEST['key'];
}
if ($_REQUEST['_reg']) {
$_urlExtra .= '&_reg=1';
}
/* Update callback url */
$this->_oauth->setCallBackUrl(FACEBOOK_CALLBACK . $_urlExtra);
/* Generate oAuth token */
$rToken = $this->_oauth->getAccessToken($_REQUEST['code']);
if (is_string($rToken)) {
try {
$_userData = $this->_api->api('me', array('access_token' => $rToken));
} catch (Exception $e) {
/* Try re-authorising */
if (stristr($e->getMessage(), 'invalid')) {
$this->redirectToConnectPage();
}
}
/* A little gymnastics */
$this->_userData = $_userData;
$_userData = $this->fetchUserData($rToken);
/* Got a member linked already? */
$_member = IPSMember::load($_userData['id'], 'all', 'fb_uid');
/* Not connected, check email address */
if (!$_member['member_id'] and $_userData['email']) {
$_member = IPSMember::load($_userData['email'], 'all', 'email');
/* We do have an existing account, so trash email forcing user to sign up with new */
if ($_member['member_id']) {
/* Update row */
IPSMember::save($_member['member_id'], array('core' => array('fb_uid' => $_userData['id'], 'fb_token' => $rToken)));
}
}
if ($_member['member_id']) {
$memberData = $_member;
/* Ensure user's row is up to date */
IPSMember::save($memberData['member_id'], array('core' => array('fb_token' => $rToken)));
/* Here, so log us in!! */
/* changed by denchu 26/12/12 */
$r = $this->_login()->loginWithoutCheckingCredentials($memberData['member_id'], TRUE);
if (is_array($r)) {
if (isset($r[1])) {
$this->registry->getClass('output')->redirectScreen($r[0], $r[1]);
$this->registry->getClass('output')->silentRedirect($r[1]);
} else {
$this->registry->getClass('output')->silentRedirect($r[0]);
}
} elseif (!$r) {
throw new Exception('LINKED_MEMBER_LOGIN_FAIL');
} else {
$this->registry->getClass('output')->silentRedirect($this->settings['base_url']);
}
} else {
/* No? Create a new member */
foreach (array('fbc_s_pic', 'fbc_s_status', 'fbc_s_aboutme') as $field) {
$toSave[$field] = 1;
}
$fb_bwoptions = IPSBWOptions::freeze($toSave, 'facebook');
$safeFBName = IPS_DOC_CHAR_SET != 'UTF-8' ? IPSText::utf8ToEntities($_userData['name']) : $_userData['name'];
/* Make sure usernames are safe */
if ($this->settings['username_characters']) {
$check_against = preg_quote($this->settings['username_characters'], "/");
$check_against = str_replace('\\-', '-', $check_against);
$safeFBName = preg_replace('/[^' . $check_against . ']+/i', '', $safeFBName);
}
/* Check ban filters? */
if (IPSMember::isBanned('email', $_userData['email']) or IPSMember::isBanned('name', $safeFBName)) {
$this->registry->output->showError('you_are_banned', 1090003);
}
$displayName = $this->settings['fb_realname'] == 'enforced' ? $safeFBName : '';
/* From reg, so create new account properly */
$toSave = array('core' => array('name' => IPSText::parseCleanValue($safeFBName), 'members_display_name' => IPSText::parseCleanValue($displayName), 'members_created_remote' => 1, 'member_group_id' => $this->settings['fbc_mgid'] ? $this->settings['fbc_mgid'] : $this->settings['member_group'], 'email' => $_userData['email'], 'fb_uid' => $_userData['id'], 'time_offset' => $_userData['timezone'], 'members_auto_dst' => 1, 'fb_token' => $rToken), 'extendedProfile' => array('pp_about_me' => IPSText::getTextClass('bbcode')->stripBadWords(IPSText::convertCharsets($_userData['about'], 'utf-8', IPS_DOC_CHAR_SET)), 'fb_bwoptions' => $fb_bwoptions));
$memberData = IPSMember::create($toSave, FALSE, FALSE, TRUE);
if (!$memberData['member_id']) {
throw new Exception('CREATION_FAIL');
}
/* Sync up photo */
$this->syncMember($memberData['member_id']);
$pmember = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id=" . $memberData['member_id']));
if ($pmember['partial_member_id']) {
//.........這裏部分代碼省略.........
示例5: registerProcessForm
//.........這裏部分代碼省略.........
}
/* Create member */
$member = array('name' => $this->request['UserName'], 'password' => $in_password, 'members_display_name' => $this->settings['auth_allow_dnames'] ? $this->request['members_display_name'] : $this->request['UserName'], 'email' => $in_email, 'member_group_id' => $mem_group, 'joined' => time(), 'ip_address' => $this->member->ip_address, 'time_offset' => $this->request['time_offset'], 'coppa_user' => $coppa, 'members_auto_dst' => intval($this->request['dst']), 'allow_admin_mails' => intval($this->request['allow_admin_mail']), 'hide_email' => $this->request['allow_member_mail'] ? 0 : 1);
/* Spam Service */
$spamCode = 0;
if ($this->settings['spam_service_enabled'] && $this->settings['spam_service_api_key']) {
/* Query the service */
$spamCode = IPSMember::querySpamService($in_email);
/* Action to perform */
$action = $this->settings['spam_service_action_' . $spamCode];
/* Perform Action */
switch ($action) {
/* Proceed with registraction */
case 1:
break;
/* Flag for admin approval */
/* Flag for admin approval */
case 2:
$member['member_group_id'] = $this->settings['auth_group'];
$this->settings['reg_auth_type'] = 'admin';
break;
/* Approve the account, but ban it */
/* Approve the account, but ban it */
case 3:
$member['member_banned'] = 1;
$member['member_group_id'] = $this->settings['banned_group'];
$this->settings['reg_auth_type'] = '';
break;
}
}
//-----------------------------------------
// Create the account
//-----------------------------------------
$member = IPSMember::create(array('members' => $member, 'pfields_content' => $this->request));
//-----------------------------------------
// Login handler create account callback
//-----------------------------------------
$this->han_login->createAccount(array('email' => $member['email'], 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $this->member->ip_address, 'username' => $member['members_display_name']));
//-----------------------------------------
// We'll just ignore if this fails - it shouldn't hold up IPB anyways
//-----------------------------------------
/*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) )
{
$this->registry->output->showError( 'han_login_create_failed', 2017, true );
}*/
//-----------------------------------------
// Validation
//-----------------------------------------
$validate_key = md5(IPSLib::makePassword() . time());
$time = time();
if ($coppa != 1) {
if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin' or $this->settings['reg_auth_type'] == 'admin_user') {
//-----------------------------------------
// We want to validate all reg's via email,
// after email verificiation has taken place,
// we restore their previous group and remove the validate_key
//-----------------------------------------
$this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address']));
if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin_user') {
IPSText::getTextClass('email')->getTemplate("reg_validate");
IPSText::getTextClass('email')->buildMessage(array('THE_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=auto_validate&uid=" . urlencode($member['member_id']) . "&aid=" . urlencode($validate_key), 'NAME' => $member['members_display_name'], 'MAN_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=05", 'EMAIL' => $member['email'], 'ID' => $member['member_id'], 'CODE' => $validate_key));
IPSText::getTextClass('email')->subject = $this->lang->words['new_registration_email'] . $this->settings['board_name'];
IPSText::getTextClass('email')->to = $member['email'];
IPSText::getTextClass('email')->sendMail();
$this->output = $this->registry->output->getTemplate('register')->showAuthorize($member);
} else {
示例6: ipb_create
function ipb_create($username, $email, $password, $id_level, $newuid)
{
global $THIS_BASEPATH, $TABLE_PREFIX, $registry;
if (!isset($THIS_BASEPATH) || empty($THIS_BASEPATH)) {
$THIS_BASEPATH = str_replace(array("\\", "/include"), array("/", ""), dirname(__FILE__));
}
if (!defined('IPS_ENFORCE_ACCESS')) {
define('IPS_ENFORCE_ACCESS', true);
}
if (!defined('IPB_THIS_SCRIPT')) {
define('IPB_THIS_SCRIPT', 'public');
}
if (!isset($registry) || empty($registry)) {
require_once $THIS_BASEPATH . '/ipb/initdata.php';
require_once IPS_ROOT_PATH . 'sources/base/ipsRegistry.php';
require_once IPS_ROOT_PATH . 'sources/base/ipsController.php';
$registry = ipsRegistry::instance();
$registry->init();
}
$member_info = IPSMember::create(array("members" => array("name" => "{$username}", "members_display_name" => "{$username}", "email" => "{$email}", "password" => "{$password}", "member_group_id" => "{$id_level}", "allow_admin_mails" => "1", "members_created_remote" => "1")));
$ipb_fid = $member_info["member_id"];
do_sqlquery("UPDATE `{$TABLE_PREFIX}users` SET `ipb_fid`=" . $ipb_fid . " WHERE `id`=" . $newuid);
}
示例7: registerProcessForm
//.........這裏部分代碼省略.........
/* Query the service */
$spamCode = IPSMember::querySpamService($in_email);
/* Action to perform */
$action = $this->settings['spam_service_action_' . $spamCode];
/* Perform Action */
switch ($action) {
/* Proceed with registration */
case 1:
break;
/* Flag for admin approval */
/* Flag for admin approval */
case 2:
$member['member_group_id'] = $this->settings['auth_group'];
$this->settings['reg_auth_type'] = 'admin';
$_spamFlag = 1;
break;
/* Approve the account, but ban it */
/* Approve the account, but ban it */
case 3:
$member['member_banned'] = 1;
$member['bw_is_spammer'] = 1;
$this->settings['reg_auth_type'] = '';
break;
/* Deny registration */
/* Deny registration */
case 4:
$this->registry->output->showError('spam_denied_account', '100x001', FALSE, '', 200);
break;
}
}
//-----------------------------------------
// Create the account
//-----------------------------------------
$member = IPSMember::create(array('members' => $member, 'pfields_content' => $custom_fields->out_fields), FALSE, FALSE, FALSE);
//-----------------------------------------
// Login handler create account callback
//-----------------------------------------
$this->han_login->createAccount(array('member_id' => $member['member_id'], 'email' => $member['email'], 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $this->member->ip_address, 'username' => $member['members_display_name'], 'name' => $member['name'], 'members_display_name' => $member['members_display_name']));
//-----------------------------------------
// We'll just ignore if this fails - it shouldn't hold up IPB anyways
//-----------------------------------------
/*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) )
{
$this->registry->output->showError( 'han_login_create_failed', 2017, true );
}*/
//-----------------------------------------
// Validation
//-----------------------------------------
$validate_key = md5(IPSMember::makePassword() . time());
$time = time();
if ($coppa != 1) {
if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin' or $this->settings['reg_auth_type'] == 'admin_user') {
//-----------------------------------------
// We want to validate all reg's via email,
// after email verificiation has taken place,
// we restore their previous group and remove the validate_key
//-----------------------------------------
$this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address'], 'spam_flag' => $_spamFlag));
if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin_user') {
/* Send out the email. */
$message = array('THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=auto_validate&uid=" . urlencode($member['member_id']) . "&aid=" . urlencode($validate_key), 'publicNoSession', 'false'), 'NAME' => $member['members_display_name'], 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=05", 'publicNoSession', 'false'), 'EMAIL' => $member['email'], 'ID' => $member['member_id'], 'CODE' => $validate_key);
IPSText::getTextClass('email')->setPlainTextTemplate(IPSText::getTextClass('email')->getTemplate("reg_validate", $this->member->language_id));
IPSText::getTextClass('email')->buildPlainTextContent($message);
IPSText::getTextClass('email')->buildHtmlContent($message);
IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email'], $this->settings['board_name']);
IPSText::getTextClass('email')->to = $member['email'];
示例8: _memberDoAdd
/**
* Add a member [process]
*
* @access private
* @return void [Outputs to screen]
*/
private function _memberDoAdd()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$in_username = trim($this->request['name']);
$in_password = trim($this->request['password']);
$in_email = trim(strtolower($this->request['email']));
$members_display_name = trim($this->request['members_display_name']);
$this->registry->output->global_message = '';
//-----------------------------------------
// Check form
//-----------------------------------------
foreach (array('name', 'password', 'email', 'member_group_id') as $field) {
if (!$_POST[$field]) {
$this->registry->output->showError($this->lang->words['m_completeform'], 11238);
}
}
//-----------------------------------------
// Check
//-----------------------------------------
if (!IPSText::checkEmailAddress($in_email)) {
$this->registry->output->global_message = $this->lang->words['m_emailinv'];
}
$userName = IPSMember::getFunction()->cleanAndCheckName($in_username, array(), 'name');
$displayName = IPSMember::getFunction()->cleanAndCheckName($members_display_name, array(), 'members_display_name');
if (count($userName['errors'])) {
$this->registry->output->global_message .= '<p>' . $this->lang->words['sm_loginname'] . ' ' . $userName['errors']['username'] . '</p>';
}
if ($this->settings['auth_allow_dnames'] and count($displayName['errors'])) {
$this->registry->output->global_message .= '<p>' . $this->lang->words['sm_display'] . ' ' . $displayName['errors']['dname'] . '</p>';
}
/* Errors? */
if ($this->registry->output->global_message) {
$this->_memberAddForm();
return;
}
//-----------------------------------------
// Load handler...
//-----------------------------------------
require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php';
$this->han_login = new han_login($this->registry);
$this->han_login->init();
$this->han_login->emailExistsCheck($in_email);
if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'EMAIL_NOT_IN_USE') {
$this->registry->output->global_message = $this->lang->words['m_emailalready'];
$this->_memberAddForm();
return;
}
//-----------------------------------------
// Allowed to add administrators?
//-----------------------------------------
if ($this->caches['group_cache'][intval($this->request['member_group_id'])]['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_add_admin')) {
$this->registry->output->global_message = $this->lang->words['m_addadmin'];
$this->_memberAddForm();
return;
}
$member = array('name' => $in_username, 'members_display_name' => $members_display_name ? $members_display_name : $in_username, 'email' => $in_email, 'member_group_id' => intval($this->request['member_group_id']), 'joined' => time(), 'ip_address' => $this->member->ip_address, 'time_offset' => $this->settings['time_offset'], 'coppa_user' => intval($this->request['coppa']), 'allow_admin_mails' => 1, 'password' => $in_password);
//-----------------------------------------
// Create the account
//-----------------------------------------
$member = IPSMember::create(array('members' => $member, 'pfields_content' => $this->request));
//-----------------------------------------
// Login handler create account callback
//-----------------------------------------
$this->han_login->createAccount(array('email' => $in_email, 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $member['ip_address'], 'username' => $member['members_display_name']));
/*if( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
{
$this->registry->output->global_message = sprintf( $this->lang->words['m_cantadd'], $this->han_login->return_code ) . $this->han_login->return_details;
$this->_memberAddForm();
return;
}*/
//-----------------------------------------
// Restriction permissions stuff
//-----------------------------------------
if ($this->memberData['row_perm_cache']) {
if ($this->caches['group_cache'][intval($this->request['member_group_id'])]['g_access_cp']) {
//-----------------------------------------
// Copy restrictions...
//-----------------------------------------
$this->DB->insert('admin_permission_rows', array('row_member_id' => $member_id, 'row_perm_cache' => $this->memberData['row_perm_cache'], 'row_updated' => time()));
}
}
//-----------------------------------------
// Send teh email (I love 'teh' as much as !!11!!1)
//-----------------------------------------
if ($this->request['sendemail']) {
IPSText::getTextClass('email')->getTemplate("account_created");
IPSText::getTextClass('email')->buildMessage(array('NAME' => $member['name'], 'EMAIL' => $member['email'], 'PASSWORD' => $in_password));
IPSText::getTextClass('email')->to = $member['email'];
IPSText::getTextClass('email')->sendMail();
}
//-----------------------------------------
// Stats
//.........這裏部分代碼省略.........
示例9: createLocalMember
/**
* Create a local member account [public interface]
*
* @access public
* @param array Member Information [members,pfields,profile_portal]
* @return array New member information
*/
public function createLocalMember($member)
{
$member['members']['members_created_remote'] = true;
$member['members']['members_display_name'] = $member['members']['members_display_name'] ? $member['members']['members_display_name'] : $member['members']['name'];
// #38703 timezone when registering
$member['members']['time_offset'] = $member['members']['time_offset'] ? $member['members']['time_offset'] : $this->settings['time_offset'];
$_return = IPSMember::create($member, FALSE, FALSE, TRUE);
$this->cache->rebuildCache('stats', 'global');
if ($_return['full']) {
IPSLib::runMemberSync('onCompleteAccount', $_return);
}
return $_return;
}
示例10: createLocalMember
/**
* Create a local member account [public interface]
*
* @access public
* @param array Member Information [members,pfields,profile_portal]
* @return array New member information
* @deprecated Just redirects to IPSMember::create
*/
public function createLocalMember($member)
{
$member['members']['members_created_remote'] = true;
return IPSMember::create($member);
}
示例11: _memberDoAdd
/**
* Add a member [process]
*
* @return @e void
*/
protected function _memberDoAdd()
{
/* Init vars */
$in_username = trim($this->request['name']);
$in_password = trim($this->request['password']);
$in_email = trim(strtolower($this->request['email']));
$members_display_name = $this->request['mirror_loginname'] ? $in_username : trim($this->request['members_display_name']);
$this->registry->output->global_error = '';
$this->registry->class_localization->loadLanguageFile(array('public_register'), 'core');
/* Check erros */
foreach (array('name', 'password', 'email', 'member_group_id') as $field) {
if (!$_POST[$field]) {
$this->registry->output->showError($this->lang->words['m_completeform'], 11238);
}
}
//-----------------------------------------
// Check
//-----------------------------------------
if (!IPSText::checkEmailAddress($in_email)) {
$this->registry->output->global_error = $this->lang->words['m_emailinv'];
}
$userName = IPSMember::getFunction()->cleanAndCheckName($in_username, array(), 'name');
$displayName = IPSMember::getFunction()->cleanAndCheckName($members_display_name, array(), 'members_display_name');
if (count($userName['errors'])) {
$_message = $this->lang->words[$userName['errors']['username']] ? $this->lang->words[$userName['errors']['username']] : $userName['errors']['username'];
$this->registry->output->global_error .= '<p>' . $this->lang->words['sm_loginname'] . ': ' . $_message . '</p>';
}
if ($this->settings['auth_allow_dnames'] and count($displayName['errors'])) {
$_message = $this->lang->words[$displayName['errors']['dname']] ? $this->lang->words[$displayName['errors']['dname']] : $displayName['errors']['dname'];
$this->registry->output->global_error .= '<p>' . $this->lang->words['sm_display'] . ': ' . $_message . '</p>';
}
/* Errors? */
if ($this->registry->output->global_error) {
$this->_memberAddForm();
return;
}
//-----------------------------------------
// Load handler...
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
$this->han_login = new $classToLoad($this->registry);
$this->han_login->init();
//-----------------------------------------
// Only check local, else a user being in Converge
// means that you can't manually add the user to the board
//-----------------------------------------
$email_check = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "email='" . $in_email . "'"));
if ($email_check['member_id']) {
$this->registry->output->global_error = $this->lang->words['m_emailalready'];
$this->_memberAddForm();
return;
}
//$this->han_login->emailExistsCheck( $in_email );
//if( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'EMAIL_NOT_IN_USE' )
//{
// $this->registry->output->global_message = $this->lang->words['m_emailalready'];
// $this->_memberAddForm();
// return;
//}
//-----------------------------------------
// Allowed to add administrators?
//-----------------------------------------
if ($this->caches['group_cache'][intval($this->request['member_group_id'])]['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_add_admin')) {
$this->registry->output->global_error = $this->lang->words['m_addadmin'];
$this->_memberAddForm();
return;
}
$member = array('name' => $in_username, 'members_display_name' => $members_display_name ? $members_display_name : $in_username, 'email' => $in_email, 'member_group_id' => intval($this->request['member_group_id']), 'joined' => time(), 'ip_address' => $this->member->ip_address, 'time_offset' => $this->settings['time_offset'], 'coppa_user' => intval($this->request['coppa']), 'allow_admin_mails' => 1, 'password' => $in_password, 'language' => IPSLib::getDefaultLanguage());
//-----------------------------------------
// Create the account
//-----------------------------------------
$member = IPSMember::create(array('members' => $member, 'pfields_content' => $this->request), FALSE, FALSE, FALSE);
//-----------------------------------------
// Login handler create account callback
//-----------------------------------------
$this->han_login->createAccount(array('email' => $in_email, 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $member['ip_address'], 'username' => $member['members_display_name']));
/*if( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
{
$this->registry->output->global_message = sprintf( $this->lang->words['m_cantadd'], $this->han_login->return_code ) . $this->han_login->return_details;
$this->_memberAddForm();
return;
}*/
//-----------------------------------------
// Restriction permissions stuff
//-----------------------------------------
if ($this->memberData['row_perm_cache']) {
if ($this->caches['group_cache'][intval($this->request['member_group_id'])]['g_access_cp']) {
//-----------------------------------------
// Copy restrictions...
//-----------------------------------------
$this->DB->insert('admin_permission_rows', array('row_member_id' => $member['member_id'], 'row_perm_cache' => $this->memberData['row_perm_cache'], 'row_updated' => time()));
}
}
//-----------------------------------------
// Send teh email (I love 'teh' as much as !!11!!1)
//.........這裏部分代碼省略.........
示例12: loginWithNewAccount
/**
* Log in and create a brand new forum account
*
* @access public
* @return mixed On success, an array containing a message and redirect URL
*
* EXCEPTION CODES:
* NO_FACEBOOK_USER_LOGGED_IN System cannot detect a logged in facebook user
* NO_FB_EMAIL Could not locate a facebook proxy email
* CREATION_FAIL Account creation failed
* ALREADY_LINKED_MEMBER The facebook UID is already linked to another IPB account
*/
public function loginWithNewAccount()
{
$loggedInUser = $this->FB()->get_loggedin_user();
if (!$loggedInUser) {
throw new Exception('NO_FACEBOOK_USER_LOGGED_IN');
}
/* Ensure that there is not already a linked account */
/* Now get the linked user */
$_member = IPSMember::load($loggedInUser, 'all', 'fb_uid');
if ($_member['member_id']) {
throw new Exception('ALREADY_LINKED_MEMBER');
}
/* Now fetch more data */
$_fbData = $this->API()->users_getInfo($loggedInUser, array('name', 'proxied_email', 'timezone', 'pic', 'pic_square', 'pic_square_with_logo', 'about_me'));
$fbData = $_fbData[0];
if (!$fbData['proxied_email']) {
throw new Exception('NO_FB_EMAIL');
}
/* Generate BW options */
foreach (array('fbc_s_pic', 'fbc_s_avatar', 'fbc_s_status', 'fbc_s_aboutme') as $field) {
$toSave[$field] = 1;
}
$fb_bwoptions = IPSBWOptions::freeze($toSave, 'facebook');
/* Generate FB hash */
$hash = $this->generateEmailHash($fbData['proxied_email']);
$memberData = IPSMember::create(array('core' => array('name' => IPSText::convertCharsets($fbData['name'], 'utf-8', IPS_DOC_CHAR_SET), 'members_display_name' => IPSText::convertCharsets($fbData['name'], 'utf-8', IPS_DOC_CHAR_SET), 'members_created_remote' => 1, 'member_group_id' => $this->settings['fbc_mgid'] ? $this->settings['fbc_mgid'] : $this->settings['member_group'], 'email' => $fbData['proxied_email'], 'time_offset' => $fbData['timezone'], 'fb_uid' => $loggedInUser, 'fb_emailhash' => $hash), 'extendedProfile' => array('pp_about_me' => IPSText::convertCharsets($fbData['about_me'], 'utf-8', IPS_DOC_CHAR_SET), 'fb_photo' => $fbData['pic'], 'fb_photo_thumb' => $fbData['pic_square_with_logo'], 'fb_bwoptions' => $fb_bwoptions, 'avatar_location' => $fbData['pic_square'], 'avatar_type' => 'facebook')), TRUE);
if (!$memberData['member_id']) {
throw new Exception('CREATION_FAIL');
}
/* Register with Facebook */
try {
$reg = $this->API()->connect_registerUsers(json_encode(array(array('email_hash' => $hash, 'account_id' => $memberData['member_id']))));
} catch (Exception $error) {
//print $error->getMessage(); exit();
}
//-----------------------------------------
// Update Stats
//-----------------------------------------
$cache = $this->cache->getCache('stats');
if ($memberData['members_display_name'] and $memberData['member_id']) {
$cache['last_mem_name'] = $memberData['members_display_name'];
$cache['last_mem_id'] = $memberData['member_id'];
}
$cache['mem_count'] += 1;
$this->cache->setCache('stats', $cache, array('array' => 1, 'deletefirst' => 0));
//-----------------------------------------
// New registration emails
//-----------------------------------------
if ($this->settings['new_reg_notify']) {
$this->lang->loadLanguageFile(array('public_register'), 'core');
$date = $this->registry->class_localization->getDate(time(), 'LONG', 1);
IPSText::getTextClass('email')->getTemplate('admin_newuser');
IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'MEMBER_NAME' => $memberData['members_display_name']));
IPSText::getTextClass('email')->subject = $this->lang->words['new_registration_email1'] . $this->settings['board_name'];
IPSText::getTextClass('email')->to = $this->settings['email_in'];
IPSText::getTextClass('email')->sendMail();
}
/* Here, so log us in!! */
return $this->_login()->loginWithoutCheckingCredentials($memberData['member_id'], TRUE);
}
示例13: _handleIpsConnect
/**
* Set member based on IPS Connect
*
* @param array Data returned from IPS Connect
* @return void
*/
protected function _handleIpsConnect($data)
{
if ($data['connect_status'] != 'SUCCESS') {
return false;
}
$update = array();
$member = IPSMember::load($data['connect_id'], 'all,members_partial', 'ipsconnect');
if (!isset($member['member_id'])) {
if (IPSText::mbstrlen($data['connect_username']) > ipsRegistry::$settings['max_user_name_length']) {
$data['connect_username'] = IPSText::mbsubstr($data['connect_username'], 0, ipsRegistry::$settings['max_user_name_length']);
}
$member = IPSMember::create(array('members' => array('name' => $data['connect_username'], 'members_display_name' => $data['connect_displayname'], 'email' => $data['connect_email'], 'ipsconnect_id' => $data['connect_id'])), FALSE, TRUE, FALSE);
}
if (!$member['ipsconnect_id']) {
$update['ipsconnect_id'] = $data['connect_id'];
}
if ($member['name'] != $data['connect_username'] and !defined('CONNECT_NOSYNC_NAMES')) {
$update['name'] = $data['connect_username'];
}
if ($member['members_display_name'] != $data['connect_displayname'] and !defined('CONNECT_NOSYNC_NAMES')) {
$update['members_display_name'] = $data['connect_displayname'];
}
if ($member['email'] != $data['connect_email']) {
$update['email'] = $data['connect_email'];
}
if (!empty($update)) {
IPSMember::save($member['member_id'], array('members' => $update));
}
self::setMember($member['member_id']);
if ($member['partial_member_id']) {
$this->DB->delete('members_partial', "partial_member_id={$member['partial_member_id']}");
}
}
示例14: finishLogin
/**
* Completes the connection
*
* @access public
* @return redirect
*
*/
public function finishLogin()
{
/* From reg flag */
$connectData = array('t_key' => '');
if ($_REQUEST['key']) {
$connectData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'twitter_connect', 'where' => "t_key='" . IPSText::md5Clean($_REQUEST['key']) . "'"));
if (!$connectData['t_key']) {
throw new Exception("NO_KEY_FOUND");
}
/* Delete connect row */
$this->DB->delete('twitter_connect', "t_key='" . IPSText::md5Clean($_REQUEST['key']) . "'");
$member = array('twitter_token' => $connectData['t_token'], 'twitter_secret' => $connectData['t_secret']);
}
if ($_REQUEST['oauth_token']) {
if ($member['twitter_token'] == $_REQUEST['oauth_token']) {
/* Reset api to ensure user is not logged in */
require_once IPS_KERNEL_PATH . 'twitter/twitteroauth.php';
/*noLibHook*/
$this->_api = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $member['twitter_token'], $member['twitter_secret']);
/* Generate oAuth token */
$rToken = $this->_api->getAccessToken($_REQUEST['oauth_verifier']);
if ($rToken['oauth_token'] and $rToken['oauth_token_secret']) {
$_userData = $this->_api->get('account/verify_credentials');
/* From registration? */
if ($connectData['t_key']) {
/* Got a member linked already? */
$_member = IPSMember::load($_userData['id'], 'all', 'twitter_id');
if ($_member['member_id']) {
$memberData = array_merge($member, $_member);
/* Ensure user's row is up to date */
IPSMember::save($memberData['member_id'], array('core' => array('twitter_token' => $rToken['oauth_token'], 'twitter_secret' => $rToken['oauth_token_secret'])));
/* Check for partial member id */
$pmember = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id=" . $memberData['member_id']));
if ($pmember['partial_member_id']) {
$this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . 'app=core&module=global§ion=register&do=complete_login&mid=' . $memberData['member_id'] . '&key=' . $pmember['partial_date']);
} else {
/* Here, so log us in!! */
/* changed by denchu 26/12/12 */
$r = $this->_login()->loginWithoutCheckingCredentials($memberData['member_id'], TRUE);
if (is_array($r)) {
if (isset($r[1])) {
$this->registry->getClass('output')->redirectScreen($r[0], $r[1]);
$this->registry->getClass('output')->silentRedirect($r[1]);
} else {
$this->registry->getClass('output')->silentRedirect($r[0]);
}
} elseif (!$r) {
throw new Exception('LINKED_MEMBER_LOGIN_FAIL');
} else {
$this->registry->getClass('output')->silentRedirect($this->settings['base_url']);
}
}
} else {
/* No? Create a new member */
/* Generate BW options */
foreach (array('tc_s_pic', 'tc_s_status', 'tc_s_aboutme', 'tc_si_status') as $field) {
$_toSave[$field] = 1;
}
$tc_bwoptions = IPSBWOptions::freeze($_toSave, 'twitter');
$safeFBName = str_replace(' ', '', IPSText::convertCharsets($_userData['screen_name'], 'utf-8', IPS_DOC_CHAR_SET));
/* Make sure usernames are safe */
if ($this->settings['username_characters']) {
$check_against = preg_quote($this->settings['username_characters'], "/");
$check_against = str_replace('\\-', '-', $check_against);
$safeFBName = preg_replace('/[^' . $check_against . ']+/i', '', $safeFBName);
}
$displayName = !$this->settings['auth_allow_dnames'] ? $safeFBName : FALSE;
/* From reg, so create new account properly */
$toSave = array('core' => array('name' => $safeFBName, 'members_display_name' => $displayName, 'members_created_remote' => 1, 'member_group_id' => $this->settings['tc_mgid'] ? $this->settings['tc_mgid'] : $this->settings['member_group'], 'email' => '', 'twitter_id' => $_userData['id'], 'twitter_token' => $rToken['oauth_token'], 'twitter_secret' => $rToken['oauth_token_secret']), 'extendedProfile' => array('pp_about_me' => IPSText::getTextClass('bbcode')->stripBadWords(IPSText::convertCharsets($_userData['description'], 'utf-8', IPS_DOC_CHAR_SET)), 'tc_bwoptions' => $tc_bwoptions));
$memberData = IPSMember::create($toSave, TRUE, FALSE, TRUE);
if (!$memberData['member_id']) {
throw new Exception('CREATION_FAIL');
}
/* Sync up photo */
$this->syncMember($memberData['member_id']);
$pmember = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id=" . $memberData['member_id']));
if ($pmember['partial_member_id']) {
$this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . 'app=core&module=global§ion=register&do=complete_login&mid=' . $memberData['member_id'] . '&key=' . $pmember['partial_date']);
} else {
throw new Exception('CREATION_FAIL');
}
}
}
}
}
}
}
示例15: __create_user_account
/**
* Routine to create a local user account
*
* @access protected
* @param string $email_address Email address of user logged in
* @param string $md5_once_password The plain text password, hashed once
* @param string $ip_address IP Address of registree
* @param string $unix_join_date The member's join date in unix format
* @param string $timezone The member's timezone
* @param string $dst_autocorrect The member's DST autocorrect settings
* @return array $member Newly created member array
*/
protected function __create_user_account($email_address = '', $md5_once_password, $ip_address, $unix_join_date, $timezone = 0, $dst_autocorrect = 0)
{
//-----------------------------------------
// Check to make sure there's not already
// a member registered.
//-----------------------------------------
$member = $this->registry->DB()->buildAndFetch(array('select' => '*', 'from' => 'members', 'where' => "email='" . $this->registry->DB()->addSlashes($email_address) . "'"));
if ($member['id']) {
return $member;
}
//-----------------------------------------
// INIT
//-----------------------------------------
$unix_join_date = $unix_join_date ? $unix_join_date : time();
$ip_address = $ip_address ? $ip_address : $this->registry->member()->ip_address;
//-----------------------------------------
// Create member
//-----------------------------------------
$member = IPSMember::create(array('members' => array('email' => $email_address, 'password' => $md5_once_password, 'joined' => $unix_join_date, 'ip_address' => $ip_address)));
return $member;
}