Advertisement
Guest User

test

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