<?php

define('SITE_URL','http://globalpaymentsinc.wysework.com/');
define('SITE_URL1','http://globalpaymentsinc.wysework.com/');
$sitename="Global Payments Inc.";

include('mailsendclass.php');	
$email_to="test@globalpay.com";
################################################################



if($_POST['ename']!='')// Inner form
{
	$fname=stripslashes($_POST['ename']);  
    $email=stripslashes($_POST['eemail']);
	$phone=stripslashes($_POST['ephone']);
	$company=stripslashes(nl2br($_POST['ecompany']));

	

	$email_fieldname='eemail';
	$phone_fieldname='ephone';


	
	$array=array(
			'ename' 	=> "Name",
			'eemail'    => "Email",
			'ephone'    => "Phone",
			'ecompany' =>"Company",
			
			
	);
	$subject="Get in Touch - " .$sitename;
}
if($_POST['cname']!='')// Inner form
{
	$fname=stripslashes($_POST['cname']);  
    $email=stripslashes($_POST['cemail']);
	$phone=stripslashes($_POST['cphone']);
	$company=stripslashes(nl2br($_POST['ccompany']));

	

	$email_fieldname='cemail';
	$phone_fieldname='cphone';


	
	$array=array(
			'cname' 	=> "Name",
			'cemail'    => "Email",
			'cphone'    => "Phone",
			'ccompany' =>"Company",
			
			
	);
	$subject="GET IN TOUCH - " .$sitename;
}

// echo'<pre>';
// print_r($_POST);
// exit();
$con_subject="Confirmation - " .$sitename;

//Replacing the to, cc and bcc email address if @techwyseintl.com is found STARTS HERE
	$email=stripslashes($email);
	$email_string = strstr($email, "@techwyseintl.com"); //Checking whether email string contains @techwyseintl.com
	$to = ($email_string=="@techwyseintl.com")? stripslashes($email) : $email_to;
	$bcc_email = ($email_string=="@techwyseintl.com")? "" : $email_bcc;
	$cc_email = ($email_string=="@techwyseintl.com")? "" : $email_cc;
//Replacing the to, cc and bcc email address if @techwyseintl.com is found ENDS HERE



if($_POST['xxx']=='hidden_value1')
{
if($_POST['ename']=='' || $_POST['eemail']=='' || $_POST['ephone']=='' || $_POST['ecompany']==''|| $_POST['footer_cap']=='')
{
?>
<script language="javascript">
			alert('Invalid Data. Cannot Proceed.');
			window.location='<?php echo SITE_URL ?>';
			</script>
<?php
exit();		
} 

if(str_replace(' ', '', $_POST['mainCaptcha']) !=$_POST['footer_cap'] ){
	?>
<script language="javascript">
			alert('Invalid Data. Cannot Proceed.');
			window.location='<?php echo SITE_URL ?>';
			</script>
<?php
exit();	
}

}
else if($_POST['yyy']=='form_two')
{

if($_POST['cname']=='' || $_POST['cemail']=='' || $_POST['cphone']=='' || $_POST['ccompany']==''|| $_POST['pop_cap']=='' )
// echo $_POST['cname']." n".
// $_POST['cemail']." n".
// $_POST['cphone']." n".
// $_POST['ccompany']." n".
// $_POST['pop_cap'];
// exit;
{
?>
<script language="javascript">
			alert('Invalid Data. Cannot Proceed.');
			window.location='<?php echo SITE_URL ?>';
			</script>
<?php
exit();		
} 

if(str_replace(' ', '', $_POST['popCaptcha']) !=$_POST['pop_cap'] ){

	?>
<script language="javascript">
			alert('Invalid Data. Cannot Proceed.');
			window.location='<?php echo SITE_URL ?>';
			</script>
<?php
exit();	
}


}
// echo $fname;
// exit();
if($fname!='')
{ 

$obj = new formTempclass();
$obj->name 		            = $fname; // This is mantatory- Field name of name
$obj->email_fieldname 		= $email_fieldname; // This is mantatory- Field name of Email which send to user 
$obj->phone_fieldname 		= $phone_fieldname; // This is mantatory- Field name of Phone  which send to user

$obj->postval_array	        = $array;

$obj->sitename 				= $sitename; //Site Name
$obj->siteurl 				= SITE_URL;  // Site Url 
$obj->mail_banner 			= "http://globalpaymentsinc.wysework.com/mails/images/mail-template.jpg"; // path of mail image 
$obj->rowbgcolor   			= "#fff"; // Bg color of each row
$obj->rowsubtitlebgcolor	= "#023F71"; // Bg color of titles like persoonal Details
$obj->footerbgcolor			= "#023F71";
$obj->footer_txtcolor		= "#fff";
$obj->bordercolor 			= "#000";

$obj->admin_mailto 			= $to;
$obj->admin_bcc_mail		= $bcc_email;
$obj->admin_cc_mail 		= $cc_email;
$obj->admin_subject 		= $subject;
$obj->con_subject			= $con_subject; // Confirmation mail Sublect
$obj->send_to_user          = true;
$obj->AdminmailSend(); 
//--- uncomment for view the tempahtes in browser

$body = $obj->UserTemplate($array);
$bodyadmin = $obj->adminTemplate($array);
/*
echo $body;
echo "<br>";
echo $bodyadmin;exit;
*/

//--- uncomment for view the tempahtes in browser
//--------------------------------------adluge code--------------------------------------
	require_once("clientcenter-api-library.php"); 
	$lead = new clientcenter();
	$lead->client_code="lh1ejc3g4cvjjij"; // Mandatory. Unique identification code.

	$lead->fname=$fname; //post  Value of first name  
	$lead->lname=$lname; //post  Value of first name
	$lead->phone=$phone;//post Value of Phone Number 
	$lead->email=$email;//post  Value of Email addess  
	$lead->other_fields=json_encode($other_fields);//post Value of other_fields 
	$lead->company_name=$company;//post  Value of City 
	$lead->city=$city;//post  Value of City 
	$lead->postalcode=$postalcode;
	$lead->comments=$comments;//post Value of Comments 
	
	$lead->status=1; // No need to change this
	
	//No need to modify any of the below code
	$lead->useragent = $_SERVER['HTTP_USER_AGENT']; //browser properties
	$lead->remote_ip=$_SERVER['REMOTE_ADDR']; //ip address
	$lead->referrer=$_SERVER['HTTP_REFERER'];// page source
	$lead->contact_date=date("Y-m-d h:i:s");
	$lead->search_engine=$_COOKIE['adl_durl'];
	$lead->keyword=$_COOKIE['adl_key'];
	$lead->source=$_COOKIE['adl_camp'];
	$lead->randomnum=$_COOKIE['adl_rand'];
	$lead->adl_ref=$_COOKIE['adl_ref'];
		
	$lead->send_to_adluge=true; // Set to true If you are sending leads to adluge //default true
	$lead->send();
	//echo "thank-you";exit;
//--------------------------------------------------------------------------------------------------

header("location:".SITE_URL."thank-you.html");
}
else
{
	header("location:".SITE_URL);
}
?>
