%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/login1.php
<?php
include('header.php');
?>

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

<?php

if (isset($_SESSION['user_id'])) {
    header('Location: user-profile.php');
    exit;
}

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

$client = new Google_Client();

$client->setClientId('338195582534-cfksgf68a1bm1sqbl8p19v7o7c26q3hn.apps.googleusercontent.com');
$client->setClientSecret('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');
$client->setRedirectUri('http://localhost/karone/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 {

            $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).";
            }
        }
    } else {
        header('Location: login.php');
        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 social media account</p>

                                        <ul class="no-bullet ps-0">
                                            <li>
                                                <a href="javascript:void(0);" onclick="handleFacebookLogin();">
                                                    <img src="img/icon_fb.svg" class="img-fluid" alt="Facebook Login">
                                                </a>
                                            </li>


                                            <li><a href="<?php echo $client->createAuthUrl(); ?>"><img src="img/icon_google.svg" class="img-fluid"></a></li>
                                            <li><a href="#"><img src="img/icon_insta.svg" class="img-fluid"></a></li>
                                            <!-- <li><a href="#"><img src="img/icon_twitter.svg" class="img-fluid"></a></li> -->
                                            <li><a href="#"><img src="img/icons8-x.svg" class="img-fluid"></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>


<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId: '1298956725229696',
            cookie: true,
            xfbml: true,
            version: 'v12.0'
        });

        FB.AppEvents.logPageView();

    };

    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {
            return;
        }
        js = d.createElement(s);
        js.id = id;
        js.src = "https://connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

    function statusChangeCallback(response) {
        // Handle the response object from FB.getLoginStatus()
        if (response.status === 'connected') {
            // Logged into your app and Facebook.
            // You can send response.authResponse.accessToken to your server for login
            window.location = 'user-profile.php';
        } else {
            // Not logged in or not authorized
            // Optionally show an error or prompt login
        }
    }

    function checkLoginState() {
        FB.getLoginStatus(function(response) {
            statusChangeCallback(response);
        });
    }
</script>


<script>
    function handleFacebookLogin() {
        FB.login(function(response) {
            if (response.authResponse) {
                FB.api('/me', { fields: 'id,name,email,picture' }, function(userInfo) {
                    $.ajax({
                        url: 'facebook-login.php',
                        type: 'POST',
                        data: {
                            id: userInfo.id,
                            name: userInfo.name,
                            email: userInfo.email,
                            picture: userInfo.picture?.data?.url || ''
                            // Note: 'phone' is not available via FB.api('/me') unless you have special permission
                        },
                        success: function(res) {
                            window.location = 'user-profile.php';
                        },
                        error: function(err) {
                            console.error('Facebook login AJAX error:', err);
                        }
                    });
                });
            } else {
                console.warn('Facebook login failed or cancelled.');
            }
        }, { scope: 'public_profile,email' });
    }
</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.';
        }
    }
}
?>

VaKeR 2022