Guest User

Untitled

a guest
May 4th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. <?
  2.  
  3. include("include/session.php");
  4.  
  5. class Process
  6. {
  7.  
  8. function Process(){
  9. global $session;
  10.  
  11. if(isset($_POST['sublogin'])){
  12. $this->procLogin();
  13. }
  14.  
  15. else if(isset($_POST['subjoin'])){
  16. $this->procRegister();
  17. }
  18.  
  19. else if(isset($_POST['subforgot'])){
  20. $this->procForgotPass();
  21. }
  22.  
  23. else if(isset($_POST['subedit'])){
  24. $this->procEditAccount();
  25. }
  26.  
  27. else if($session->logged_in){
  28. $this->procLogout();
  29. }
  30.  
  31. else{
  32. header("Location: main.php");
  33. }
  34. }
  35.  
  36. function procLogin(){
  37. global $session, $form;
  38.  
  39. $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember']));
  40.  
  41.  
  42. if($retval){
  43. header("Location: main.php");
  44. }
  45.  
  46. else{
  47. $_SESSION['value_array'] = $_POST;
  48. $_SESSION['error_array'] = $form->getErrorArray();
  49. header("Location: ".$session->referrer);
  50. }
  51. }
  52.  
  53. function procLogout(){
  54. global $session;
  55. $retval = $session->logout();
  56. header("Location: main.php");
  57. }
  58.  
  59. function procRegister(){
  60. global $session, $form;
  61.  
  62. if(ALL_LOWERCASE){
  63. $_POST['user'] = strtolower($_POST['user']);
  64. }
  65.  
  66. $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email']);
  67.  
  68.  
  69. if($retval == 0){
  70. $_SESSION['reguname'] = $_POST['user'];
  71. $_SESSION['regsuccess'] = true;
  72. header("Location: ".$session->referrer);
  73. }
  74. else if($retval == 1){
  75. $_SESSION['value_array'] = $_POST;
  76. $_SESSION['error_array'] = $form->getErrorArray();
  77. header("Location: ".$session->referrer);
  78. }
  79.  
  80. else if($retval == 2){
  81. $_SESSION['reguname'] = $_POST['user'];
  82. $_SESSION['regsuccess'] = false;
  83. header("Location: ".$session->referrer);
  84. }
  85. }
  86.  
  87.  
  88. function procForgotPass(){
  89. global $database, $session, $mailer, $form;
  90.  
  91. $subuser = $_POST['user'];
  92. $field = "user";
  93. if(!$subuser || strlen($subuser = trim($subuser)) == 0){
  94. $form->setError($field, "* Username not entered<br>");
  95. }
  96. else{
  97.  
  98. $subuser = stripslashes($subuser);
  99. if(strlen($subuser) < 5 || strlen($subuser) > 30 ||
  100. !eregi("^([0-9a-z])+$", $subuser) ||
  101. (!$database->usernameTaken($subuser))){
  102. $form->setError($field, "* Username does not exist<br>");
  103. }
  104. }
  105.  
  106.  
  107. if($form->num_errors > 0){
  108. $_SESSION['value_array'] = $_POST;
  109. $_SESSION['error_array'] = $form->getErrorArray();
  110. }
  111. else{
  112.  
  113. $newpass = $session->generateRandStr(8);
  114.  
  115.  
  116. $usrinf = $database->getUserInfo($subuser);
  117. $email = $usrinf['email'];
  118.  
  119.  
  120. if($mailer->sendNewPass($subuser,$email,$newpass)){
  121.  
  122. $database->updateUserField($subuser, "password", md5($newpass));
  123. $_SESSION['forgotpass'] = true;
  124. }
  125.  
  126. else{
  127. $_SESSION['forgotpass'] = false;
  128. }
  129. }
  130.  
  131. header("Location: ".$session->referrer);
  132. }
  133.  
  134. function procEditAccount(){
  135. global $session, $form;
  136.  
  137. $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email']);
  138.  
  139.  
  140. if($retval){
  141. $_SESSION['useredit'] = true;
  142. header("Location: ".$session->referrer);
  143. }
  144.  
  145. else{
  146. $_SESSION['value_array'] = $_POST;
  147. $_SESSION['error_array'] = $form->getErrorArray();
  148. header("Location: ".$session->referrer);
  149. }
  150. }
  151. };
  152.  
  153. $process = new Process;
  154.  
  155. ?>
Advertisement
Add Comment
Please, Sign In to add comment