<?php
include_once("include/main.inc.php");
$admin_res=getAdminDetails();
$pg= "contact";
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$ee=explode('/',$actual_link);
$afterChunk = $ee[3];
$eem=explode('?',$afterChunk);

$finalUrl = $eem[1];


if($finalUrl){
     $url=site_url."/".contact-us.".htm"; 
   echo "<script>
           window.location = '".$url."';
         </script>";
 }

$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 = '6LfgpbghAAAAAHolCg2Kh_jMQeEv62hOVzlf2SQG';
		//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 = "
            Customer Details:

            Url: ".$referer."

            Name: ".$name."

            Email: ".$email."

            Mobile: ".$mobileNumber."

            Location:".$location."

            Message: ".$message."
            ";
            
 $to =  $admin_res['email'];
$to2 = "webpulseindia@gmail.com";
$to3 = "priyanka@aarnasystems.in";
$to4 = "ankita@aarnasystems.in";
// $to = 'developer.wpsrnc@gmail.com';
            
                $headers = "MIME-Version: 1.0" . "\r\n";
             $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
            $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);
            $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!';}
}
}
$contactpage=mysqli_query($dbconn,"select * from static_pages where pageID='3'");
$cont_res=mysqli_fetch_array($contactpage);

$page_metatitle = str_replace('hotkeyword1',$cont_res[keyword1],str_replace('companyname', $admin_res[companyName], str_replace('city', $admin_res[city], str_replace('city', $admin_res[city], str_replace('state', $admin_res[state], str_replace('country', $admin_res[country], $cont_res['page_metatitle']))))));

$page_metakey = str_replace('hotkeyword1',$cont_res[keyword1],str_replace('companyname', $admin_res[companyName], str_replace('city', $admin_res[city], str_replace('state', $admin_res[state], str_replace('country', $admin_res[country], $cont_res['page_keyword'])))));

$page_metadesc = str_replace('hotkeyword1',$cont_res[keyword1],str_replace('companyname', $admin_res[companyName], str_replace('phone', $admin_res[phone],str_replace('address', $admin_res[address], str_replace('city', $admin_res[city], str_replace('state', $admin_res[state], str_replace('country', $admin_res[country], $cont_res['page_metadesc'])))))));
?>
<!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><?=$page_metatitle?></title>
    <meta name="description" content="<?=$page_metadesc?>">
    <meta name="keywords" content="<?=$page_metakey?>">
    <?php include 'components/top_header.php';?>
</head>

<body>
    <div class="webpulse-main-wrapper">
        <!-- Header -->
        <?php include 'components/header.php';?>



        <!-- Heading Banner -->
        <section class="heading_banner" style="background-image: url(<?=theme_url?>images/contact/contact.jpg)">
            <div class="container">
                <div class="row">
                    <div class="col-lg-12 text-center">
                        <h1 class="cat_title">Contact Us</h1>
                        <div class="clearfix"></div>
                        <div class="cat_title2">We Are Available For You</div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Breadcrumb -->
        <div class="inner_breadcrumb hidden-xs">
            <div class="container">
                <div class="row">
                    <div class="col-lg-12">
                        <ul class="breadcrumb">
                            <li><a href="<?=site_url?>" title="Home">Home</a></li>
                            <li class="active">Contact Us</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>


        <!-- Home About -->
        <section class="contact_page ptb-50 bg-grey">
            <div class="container">

                <div class="contact_form_grid1">
                    <div class="row">
                        <div class="col-lg-5 contact_details">
                            <h2 class="contact-title">Contact Information</h2>
                            <p>Write to us or call us, get quick response powered by our advanced coustomer support team
                                .</p>
                            <ul class="address_list">
                                <li> <span class="fa fa-map-marker"></span><?=$admin_res['address']?> </li>
                                <li><a href="tel:<?=$admin_res['phone']?>"><span class="fa fa-phone"></span> Call: <?=$admin_res['phone']?></a> , <a href="tel:<?=$admin_res['whatsapp_no']?>"><?=$admin_res['whatsapp_no']?></a></li>
                                <!--
                                <li><a href="javascript:void()"><span class="fa fa-whatsapp"></span> Fax:
                                        +91-99112-44888</a></li>
-->
                                <li><a href="mailto:<?=$admin_res['email']?>"><span class="fa fa-envelope"></span>Mail:
                                        <?=$admin_res['email']?></a></li>
                                <?php if($admin_res['website']){?> <li><a href="<?=$admin_res['website']?>"><span class="fa fa-globe"></span><?=$admin_res['website']?></a></li><?php  } ?>
                            </ul>
                            <h2 class="contact-title">Get in Touch</h2>
                            <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"><svg viewBox="0 0 24 24" width="15" height="15" fill="currentColor" role="img">

<g>

    <path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z">

    </path>

</g>

</svg></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-lg-7 form_grid">
                            <h3 class="contact-title">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-lg-6 col-md-6 col-sm-6 col-xs-12">
                                        <div class="form-group">
                                            <input tabindex="1" class="form-control" type="text" name="names" placeholder="Your Name*" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                        <div class="form-group">
                                            <input tabindex="2" class="form-control" type="email" name="emails" placeholder="Your Email ID*" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-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" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                        <div class="form-group">
                                            <input class="form-control" type="text" name="locations" placeholder="Location*" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                        <div class="form-group">
                                            <textarea class="form-control" rows="5" placeholder="Comments Here*" required name="messages"></textarea>
                                        </div>
                                    </div>
                                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                        <div class="form-group" style="margin-bottom: 0;">
                                            <div class="g-recaptcha" data-sitekey="6LfgpbghAAAAANHLDpMgpfdCUv0f-96aG_a3qCWV"></div>
                                        </div>
                                    </div>
                                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                        <div class="form-group">
                                            <button tabindex="7" class="read_more_product btn-style-two" type="submit" name="submit-contact" value="Submit" data-submit="...Sending"><span>Submit</span></button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>

                    </div>



                </div>
            </div>
        </section>


        <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3653284.1265861713!2d73.45295067634073!3d26.595274629250405!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3967ef5f2a9fc89f%3A0x7b8b8d008da99c39!2sAarna%20Systems%20And%20Wellness%20Pvt.%20Ltd!5e0!3m2!1sen!2sin!4v1657532135064!5m2!1sen!2sin" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>

        <div class="clearfix"></div>

        <?php include 'components/app_testi_clients.php';?>
        <!-- Footer -->
        <?php include 'components/footer.php';?>
    </div>
    <?php include 'components/bottom_footer.php';?>
    <script>
        jQuery(document).ready(function($) {
            $("#contact_form").validate({
                rules: {
                    name: "required",
                    message: "required",
                    location: "required",
                    email: {
                        required: true,
                        email: true
                    },
                    phone: {
                        required: true,
                        number: true,
                        minlength: 10,
                    }
                },
                messages: {
                    name: "Please enter your name",
                    message: "Please enter message",
                    email: {
                        required: "Please enter your email address"
                    },
                    location: "Please enter your location",
                    phone: {
                        required: "Please enter your mobile no.",
                        number: "Mobile No. contains only numbers",
                        minlength: "Your Mobile No. must be at least 10 characters long",
                    }
                },
            })
        });

    </script>
</body>

</html>
