Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!defined('KODEVS') || KODEVS != 1)
- die();
- class Page {
- private $site, $database, $content;
- private $cacheable = FALSE;
- private $cacheTime = 0;
- private $db = null;
- function __construct($site) {
- $this->site = $site;
- $this->config = $site->config;
- $this->database = $site->database;
- $this->db = $this->database[ADB];
- Template::SetVar('title', $this->config['SITE']['TITLE'] . Template::GetLangVar('PAGE_REGISTER_TITLE'));
- if (isset($_GET['act']))
- $this->cacheable = FALSE;
- }
- function Run() {
- if (isset($_SESSION['bLoggedIn']) && $_SESSION['bLoggedIn'] == FALSE) {
- $this->content = Template::Load('error', array('errmsg' => 'You are logged in so you do know your credentials!'));
- return;
- }
- switch (@$_GET['act']) {
- case 'login' : $this->SendLogin();
- break;
- case 'password' : $this->SendPassword();
- break;
- default : $this->content = Template::Load('forgotpassword', array('forum' => $this->config['SITE']['FORUM']));
- }
- }
- function Error($error) {
- Template::SetVar('reg_error', '<@forgotpassword-error@>');
- Template::SetVar('reg_errmsg', Template::GetLangVar($error));
- $this->content = Template::Load('forgotpassword');
- }
- function SendLogin() {
- if (!isset($_POST['securepin']) || !isset($_POST['email'])) {
- $this->content = Template::Load('error', array('errmsg' => 'Incorrect data!'));
- return;
- }
- $email = @$_POST['email'];
- if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $this->content = Template::Load('error', array('errmsg' => 'Incorrect email!'));
- return;
- }
- $login = "";
- $code = intval(@$_POST['securepin']);
- $num_rows = $this->db->doQuery('SELECT strAccountID, strSocNo FROM TB_USER WHERE strEmail = ?', $email);
- if (1 != $num_rows) {
- $this->content = Template::Load('error', array('errmsg' => 'Incorrect email address!'));
- return;
- } else {
- $result = $this->db->doRead();
- $security_pin = $result['strSocNo'];
- if ($security_pin != $code) {
- $this->content = Template::Load('error', array('errmsg' => 'Incorrect Email address or Security Code!'));
- return;
- }
- $login = $result['strAccountID'];
- }
- $message = "Dear user!<br />"
- . "This message is sent automatically because you or someone else used option to recover Login information from "
- . $this->config['SITE']['TITLE']
- . ".<br />Please do not replay to this message.<br />"
- . "In case you need to contact us please use: <a href='mailto:"
- . $this->config['SITE']['EMAIL']['CONTACT']['ADDRESS']
- . "'>"
- . $this->config['SITE']['EMAIL']['CONTACT']['ADDRESS']
- . "</a>.<br />"
- . "Your login is: "
- . $login
- . "<br />Please use this login on <a href='"
- . $this->config['SITE']['URL']
- . "'>"
- . $this->config['SITE']['TITLE']
- . "</a> site.</br >"
- . "Your Global Knight Online Team";
- if (!$this->SendEmail($email, $this->config['SITE']['TITLE'] . " - login reminder", $message, "")) {
- $this->content = Template::Load('error', array('errmsg' => 'Internal server error!'));
- return;
- }
- $this->content = Template::Load('forgotpassword-complete');
- }
- function SendPassword() {
- if (!isset($_POST['securepin']) || !isset($_POST['email'])) {
- $this->content = Template::Load('error', array('errmsg' => 'Incorrect data!'));
- return;
- }
- $email = @$_POST['email'];
- if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $this->content = Template::Load('error', array('errmsg' => 'Incorrect email!'));
- return;
- }
- $password = "";
- $code = intval(@$_POST['securepin']);
- $num_rows = $this->db->doQuery('SELECT strPasswd, strSocNo FROM TB_USER WHERE strEmail = ?', $email);
- if (1 != $num_rows) {
- $this->content = Template::Load('error', array('errmsg' => 'Incorrect email address!'));
- return;
- } else {
- $result = $this->db->doRead();
- $security_pin = $result['strSocNo'];
- if ($security_pin != $code) {
- $this->content = Template::Load('error', array('errmsg' => 'Incorrect Email address or Security Code!'));
- return;
- }
- $password = $result['strPasswd'];
- }
- $message = "Dear user!<br />"
- . "This message is sent automatically because you or someone else used option to recover Password information from "
- . $this->config['SITE']['TITLE']
- . ".<br />Please do not replay to this message.<br />"
- . "In case you need to contact us please use: <a href='mailto:"
- . $this->config['SITE']['EMAIL']['CONTACT']['ADDRESS']
- . "'>"
- . $this->config['SITE']['EMAIL']['CONTACT']['ADDRESS']
- . "</a>.<br />"
- . "Your password is: "
- . $password
- . "<br />Please use this password on <a href='"
- . $this->config['SITE']['URL']
- . "'>"
- . $this->config['SITE']['TITLE']
- . "</a> site.</br >"
- . "Your Global Knight Online Team";
- if (!$this->SendEmail($email, $this->config['SITE']['TITLE'] . " - password reminder", $message, "")) {
- $this->content = Template::Load('error', array('errmsg' => 'Internal server error!'));
- return;
- }
- $this->content = Template::Load('forgotpassword-complete');
- }
- function GetTemplate() {
- return $this->content;
- }
- function IsCacheable() {
- return $this->cacheable;
- }
- function CacheTime() {
- return $this->cacheTime;
- }
- function __destruct() {
- }
- function SendEmail($email, $subject, $message, $body) {
- require './include/PHPMailer/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = $this->config['SITE']['EMAIL']['AUTOMAT']['SMTP']; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = $this->config['SITE']['EMAIL']['AUTOMAT']['USERNAME'];// SMTP username
- $mail->Password = $this->config['SITE']['EMAIL']['AUTOMAT']['PASSWORD'];// SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = $this->config['SITE']['EMAIL']['AUTOMAT']['PORT']; // TCP port to connect to
- $mail->setFrom($this->config['SITE']['EMAIL']['AUTOMAT']['ADDRESS'], $this->config['SITE']['TITLE']);
- $mail->addAddress($email, 'You'); // Add a recipient
- $mail->addReplyTo($this->config['SITE']['EMAIL']['AUTOMAT']['SMTP'], $this->config['SITE']['TITLE']);
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = $subject;
- $mail->Body = $message;
- $mail->AltBody = $body;
- if (!$mail->send()) {
- return false;
- // echo 'Message could not be sent.';
- // echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- return true;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement