Advertisement
Guest User

register

a guest
May 20th, 2016
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.43 KB | None | 0 0
  1. <?php include '../includes/config.php';?>
  2. <?php
  3. if (!isset($_SESSION['ucp_loggedin']) or !$_SESSION['ucp_loggedin'])
  4. {
  5.  
  6. if (!isset($_POST['register']))
  7. {
  8.  
  9.  
  10. ?>
  11. <!-- MAIN CONTENT -->
  12. <div class="one separator"></div>
  13. <!-- WELCOME BLOCK -->
  14. <div class="one notopmargin">
  15. <h1 class="welcome nobottommargin left"><?php echo $global['UCP']['Register']['Title']; ?></h1>
  16. <p class="left description "><?php echo $global['UCP']['Register']['Status']; ?></p>
  17. </div>
  18. <!-- END WELCOME BLOCK -->
  19. <div class="one separator margin15"></div>
  20. <div class="one last">
  21. <script type="text/javascript" src="/js/prototype/prototype.js"></script>
  22. <script type="text/javascript" src="/js/bramus/jsProgressBarHandler.js"></script>
  23. <script type="text/javascript">
  24. <!--
  25. function validate_form(thisform)
  26. {
  27. with (thisform)
  28. {
  29. if (thisform.username.value==null || thisform.username.value=="" || thisform.username.value.length<3 || thisform.username.value.length>30 )
  30. {
  31. alert("Please ensure you have entered a valid username.\n\n Usernames must be between 3 and 30 characters long.");
  32. return false;
  33. }
  34. else if (thisform.password.value==null || thisform.password.value=="" || thisform.password.value.length<3 || thisform.password.value.length>30 )
  35. {
  36. alert("Please ensure you have entered a valid password.\n\n Passwords must be between 3 and 30 characters long.");
  37. return false;
  38. }
  39. else if (thisform.emailaddress.value==null || thisform.emailaddress.value=="" || thisform.emailaddress.value.length<3 || thisform.emailaddress.value.length>100 )
  40. {
  41. alert("Please ensure you have entered a valid e-mail address.\n\n Passwords must be between 3 and 100 characters long.");
  42. return false;
  43. }
  44. else if (thisform.password.value != thisform.password2.value)
  45. {
  46. alert("You didn't use the same password twice. Please correct this and try it again.");
  47. thisform.password.value = ''
  48. thisform.password2.value = ''
  49. return false;
  50. }
  51. else
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57.  
  58. Event.observe(window, 'load', function() {
  59. securityPB = new JS_BRAMUS.jsProgressBar($('securitybar'), 0, {animate: false, width:120, height: 12});
  60. }, false);
  61.  
  62.  
  63. function hasNumbers(t)
  64. {
  65. var regex = /\d/g;
  66. return regex.test(t);
  67. }
  68.  
  69. function hasSpecialCharacters(t)
  70. {
  71. var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_";
  72. for (var i = 0; i < t.length; i++)
  73. {
  74. if (iChars.indexOf(t.charAt(i)) != -1)
  75. return true;
  76. }
  77. return false;
  78. }
  79.  
  80. function isValidEmail(t)
  81. {
  82. for (var i = 0; i < t.length; i++)
  83. {
  84. if ( t.charAt(i) == "@")
  85. return true;
  86. }
  87. return false;
  88. }
  89.  
  90. function checkSecurity(field)
  91. {
  92. var value = field.value
  93. var len = value.length
  94.  
  95. if (hasNumbers(value))
  96. len = len * 2
  97.  
  98. if (hasSpecialCharacters(value))
  99. len = len * 2
  100.  
  101. len = Math.round((len / 30) * 100, 0)
  102.  
  103. securityPB.setPercentage(len, false)
  104. }
  105. //-->
  106. </script>
  107. <form action="" method="post" onSubmit="return validate_form(this)">
  108. <h2>Register</h2>
  109. <input type="text" name="username" maxlength="30" class="text-input"/><label for="username">Username (eg. Player2321)</label>
  110. <br />
  111. <input type="emailaddress" name="emailaddress" maxlength="30" class="text-input"/><label for="emailaddress">Email Address</label>
  112. <br />
  113. <input type="password" name="password" maxlength="32" class="text-input" onKeyUp="checkSecurity(this)"/><label for="password">Password</label>
  114. <br />
  115. <input type="password" name="password2" maxlength="32" class="text-input"/><label for="password2">Repeat Password</label>
  116. <br />
  117. Password Strength <div class="securitybar" id="securitybar"></div>
  118.  
  119. <br />
  120. <input type="submit" class="button black" name="register" value="Register"/><a class="button black" href="/ucp/login/">Login</a><br /><a href="/ucp/forgot-password/">&nbsp;Forgot Password</a>
  121. </form>
  122. <?php
  123. if (isset($_SESSION["reg:errno"]))
  124. $errno = $_SESSION["reg:errno"];
  125. else
  126. $errno = 0;
  127.  
  128. if ($errno==1)
  129. echo '<h6 class="sh6">This account already exists!</h6>';
  130. elseif ($errno==2)
  131. echo '<h6 class="sh6">Unknown Error</h6>';
  132. elseif ($errno==3)
  133. echo '<h6 class="sh6">This email address is already in use!</h6>';
  134. elseif ($errno==4)
  135. echo '<h6 class="sh6">Please complete all fields.</h6>';
  136. elseif ($errno==5)
  137. echo '<h6 class="sh6">Passwords do not match!</h6>';
  138. elseif ($errno==6)
  139. echo '<h6 class="sh6">That email address is invalid!</h6>';
  140. elseif ($errno==7)
  141. echo '<h6 class="sh6">Uh-Oh! Database is offline!</h6>';
  142.  
  143. unset($_SESSION["reg:errno"]);
  144. ?>
  145. </div>
  146. <?php
  147. } else {
  148. if (isset($_POST['username']) and isset($_POST['password']) and isset($_POST['password2']) and isset($_POST['emailaddress']))
  149. {
  150. if ($_POST['password'] != $_POST['password2'])
  151. {
  152. $_SESSION["reg:errno"] = 5;
  153. header("Location: /ucp/register/");
  154. }
  155. else { // passwords match
  156. if (check_email_address($_POST['emailaddress'])) // Is the mail address vailid?
  157. {
  158. $MySQLConn = @mysql_connect($Config['database']['hostname'], $Config['database']['username'], $Config['database']['password']);
  159. if (!$MySQLConn) {
  160. $_SESSION["reg:errno"] = 7;
  161. header("Location: /ucp/register/");
  162. }
  163. else {
  164. $selectdb = @mysql_select_db($Config['database']['database'], $MySQLConn);
  165. // Got a server connection
  166.  
  167. // escape some stuff
  168. $username = mysql_real_escape_string($_POST['username'], $MySQLConn);
  169. $password = md5($Config['server']['hashkey'] . $_POST['password']);
  170. $emailaddress = mysql_real_escape_string($_POST['emailaddress'], $MySQLConn);
  171. $ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR'], $MySQLConn);
  172.  
  173. $mQuery1 = mysql_query("SELECT `id` FROM `accounts` WHERE `username`='" . $username . "' LIMIT 1", $MySQLConn);
  174. if (mysql_num_rows($mQuery1) == 0)
  175. { // username is free
  176. $mQuery2 = mysql_query("SELECT `id` FROM `accounts` WHERE `username`='" . $username . "' LIMIT 1", $MySQLConn);
  177. if (mysql_num_rows($mQuery2) == 0)
  178. { // e-mail address is not used yet
  179. // make the account
  180. $mQuery3 = mysql_query("INSERT INTO `accounts` SET `username`='" . $username . "', `password`='" . $password . "', email='" . $emailaddress. "', registerdate=NOW(), ip='" . $ip . "', country='SC', friendsmessage='Hello', appstate='3'", $MySQLConn);
  181.  
  182. $smtp = new SMTP($Config['SMTP']['hostname'], 25, false, 5);
  183. $smtp->auth($Config['SMTP']['username'], $Config['SMTP']['password']);
  184. $smtp->mail_from($Config['SMTP']['from']);
  185.  
  186. $smtp->send($emailaddress, 'Welcome to Evolution Gaming!', 'Hi
  187.  
  188. Thank you for joining Evolution Gaming, and our MTA Roleplay server.
  189.  
  190. Your login details are displayed below.
  191.  
  192. Username: '.$username.'
  193. Password: '.$_POST['password'].'
  194. Control Panel: http://evolutiongaming.org
  195. Forums: http://evolutiongaming.org/forums/
  196.  
  197.  
  198.  
  199. Kind Regards,
  200. Chuevo');
  201.  
  202. $_SESSION['errno'] = 7;
  203. header("Location: /ucp/login/");
  204. }
  205. else
  206. {
  207. $_SESSION["reg:errno"] = 3;
  208. header("Location: /ucp/register/");
  209. }
  210. }
  211. else
  212. {
  213. $_SESSION["reg:errno"] = 1;
  214. header("Location: /ucp/register/");
  215. }
  216.  
  217. }
  218. }
  219. else {
  220. $_SESSION["reg:errno"] = 6;
  221. header("Location: /ucp/register/");
  222. }
  223. }
  224. }
  225. else {
  226. $_SESSION["reg:errno"] = 4;
  227. header("Location: /ucp/register/");
  228. }
  229. }
  230. }
  231. else {
  232. header("Location: /ucp/main/");
  233. }
  234. ?>
  235.  
  236. <!-- END MAIN CONTENT -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement