Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_SERVER['HTTP_CF_CONNECTING_IP']) == true)
- $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
- include_once '../class/assets/dbconfig.php';
- $username = $_REQUEST['username'];
- $password = $_REQUEST['password'];
- $email = $_REQUEST['email'];
- $confirm = $_REQUEST['confirm'];
- $ip = $_SERVER['REMOTE_ADDR'];
- if(strlen($username) < 3 or strlen($username) > 24)
- {
- echo $txtError = ("Username invalido (3 - 24 caratteri)."); return false;
- }
- if(preg_match('/[^A-Za-z0-9_]/', $username) == true)
- {
- echo $txtError = ("Caratteri invalidi."); return false;
- }
- if($password != $confirm)
- {
- echo $txtError = ("Password diverse."); return false;
- }
- if(strlen($confirm) < 8 or strlen($confirm) > 32)
- {
- echo $txtError = ("Password invalida (8 - 32 caratteri)."); return false;
- }
- if(filter_var($email, FILTER_VALIDATE_EMAIL) != true)
- {
- echo $txtError = ("Email non valida."); return false;
- }
- $db = getDB();
- $stmt = $db->prepare("SELECT email, username FROM accounts WHERE email=:email OR username=:username");
- $stmt->bindParam("email", $email, PDO::PARAM_STR);
- $stmt->bindParam("username", $username, PDO::PARAM_STR);
- $stmt->execute();
- $count = $stmt->rowCount();
- if($count)
- {
- $data = $stmt->fetch(PDO::FETCH_ASSOC);
- if($data['email'] == $email) echo $txtError = ("Email già utilizzata.<br>");
- if($data['username'] == $username) echo $txtError = ("Account già registrato.");
- return false;
- }
- $tmp_token = random_bytes(8);
- $token_register = bin2hex($tmp_token);
- $hash_password = hash('whirlpool', $confirm);
- $stmt = $db->prepare("INSERT INTO accounts (username, password, email, confirmed, created_at, register_token, ip) VALUES (:username, :hash_password, :email, '0', NOW(), :token_register, :ip)");
- $stmt->bindParam("username", $username, PDO::PARAM_STR);
- $stmt->bindParam("hash_password", $hash_password, PDO::PARAM_STR);
- $stmt->bindParam("email", $email, PDO::PARAM_STR);
- $stmt->bindParam("token_register", $token_register, PDO::PARAM_STR);
- $stmt->bindParam("ip", $ip, PDO::PARAM_STR);
- $stmt->execute();
- $mail_receiver = $email;
- $mail_object = "Registrazione";
- $mail_body = "
- <body>
- <font size='3'>Benvenuto/a su Los Santos Roleplay, <b>$username</b>.<br>
- <br>Il sistema richiede la conferma dell'indirizzo email prima di poter utilizzare l'account registrato, si prega quindi di premere sul tasto di seguito per confermarla:
- <a href='http://ucp.ls-rp.it/send/account_confirm.php?key=$token_register'>Pagina attivazione</a>.<br>
- <br>Link: http://ucp.ls-rp.it/send/account_confirm.php?key=$token_register<br>
- Una volta cliccato sul link, sarai reinderizzato alla pagina di login. Inserisci i tuoi dati e potrai utilizzare l'account.<br>
- <br>Distinti saluti, lo staff di <b>Los Santos Roleplay</b>.
- </body>
- ";
- include '../core/emailconfig.php';
- echo $txtError = ("Account creato.<br>Controlla la tua email per confermarlo.<br>Clicca <a href='index.php'>qui</a> per andare al login.");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement