Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ACS (Account Creation Server) v1.0 by Berzerker
- Rules:
- -Usernames may not have special characters
- -Passwords have no limitations
- -The app itself checks if a username is already taken
- Packet Format:
- <packet>
- <username>Username</username>
- <password>Password</password>
- </packet>
- */
- //Start connect to MySQL database
- $servername = "SERVER NAME"; //Change this
- $usernameSQL = "USERNAME"; //Change this
- $passwordSQL = "PASSWORD"; //Change this
- $conn = new mysqli($servername, $usernameSQL, $passwordSQL);
- //End connect to MySQL database
- $packetRecieved=$_POST["messagePacket"]; //Recieves the message from the app
- $xmlUnparsed=new SimpleXMLElement($packetRecieved);
- //Start XML parsing
- $xmlUsername=$xmlUnparsed->username;
- $xmlPassword=$xmlUnparsed->password;
- //End XML parsing
- //Start sanatizing input
- $sanatizedUsername=filter_var($xmlUsername, FILTER_SANITIZE_STRING);
- $sanatizedPassword=filter_var($xmlPassword, FILTER_SANITIZE_STRING);
- //End sanatizing input
- //Start add account to database
- $username=$sanatizedUsername;
- $password=$sanatizedPassword;
- $getNewestId="SELECT LAST(id) FROM accounts;";
- $id=$getNewestId+1;
- $sqlUpdate="INSERT INTO accounts (id,username,password) VALUES ('$id','$username','$password');";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement