Thanks 2017-03-21T18:24:23+00:00

[insert_php]
if(!empty($_POST[’email’]) && $_POST[’email’]!=”){

if($_SERVER[‘HTTP_REFERER’]!=’http://code-brew.tech/’ && $_SERVER[‘HTTP_REFERER’]!=’http://code-brew.com/’){

if($_POST[‘ebook_name’] == ‘OnDemand’){

// old API key – 94834717e05d45e98101b0250fa654e4
// new API key – b5131f47a9724e56af62e5721a2cdd88

$ch = curl_init(‘https://api2.autopilothq.com/v1/contact?’);
curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
curl_setopt($ch,CURLOPT_HTTPHEADER,array(‘autopilotapikey: b5131f47a9724e56af62e5721a2cdd88′,’Content-Type: application/json’));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$data2 = ‘{“contact”: {“Email”: “‘.$_POST[’email’].'”}}’;
curl_setopt($ch, CURLOPT_POSTFIELDS, $data2);
$response = curl_exec($ch);
curl_close($ch);

$contact_id = json_decode($response)->contact_id;

$ch = curl_init(‘https://api2.autopilothq.com/v1/trigger/0004/contact/’.$contact_id);
curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
curl_setopt($ch,CURLOPT_HTTPHEADER,array(‘autopilotapikey: b5131f47a9724e56af62e5721a2cdd88′,’Content-Type: application/json’));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
curl_close($ch);

}
elseif($_POST[‘ebook_name’] == “Marketing CookBook”){

$ch = curl_init(‘https://api2.autopilothq.com/v1/contact?’);
curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
curl_setopt($ch,CURLOPT_HTTPHEADER,array(‘autopilotapikey: 94834717e05d45e98101b0250fa654e4′,’Content-Type: application/json’));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$data2 = ‘{“contact”: {“Email”: “‘.$_POST[’email’].'”, “FirstName”:”‘.$_POST[‘uname’].'”}}’;
curl_setopt($ch, CURLOPT_POSTFIELDS, $data2);
$response = curl_exec($ch);
curl_close($ch);

$contact_id = json_decode($response)->contact_id;

$ch = curl_init(‘https://api2.autopilothq.com/v1/trigger/0002/contact/’.$contact_id);
curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
curl_setopt($ch,CURLOPT_HTTPHEADER,array(‘autopilotapikey: 94834717e05d45e98101b0250fa654e4′,’Content-Type: application/json’));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
curl_close($ch);

}

mysql_connect(‘localhost’,’root’,’core2duo’);
mysql_select_db(‘codebrew’);
$sql = “insert into ebook_users(email,name,ebook_name,referrer,ip_address,status)values(‘”.mysql_escape_string($_POST[’email’]).”‘,'”.mysql_escape_string($_POST[‘uname’]).”‘,'”.mysql_escape_string($_POST[‘ebook_name’]).”‘,'”.mysql_escape_string($_SERVER[‘HTTP_REFERER’]).”‘, ‘”.mysql_escape_string($_SERVER[‘REMOTE_ADDR’]).”‘,’0’)”;
$res = mysql_query($sql);
}else{

mysql_connect(‘localhost’,’root’,’core2duo’);
mysql_select_db(‘codebrew’);
$sql = “insert into ebook_users(email,name,ebook_name,referrer,ip_address,status)values(‘”.mysql_escape_string($_POST[’email’]).”‘,'”.mysql_escape_string($_POST[‘uname’]).”‘,'”.mysql_escape_string($_POST[‘ebook_name’]).”‘,'”.mysql_escape_string($_SERVER[‘HTTP_REFERER’]).”‘, ‘”.mysql_escape_string($_SERVER[‘REMOTE_ADDR’]).”‘,’1’)”;
$res = mysql_query($sql);
}

if($_POST[‘ebook_name’] == ‘OnDemand’)
header(‘Location: https://www.code-brew.com/on-demand.pdf’);
elseif($_POST[‘ebook_name’] == “Marketing CookBook”)
header(‘Location: https://www.code-brew.com/appreneur_marketing_cook_book.pdf’);

exit();

/*header(‘Content-type: application/pdf’);
header(‘Content-disposition: attachment; filename=on-demand.pdf’);
readfile(“on-demand.pdf”);*/

/*$pdfname = “on-demand.pdf”;
$file_url = “https://www.code-brew.com/on-demand.pdf”;
header(‘Content-Type: application/pdf’);
header(“Content-Transfer-Encoding: Binary”);
header(“Content-disposition: attachment; filename=”.$pdfname);
readfile($file_url);*/

/*$pdfname = “OnDemand.pdf”;
$file_url = “https://www.code-brew.com/on-demand.pdf”;
header(‘Content-Type: application/pdf’);
header(“Content-Transfer-Encoding: Binary”);
header(“Content-disposition: attachment; filename=”.$pdfname);
readfile($file_url);*/

/*ob_start();
$file = ‘https://www.code-brew.com/on-demand.pdf’;

if (file_exists($file))
{
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename=’.basename($file));
header(‘Content-Transfer-Encoding: binary’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate’);
header(‘Pragma: public’);
header(‘Content-Length: ‘ . filesize($file));
ob_clean();
flush();
readfile($file);
exit();
}*/
}
[/insert_php]