Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 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.  
  12. function __construct($site)
  13. {
  14. $this->site = $site;
  15. $this->config = $site->config;
  16. $this->database = $site->database;
  17.  
  18. Template::SetVar('title', $this->config['SITE']['TITLE'] . Template::GetLangVar('PAGE_REGISTER_TITLE'));
  19.  
  20. if (isset($_GET['act']))
  21. $this->cacheable = FALSE;
  22. }
  23.  
  24. function Run()
  25. {
  26. Template::SetVar('reg_error', NULL);
  27. if ($this->site->loggedIn)
  28. {
  29. $this->content = Template::Load('error', array('errmsg' => Template::GetLangVar('REG_ALREADY_REGGED')));
  30. return;
  31. }
  32.  
  33. switch (@$_GET['act'])
  34. {
  35. case 'process':
  36. $this->Process();
  37. break;
  38.  
  39. case 'verify':
  40. break;
  41.  
  42. default:
  43. $this->content = Template::Load('register');
  44. }
  45.  
  46. }
  47.  
  48. function Process()
  49. {
  50. $s = $this->site;
  51. $db = $this->database[ADB];
  52.  
  53. if (!@isset($_POST['submit']))
  54. {
  55. Template::SetVar('reg_error', NULL);
  56. $this->content = Template::Load('register');
  57. return;
  58. }
  59.  
  60. $user = $s->SanitizeName(@$_POST['user']);
  61. $pass1 = $s->SanitizeName(@$_POST['passwd1'], 12);
  62. $pass2 = $s->SanitizeName(@$_POST['passwd2'], 12);
  63. $wpass1 = $s->SanitizeName(@$_POST['wpasswd1'], 16);
  64. $wpass2 = $s->SanitizeName(@$_POST['wpasswd2'], 16);
  65.  
  66. if (strlen(@$_POST['user']) > 20 || strlen($user) < 3)
  67. {
  68. $this->Error('REG_ACC_SIZE');
  69. return;
  70. }
  71.  
  72. if (!preg_match("/^[a-zA-Z0-9]+$/", $_POST['user']))
  73. {
  74. $this->Error('REG_ACC_INVALID');
  75. return;
  76. }
  77.  
  78. if (strlen($pass1) > 12 || strlen($pass1) < 5)
  79. {
  80. $this->Error('REG_PASS_SIZE');
  81. return;
  82. }
  83.  
  84. if ($pass1 != $pass2)
  85. {
  86. $this->Error('REQ_PASS_MATCH');
  87. return;
  88. }
  89.  
  90. if (strlen($wpass1) > 16 || strlen($wpass1) < 6)
  91. {
  92. $this->Error('REG_WPASS_SIZE');
  93. return;
  94. }
  95.  
  96. if ($wpass1 != $wpass2)
  97. {
  98. $this->Error('REQ_WPASS_MATCH');
  99. return;
  100. }
  101.  
  102. $num_rows = $db->doQuery('SELECT strAccountID FROM TB_USER WHERE strAccountID = ?', $user);
  103. if ($num_rows == -1)
  104. {
  105. $this->Error('DB_ERROR');
  106. $db->getError();
  107. return;
  108. }
  109. elseif ($num_rows > 0)
  110. {
  111. $this->Error('REG_ACCOUNT_IN_USE');
  112. return;
  113. }
  114.  
  115. $num_rows = $db->doQuery('INSERT INTO TB_USER (strAccountID, strPasswd) VALUES(?, ?)', $user,$s->SanitizeName(@$_POST['passwd1'], 12), md5($pass1), $wpass1);
  116. if ($num_rows == -1)
  117. {
  118. $this->Error('DB_ERROR');
  119. $db->getError();
  120. return;
  121. }
  122.  
  123. $num_rows = $db->doQuery('INSERT INTO WAREHOUSE (strAccountID, nMoney, dwTime, WarehouseData, strSerial, strWarehousePW) VALUES(?, 0, 0, NULL, NULL, ?)', $user, $wpass1);
  124. if ($num_rows == -1)
  125. {
  126. $this->Error('DB_ERROR');
  127. $db->getError();
  128. return;
  129. }
  130.  
  131. $this->content = Template::Load('register-complete');
  132. }
  133.  
  134. function Error($error)
  135. {
  136. Template::SetVar('reg_error', '<@register-error@>');
  137. Template::SetVar('reg_errmsg', Template::GetLangVar($error));
  138. $this->content = Template::Load('register');
  139. }
  140.  
  141. function GetTemplate()
  142. {
  143. return $this->content;
  144. }
  145.  
  146. function IsCacheable()
  147. {
  148. return $this->cacheable;
  149. }
  150.  
  151. function CacheTime()
  152. {
  153. return $this->cacheTime;
  154. }
  155.  
  156. function __destruct()
  157. {
  158. }
  159. }
  160.  
  161. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement