Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.00 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('KODEVS') || KODEVS != 1)
  4. die();
  5.  
  6. class Page {
  7.  
  8. private $site, $database, $content;
  9. private $cacheable = FALSE;
  10. private $cacheTime = 0;
  11. private $db = null;
  12.  
  13. function __construct($site) {
  14. $this->site = $site;
  15. $this->config = $site->config;
  16. $this->database = $site->database;
  17. $this->db = $this->database[ADB];
  18.  
  19. Template::SetVar('title', $this->config['SITE']['TITLE'] . Template::GetLangVar('PAGE_REGISTER_TITLE'));
  20.  
  21. if (isset($_GET['act']))
  22. $this->cacheable = FALSE;
  23. }
  24.  
  25. function Run() {
  26. if (isset($_SESSION['bLoggedIn']) && $_SESSION['bLoggedIn'] == FALSE) {
  27. $this->content = Template::Load('error', array('errmsg' => 'You are logged in so you do know your credentials!'));
  28. return;
  29. }
  30.  
  31. switch (@$_GET['act']) {
  32. case 'login' : $this->SendLogin();
  33. break;
  34. case 'password' : $this->SendPassword();
  35. break;
  36. default : $this->content = Template::Load('forgotpassword', array('forum' => $this->config['SITE']['FORUM']));
  37. }
  38. }
  39.  
  40. function Error($error) {
  41. Template::SetVar('reg_error', '<@forgotpassword-error@>');
  42. Template::SetVar('reg_errmsg', Template::GetLangVar($error));
  43. $this->content = Template::Load('forgotpassword');
  44. }
  45.  
  46. function SendLogin() {
  47. if (!isset($_POST['securepin']) || !isset($_POST['email'])) {
  48. $this->content = Template::Load('error', array('errmsg' => 'Incorrect data!'));
  49. return;
  50. }
  51.  
  52. $email = @$_POST['email'];
  53. if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
  54. $this->content = Template::Load('error', array('errmsg' => 'Incorrect email!'));
  55. return;
  56. }
  57.  
  58. $login = "";
  59. $code = intval(@$_POST['securepin']);
  60. $num_rows = $this->db->doQuery('SELECT strAccountID, strSocNo FROM TB_USER WHERE strEmail = ?', $email);
  61. if (1 != $num_rows) {
  62. $this->content = Template::Load('error', array('errmsg' => 'Incorrect email address!'));
  63. return;
  64. } else {
  65. $result = $this->db->doRead();
  66. $security_pin = $result['strSocNo'];
  67. if ($security_pin != $code) {
  68. $this->content = Template::Load('error', array('errmsg' => 'Incorrect Email address or Security Code!'));
  69. return;
  70. }
  71. $login = $result['strAccountID'];
  72. }
  73.  
  74. $message = "Dear user!<br />"
  75. . "This message is sent automatically because you or someone else used option to recover Login information from "
  76. . $this->config['SITE']['TITLE']
  77. . ".<br />Please do not replay to this message.<br />"
  78. . "In case you need to contact us please use: <a href='mailto:"
  79. . $this->config['SITE']['EMAIL']['CONTACT']['ADDRESS']
  80. . "'>"
  81. . $this->config['SITE']['EMAIL']['CONTACT']['ADDRESS']
  82. . "</a>.<br />"
  83. . "Your login is: "
  84. . $login
  85. . "<br />Please use this login on <a href='"
  86. . $this->config['SITE']['URL']
  87. . "'>"
  88. . $this->config['SITE']['TITLE']
  89. . "</a> site.</br >"
  90. . "Your Global Knight Online Team";
  91.  
  92. if (!$this->SendEmail($email, $this->config['SITE']['TITLE'] . " - login reminder", $message, "")) {
  93. $this->content = Template::Load('error', array('errmsg' => 'Internal server error!'));
  94. return;
  95. }
  96.  
  97. $this->content = Template::Load('forgotpassword-complete');
  98. }
  99.  
  100. function SendPassword() {
  101. if (!isset($_POST['securepin']) || !isset($_POST['email'])) {
  102. $this->content = Template::Load('error', array('errmsg' => 'Incorrect data!'));
  103. return;
  104. }
  105.  
  106. $email = @$_POST['email'];
  107. if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
  108. $this->content = Template::Load('error', array('errmsg' => 'Incorrect email!'));
  109. return;
  110. }
  111.  
  112. $password = "";
  113. $code = intval(@$_POST['securepin']);
  114. $num_rows = $this->db->doQuery('SELECT strPasswd, strSocNo FROM TB_USER WHERE strEmail = ?', $email);
  115. if (1 != $num_rows) {
  116. $this->content = Template::Load('error', array('errmsg' => 'Incorrect email address!'));
  117. return;
  118. } else {
  119. $result = $this->db->doRead();
  120. $security_pin = $result['strSocNo'];
  121. if ($security_pin != $code) {
  122. $this->content = Template::Load('error', array('errmsg' => 'Incorrect Email address or Security Code!'));
  123. return;
  124. }
  125. $password = $result['strPasswd'];
  126. }
  127.  
  128. $message = "Dear user!<br />"
  129. . "This message is sent automatically because you or someone else used option to recover Password information from "
  130. . $this->config['SITE']['TITLE']
  131. . ".<br />Please do not replay to this message.<br />"
  132. . "In case you need to contact us please use: <a href='mailto:"
  133. . $this->config['SITE']['EMAIL']['CONTACT']['ADDRESS']
  134. . "'>"
  135. . $this->config['SITE']['EMAIL']['CONTACT']['ADDRESS']
  136. . "</a>.<br />"
  137. . "Your password is: "
  138. . $password
  139. . "<br />Please use this password on <a href='"
  140. . $this->config['SITE']['URL']
  141. . "'>"
  142. . $this->config['SITE']['TITLE']
  143. . "</a> site.</br >"
  144. . "Your Global Knight Online Team";
  145.  
  146. if (!$this->SendEmail($email, $this->config['SITE']['TITLE'] . " - password reminder", $message, "")) {
  147. $this->content = Template::Load('error', array('errmsg' => 'Internal server error!'));
  148. return;
  149. }
  150.  
  151. $this->content = Template::Load('forgotpassword-complete');
  152. }
  153.  
  154. function GetTemplate() {
  155. return $this->content;
  156. }
  157.  
  158. function IsCacheable() {
  159. return $this->cacheable;
  160. }
  161.  
  162. function CacheTime() {
  163. return $this->cacheTime;
  164. }
  165.  
  166. function __destruct() {
  167.  
  168. }
  169.  
  170. function SendEmail($email, $subject, $message, $body) {
  171. require './include/PHPMailer/PHPMailerAutoload.php';
  172.  
  173. $mail = new PHPMailer;
  174.  
  175. $mail->isSMTP(); // Set mailer to use SMTP
  176. $mail->Host = $this->config['SITE']['EMAIL']['AUTOMAT']['SMTP']; // Specify main and backup SMTP servers
  177. $mail->SMTPAuth = true; // Enable SMTP authentication
  178. $mail->Username = $this->config['SITE']['EMAIL']['AUTOMAT']['USERNAME'];// SMTP username
  179. $mail->Password = $this->config['SITE']['EMAIL']['AUTOMAT']['PASSWORD'];// SMTP password
  180. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  181. $mail->Port = $this->config['SITE']['EMAIL']['AUTOMAT']['PORT']; // TCP port to connect to
  182.  
  183. $mail->setFrom($this->config['SITE']['EMAIL']['AUTOMAT']['ADDRESS'], $this->config['SITE']['TITLE']);
  184. $mail->addAddress($email, 'You'); // Add a recipient
  185. $mail->addReplyTo($this->config['SITE']['EMAIL']['AUTOMAT']['SMTP'], $this->config['SITE']['TITLE']);
  186.  
  187. $mail->isHTML(true); // Set email format to HTML
  188.  
  189. $mail->Subject = $subject;
  190. $mail->Body = $message;
  191. $mail->AltBody = $body;
  192.  
  193. if (!$mail->send()) {
  194. return false;
  195. // echo 'Message could not be sent.';
  196. // echo 'Mailer Error: ' . $mail->ErrorInfo;
  197. } else {
  198. return true;
  199. }
  200. }
  201.  
  202. }
  203.  
  204. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement