Code:
<?php
///////////////////////////////////////
//CCart Pro 2.1b IPN updated version 2
//Licenced Under GPL 2003/////////////
//www.theguitarfiles.com/CC/CallowaysCart
//www.theguitarfiles.com//////////////
///////////////////////////////////////
include "config.php";
////////////////////////////////////////////
///////EDIT the 2 email address below////////
$from_email="hcrc@horror-code.com"; //<-------------Enter your email address here
$reply_email="sales@horror-code.com";//<-------------Enter your reply email address here
////////////////////////////////////////////
///////END EDIT////////
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
$ipn_id = $_POST['ipn_id'];
$txn_id = $_POST['txn_id'];
$item_name1 = $_POST['item_name1'];
$item_name2 = $_POST['item_name2'];
$item_name3 = $_POST['item_name3'];
$item_name4 = $_POST['item_name4'];
$item_name5 = $_POST['item_name5'];
$receiver_email = $_POST['receiver_email'];
$item_number1 = $_POST['item_number1'];
$item_number2 = $_POST['item_number2'];
$item_number3 = $_POST['item_number3'];
$item_number4 = $_POST['item_number4'];
$item_number5 = $_POST['item_number5'];
$payment_status = $_POST['payment_status'];
$payment_type = $_POST['payment_type'];
$payment_gross = $_POST['payment_gross'];
$payment_fee = $_POST['payment_fee'];
$tax = $_POST['tax'];
$pending_reason = $_POST['pending_reason'];
$payer_email = $_POST['payer_email'];
$payer_id = $_POST['payer_id'];
$num_cart_items = $_POST['num_cart_items'];
$quantity1 = $_POST['quantity1'];
$quantity2 = $_POST['quantity2'];
$quantity3 = $_POST['quantity3'];
$quantity4 = $_POST['quantity4'];
$quantity5 = $_POST['quantity5'];
$payment_date = $_POST['payment_date'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address_street = $_POST['address_street'];
$address_city = $_POST['address_city'];
$address_state = $_POST['address_state'];
$address_zip = $_POST['address_zip'];
$address_country = $_POST['address_country'];
$address_status = $_POST['address_status'];
$verify_sign = $_POST['verify_sign'];
$option_name1 = $_POST['option_name1'];
$option_selection1 = $_POST['option_selection1'];
$option_name2 = $_POST['option_name2'];
$option_selection2 = $_POST['option_selection2'];
$memo = $_POST['memo'];
$custom = $_POST['custom'];
$invoice = $_POST['invoice'];
$txn_type = $_POST['txn_type'];
$subscr_id = $_POST['subscr_id'];
$subscr_date = $_POST['subscr_date'];
$subscr_effective = $_POST['subscr_effective'];
$period1 = $_POST['period1'];
$period2 = $_POST['period2'];
$period3 = $_POST['period3'];
$amount1 = $_POST['amount1'];
$amount2 = $_POST['amount2'];
$amount3 = $_POST['amount3'];
$mc_amount1 = $_POST['mc_amount1'];
$mc_amount2 = $_POST['mc_amount2'];
$mc_amount3 = $_POST['mc_amount3'];
$mc_currency = $_POST['mc_currency'];
$mc_gross = $_POST['mc_gross'];
$recurring = $_POST['recurring'];
$recur_times = $_POST['recur_times'];
$password = $_POST['password'];
$username = $_POST['username'];
if (!$fp) {
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$mailbody.="NOTE:This is an automated customer receipt: Please do not reply\n\n";
$mailbody.="=======================================================\n\n";
$mailbody.="Dear $first_name $last_name,\n";
$mailbody.="Thank you for your recent order with us!\n\n";
$mailbody.="Your order will has be processed \n\n";
$mailbody.="If you have any questions, please contact us: $from_email\n\n";
$mailbody.="Customer ID#: $payer_id \n\n";
$mailbody.="Invoice#: $txn_id\n\nDate/Time Of Order:$payment_date\n\nOrder Details:\n\n";
$mailbody.="=======================================================\n\n";
$mailbody.="Product Description: ($item_name1) \n";
$mailbody.="Item #: ($item_number1) \n";
$mailbody.="Quantity: ($quantity1)\n\n";
if ($item_name2==""){
}else{
$mailbody.="Product Description (2): ($item_name2)\n";
$mailbody.="Item #: ($item_number2) \n";
$mailbody.="Quantity: ($quantity2)\n\n";
}
if ($item_name3==""){
}else{
$mailbody.="Product Description (3):($item_name3) \n";
$mailbody.="Item #: ($item_number3) \n";
$mailbody.="Quantity: ($quantity3)\n\n";
}
if ($item_name4==""){
}else{
$mailbody.="Product Description (4):($item_name4) \n";
$mailbody.="Item #: ($item_number4) \n";
$mailbody.="Quantity: ($quantity4)\n\n ";
}
if ($item_name5==""){
}else{
$mailbody.="Product Description (5):($item_name5) \n";
$mailbody.="Item #: ($item_number5) \n";
$mailbody.="Quantity: ($quantity5)\n\n";
}
$mailbody.="=======================================================\n\n";
$mailbody.="Total Products to be shipped:($num_cart_items)\n\n";
$mailbody.="Total Gross Payment=$$payment_gross \n\n";
$mailbody.="Sales Tax=$$tax\n\n";
$mailbody.="=======================================================\n\n";
$mailbody.="Shipping To Address: \n\n $address_street\n $address_city \n $address_state $address_zip\n $address_country \n\n";
$mailbody.="Your Address is : $address_status by Paypal\n\n";
$mailbody.="=======================================================\n\n";
$mailbody.=" Verify ID: $verify_sign\n\n $first_name - Please print this email for your personal records\n\n Thanks again for shopping with us!\n\n";
mail($payer_email, "Thanks for your order", $mailbody, "From: $from_email\nReply-To: $reply_email");
global $db
$resultat_sql = $db->sql_query("INSERT INTO CCart_ipn_orders(ipn_id,
txn_id,
item_name1,
item_name2,
item_name3,
item_name4,
item_name5,
receiver_email,
item_number1,
item_number2,
item_number3,
item_number4,
item_number5,
payment_status,
payment_type,
payment_gross,
payment_fee,
tax,
pending_reason,
payer_email,
payer_id,
num_cart_items,
quantity1,
quantity2,
quantity3,
quantity4,
quantity5,
payment_date,
first_name,
last_name,
address_street,
address_city,
address_state,
address_zip,
address_country,
address_status,
verify_sign,
option_name1,
option_selection1,
option_name2,
option_selection2,
memo,
custom,
invoice,
txn_type,
subscr_id,
subscr_date,
subscr_effective,
period1,
period2,
period3,
amount1,
amount2,
amount3,
mc_amount1,
mc_amount2,
mc_amount3,
mc_currency,
mc_gross,
recurring,
recur_times,
password,
username )
VALUES ('$ipn_id',
'$txn_id',
'$item_name1',
'$item_name2',
'$item_name3',
'$item_name4',
'$item_name5',
'$receiver_email',
'$item_number1',
'$item_number2',
'$item_number3',
'$item_number4',
'$item_number5',
'$payment_status',
'$payment_type',
'$payment_gross',
'$payment_fee',
'$tax',
'$pending_reason',
'$payer_email',
'$payer_id',
'$num_cart_items',
'$quantity1',
'$quantity2',
'$quantity3',
'$quantity4',
'$quantity5',
'$payment_date',
'$first_name',
'$last_name',
'$address_street',
'$address_city',
'$address_state',
'$address_zip',
'$address_country',
'$address_status',
'$verify_sign',
'$option_name1',
'$option_selection1',
'$option_name2',
'$option_selection2',
'$memo',
'$custom',
'$invoice',
'$txn_type',
'$subscr_id',
'$subscr_date',
'$subscr_effective',
'$period1',
'$period2',
'$period3',
'$amount1',
'$amount2',
'$amount3',
'$mc_amount1',
'$mc_amount2',
'$mc_amount3',
'$mc_currency',
'$mc_gross',
'$recurring',
'$recur_times',
'$password',
'$username' )",$db);
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>
|