<?php
//ob_start();
$remote_ip=$_SERVER['REMOTE_ADDR'];
//new//
$url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
function getBrowser() 

{ 
    $u_agent = $_SERVER['HTTP_USER_AGENT'];
    $bname = 'Unknown';
    $platform = 'Unknown';
    $version= "";

    //First get the platform?
    if (preg_match('/linux/i', $u_agent)) {
        $platform = 'linux';
    }
    elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
        $platform = 'mac';
    }
    elseif (preg_match('/windows|win32/i', $u_agent)) {
        $platform = 'windows';
    }

    // Next get the name of the useragent yes seperately and for good reason
    if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) 
    { 
        $bname = 'Internet Explorer'; 
        $ub = "MSIE"; 
    } 
    elseif(preg_match('/Firefox/i',$u_agent)) 
    { 
        $bname = 'Mozilla Firefox'; 
        $ub = "Firefox"; 
    } 
    elseif(preg_match('/Chrome/i',$u_agent)) 
    { 
        $bname = 'Google Chrome'; 
        $ub = "Chrome"; 
    } 
    elseif(preg_match('/Safari/i',$u_agent)) 
    { 
        $bname = 'Apple Safari'; 
        $ub = "Safari"; 
    } 
    elseif(preg_match('/Opera/i',$u_agent)) 
    { 
        $bname = 'Opera'; 
        $ub = "Opera"; 
    } 
    elseif(preg_match('/Netscape/i',$u_agent)) 
    { 
        $bname = 'Netscape'; 
        $ub = "Netscape"; 
    } 

    // finally get the correct version number
    $known = array('Version', $ub, 'other');
    $pattern = '#(?<browser>' . join('|', $known) .
    ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
    if (!preg_match_all($pattern, $u_agent, $matches)) {
        // we have no matching number just continue
    }

    // see how many we have
    $i = count($matches['browser']);
    if ($i != 1) {
        //we will have two since we are not using 'other' argument yet
        //see if version is before or after the name
        if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
            $version= $matches['version'][0];
        }
        else {
            $version= $matches['version'][1];
        }
    }
    else {
        $version= $matches['version'][0];
    }

    // check if we have a number
    if ($version==null || $version=="") {$version="?";}

    return array(
        'userAgent' => $u_agent,
        'name'      => $bname,
        'version'   => $version,
        'platform'  => $platform,
        'pattern'    => $pattern
    );
} 

// now try it
$ua=getBrowser();
$yourbrowser= "Browser : " . $ua['name'] . ", " . $ua['version'] . ", Operating System : " .$ua['platform'] . "<br >" ;
$newletter='<table bgcolor="#f3f3f3" style="width:600px;border:1pt solid #e2e2e2;background:#f3f3f3;font-family:"Open Sans", sans-serif" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:none;padding:0in 15.0pt 0in 15.0pt">
<table style="width:560px" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:none;border-bottom:solid #e2e2e2 1.0pt;padding:9.0pt 0in 9.0pt 0in">
<p style="text-align:center" align="center"><strong><span style="font-size:18.5pt;color:#196ece;text-transform:none">Thank You For Your Enquiry</span></strong></p>
</td>
</tr>
<tr>
<td style="padding:6.0pt 0in 0in 0in">
<p style="margin-bottom:12.0pt;text-align:center"><span style="font-size:15pt;color:#000000">You will receive a reply within 24 hours, except on Sundays and holidays.</span></p>
</td>
</tr>
<tr>
<td style="border:none;border-top:solid #e2e2e2 1.0pt;padding:0in 0in 0in 0in">
<table style="width:560px" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding:0in 0in 0in 0in">
<p><strong><span style="font-size:9.0pt;color:#414141;text-transform:none">Follow us at</span></strong><span style="font-size:10.5pt;color:#414141"><br><a href="https://www.facebook.com/netexpertsindia" target="_blank"><span style="text-decoration:none"><img src="http://netexpertsindia.com/images/fb.gif" alt="Facebook" width="32" height="31" border="0" ></span></a><a href="https://twitter.com/NetExpertsIN" target="_blank"><span style="text-decoration:none"><img src="http://netexpertsindia.com/images/twiter.gif" alt="Twitter" width="32" height="31" border="0" ></span></a><a href="http://www.linkedin.com/company/netexperts-india" target="_blank"><span style="text-decoration:none"><img src="http://netexpertsindia.com/images/linkd.png" alt="Linkedin" width="32" height="31" border="0" ></span></a><a href="https://www.youtube.com/user/netexpertsdelhi" target="_blank"><span style="text-decoration:none"><img src="http://netexpertsindia.com/images/Youtube.png" alt="Youtube" width="32" height="31" border="0" ></span></a></span></p>
</td>

<td style="padding:0in 0in 0in 0in">
<p style="text-align:right" align="right"><a href="http://www.netexpertsindia.com/" target="_blank"><span style="text-decoration:none"><img src="http://netexpertsindia.com/images/logo-color-1.png" alt="netexperts" height="70" border="0" ></span></a></p>
</td>
</tr>
<tr>
<td style="padding:0in 0in 0in 0in" colspan="2">
<p>&nbsp;</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>';
if(isset($_POST['mailsubmit']) )
 {

  $message='';
  
  $message .='<div style="min-height:300px; padding:10px; font-size:12px;">
	<h2 style="margin:0; padding:5px 0 20px; text-transform:none;">CCNA Enquiry LPM</h2>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<br>
  <tr>
    <td width="29%" height="25">Your Name</td>
    <td width="5%" height="25">:</td>
    <td width="66%" height="25"> '.$_POST['name'].'</td>
  </tr>
  <tr>
    <td height="25">Your Email</td>
    <td height="25">:</td>
    <td height="25">'.$_POST['email'].'</td>
  </tr>
    <tr>
    <td height="25">Your Phone Number</td>
    <td height="25">:</td>
    <td height="25">'.$_POST['phone'].'</td>
  </tr>



  <tr>
    <td height="25">You Curse Apply</td>
    <td height="25">:</td>
    <td height="25">'.$_POST['course'].'</td>
  </tr>
  <tr>
    <td height="25">Your Training Mode</td>
    <td height="25">:</td>
    <td height="25">'.$_POST['Training-Mode'].'</td>
  </tr>
  <tr>
    <td height="25">&nbsp;</td>
    <td height="25">&nbsp;</td>
    <td height="25">&nbsp;</td>
  </tr>
</table>
<p>User IP : '.$remote_ip.'</p>
<p>From the URL : '.$url.'</p>
<p>'.$yourbrowser.'</p>
</div>
</div>' ;


   //echo $message; exit;
$subject  = "CCNA Enquiry LPM" ;   
$to = "ads@aptronnoida.in";
//$to = "sajid.aptrontechnologies@gmail.com";
$from     = $_POST['email'] ;

$mail_headers = "MIME-Version: 1.0\n" ;
$mail_headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$mail_headers .= "From: ".$from."\r\n";
$mail_headers .= "Reply-To: ".$from."\n";				
$mail_headers.="X-Priority: 1\r\n". //headers for priority
		       "Priority: Urgent\r\n".
		       "Importance: high";
		  // Mail it
mail($to, $subject, $message, $mail_headers);

/***** Back mail 2*****/
$mail_headers1 = "MIME-Version: 1.0\n" ;
$mail_headers1 .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$mail_headers1 .= "From: APTRON <info@aptronnoida.in>\n";
$mail_headers1.="X-Priority: 1\r\n". //headers for priority
		       "Priority: Urgent\r\n".
		       "Importance: high";
$mail_message1 = '<div>'.$newletter.'</div>';
$mail_subject1="Thank You For Your Enquiry";
		  // Mail it
mail($from, $mail_subject1,$mail_message1,$mail_headers1);
				
				/***** Back mail 2 ends*****/


print_r('<script>');
print_r('self.location= "http://aptronnoida.in/thankyou.html"');
print_r('</script>');
exit();
}

if(isset($_POST['bottomEmail']) )
 {
 
  $message='';
  
  $message .='<div style="min-height:300px; padding:10px; font-size:12px;">
	<h2 style="margin:0; padding:5px 0 20px; text-transform:none;">CCNA Enquiry LPB</h2>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<br>
  <tr>
    <td width="29%" height="25">Name</td>
    <td width="5%" height="25">:</td>
    <td width="66%" height="25"> '.$_POST['name'].'</td>
  </tr>
    <tr>
    <td height="25">Email ID</td>
    <td height="25">:</td>
    <td height="25">'.$_POST['email'].'</td>
  </tr>
      <tr>
    <td height="25">Phone Number</td>
    <td height="25">:</td>
    <td height="25">'.$_POST['phone'].'</td>
  </tr>
  
  <tr>
    <td height="25">&nbsp;</td>
    <td height="25">&nbsp;</td>
    <td height="25">&nbsp;</td>
  </tr>
</table>
<p>User IP : '.$remote_ip.'</p>
<p>From the URL : '.$url.'</p>
<p>'.$yourbrowser.'</p>
</div>
</div>' ;


  // echo $message; exit;
$subject  = "CCNA Enquiry LPB" ;   
$to = "ads@aptronnoida.in";
$from     = $_POST['email'] ;
/* $headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$from."" . "\r\n";

mail($to,$subject,$message,$headers);  */


$mail_headers = "MIME-Version: 1.0\n" ;
$mail_headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$mail_headers .= "From: ".$from."\r\n";
$mail_headers .= "Reply-To: ".$from."\n";					
$mail_headers.="X-Priority: 1\r\n". //headers for priority
		       "Priority: Urgent\r\n".
		       "Importance: high";
		  // Mail it
mail($to, $subject, $message, $mail_headers);

/***** Back mail 2*****/
$mail_headers1 = "MIME-Version: 1.0\n" ;
$mail_headers1 .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$mail_headers1 .= "From: Netexperts <info@aptronnoida.in>\n";
$mail_headers1.="X-Priority: 1\r\n". //headers for priority
		       "Priority: Urgent\r\n".
		       "Importance: high";
$mail_message1 = '<div>'.$newletter.'</div>';
$mail_subject1="Thank You For Your Enquiry";
		  // Mail it
mail($from, $mail_subject1,$mail_message1,$mail_headers1);
				
/***** Back mail 2 ends*****/

print_r('<script>');
print_r('self.location= "http://aptronnoida.in/thankyou.html"');
print_r('</script>');
exit();
}


?>
