public function forgotPassword() { $retArray = array('success' => false); $email = $this->input->post('email', TRUE); $is_valid = email_valid($email); if (!$is_valid) { $retArray['message'] = 'That is not a valid e-mail address.'; } else { $this->load->helper('genmail'); $retArray['success'] = true; $retArray['message'] = 'Thanks! A temporary password has been e-mailed to you that '; $retArray['message'] .= 'will be valid for one hour.'; $genMail = array(); $genMail['to'] = $email; $genMail['subject'] = 'Reset your Log the Dog password!'; $rndpw = $this->_randomPassword(); $this->load->model('account_model'); $acctinfo = $this->account_model->retrieveId($email); $link = base_url() . 'account/user_reset?flirzel=' . $acctinfo['id'] . '&kwerp=' . $rndpw; $genMail['message'] = 'We have received your request to reset your password. Please '; $genMail['message'] .= 'click on the following link:<br /> <br />'; $genMail['message'] .= '<a href="' . $link . '">' . $link . '</a><br /> <br />'; $genMail['message'] .= "If the link doesn't work, then copy the following line "; $genMail['message'] .= "and paste it into your web browser's address bar:<br /> <br />"; $genMail['message'] .= $link; gen_mail($genMail); $exp = date('Y-m-d H:i:s', time() + 3600); $pass = password_hash($rndpw, PASSWORD_BCRYPT); $retArray['create_temp'] = $this->account_model->create_temp($acctinfo['id'], $pass, $exp); } echo json_encode($retArray); exit; }
function savedata($form, $id) { $all_files = array(); $correct = FALSE; @session_start(); $id_for_old = $id; if (!$form->form_front) { $id = ''; } if (isset($_POST["counter" . $id])) { $counter = esc_html($_POST["counter" . $id]); if (isset($_POST["captcha_input"])) { $captcha_input = esc_html($_POST["captcha_input"]); $session_wd_captcha_code = isset($_SESSION[$id . '_wd_captcha_code']) ? $_SESSION[$id . '_wd_captcha_code'] : '-'; if ($captcha_input == $session_wd_captcha_code) { $correct = TRUE; } else { echo "<script> alert('" . addslashes(__('Error, incorrect Security code.', 'form_maker')) . "');\n\t\t\t\t\t\t</script>"; } } elseif (isset($_POST["recaptcha_response_field"])) { $recaptcha_response_field = $_POST["recaptcha_response_field"]; $privatekey = $form->private_key; $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $recaptcha_response_field); if ($resp->is_valid) { $correct = TRUE; } else { echo "<script> alert('" . addslashes(__('Error, incorrect Security code.', 'form_maker')) . "');\n\t\t\t\t\t\t\t</script>"; } } else { $correct = TRUE; } if ($correct) { $result_temp = save_db($counter, $id_for_old); $all_files = $result_temp[0]; if (is_numeric($all_files)) { remove($all_files, $id_for_old); } elseif (isset($counter)) { gen_mail($counter, $all_files, $id_for_old, $result_temp[1]); } } return $all_files; } return $all_files; }
public function create_account() { //TODO: verify created account $sp = '<br /> <br />'; $this->load->model('login_model'); $user_email = $this->input->post('user_email', TRUE); $user_remail = $this->input->post('user_remail', TRUE); $user_password = $this->input->post('user_password', TRUE); $user_name = $this->input->post('user_name', TRUE); $user_repass = $this->input->post('user_repass', TRUE); $user_language = $this->input->post('language', TRUE); $gmail = ''; $g_exists = false; $account = array(); $retArray = array(); $success = true; $invalid = false; // flag to reduce redundant error messaging $error = ''; // Do we have a name? if (strlen($user_name) < 2) { $success = false; $error .= 'Please provide your name.'; if (strlen($user_name) === 1) { $error .= ' (Seriously? Just one character?!)'; } $error .= $sp; } // Is this a plausible e-mail address? if (!email_valid($user_email)) { $success = false; $invalid = true; $error .= 'Please provide a valid e-mail address.' . $sp; } // Does the e-mail address match the confirmation? if (!$invalid && $user_email !== $user_remail) { $success = false; $error .= 'Please ensure your e-mail address is the same in both e-mail fields.' . $sp; } // Does the password meet the criteria? $valid_password = valid_password($user_password, $user_email, $user_name); if (!$valid_password['valid']) { $success = false; $invalid = true; $error .= $valid_password['error']; } else { $invalid = false; } // Does the password match the confirmation? if (!$invalid && $user_password !== $user_repass) { $success = false; $error .= 'Please ensure your password is the same in both password fields.' . $sp; } // Is this e-mail address already tied to an account? if ($this->login_model->doesUserExist($user_email) && $success) { // user was found; do NOT create account $success = false; $error .= 'We already have that e-mail in our user base.'; } else { // user was not found; create account // Is it a Gmail user? If so, check for alias if (stristr($user_email, 'gmail.com')) { $gmail_parts = explode('@', $user_email); $g_user = str_replace('.', '', $gmail_parts[0]); $g_user = str_replace('+', '', $g_user); $gmail = $g_user . '@gmail.com'; $g_exists = $this->login_model->checkForGmail($gmail); } // Return messsage saying it's an existing Gmail alias if ($g_exists) { $error = 'It appears that your e-mail address is '; $error .= 'an alias of a Gmail address that is already '; $error .= 'registered. Should we create an accont with '; $error .= 'this e-mail address anyway?'; $success = false; } if ($success) { // no Gmail alias found; continue to create acct $password = password_hash($user_password, PASSWORD_BCRYPT); $account['username'] = $user_name; $account['email'] = $user_email; $account['password'] = $password; $account['gmail'] = $gmail; $account['language'] = $user_language; $go_create = $this->login_model->addAccount($account); if (!$go_create) { $success = false; $error .= 'There was a problem creating your account. '; $error .= 'We don\'t know what happened, but it was '; $error .= 'most likely our fault. We\'re terribly '; $error .= 'sorry, and we\'ll look into the problem as '; $error .= 'soon as possible.'; } } } // Return stuff $retArray['success'] = $success; if ($success) { // notify the webmaster that a new user has registered $this->load->helper('genmail'); $mail_info['to'] = '*****@*****.**'; $mail_info['subject'] = ' *** NEW LTD USER ***'; $message = 'The following user has registered for an account:<br />'; foreach ($account as $k => $v) { $message .= $k . ': ' . $v . '<br />'; } $message .= '<br />Server info:<br />'; foreach ($_SERVER as $kk => $vv) { $message .= $kk . ': ' . json_encode($vv) . '<br />'; } $mail_info['message'] = $message; gen_mail($mail_info); // see if the user has any dogs already registered $dogs = $this->login_model->retrieveDogs($this->session->userdata('insert_id'), true); if ($dogs) { $retArray['dogs'] = $dogs; } $retArray['creds'] = array('email' => $user_email, 'password' => $user_password); } if (strlen($error) > 0) { $retArray['error'] = $error; } echo json_encode($retArray); }