Advertisement
Guest User

Untitled

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