<?php
include_once("include/main.inc.php");
$admin_res=getAdminDetails();
$pg= "contact";

$referer = $_SERVER['HTTP_REFERER'];
    $ip=$_SERVER['REMOTE_ADDR'];
    $mobileNumber = "";
    if (isset($_POST['submit-contact']))
    {
        $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 || strpos($message,'/')!==false){
      $errMsg ='URL(s) and special characters are not allowed!';
  } else {    
            if($name != '' && $email != '' && $mobileNumber != '' && $location != '' && $message != '' && $ip != '' ){
if(strlen($mobileNumber)==10){
//$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) {
            $errMsg = 'Please click on the reCAPTCHA box.';
        }	
        
        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=now()";
            $qry=mysqli_query($dbconn,$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 = $admin_res['bcc'];
            // $to3 = 'vicky.wpsranchi@gmail.com';
            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);
       
            $succMsg = 'Thank you for your enquiry. Our team will contact you soon.';
       }  
} else { $errMsg ='Robot verification failed, please try again.';}
} else { $errMsg ='Please Enter 10 Digit Mobile Number';}
} else { $errMsg ='All the fields are Mandatory!';}
}
}




$ptitle= $admin_res['companyName']." | Contact Us";
?>
<!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><?=$ptitle?></title>
    <meta name="description" content="<?=$admin_res['companyName']?>, <?=$admin_res['address']?>, <?=$admin_res['city']?>, <?=$admin_res['state']?>, <?=$admin_res['country']?>. Trusted Brand Since 2012, Topmost
Plywood Manufacturer, Supplier and Exporter." />
<meta name="keywords" content="<?=$admin_res['companyName']?>, <?=$admin_res['companyName']?> <?=$admin_res['city']?>, <?=$admin_res['companyName']?> <?=$admin_res['state']?>, <?=$admin_res['companyName']?> <?=$admin_res['country']?>" />
    <?php include "app_top.php"; ?>
</head>

<body>
    <?php include 'app_header.php';?>




    <section class="heading_banner" style="background-image: url(<?=theme_url?>images/contact-banner.jpg)">
        <div class="container">
            <div class="row">
                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-center">
                    <h1 class="cat_title">Contact Us</h1>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </section>

    <!-- Breadcrumb--->
    <section 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-12">
                    <ul class="breadcrumb">
                        <li><a href="<?=site_url?>" title="Home">Home</a></li>
                        <li class="active">Contact Us</li>
                    </ul>
                </div>
            </div>
        </div>
    </section>


    <!-- Home About--->
    <section class="contact_page">
        <div class="container">
            <div class="contact_form_grid1">
                <div class="row">
                    <div class="col-xxl-5 col-xl-5 col-lg-5 col-md-5 col-sm-12 col-12 contact_details">
                        <h2 class="tt">Contact Information</h2>
                        <p>Write to us or call us, get quick response powered by our advanced Customer support team .</p>
                        <ul class="address_list">
                            <li>
                                <div class="d-flex align-items-center">
                                <span class="fa fa-map-marker"></span> 
                                <div> <?=$admin_res['address']?></div>
                                </div>
                            </li>
                            <li>
                                <div class="d-flex align-items-center">
                                <span class="fa fa-phone"></span>
                                <div>
                                <a href="tel:<?=$admin_res['phone']?>" title="<?=$admin_res['phone']?>">Call:<?=$admin_res['phone']?></a>,
                                <a href="tel:<?=$admin_res['mobile']?>" title="<?=$admin_res['mobile']?>"><?=$admin_res['mobile']?></a>
                                </div>
                                </div>
                            </li>
                            <li><a href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#whatsapp" title="Whatsapp Now"><span class="fa fa-whatsapp"></span> Whatsapp: <?=$admin_res['phone']?></a></li>
                            <?php if($admin_res['website']){ ?><li><a href="<?=$admin_res['website']?>" title="<?=$admin_res['website']?>"><span class="fa fa-globe"></span> <?=$admin_res['website']?></a></li><?php } ?>
                        </ul>
                        <!-- <div class="tt">Get in Touch</div> -->
                        <ul class="social_list">
                                     <?php if(facebook()){ ?>
                <li><a href="<?php echo facebook();?>" target="blank"><i
                      class="fa fa-facebook-f"></i></a>
                </li>
                  <?php } ?>
                <?php if(twitter()){ ?>
                <li><a href="<?php echo twitter();?>" target="blank"><i class="fa fa-twitter"></i></a>
                </li>
                <?php } ?>
                <?php if(instagram()){ ?>
                <li><a href="<?php echo instagram();?>" target="blank"><i
                      class="fa fa-instagram"></i></a>
                </li>
                <?php } ?>
                 <?php if(linkedin()){ ?>
                <li ><a href="<?php echo linkedin();?>" target="blank"><i class="fa fa-linkedin"></i></a>
                </li>
                 <?php } ?>
                   <?php if(youtube()){ ?>
                  <li ><a href="<?php echo youtube();?>" target="blank"><i class="fa fa-youtube"></i></a>
                </li>
                <?php } ?>
                        </ul>
                    </div>
                    <div class="col-xxl-7 col-xl-7 col-lg-7 col-md-7 col-sm-12 col-12 form_grid">
                        <h3 class="tt">We want to hear from you!</h3>
                       <form  name="contact-form" method="post" id="contact_form">
<script>
    setTimeout(function(){$.getScript("https://www.google.com/recaptcha/api.js")}, 10000);
</script>
<?php if(!empty($errMsg)): ?><div class="alert alert-danger alert-dismissible fade show"><?php echo $errMsg; ?><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div><?php endif; ?>
<?php if(!empty($succMsg)): ?><div class="alert alert-success alert-dismissible fade show"><?php echo $succMsg; ?><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div><?php endif; ?>
                        <div class="row">
                                <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">
                                    <div class="form-group">
                                        <input class="form-control" type="text" name="names" onkeyup="validateOnlyTextField(this)" placeholder="Full Name*" required>
                                    </div>
                                </div>
                                <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">
                                    <div class="form-group">
                                        <input class="form-control" type="email" name="emails" placeholder="Email ID*" required>
                                    </div>
                                </div>
                                <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">
                                    <div class="form-group">
                                        <input class="form-control" type="tel" name="mobiles" placeholder="Your Phone No*" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" maxlength="10" placeholder="Phone No*" required>
                                    </div>
                                </div>
                                <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">
                                    <div class="form-group">
                                        <input class="form-control" type="text" name="locations" placeholder="Location*" required>
                                    </div>
                                </div>
                                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                                    <div class="form-group">
                                        <textarea class="form-control" rows="5" placeholder="Comments Here*" required name="messages"></textarea>
                                    </div>
                                </div>
                                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                                    <div class="form-group" style="margin-bottom: 0;">
                                        <div class="g-recaptcha" data-sitekey="<?= SITE_KEY; ?>"></div>
                                    </div>
                                </div>
                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                    <div class="form-group">
                                        <button type="submit" name="submit-contact" class="read_more_btn_2">Submit</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>

    
    <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d13989.162145492543!2d77.04157020401802!3d28.770592109430513!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x390d0798efc5a469%3A0xc1f5590fa406014e!2sPuth%20Khurd%2C%20Delhi%2C%20110039!5e0!3m2!1sen!2sin!4v1685942483630!5m2!1sen!2sin" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>

    <?php include "app_footer.php";?>
    <?php include "app_bottom.php";?>
</body>

</html>