<?php
include_once("include/main.inc.php");
$admin_sql = mysqli_query($dbcon, "select * from admin_details");
$admin_res = mysqli_fetch_array($admin_sql);
date_default_timezone_set('Asia/Kolkata');
$enq_date = date('Y-m-d H:i:s');
$hover = "contact";
$page_metatitle = "Contact Us - Mangla Plastic Industries";
$page_metakey = "Contact Us - Mangla Plastic Industries";
$page_metadesc = "Contact Us - Mangla Plastic Industries";
$referer = $_SERVER['HTTP_REFERER'];
$ip = $_SERVER['REMOTE_ADDR'];
$mobileNumber = "";
if (isset($_POST['submit-side'])) {
  $name = !empty($_POST['names']) ? $_POST['names'] : '';
  $email = !empty($_POST['emails']) ? $_POST['emails'] : '';
  $mobileNumber = (!empty($_POST['mobiles'])) ? $_POST['mobiles'] : '';
  $location = !empty($_POST['locations']) ? $_POST['locations'] : '';
  $message = !empty($_POST['messages']) ? $_POST['messages'] : '';
  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) {
    $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 != '') {

      //$qry=mysql_query($sql_ens);	
      //reCAPTCHA validation
      if (isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) {

        $secret = SECRET_KEY;
        //get verify response data
        $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'";
          $qry = mysqli_query($dbcon, $sql_ens);

          $subject = utf8_encode($admin_res['subject']);
          $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;">' . $mobileNumber . '</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();
          if ($to != '') {
            smtp_mailer($to, $email, $name, $subject, $htmlContent);
          }
          if ($to2 != '') {
            smtp_mailer($to2, $email, $name, $subject, $htmlContent);
          }
          if ($to3) {
            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 click on 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 charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- <title>Contact Us - Mangla Plastic Industries</title>
  <meta name=description content="Contact Us - Mangla Plastic Industries" />
  <meta name=keywords content="Contact Us - Mangla Plastic Industries" /> -->
  <?php include "top.php"; ?>
</head>

<body>
  <div class="webpulse-main-wrapper wrapper-wide" id="top">
    <?php include "header.php"; ?>
    <div class="clearfix"></div>
    <section class="heading_banner about_us_banner" style="background-image: url('https://www.manglaplastic.com/images/contact.jpg')">
      <div class="container">
        <div class="row">
          <div class="col-sm-12 col-lg-12 col-md-12 col-xl-12 col-xxl-12 text-center">
            <h1 class="cat_title">Contact Us - Mangla Plastic Industries</h1>
            <div class="clearfix"></div>
          </div>
        </div>
      </div>
    </section>
    <div class="inner_breadcrumb hidden-xs">
      <div class="container">
        <div class="row">
          <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 col-12">
            <ul class="breadcrumb">
              <li><a href="<?= SITE_URL_PATH; ?>" title="Home">Home</a></li>
              <li class="active">Contact Us</li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <section class="contact_page">
      <div class="container">
        <div class="contact_form_grid1">
          <div class="row">
            <div class="col-sm-12 col-lg-6 col-md-6 col-xl-6 col-xxl-6 contact_details">
              <h2>Mangla Plastic Industries Contact Details</h2>
              <p>Write to us or call us, get quick response powered by our advanced customer support team .</p>
              <ul class="address_list">
                <li><a href="tel:<?= $admin_res['phone']; ?>"><i class="fa-solid fa-phone margintop"></i> <?= $admin_res['phone']; ?></a></li>
                <li><a href="tel:<?= $admin_res['mobile']; ?>"><i class="fa-solid fa-phone margintop"></i> <?= $admin_res['mobile']; ?></a></li>
                <li><a href="javascript:void();"><i class="fa-solid fa-location-dot margintop"></i> <?php echo html_entity_decode($admin_res['address']); ?></a></li>

                <!-- <li><a href="mailto:anil_mangla@yahoo.co.in"><i class="fa-regular fa-envelope margintop"></i>  anil_mangla@yahoo.co.in</a></li> -->

                <!-- <li><a href="https://safetygumboot.com" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
  <path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 1.855A7.97 7.97 0 0 0 5.145 4H7.5V1.077zM4.09 4a9.267 9.267 0 0 1 .64-1.539 6.7 6.7 0 0 1 .597-.933A7.025 7.025 0 0 0 2.255 4H4.09zm-.582 3.5c.03-.877.138-1.718.312-2.5H1.674a6.958 6.958 0 0 0-.656 2.5h2.49zM4.847 5a12.5 12.5 0 0 0-.338 2.5H7.5V5H4.847zM8.5 5v2.5h2.99a12.495 12.495 0 0 0-.337-2.5H8.5zM4.51 8.5a12.5 12.5 0 0 0 .337 2.5H7.5V8.5H4.51zm3.99 0V11h2.653c.187-.765.306-1.608.338-2.5H8.5zM5.145 12c.138.386.295.744.468 1.068.552 1.035 1.218 1.65 1.887 1.855V12H5.145zm.182 2.472a6.696 6.696 0 0 1-.597-.933A9.268 9.268 0 0 1 4.09 12H2.255a7.024 7.024 0 0 0 3.072 2.472zM3.82 11a13.652 13.652 0 0 1-.312-2.5h-2.49c.062.89.291 1.733.656 2.5H3.82zm6.853 3.472A7.024 7.024 0 0 0 13.745 12H11.91a9.27 9.27 0 0 1-.64 1.539 6.688 6.688 0 0 1-.597.933zM8.5 12v2.923c.67-.204 1.335-.82 1.887-1.855.173-.324.33-.682.468-1.068H8.5zm3.68-1h2.146c.365-.767.594-1.61.656-2.5h-2.49a13.65 13.65 0 0 1-.312 2.5zm2.802-3.5a6.959 6.959 0 0 0-.656-2.5H12.18c.174.782.282 1.623.312 2.5h2.49zM11.27 2.461c.247.464.462.98.64 1.539h1.835a7.024 7.024 0 0 0-3.072-2.472c.218.284.418.598.597.933zM10.855 4a7.966 7.966 0 0 0-.468-1.068C9.835 1.897 9.17 1.282 8.5 1.077V4h2.355z"/>
</svg> www.safetygumboot.com</a></li> -->

              </ul>
              <h3>Get in Touch</h3>
              <ul class="social_list">
                <li><a class="facebook" href="<?= $admin_res['facebook_link']; ?>" target="_blank"><i class="fa-brands fa-facebook-f"></i></a></li>
                <li><a class="twitter" href="<?= $admin_res['twitter_link']; ?>" target="_blank">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-twitter-x" viewBox="0 0 16 16">
                      <path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865z" />
                    </svg>
                  </a></li>
                <li><a class="instagram" href="<?= $admin_res['instagram_link']; ?>" target="_blank"><i class="fa-brands fa-instagram"></i></a></li>
                <li><a class="youtube" href="<?= $admin_res['youtube_link']; ?>" target="_blank"><i class="fa-brands fa-youtube"></i></a></li>
              </ul>
            </div>
            <div class="col-sm-12 col-lg-6 col-md-6 col-xl-6 col-xxl-6 form_grid">
              <h4>Contact Us</h4>
              <form name="contact-form" method="post" id="contact_form">
                <!-- <script src="https://www.google.com/recaptcha/api.js" async defer></script> -->
                <div class="alert alert-danger contact-error-message d-none"></div>
                <div class="alert alert-success contact-success-message d-none"></div>
                <div class="row">
                  <div class="col-sm-12 col-lg-6 col-md-12 col-xl-6 col-xxl-6">
                    <div class="form-group">
                      <input placeholder="Full Name *" class="form-control" type="text" tabindex="1" name="names" id="names1" value="<?php echo !empty($name) ? $name : ''; ?>" required="" pattern="[a-z A-Z]+" onkeyup="validateOnlyTextField(this)">
                    </div>
                  </div>
                  <div class="col-sm-12 col-lg-6 col-md-12 col-xl-6 col-xxl-6">
                    <div class="form-group">
                      <input placeholder="Email ID *" class="form-control" type="email" tabindex="2" name="emails" id="emails1" value="<?php echo !empty($email) ? $email : ''; ?>" required="">
                    </div>
                  </div>
                  <div class="col-sm-12 col-lg-6 col-md-12 col-xl-6 col-xxl-6">
                    <div class="form-group">
                    <input type="hidden" class="countryName countryName" name="countryName" value="">
                      <input placeholder="Phone Number *" class="form-control telePhone mobile" type="tel" maxlength="10" minlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
                        oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" tabindex="3" name="mobiles" id="mobiles1" value="<?php echo (!empty($mobileNumber)) ? $mobileNumber : ''; ?>" required="">
                    </div>
                  </div>
                  <div class="col-sm-12 col-lg-6 col-md-12 col-xl-6 col-xxl-6">
                    <div class="form-group">
                      <input placeholder="Location*" class="form-control" type="text" tabindex="4" name="locations" onkeypress="return ValidateAlpha(event)" value="<?php echo !empty($location) ? $location : ''; ?>" required="" pattern="[a-z A-Z]+">
                    </div>
                  </div>
                  <div class="col-sm-12 col-lg-12 col-md-12 col-xl-12 col-xxl-12">
                    <div class="form-group">
                      <textarea placeholder="Type your Message Here...." class="form-control" required="" tabindex="5" name="messages" id="messages1"><?php echo !empty($message) ? $message : ''; ?></textarea>
                    </div>
                  </div>

                  <div class="col-sm-12 col-lg-6 col-md-12 col-xl-6 col-xxl-6">
                    <div class="form-group" style="margin-bottom: 0;">
                      <div tabindex="6" class="g-recaptcha" data-sitekey="<?= SITE_KEY; ?>"></div>
                    </div>
                  </div>
                  <div class="col-12">
                    <div class="form-group">
                      <button tabindex="7" class="modal_btn" type="submit" name="submit-side" value="Submit" data-submit="...Sending">Submit</button>
                    </div>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </section>
    <?php include "award_video.php"; ?>
    <!-- <?php include 'testimonail.php'; ?> -->
    <div class="maps">
      <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3500.4286604578624!2d76.92954277439772!3d28.676821182070107!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x390d165555555555%3A0x91f49456d26b6e3e!2sMANGLA%20PLASTIC%20INDUSTRIES!5e0!3m2!1sen!2sin!4v1695624842046!5m2!1sen!2sin" height="400" style="border:0;width:100%;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
    </div>
    <?php include "footer.php"; ?>
  </div>
  <?php include "bottom.php"; ?>
</body>

</html>