Created
December 8, 2017 02:07
-
-
Save anonymous/6fe2f36d721da8ccce2cb5c7262c93bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('XF_ROOT', $_SERVER['DOCUMENT_ROOT'] . '/members'); // set this! | |
define('TIMENOW', time()); | |
define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed | |
require_once(XF_ROOT . '/library/XenForo/Autoloader.php'); | |
XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library'); | |
XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT); | |
XenForo_Application::set('page_start_time', TIMENOW); | |
XenForo_Application::disablePhpErrorHandler(); | |
XenForo_Session::startPublicSession(); | |
error_reporting(E_ALL & ~E_NOTICE); // Turn off the strict error reporting. | |
define('DB_USER', ''); | |
if($_POST){ | |
//Set User Data | |
$data = array( | |
'username' => strtolower($_POST['customer']['first_name']."_".$_POST['customer']['last_name']), | |
'email' => $_POST['customer']['email'],//Must be unique | |
'timezone' => "Australia/Sydney",//Country/City | |
'gender' => "female",//Gender in english | |
'dob_day' => 01, | |
'dob_month' => 01, | |
'dob_year' => 1988, | |
); | |
//Set Raw Passwords | |
$passwords = array('password' => $_POST['customer']['id'], 'password_confirm' => $_POST['customer']['id']); | |
//Get the default options from XenForo. | |
$options = XenForo_Application::get('options'); | |
//Create the dataWriter object, set the defaults. | |
$writer = XenForo_DataWriter::create('XenForo_DataWriter_User'); | |
if ($options->registrationDefaults) { | |
$writer->bulkSet($options->registrationDefaults, array('ignoreInvalidFields' => true)); | |
} | |
$writer->bulkSet($data); | |
$writer->setPassword($passwords['password'], $passwords['password_confirm']); | |
//If the email corresponds to an existing Gravatar, use it | |
if ($options->gravatarEnable && XenForo_Model_Avatar::gravatarExists($data['email'])) { | |
$writer->set('gravatar', $data['email']); | |
} | |
//Save the User to Database: | |
$writer->set('user_group_id', XenForo_Model_User::$defaultRegisteredGroupId); | |
$writer->set('language_id', XenForo_Visitor::getInstance()->get('language_id')); | |
$writer->advanceRegistrationUserState(); | |
$writer->preSave(); | |
$writer->save(); | |
//Get the User as a Variable: | |
$user = $writer->getMergedData(); | |
//Log the ip of the user registering | |
XenForo_Model_Ip::log($user['user_id'], 'user', $user['user_id'], 'register'); | |
$mail = new Zend_Mail('utf-8'); | |
$mail->setBodyText('Your temporary password is: '.$_POST['customer']['id'].". Please change immediately once logged in. Visit below link to login. \n\n http://propertyinvestory.com/members/index.php"); | |
$mail->setFrom('ts@tyroneshum.com', 'PropertyInvestory Moderator'); | |
$mail->addTo($_POST['customer']['email'], $_POST['customer']['first_name']." ".$_POST['customer']['last_name']); | |
$mail->setSubject('PropertyInvestory Membership: Temporary Password'); | |
$transport = new Zend_Mail_Transport_Sendmail(); | |
$transport->send($mail); | |
//Set the user back to the browser session | |
#XenForo_Application::get('session')->changeUserId($user['user_id']); | |
#XenForo_Visitor::setup($user['user_id']); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment