Guest User

register.php

a guest
Apr 9th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.95 KB | None | 0 0
  1. <?php
  2. require('config.php');
  3. require('functions.php');
  4.  
  5. if(IsLogged()){
  6. header('location: /');
  7. }
  8. ?>
  9. <!DOCTYPE html>
  10. <html lang="en">
  11.  
  12. <head>
  13. <meta charset="utf-8">
  14. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  15. <!-- Tell the browser to be responsive to screen width -->
  16. <meta name="viewport" content="width=device-width, initial-scale=1">
  17. <meta name="description" content="">
  18. <meta name="author" content="">
  19. <!-- Favicon icon -->
  20. <link rel="icon" type="image/png" sizes="16x16" href="favicon.png">
  21. <title>Registro - Babilonia Roleplay</title>
  22. <!-- Bootstrap Core CSS -->
  23. <link href="css/lib/bootstrap/bootstrap.min.css" rel="stylesheet">
  24. <!-- Custom CSS -->
  25. <link href="css/helper.css" rel="stylesheet">
  26. <link href="css/style.css" rel="stylesheet">
  27. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  28. <!-- WARNING: Respond.js doesn't work if you view the page via file:** -->
  29. <!--[if lt IE 9]>
  30. <script src="https:**oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  31. <script src="https:**oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  32. <![endif]-->
  33. </head>
  34. <script src='https://www.google.com/recaptcha/api.js'></script>
  35. <body class="fix-header fix-sidebar">
  36. <!-- Preloader - style you can find in spinners.css -->
  37. <div class="preloader">
  38. <svg class="circular" viewBox="25 25 50 50">
  39. <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
  40. </div>
  41. <!-- Main wrapper -->
  42. <div id="main-wrapper">
  43. <div class="unix-login">
  44. <div class="container-fluid">
  45. <div class="row justify-content-center">
  46. <div class="col-lg-4">
  47. <div class="login-content card">
  48. <div class="login-form">
  49. <h4>Registra tu cuenta</h4>
  50. <?php
  51. if(isset($_POST['commit'])){
  52. $name = mysqli_real_escape_string($con, $_POST['name']);
  53. $surname = mysqli_real_escape_string($con, $_POST['surname']);
  54. $username = $name.'_'.$surname;
  55. $password = mysqli_real_escape_string($con, md5($_POST['password']));
  56. $password2 = mysqli_real_escape_string($con, md5($_POST['password2']));
  57. $email = mysqli_real_escape_string($con, $_POST['email']);
  58. $date = mysqli_real_escape_string($con, $_POST['birthdate']);
  59. $sex = mysqli_real_escape_string($con, $_POST['sex']);
  60. $age = age_calculator($date);
  61. $ip = $_SERVER['REMOTE_ADDR'];
  62. ///////////////////
  63. $log1n = "SELECT * FROM usuarios WHERE nombre='$username'";
  64. $eeee = $con->query($log1n);
  65. $row_cnt = mysqli_num_rows($eeee);
  66. ///////////////////
  67. $ipipipip = "SELECT * FROM usuarios WHERE ip='$ip'";
  68. $ipipip = $con->query($ipipipip);
  69. $ipip = mysqli_num_rows($ipipip);
  70. ///////////////////
  71.  
  72. if (!check_date($date)) {
  73. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "Fecha invalida.","error");}, 1); </script>';
  74. $error = 1;
  75. }
  76.  
  77. if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  78. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "Email invalido.","error");}, 1); </script>';
  79. $error = 1;
  80. }
  81.  
  82. if(strlen($_POST['password']) < 8){
  83. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "La contrase&ntilde;a debe tener 8 o m&aacute;s caracteres.","error");}, 1); </script>';
  84. $error = 1;
  85. }
  86.  
  87. if(strlen($username) > 30){
  88. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "El nombre de usuario debe tener maximo 30 caracteres.","error");}, 1); </script>';
  89. $error = 1;
  90. }
  91.  
  92. if(strlen($username) < 10){
  93. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "El nombre de usuario debe tener minimo 10 caracteres.","error");}, 1); </script>';
  94. $error = 1;
  95. }
  96.  
  97. if($ipip >= 1){
  98. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "Ya existe una cuenta vinculada con tu direcci&oacute;n IP.","error");}, 1); </script>';
  99. $error = 1;
  100. }
  101.  
  102. if($row_cnt >= 1){
  103. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "Ya existe una cuenta con ese nombre.","error");}, 1); </script>';
  104. $error = 1;
  105. }
  106.  
  107. if (!preg_match("/^[a-zA-Z]+$/", $name) OR !preg_match("/^[a-zA-Z]+$/", $surname))
  108. {
  109. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "El nombre y/o apellido solo pueden contener caracteres validos.","error");}, 1); </script>';
  110. $error = 1;
  111. }
  112.  
  113. if($password != $password2){
  114. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "Las contraseñas no coinciden.","error");}, 1); </script>';
  115. $error = 1;
  116. }
  117.  
  118. if(empty($name) OR empty($surname) OR empty($password) OR empty($password2) OR empty($email)){
  119. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "Faltan datos","error");}, 1); </script>';
  120. $error = 1;
  121. }
  122.  
  123. $recaptcha = $_POST["g-recaptcha-response"];
  124.  
  125. $url = 'https://www.google.com/recaptcha/api/siteverify';
  126. $data = array(
  127. 'secret' => '6LfTHUQUAAAAABVRPx9FpEsAlyJQDUWVELncjq-7',
  128. 'response' => $recaptcha
  129. );
  130. $options = array(
  131. 'http' => array (
  132. 'method' => 'POST',
  133. 'content' => http_build_query($data)
  134. )
  135. );
  136. $context = stream_context_create($options);
  137. $verify = file_get_contents($url, false, $context);
  138. $captcha_success = json_decode($verify);
  139. if(!$captcha_success->success) {
  140. $html = '<script type="text/javascript">setTimeout(function () {swal("Oops...", "Demuestra que no eres un robot completando el captcha.","error");}, 1); </script>';
  141. $error = 1;
  142. }
  143.  
  144. if($error == 1){
  145. echo $html; // <a onclick="history.back()"><b>Volver atr&aacute;s</b></a><hr></center>';
  146. }else{
  147.  
  148. if ($con->query("INSERT INTO usuarios (nombre, apodo, clave, ip, email, edad, avatar, sexo) VALUES ('$username', '$username', '$password', '$ip', '$email', '$age', '../images/default-avatar.png', '$sex')") === TRUE) {
  149.  
  150. $ch3ck = "SELECT * FROM usuarios WHERE nombre='$username'";
  151. $checkk = $con->query($ch3ck);
  152. $check = $checkk->fetch_row();
  153. $newID = $check[0];
  154. setcookie('id', $newID, time() + (86400 * 30), "/");
  155. header("Location: /");
  156.  
  157.  
  158.  
  159. }
  160. }
  161. }
  162.  
  163. ?>
  164. <form method="post">
  165. <div class="form-group" style="display: inline;">
  166. <label>Nombre del personaje</label><br>
  167. <input type="text" name="name" class="form-control" value="" placeholder="Nombre" style="width: 150px; display: inline;"> <input type="text" name="surname" class="form-control" style="width: 153px; display: inline;" value="" placeholder="Apellido">
  168. </div>
  169. <div class="form-group" style="margin-top: 10px;">
  170. <label>Sexo</label> <select name="sex" class="form-control" style="width: 264px; display: inline;">
  171. <option value="1">Masculino</option>
  172. <option value="2">Femenino</option>
  173. </select>
  174. </div>
  175. <div class="form-group" style="margin-top: -10px;">
  176. <label>Dirección de correo electrónico</label>
  177. <input type="email" name="email" class="form-control" placeholder="correo@dominio.com">
  178. </div>
  179. <div class="form-group" style="margin-top: -10px;">
  180. <label>Contraseña</label><br>
  181. <input type="password" name="password" class="form-control" value="" placeholder="Clave" style="width: 150px; display: inline;"> <input type="password" name="password2" class="form-control" style="width: 153px; display: inline;" value="" placeholder="Confirmar clave">
  182. </div>
  183. <div class="form-group" style="margin-top: -10px;">
  184. <label>Fecha de nacimiento</label>
  185. <input type="date" class="form-control" name="birthdate" value="<?php echo date("Y-m-d");?>">
  186. </div>
  187.  
  188. <div class="g-recaptcha" data-sitekey="6LfTHUQUAAAAANpZiHraiGzvKlJKf7CYtK1U0bqB"></div>
  189. <input type="submit" class="btn btn-primary btn-flat m-b-30 m-t-30" value="Registrarse" name="commit">
  190. </form>
  191. <hr style="margin-top: -7px">
  192. <a href="/login">
  193. <button class="btn btn-success">
  194. ¿Ya tienes cuenta? Inicia sesión
  195. </button>
  196. </a>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203.  
  204. </div>
  205. <!-- End Wrapper -->
  206. <!-- All Jquery -->
  207. <script src="js/lib/jquery/jquery.min.js"></script>
  208. <!-- Bootstrap tether Core JavaScript -->
  209. <script src="js/lib/bootstrap/js/popper.min.js"></script>
  210. <script src="js/lib/bootstrap/js/bootstrap.min.js"></script>
  211. <!-- slimscrollbar scrollbar JavaScript -->
  212. <script src="js/jquery.slimscroll.js"></script>
  213. <!--Menu sidebar -->
  214. <script src="js/sidebarmenu.js"></script>
  215. <!--stickey kit -->
  216. <script src="js/lib/sticky-kit-master/dist/sticky-kit.min.js"></script>
  217. <!--Custom JavaScript -->
  218. <script src="js/custom.min.js"></script>
  219. <link href="/css/lib/sweetalert/sweetalert.css" rel="stylesheet">
  220. <script src="js/lib/sweetalert/sweetalert.min.js"></script>
  221. <!-- scripit init -->
  222. <script src="js/lib/sweetalert/sweetalert.init.js"></script>
  223.  
  224. <style>
  225. body{
  226. background-image: url("images/background/bg_pcu.jpg");
  227. background-repeat: no-repeat;
  228. background-size: 100% 100%;
  229. }
  230. </style>
  231.  
  232. </body>
  233.  
  234. </html>
Add Comment
Please, Sign In to add comment