Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $app->post("/encrypt/register", function() use($app){
- $db_con = DBConnection();
- $allPostVars = $app->request->post();
- $error;
- $encrypt_2 = $allPostVars["encrypt_2"];
- $encrypt_3 = $allPostVars["encrypt_3"];
- $encrypt_4 = $allPostVars["encrypt_4"];
- $encrypt_4_1 = $allPostVars["encrypt_4_1"];
- $checkPassword = EncryptPss($encrypt_4, $encrypt_4_1);
- $encrypt_2 = md5($encrypt_2);
- $encrypt_3 = md5($encrypt_3);
- $encrypt_4 = md5($encrypt_4);
- if($checkPassword == 1){
- try{
- $sql = "INSERT INTO encrypt(encrypt_2, encrypt_3, encrypt_4) values ('$encrypt_2', '$encrypt_3','$encrypt_4')";
- $stmt = $db_con->exec($sql);
- }catch(PDOException $e){
- $error = $e->getMessage();
- }
- if(isset($error)){
- echo '{"status":false}';
- }else{
- echo '{"status":true}';
- }
- }else{
- echo '{"status":false}';
- }
- });
- $app->post("/encrypt/login", function() use($app){
- $dbCon = DBConnection();
- $req = $app->request->post();
- $email = $req['encrypt_2'];
- $password = $req['encrypt_4'];
- $email = md5($email);
- $password = md5($password);
- $sql = "SELECT * FROM encrypt WHERE encrypt_2 = '$email' AND encrypt_4 = '$password'";
- try{
- $stmt = $dbCon->prepare($sql);
- $stmt->bindParam("email", $email);
- $stmt->bindParam("password", $password);
- $stmt->execute();
- $count = $stmt->rowCount();
- if($count == 0){
- echo '{"status":false}';
- }else{
- echo '{"status":true}';
- }
- }catch(PDOException $e){
- echo '{"status":false}';
- }
- });
- $app->post("/encrypt/login2", function() use($app){
- $dbCon = DBConnection();
- $req = $app->request->post();
- $email = $req['encrypt_2'];
- $username = $req['encrypt_3'];
- $emailChecker = EncryptEml($email);
- $email = md5($email);
- $username = md5($username);
- if($emailChecker == 0){
- try{
- $sql = "INSERT INTO encrypt(encrypt_2, encrypt_3) values ('$email', '$username')";
- $stmt = $dbCon->exec($sql);
- }catch(PDOException $e){
- $error = $e->getMessage();
- }
- if(isset($error)){
- echo '{"status":false}';
- }else{
- echo '{"status":true}';
- }
- }else{
- echo '{"status":true}';
- }
- });
- function EncryptPss($password_1, $password_2){
- if($password_1 == $password_2){
- return TRUE;
- }else{
- return FALSE;
- }
- }
- function EncryptEml($email){
- $db = DBConnection();
- $error;
- $sql = "SELECT encrypt_2 FROM encrypt WHERE encrypt_2 = '$email'";
- $result = $db->query($sql);
- $count = $result->rowCount();
- return $count;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement