/** * Implementation of the signup logic. * * @param SignupRequest $p_request * @return ViewSpec * @throw \Runtimeexception account creation failed */ private function doWork($p_request) { $preconfirm = self::preconfirm_some_emails($p_request->enteredEmail); $confirm = rand(1000, 9999); //generate confirmation code $player_params = ['send_email' => $p_request->enteredEmail, 'send_pass' => $p_request->enteredPass, 'send_class' => $p_request->enteredClass, 'preconfirm' => $preconfirm, 'confirm' => $confirm, 'referred_by' => $p_request->enteredReferral, 'ip' => $p_request->clientIP]; // Create the player if ($error = create_account_and_ninja($p_request->enteredName, $player_params)) { throw new \RuntimeException($error, 4); } if ($preconfirm) { $completedPhase = 4; confirm_player($p_request->enteredName, false, true); // name, no confirm #, just autoconfirm. $confirmed = true; } else { $completedPhase = 5; $confirmed = false; } return ['template' => self::TEMPLATE, 'title' => self::TITLE, 'parts' => ['classes' => $this->classes, 'class_display' => class_display_name_from_identity($p_request->enteredClass), 'signupRequest' => $p_request, 'submit_successful' => true, 'completedPhase' => $completedPhase, 'confirmed' => $confirmed, 'submitted' => true, 'error' => ''], 'options' => ['quickstat' => false]]; }
function send_signup_email($account_id, $signup_email, $signup_name, $confirm, $class_identity) { /*$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: ".SYSTEM_EMAIL_NAME." <".SYSTEM__EMAIL.">\r\n"; $headers .= "Reply-To: ".SUPPORT_EMAIL_NAME." <".SUPPORT_EMAIL.">\r\n";*/ // *** Sends out the confirmation email to the chosen email address. *** $class_display = class_display_name_from_identity($class_identity); $_to = array("{$signup_email}" => $signup_name); $_subject = 'NinjaWars Account Sign Up'; $_body = render_template('signup_email_body.tpl', array('send_name' => $signup_name, 'signup_email' => $signup_email, 'confirm' => $confirm, 'send_class' => $class_display, 'SUPPORT_EMAIL' => SUPPORT_EMAIL, 'account_id' => $account_id)); $_from = array(SYSTEM_EMAIL => SYSTEM_EMAIL_NAME); // *** Create message object. *** $message = new Nmail($_to, $_subject, $_body, $_from); // *** Set replyto address. *** $message->setReplyTo(array(SUPPORT_EMAIL => SUPPORT_EMAIL_NAME)); if (DEBUG) { $message->dump = true; } $sent = false; // By default, assume failure. $sent = $message->send(); return $sent; }
function send_signup_email($account_id, $signup_email, $signup_name, $confirm, $class_identity) { // *** Sends out the confirmation email to the chosen email address. *** $class_display = class_display_name_from_identity($class_identity); $_to = array("{$signup_email}" => $signup_name); $_subject = 'NinjaWars Account Sign Up'; $_body = render_template('signup_email_body.tpl', array('send_name' => $signup_name, 'signup_email' => $signup_email, 'confirm' => $confirm, 'send_class' => $class_display, 'SUPPORT_EMAIL' => SUPPORT_EMAIL, 'account_id' => $account_id)); $_from = array(SYSTEM_EMAIL => SYSTEM_EMAIL_NAME); // *** Create message object. *** $message = new Nmail($_to, $_subject, $_body, $_from); // *** Set replyto address. *** $message->setReplyTo(array(SUPPORT_EMAIL => SUPPORT_EMAIL_NAME)); return $message->send(); }
if ($error = init($private, $alive)) { display_error($error); } else { $starting_referral = in('referrer'); $enteredName = trim(in('send_name', '', 'toText')); $enteredEmail = trim(in('send_email', '', 'toText')); $enteredClass = strtolower(trim(in('send_class', ''))); $enteredReferral = trim(in('referred_by', $starting_referral)); $enteredPass = in('key', null, 'toText'); $enteredCPass = in('cpass', null, 'toText'); $submitted = in('submit'); $submit_successful = false; // *** Default. $error = null; if ($submitted) { $class_display = class_display_name_from_identity($enteredClass); $completedPhase = 0; if ($enteredPass == $enteredCPass) { if (!validate_signup_phase0($enteredName, $enteredEmail, $enteredClass, $enteredPass)) { $error = 'Phase 1 Incomplete: You did not correctly fill out all the necessary information.'; } else { $phase1 = validate_username($enteredName); if ($phase1) { $error = $phase1; } else { $completedPhase = 1; $phase2 = validate_password($enteredPass); if ($phase2) { $error = $phase2; } else { $completedPhase = 2;