Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once '../Modules/Routes.php';
- require_once '../Modules/Definitions.php';
- require_once '../Modules/Tools.php';
- Routes::POST(function(){
- $name = isset($_POST['name']) ? trim($_POST['name']) : null;
- $surname = isset($_POST['surname']) ? trim($_POST['surname']) : null;
- $phone = isset($_POST['phone']) ? trim($_POST['phone']) : null;
- $email = isset($_POST['email']) ? trim($_POST['email']) : null;
- $password = isset($_POST['password']) ? trim($_POST['password']) : null;
- if($name == null)
- Tools::Response("Error", "400", "0x000", "Bad Request", "Name is null or was not setted");
- if($surname == null)
- Tools::Response("Error", "400", "0x000", "Bad Request", "Surname is null or was not setted");
- if($phone == null)
- Tools::Response("Error", "400", "0x000", "Bad Request", "Phone is null or was not setted");
- if($email == null)
- Tools::Response("Error", "400", "0x000", "Bad Request", "Email is null or was not setted");
- if($password == null)
- Tools::Response("Error", "400", "0x000", "Bad Request", "Password is null or was not setted");
- if(!preg_match(REGEX_NAME, $name))
- Tools::Response("Error", "400", "0x000", "Bad Request", "Name is wrong");
- if(!preg_match(REGEX_SURNAME, $surname))
- Tools::Response("Error", "400", "0x000", "Bad Request", "Surname is wrong");
- if(!preg_match(REGEX_PHONE, $phone))
- Tools::Response("Error", "400", "0x000", "Bad Request", "Phone is wrong");
- if(!filter_var($email, FILTER_VALIDATE_EMAIL))
- Tools::Response("Error", "400", "0x000", "Bad Request", "Email is wrong");
- if(!preg_match(REGEX_PASSWORD, $password))
- Tools::Response("Error", "400", "0x000", "Bad Request", "Password is wrong");
- @$connection = mysqli_connect(DATABASE_ADDRESS, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME)
- or die(Tools::Response("Error", "500", "0x000", "Internal Server Error", "Error connecting to database", "RETURN"));
- @$selection = mysqli_select_db()
- or die(Tools::Response("Error", "500", "0x000", "Internal Server Error", "Error selecting to database", "RETURN"));
- @$query_0 = mysqli_query($connection, "SELECT `phone`, `email` FROM `users` WHERE `phone` = '$phone' OR `email` = '$email'")
- or die(Tools::Response("Error", "500", "0x000", "Internal Server Error", "Error querying in database", "RETURN"));
- @$query_0_fetched = mysqli_fetch_array($query_0)
- or die(Tools::Response("Error", "500", "0x000", "Internal Server Error", "Error fetching response", "RETURN"));
- if($query_0 -> num_rows > 0){
- if($query_0_fetched['email'] == $email)
- Tools::Response("Error", "xxx", "0x000", "xxx xxx xxx", "This email is not available");
- if($query_0_fetched['phone'] == $phone)
- Tools::Response("Error", "xxx", "0x000", "xxx xxx xxx", "This phone is not available");
- }
- //CONTINUA
- //CONTINUA
- //CONTINUA
- });
- Routes::GET(function(){
- echo 'GET';
- });
- Routes::PUT(function(){
- echo 'PUT';
- });
- Routes::PATCH(function(){
- echo 'PATCH';
- });
- Routes::DELETE(function(){
- echo 'DELETE';
- });
- Routes::ANY(function(){
- echo 'ANY';
- });
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement