Guest User

Untitled

a guest
Oct 20th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. <?php
  2.  
  3. class Register
  4. {
  5.  
  6. private $dob = null,
  7. $gender = 'male',
  8. $username = 'Guest',
  9. $password = null,
  10. $email = null,
  11. $secCode = null,
  12. $minAge = 11,
  13. $maxAge = 100;
  14.  
  15. private $step = 1,
  16. $errorMessage = null,
  17. $currentPage = null,
  18. $bgClass = null;
  19.  
  20. public function __construct()
  21. {
  22.  
  23. $this->currentPage = $_GET['page'];
  24.  
  25. $this->_setData();
  26.  
  27. $this->_findValidPage();
  28.  
  29. }
  30.  
  31. private function _setData()
  32. {
  33.  
  34. if( $_SESSION )
  35. {
  36.  
  37. foreach( $_SESSION as $key => $value )
  38. {
  39.  
  40. $key = str_replace('bean_', '', $key);
  41.  
  42. $this->$key = $value;
  43.  
  44. }
  45.  
  46. }
  47.  
  48. }
  49.  
  50. private function _findValidPage( )
  51. {
  52.  
  53. switch( $this->grabSession('step') )
  54. {
  55.  
  56. default:
  57.  
  58. $this->setSession('step', 1);
  59.  
  60. $this->redirect();
  61.  
  62. break;
  63.  
  64. case 1:
  65.  
  66. if( $this->currentPage != 'start' )
  67. {
  68.  
  69. if( !$this->grabData('dob') || $this->grabData('bean_gender') )
  70. {
  71.  
  72. $this->redirect();
  73.  
  74. }
  75. }
  76.  
  77. $this->grabData('bgClass', 'background-agegate');
  78. $this->grabData('template', 'start');
  79.  
  80. break;
  81.  
  82. case 2:
  83.  
  84. if( $this->currentPage != 'email_password' )
  85. {
  86.  
  87. if( !$this->grabData('email') || !$this->grabData('password') )
  88. {
  89.  
  90. $this->redirect('email_password');
  91.  
  92. }
  93.  
  94. }
  95.  
  96. $this->grabData('bgClass', 'background-accountdetails-'.$this->grabData('gender') );
  97.  
  98. break;
  99.  
  100. }
  101.  
  102. }
  103.  
  104. private function redirect( $pageName = 'start' )
  105. {
  106.  
  107. header('Location: /quickregister/' . $pageName );
  108.  
  109. }
  110.  
  111. public function grabSession( $key )
  112. {
  113.  
  114. return ($_SESSION[$key] ? $_SESSION[$key] : false);
  115.  
  116. }
  117.  
  118. public function setSession( $key, $value = '' )
  119. {
  120.  
  121. $_SESSION[$key] = $value;
  122.  
  123. }
  124.  
  125. public function grabData( $key, $value = '' )
  126. {
  127.  
  128. if( $value )
  129. {
  130.  
  131. $this->$key = $value;
  132.  
  133. return $value;
  134.  
  135. }
  136. else
  137. {
  138.  
  139. return $this->$key ? $this->$key : false;
  140.  
  141. }
  142.  
  143. }
  144.  
  145.  
  146. }
Add Comment
Please, Sign In to add comment