<?php

include_once("include/main.inc.php");

date_default_timezone_set('Asia/Kolkata');

$enq_date = date('Y-m-d H:i:s');

$hover = "contact";

$page_metatitle = "Contact Us | Vashikaran Specialist Astrologer in India – Astrologer Arjun Shastri";

$page_metakey = "Vashikaran Specialist Astrologer in India, Astrologer Arjun Shastri, Contact Vashikaran Astrologer, Love Problem Solution, Black Magic Specialist, Vashikaran Expert India, Online Astrology Consultation, Relationship Problem Solution";

$page_metadesc = "Get in touch with Astrologer Arjun Shastri – a renowned Vashikaran Specialist Astrologer in India. Contact now for trusted solutions to your love and life problems.";

$referer = $_SERVER['HTTP_REFERER'];

$ip = $_SERVER['REMOTE_ADDR'];

if (isset($_POST['submit_contact'])) {

    $name = !empty($_POST['name']) ? $_POST['name'] : '';

    $email = !empty($_POST['email']) ? $_POST['email'] : '';

    $mobileNumber = (!empty($_POST['mobile'])) ? $_POST['mobile'] : '';

    $location = !empty($_POST['location']) ? $_POST['location'] : '';

    $message = !empty($_POST['message']) ? $_POST['message'] : '';

    $code = (!empty($_POST['code'])) ? $_POST['code'] : '';

    $countryNames = (!empty($_POST['countryName'])) ? $_POST['countryName'] : '';

    $countryName1 = explode('(', $countryNames);

    $countryName = $countryName1[0];

    $code = $code != '' ? $code : '91';

    $countryName = $countryName != '' ? $countryName : 'India';

    $mobileNumbers = '+' . $code . ' - ' . $mobileNumber;

    if (strpos($message, '#') !== false || strpos($message, '%') !== false || strpos($message, '@') !== false || strpos($message, '&') !== false || strpos($message, '~') !== false || strpos($message, 'https') !== false || strpos($message, 'http') !== false || strpos($message, 'www') !== false || strpos($message, '?') !== false || strpos($location, '#') !== false || strpos($location, '%') !== false || strpos($location, '@') !== false || strpos($location, '&') !== false || strpos($location, '~') !== false || strpos($location, 'https') !== false || strpos($location, 'http') !== false || strpos($location, 'www') !== false || strpos($location, '?') !== false || strpos($name, '#') !== false || strpos($name, '%') !== false || strpos($name, '@') !== false || strpos($name, '&') !== false || strpos($name, '~') !== false || strpos($name, 'https') !== false || strpos($name, 'http') !== false || strpos($name, 'www') !== false || strpos($name, '?') !== false) {

        $resp = [

            'message_response' => 'URL(s) and special characters are not allowed',

            'status' => false

        ];

        echo json_encode($resp);

        exit;
    } else {

        if ($name != '' && $email != '' && $mobileNumber != '' && $location != '' && $message != '' && $ip != '') {

            if (isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) {

                $secret = secret_key;

                $data = array('secret' => $secret, 'response' => $_POST['g-recaptcha-response']);
                $verify = curl_init();
                curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
                curl_setopt($verify, CURLOPT_POST, true);
                curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
                curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
                $response = curl_exec($verify); //var_dump($response);

                $response = json_decode($response);

                if (!$response->success) {

                    $resp = [

                        'message_response' => 'Robot verification failed, please try again.',

                        'status' => false

                    ];

                    echo json_encode($resp);

                    exit;
                }

                if ($response->success) {

                    $sql_ens = "insert into tbl_enquiry set en_name='$name', en_email='$email', en_mobile='$mobileNumber', en_country='$location', en_comment='$message', en_url='$referer', en_date='$enq_date',en_zcode='$code',en_country_name='$countryName', en_ip='$ip'";

                    $qry = mysqli_query(
                        $GLOBALS['dbconn'],

                        $sql_ens
                    );

                    $subject = utf8_encode($admin_res['subject']);

                    // $htmlContent = "

                    // Customer Details:

                    // Url: ".$referer."

                    // Name: ".$name."

                    // Email: ".$email."

                    // Mobile: ".$mobileNumber."

                    // Location:".$location."

                    // Message: ".$message."

                    // ";

                    $htmlContent =  '<table border="0" width="100%">

            <tbody>

      <tr>

        <td colspan="2">

          <strong>Dear Admin</strong></td>

      </tr>

      <tr>

        <td colspan="2">

          Enquiry Received with following info :</td>

      </tr>

      <tr>

        <td colspan="2">

          &nbsp;</td>

      </tr>

      <tr>

        <td width="26%">

          <strong>Post URL : </strong></td>

        <td>

          <span style="margin-top: 15px;">' . $referer . '</span></td>

      </tr>

      <tr>

        <td width="26%">

          <strong>Name : </strong></td>

        <td>

          <span style="margin-top: 15px;">' . $name . '</span></td>

      </tr>

      <tr>

        <td width="26%">

          <strong>Email Id : </strong></td>

        <td>

          <span style="margin-top: 15px;">' . $email . '</span></td>

      </tr>

      <tr>

        <td width="26%">

          <strong>Contact No : </strong></td>

        <td>

          <span style="margin-top: 15px;">' . $mobileNumbers . '</span></td>

      </tr>

      <tr>

  <td>

    <strong>Country : </strong></td>

  <td>

    <span style="margin-top: 15px;">' . $countryName . '</span></td>

</tr>

      <tr>

        <td>

          <strong>Location : </strong></td>

        <td>

          <span style="margin-top: 15px;">' . $location . '</span></td>

      </tr>

      <tr>

        <td>

          <strong>Message : </strong></td>

        <td>

          <span style="margin-top: 15px;">' . $message . '</span></td>

      </tr>

    </tbody>

            </table>';

                    $to = $admin_res['email'];

                    $to2 = $admin_res['cc'];

                    $to3 = 'webpulseindia@gmail.com';

                   

                    // $headers = 'From: '.'Webpulseindia.com'.' enquiry@webpulseindia.com' . "\r\n" .

                    // 'Reply-To:  '.$name.'<'.$email.'>' . "\r\n" .

                    // 'X-Mailer: PHP/' . phpversion();

                    // @mail($to,$subject,$htmlContent,$headers);

                    // @mail($to2,$subject,$htmlContent,$headers);

                    // @mail($to3,$subject,$htmlContent,$headers);

                    if ($to != '') {

                        smtp_mailer($to, $email, $name, $subject, $htmlContent);
                    }

                    if ($to2 != '') {

                        smtp_mailer($to2, $email, $name, $subject, $htmlContent);
                    }

                    smtp_mailer($to3, $email, $name, $subject, $htmlContent);

                    $resp = [

                        'message_response' => 'Thank you for your enquiry. Our team will contact you soon.',

                        'status' => true

                    ];

                    echo json_encode($resp);

                    exit;
                }
            } else {

                $resp = [

                    'message_response' => 'Please check the recaptcha box!',

                    'status' => false

                ];

                echo json_encode($resp);

                exit;
            }
        } else {

            $resp = [

                'message_response' => 'All the fields are Mandatory!',

                'status' => false

            ];

            echo json_encode($resp);

            exit;
        }
    }
}

?>

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

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <?php include 'app_top.php'; ?>
</head>

<body>
  <?php include 'app_header.php'; ?>
  <div class="img-breadcum" style="background-image: url(<?=site_url;?>/designer/images/contact-banner.jpg);">
    <div class="container">
      <h1 class="tt">Contact Us - <?=$admin_res['companyName'];?></h1>
    </div>
  </div>
  <div class="breadcum-sec">
    <div class="container-fluid px-md-5">
      <ul>
        <li><a href="<?=site_url;?>" title="Home">Home</a></li>
        <li>Contact Us</li>
      </ul>
    </div>
  </div>
  <div class="section">
    <div class="container">
      <div class="row g-4">
        <div class="col-lg-5 col-12">
          <div class="contact-bx mb-4">
            <div class="head-sec left mb-3">
              <h2 class="tt">Contact Information</h2>
              <p>Write to us or call us, get quick response powered by our advanced customer support team.</p>
            </div>
            <div class="con-bx">
              <div class="ic-bx">
                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-fill" viewBox="0 0 16 16">
                  <path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6"></path>
                </svg>
              </div>
              <p>
                <strong> Contact Person: </strong> <?=$admin_res['name'];?>
              </p>
            </div>
            <div class="con-bx">
              <div class="ic-bx">
                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-telephone-fill" viewBox="0 0 16 16">
                  <path fill-rule="evenodd" d="M1.885.511a1.745 1.745 0 0 1 2.61.163L6.29 2.98c.329.423.445.974.315 1.494l-.547 2.19a.68.68 0 0 0 .178.643l2.457 2.457a.68.68 0 0 0 .644.178l2.189-.547a1.75 1.75 0 0 1 1.494.315l2.306 1.794c.829.645.905 1.87.163 2.611l-1.034 1.034c-.74.74-1.846 1.065-2.877.702a18.6 18.6 0 0 1-7.01-4.42 18.6 18.6 0 0 1-4.42-7.009c-.362-1.03-.037-2.137.703-2.877z"></path>
                </svg>
              </div>
              <a href="tel:<?=$admin_res['mobile'];?>" title="Call Us">Call Us: <?=$admin_res['mobile'];?></a>
            </div>
          </div>
          <div class="contact-bx ft-bx">
            <div class="head-sec left mb-2">
              <h3 class="tt">You can follow us at</h3>
            </div>
            <ul class="social">
            <?php if ($admin_res['facebook'] != '') { ?>
              <li><a href="<?= $admin_res['facebook']; ?>" title="Facebook"><img src="<?=site_url;?>/designer/images/icon/facebook.png" alt="Facebook" title="Facebook"></a></li>
              <?php if ($admin_res['instagram'] != '') { ?>
              <li><a href="<?= $admin_res['instagram']; ?>" title="Instagram"><img src="<?=site_url;?>/designer/images/icon/insta.png" alt="Instagram" title="Instagram"></a></li>
              <?php } if ($admin_res['twitter'] != '') { ?>
              <li><a href="<?= $admin_res['twitter']; ?>" title="Twitter"><img src="<?=site_url;?>/designer/images/icon/twitter.png" alt="Twitter" title="Twitter"></a></li>
              <?php } ?>
              <?php } if ($admin_res['youtube'] != '') { ?>
              <li><a href="<?= $admin_res['youtube']; ?>" title="Youtube"><img src="<?=site_url;?>/designer/images/icon/youtube.png" alt="Youtube" title="Youtube"></a></li>
              <?php } ?>
            </ul>
          </div>
        </div>
        <div class="col-lg-7 col-12">
          <div class="contact-bx">
            <div class="head-sec left mb-3">
              <h4 class="tt">We want to hear from you!</h4>
            </div>
            <form name="contact-form" method="post" id="contact_form">
              <div id="pop_up"></div>
              <script src="https://www.google.com/recaptcha/api.js" async defer></script>
              <div class="row gx-2">
                <div class="col-lg-6 col-12">
                  <div class="form-group">
                    <label class="form-label">Full Name*</label>
                    <input type="text" class="form-control" name="name" onkeyup="validateOnlyTextField(this)" placeholder="Full Name">
                  </div>
                </div>
                <div class="col-lg-6 col-12">
                  <div class="form-group">
                    <label class="form-label">Email id*</label>
                    <input type="email" class="form-control" name="email" placeholder="Email id">
                  </div>
                </div>
                <div class="col-lg-6 col-12">
                  <div class="form-group">
                  <input type="hidden" name="countryName" class="countryName" value="">
                  <input type="hidden" name="code" class="code" value="">
                    <label class="form-label">Mobile No.*</label>
                    <input type="tel" class="form-control telePhone" name="mobile" placeholder="Mobile Number"  maxlength="10" minlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" autocomplete="off">
                  </div>
                </div>
                <div class="col-lg-6 col-12">
                  <div class="form-group">
                    <label class="form-label">Your Location*</label>
                    <input type="text" class="form-control" name="location" placeholder="Your Location">
                  </div>
                </div>
                <div class="col-12">
                  <div class="form-group">
                    <label class="form-label">Your Message*</label>
                    <textarea class="form-control" placeholder="Your Message" name="message"></textarea>
                  </div>
                </div>
                <div class="form-group mb-0">
                  <div class="g-recaptcha" data-sitekey="<?=site_key;?>">
                    <!-- <div style="width: 304px; height: 78px;">
                      <div><iframe title="reCAPTCHA" width="304" height="78" role="presentation" name="a-4e9yfjf3m5fk" frameborder="0" scrolling="no" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation allow-modals allow-popups-to-escape-sandbox allow-storage-access-by-user-activation" src="https://www.google.com/recaptcha/api2/anchor?ar=1&amp;k=<?=site_key;?>&amp;co=aHR0cDovL2xvY2FsaG9zdDo4MA..&amp;hl=en&amp;v=ItfkQiGBlJDHuTkOhlT3zHpB&amp;size=normal&amp;cb=691690fx44f7"></iframe></div><textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea>
                    </div> -->
                  </div>
                </div>
                <div class="col-12">
                  <button class="main-btn w-100 justify-content-center" name="submit_contact" type="submit">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-envelope" viewBox="0 0 16 16">
                      <path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1zm13 2.383-4.708 2.825L15 11.105zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741M1 11.105l4.708-2.897L1 5.383z"></path>
                    </svg> Submit </button>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>


  <?php include 'app_footer.php'; ?>
  <?php include 'app_bottom.php'; ?>

  
</body>

</html>