HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/salesforce-custom-component/wp-content/themes/custom-theme/single.php
<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"
        rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css" rel="stylesheet" />


    <title><?php echo the_title(); ?></title>
</head>
<style>
    body {
        font-family: "Montserrat", sans-serif !important;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    h1 {
        color: #ffffff;
    }

    h2 {
        color: #000000;
        font-weight: 600;

    }

    p {
        color: #000000;
        font-weight: 500;
        line-height: 1.8rem;
    }

    ol li {
        color: #000000;
        font-weight: 500;
        line-height: 2rem;
    }

    ul li {
        color: #000000;
        font-weight: 500;
        line-height: 2rem;
    }

    ul li.ul-list-style {
        list-style: lower-alpha;
    }

    a.button-get-it-know {
        text-decoration: none;
        background-color: #0176d3;
        color: #ffffff;
        font-size: 1.3rem;
        font-weight: 500;
        padding: 8px 15px;
        border-radius: 3px;
    }

    img.attachment-medium.size-medium.wp-post-image {
        width: 100%;
        height: auto;
        border: 2px solid #0176d3;
        border-radius: 4px;
        margin-bottom: 2.5rem;
    }
</style>
<?php
global $wpdb;
$table_name = 'wp_otp';
$results = $wpdb->get_results("SELECT * FROM $table_name  where email = 'rohit.m@cccinfotech.com'");
// print_r($results);
if ($results) {
    foreach ($results as $row) {
        $getemail = $row->email;
        $getotp = $row->otp;
    }
}
?>

<body>
    <main>
        <section class="bg-dark mb-5">
            <div class="container py-5">
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="text-white"> <?php echo the_title(); ?></h1>
                    </div>
                </div>

            </div>
        </section>
        <div class="container ">
            <div class="row justify-content-between">
                <div class="col-lg-7" style="height: 500px; overflow-y: auto;">
                    <p> <?php echo the_content(); ?></p>

                </div>
                <div class="col-lg-4">
                    <div>

                        <?php
                        if (has_post_thumbnail()) {
                            $featured_image_url = get_the_post_thumbnail_url(get_the_ID(), 'full');
                        }
                        ?>

                        <a href="<?php echo $featured_image_url; ?>">
                            <?php
                            echo '<img style="width:100%; border: 2px solid #0176d3; border-radius: 4px; margin-bottom: 2.5rem;" src="' . esc_url($featured_image_url) . '" alt="' . esc_attr(get_the_title()) . '">';
                            ?>
                        </a>
                    </div>

                    <?php

                    $link = get_field('package_url');
                    if ($link):
                        $link_url = $link['url'];
                        $link_title = $link['title'];
                        $link_target = $link['target'] ? $link['target'] : '_self';
                    ?>
                        <a class="button-get-it-know" href="<?php echo esc_url($link_url); ?>"
                            target="<?php echo esc_attr($link_target); ?>"><?php echo esc_html($link_title); ?></a>
                    <?php endif; ?>
                </div>
            </div>

            <!-- Button trigger modal -->
            <!-- <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
                Get It Now
            </button> -->


            <!-- Modal -->
            <div class="modal fade " id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel"
                aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Email Verifaction</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body">
                            <form>
                                <div class="mb-3">
                                    <label for="email" class="form-label">Email address</label>
                                    <input type="email" class="form-control" id="email" aria-describedby="email"
                                        required>
                                    <span id="emailId"></span>
                                    <!-- <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div> -->
                                </div>
                                <button type="button" class="btn btn-primary" id="sumbit_btn">Submit</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal fade " id="otpModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Email Verifaction</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body">
                            <form>
                                <div class="mb-3">
                                    <label for="otp_email" class="form-label">otp_email address</label>
                                    <input type="otp_email" class="form-control" id="otp_email" value="<?php echo $getemail; ?>"
                                        aria-describedby="otp_email" readonly required>
                                </div>
                                <div class="mb-3">
                                    <label for="otp" class="form-label">OTP </label>
                                    <input type="text" class="form-control" id="otp" aria-describedby="otp" required>
                                    <div class="timer mt-3"> <button type="button" class="btn btn-primary" style="color: #ffffff;" id="resend_otp">Resend OTP</button></div>
                                    <div class=" mt-3" id="otp_timer"><strong>Time remaining:<span id="timer"></span></strong> </div>
                                    <!-- <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div> -->
                                </div>
                                <button type="button" class="btn btn-primary" id="otp_btn">Submit</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php

        if (is_child_theme()) {
            $config_path = get_stylesheet_directory() . '/config.php';
        } else {
            $config_path = get_template_directory() . '/config.php';
        }
        if (file_exists($config_path)) {
            include_once($config_path);
        } else {
            // Handle the case where the file does not exist
            error_log('Config file not found at: ' . $config_path);
        }
        $DB_HOST = '';
        $DB_PASSWORD = '';
        $DB_USER = '';
        $DB_NAME = '';
        // Retrieve the database name
        if (defined('DB_NAME')) {
            $DB_NAME = DB_NAME;
            $DB_HOST = DB_HOST;
            $DB_PASSWORD = DB_PASSWORD;
            $DB_USER = DB_USER;
        } else {
            // Handle the case where DB_NAME is not defined
            $DB_NAME = 'not defined';
            $DB_HOST = 'not defined';
            $DB_PASSWORD = 'not defined';
            $DB_USER = 'not defined';
        }

        ?>
    </main>




    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
</body>
<script>
    document.querySelector('#sumbit_btn').addEventListener('click', function() {
        // startResendTimer();
        let user_email = document.querySelector('#email');
        let email = user_email.value;

        let db_host = "<?php echo $DB_HOST; ?>";
        let db_password = "<?php echo $DB_PASSWORD; ?>";
        let db_user = "<?php echo $DB_USER; ?>";
        let bd_name = "<?php echo $DB_NAME; ?>";

        function getEmailDomain(email) {
            // Split the email by '@' and return the second part
            let parts = email.split('@');
            return parts.length === 2 ? parts[1] : null; // Ensure the email contains '@'
        }
        let domain = getEmailDomain(email);
        console.log("Email Domain==>" + domain);
        if (domain == "cccinfotech.com") {
            $("#sumbit_btn").prop('disabled', true);
            $("#sumbit_btn").html("OTP Sending...");
            alert("Email Domain Matched==>" + domain)
            $.ajax({
                url: '<?php echo get_template_directory_uri(); ?>/insert.php',
                method: 'POST',
                data: {
                    email: email,
                    db_host: db_host,
                    db_password: db_password,
                    db_user: db_user,
                    bd_name: bd_name,
                },
                // processData: false,
                // contentType: false,
                success: function(response) {
                    alert('Your form has been sent successfully.');
                    $("#sumbit_btn").prop('disabled', false);
                    $("#sumbit_btn").html("Submit");
                    // $("#exampleModal").modal("hide");
                    // $("#otpModal").modal("show");
                    location.href = 'http://localhost/custom-plugin-code/otp-verify/?email=' + email;
                },
                error: function(xhr, status, error) {
                    alert('Your form was not sent successfully.');
                    console.error(error);
                }
            });
        } else if (!domain) {
            // $('#emailId').html('Invalid Email!!!').css('color', 'red');
            $('#emailId').html('*Please fill the email!').css('color', 'red');

        } else {
            alert("Email Domain Not Matched==>" + domain);
            $('#emailId').html('Invalid Email!!!').css('color', 'red');
            // $('#emailId').html('*Please fill the email!').css('color', 'red');

        }
    });


    // document.addEventListener('DOMContentLoaded', function() {
    //     const timerElement = document.getElementById('timer');
    //     const otpExpiryTime = 120; // OTP expiry time in seconds (e.g., 60 seconds)

    //     function startTimer(duration, display) {
    //         let timer = duration,
    //             minutes, seconds;
    //         const interval = setInterval(function() {
    //             minutes = parseInt(timer / 60, 10);
    //             seconds = parseInt(timer % 60, 10);

    //             minutes = minutes < 10 ? '0' + minutes : minutes;
    //             seconds = seconds < 10 ? '0' + seconds : seconds;

    //             display.textContent = minutes + ':' + seconds;

    //             if (--timer < 0) {
    //                 clearInterval(interval);
    //                 display.textContent = '00:00';
    //                 // Optionally disable OTP input or notify user that OTP has expired
    //                 // alert('OTP has expired');
    //             }
    //         }, 1000);
    //     }

    //     // Start the timer with the given duration
    //     startTimer(otpExpiryTime, timerElement);
    // });
    document.querySelector('#otp_btn').addEventListener('click', function() {
        // startResendTimer();
        let user_email = document.querySelector('#email');
        let user_otp = document.querySelector('#otp');
        let email = user_email.value;
        let otp = user_otp.value;
        let db_host = "<?php echo $DB_HOST; ?>";
        let db_password = "<?php echo $DB_PASSWORD; ?>";
        let db_user = "<?php echo $DB_USER; ?>";
        let bd_name = "<?php echo $DB_NAME; ?>";
        $.ajax({
            url: '<?php echo get_template_directory_uri(); ?>/check-otp.php',
            method: 'POST',
            data: {
                email: email,
                otp: otp,
                db_host: db_host,
                db_password: db_password,
                db_user: db_user,
                bd_name: bd_name,
            },
        });
    });





    // $(document).ready(function() {
    //     otpTimer();
    // });

    // function otpTimer() {
    //     var settimer = "0:10";
    //     var interval = setInterval(function() {
    //         var otptimer = settimer.split(':');
    //         //by parsing integer, I avoid all extra string processing
    //         var minutes = parseInt(otptimer[0], 10);
    //         var seconds = parseInt(otptimer[1], 10);
    //         --seconds;
    //         minutes = (seconds < 0) ? --minutes : minutes;
    //         seconds = (seconds < 0) ? 60 : seconds;
    //         seconds = (seconds < 10) ? '0' + seconds : seconds;
    //         //minutes = (minutes < 10) ?  minutes : minutes;
    //         $('span#otp_count_down').html('Resend OTP in <strong>' + minutes + ':' + seconds + '</strong>');
    //         if (minutes < 0) clearInterval(interval);
    //         //check if both minutes and seconds are 0
    //         if ((seconds <= 0) && (minutes <= 0)) clearInterval(interval);
    //         settimer = minutes + ':' + seconds;
    //     }, 1000);

    //     setTimeout(function() {
    //         $("span#otp_count_down").hide();
    //         $('span#resend_otp').css('display', '');
    //     }, 60000);
    // }

    // let timerOn = true;

    // function timer(remaining) {
    //     document.getElementById("resend_otp").style.display = "none";
    //     var m = Math.floor(remaining / 60);
    //     var s = remaining % 60;
    //     m = m < 10 ? '0' + m : m;
    //     s = s < 10 ? '0' + s : s;
    //     document.getElementById('timer').innerHTML = m + ':' + s;
    //     remaining -= 1;
    //     if (remaining >= 0 && timerOn) {
    //         setTimeout(function() {
    //             timer(remaining);
    //         }, 1000);
    //         return;
    //     }
    //     if (!timerOn) {
    //         // Do validate stuff here
    //         return;
    //     }
    //     // Do timeout stuff here
    //     alert('Timeout for otp');
    //     document.getElementById("resend_otp").style.display = "block";
    //     document.getElementById("otp_timer").style.display = "none";


    // }
    // timer(10);

    // document.querySelector('#resend_otp').addEventListener('click', function() {
    //     let user_email = document.querySelector('#email');
    //     let email = user_email.value;
    //     <?php
            //     global $wpdb;
            //     $table_name = 'wp_otp';
            //     $results = $wpdb->get_results("SELECT * FROM $table_name  where email = ''");
            //     // print_r($results);
            //     if ($results) {
            //         foreach ($results as $row) {
            //             $getemail = $row->email;
            //             $getotp = $row->otp;
            //         }
            //     }
            //     
            ?>
    //     $.ajax({
    //         url: '<?php echo get_template_directory_uri(); ?>/insert.php',
    //         method: 'POST',
    //         data: {
    //             email: email,

    //         },
    //         // processData: false,
    //         // contentType: false,
    //         success: function(response) {
    //             alert('Your form has been sent successfully.');
    //             $("#sumbit_btn").prop('disabled', false);
    //             $("#sumbit_btn").html("Submit");
    //             $("#exampleModal").modal("hide");
    //             $("#otpModal").modal("show");
    //         },
    //         error: function(xhr, status, error) {
    //             alert('Your form was not sent successfully.');
    //             console.error(error);
    //         }
    //     });
    // });
</script>



</html>