Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. <?
  2. class pages{
  3.  
  4.  
  5. function index(){
  6.  
  7. include_once('template/header.php');
  8. include_once('template/menu.html');
  9. include_once('template/serverstats.php');
  10. include_once('template/slider.html');
  11. include_once('template/news.php');
  12. include_once('template/footer.php');
  13.  
  14.  
  15. }
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. function register( $errors = false, $success = false )
  23. {
  24.  
  25. global $main;
  26. echo('
  27. <div id="box4" class="box">
  28. <h1 id="heading4" class="heading">Registration</h1>
  29. <div class="content">
  30. <h1 class="title">Register</h1>
  31. <h2 class="meta">Register for our ingame server and forums!</h2>
  32. <p>
  33. <center>');
  34. if( $success != false) {
  35.  
  36. echo('<img src="images/check_mark.png" /><span style="color:green;">'.$success.'</span>');
  37. }
  38. elseif( $errors != false )
  39. {
  40.  
  41. $main->func->show_errors( $errors );
  42.  
  43.  
  44. }
  45. echo('
  46. <form action="?page=Register&act=do_register" method="post">
  47. <table border="0">
  48. <tr><td align="right">
  49. Username: </td><td><input type="text" name="username" />
  50. </td></tr>
  51. <tr><td align="right">
  52. Password: </td><td><input type="password" name="password" /><br />
  53. </td></tr>
  54. <tr><td align="right">
  55. Confirm Password: </td><td><input type="password" name="password_confirm" /><br />
  56. </td></tr>
  57. <tr><td align="right">
  58. Email: </td><td><input type="text" name="email" /><br />
  59. </td></tr>
  60. <tr><td align="right">
  61. Expansion: </td><td><select name="exp">
  62. <option value="0">No Expansion</option>
  63. <option value="1">Burning Crusade</option>
  64. <option value="1">Wrath of the Lich King</option>
  65. </select>
  66.  
  67. <br />
  68. </td></tr>
  69. <tr><td colspan="2" align="center">
  70. <input type="submit" value="Register" class="button" />
  71. </td></tr></table>
  72. </p>
  73.  
  74. </div>
  75. </div>
  76. ');
  77. }
  78.  
  79. function do_register()
  80. {
  81. $errors = 0;
  82.  
  83. global $main;
  84.  
  85. $data = $main->func->cleanse( $_POST );
  86.  
  87. $main->db->con( 'logon' );
  88.  
  89. $email = 'select id from account where email = "'.$data['email'].'"';
  90. $username = 'select id from account where username = "'.$data['username'].'"';
  91.  
  92. $email = $main->db->query( $email );
  93. $username = $main->db->query( $username );
  94.  
  95. $email = $main->db->num_rows( $email );
  96. $username = $main->db->num_rows( $username );
  97.  
  98. foreach( $data as $k => $v ) { if( $v == "" ) { $errors++; $error_array[0]='Fill in all required fields.'; } }//empty check
  99. if( $data['password'] != $data['password_confirm'] ) { $errors++; $error_array[1]='Passwords do not match.'; }//check password
  100. if( $email >= 2 ) { $errors++; $error_array[2]='Only 2 accounts per email are allowed.'; }//no more than 2 accounts per email
  101. if( $username != 0 ) { $errors++; $error_array[3]='Username exists.'; }//unique username check
  102. if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $data['email'])) { $errors++; $error_array[4]='Enter a correct email.'; }//email format check
  103. if(( $exp != 1 ) && ( $exp != 0 )) { $errors++; $error_array[5] = 'Expansion error, please try again'; }//check for correct exp
  104.  
  105. $e_pass = strtoupper(sha1(strtoupper($data['username']).":".strtoupper($data['password'])));
  106.  
  107. if( $errors = 0 || $errors == "")
  108. {
  109. $main->db->con( 'logon' );
  110.  
  111. $sql = 'insert into account (username, sha_pass_hash, email, expansion)
  112. VALUES("'.$data['username'].'", "'.$e_pass.'", "'.$data['email'].'", "'.$data['exp'].'")';
  113. $main->db->query( $sql );
  114.  
  115. $success = 'Account created successfully!';
  116.  
  117. $this->index( false, $success );
  118. }
  119. else{
  120. $this->index( $error_array, false );
  121. }
  122.  
  123. }
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. }
  134. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement