Hi Simon, oh i see it now! how to apply the changes? Can you help me with this? Which one to change exactly in this file?
P.s. still waiting for your pm reply btw :/ the files
PHP Code:
<?php /* AWCoding Back-End created by AWNetwork, Inc., Version 4.0.0, PayPal Method File, Copyright 2010 all rights reserved */
class paypal {
function test( $sid ){
global $vbulletin;
$communication = false;
$query = 'cmd=_notify-validate';
if ( !$communication ){
if ( $vbulletin->options[$sid.'_paypal_test'] == 1 ){
$domain = "www.sandbox.paypal.com";
} else {
$domain = "www.paypal.com";
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Host: $domain\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen( $query )."\r\n\r\n";
if ( $fp = fsockopen( $domain, 80, $errno, $errstr, 15 ) ){
socket_set_timeout( $fp, 10 );
fwrite( $fp, $header.$query );
while ( !feof( $fp ) ){
$result = fgets( $fp, 1024 );
if ( strcmp( $result, 'INVALID' ) == 0 ){
$communication = true;
break;
}
}
fclose( $fp );
}
if ( !$communication ){
if ( $vbulletin->options[$sid.'_paypal_test'] == 1 ){
$domain = "ssl://www.sandbox.paypal.com";
$host = 'www.sandbox.paypal.com';
} else {
$domain = "ssl://www.paypal.com";
$host = 'www.paypal.com';
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Host: $domain\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen( $query )."\r\n\r\n";
if ( $fp = fsockopen( $domain, 443, $errno, $errstr, 15 ) ){
socket_set_timeout( $fp, 10 );
fwrite( $fp, $header.$query );
while ( !feof( $fp ) ){
$result = fgets( $fp, 1024 );
if ( strcmp( $result, 'INVALID' ) == 0 ){
$communication = true;
break;
}
}
fclose( $fp );
}
}
if ( !$communication ){
if ( $vbulletin->options[$sid.'_paypal_test'] == 1 ){
$domain = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$domain = "https://www.paypal.com/cgi-bin/webscr";
}
$ch = curl_init();
curl_setopt ( $ch, CURLOPT_URL, $domain );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 15 );
curl_setopt ( $ch, CURLOPT_POST, true );
curl_setopt ( $ch, CURLOPT_POSTFIELDSIZE, 0 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, Array( "Content-Type: application/x-www-form-urlencoded", "Content-Length: ".strlen( $req ) ) );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
$result = curl_exec( $ch );
curl_close( $ch );
if ( $result !== false ){
$communication = true;
}
}
if ( !$communication ){
if ( $vbulletin->options[$sid.'_paypal_test'] == 1 ){
$domain = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$domain = "https://www.paypal.com/cgi-bin/webscr";
}
$ch = curl_init();
curl_setopt ( $ch, CURLOPT_URL, $domain );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 15 );
curl_setopt ( $ch, CURLOPT_POST, true );
curl_setopt ( $ch, CURLOPT_POSTFIELDSIZE, 0 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, Array( "Content-Type: application/x-www-form-urlencoded", "Content-Length: ".strlen( $req ) ) );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt ( $ch, CURLOPT_HTTPPROXYTUNNEL, TRUE );
curl_setopt ( $ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP );
curl_setopt ( $ch, CURLOPT_PROXY, "http://proxy.shr.secureserver.net:3128" );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
$result = curl_exec( $ch );
curl_close( $ch );
if ( $result !== false ){
$communication = true;
}
}
}
return ( !empty( $vbulletin->options[$sid.'_paypal_email'] ) AND $communication );
}
function add( $pid ){
global $vbulletin, $vbphrase, $AWC, $BASE, $TRANS;
$AWC['IN']['mc_gross'] = $AWC['IN']['amt'];
$AWC['IN']['mc_fee'] = '0';
$AWC['IN']['payment_status'] = 'Unconfirmed';
$AWC['IN']['txn_id'] = $pid;
unset( $AWC['IN']['amt'], $AWC['IN']['do'] );
$db_string = null;
$db_string = $BASE->compile_db_insert_string( $AWC['IN'] );
$vbulletin->db->query_write("
INSERT INTO `".TABLE_PREFIX."awc_payments`
(".$db_string['FIELD_NAMES'].")
VALUES
(".$db_string['FIELD_VALUES'].")
");
if ( $vbulletin->options['awc_ns_en'] ){
if ( $vbulletin->options['awc_ns_tn_en'] ){
$msg_rec_ids = explode( ",", $vbulletin->options['awc_ns_tn_rec'] );
foreach ( $msg_rec_ids AS $msg_rec_id ){
$TRANS->notify_send( 'new', $msg_rec_id );
}
}
if ( $AWC['IN']['userid'] > 0 && $vbulletin->options['awc_ns_ts_en'] ){
$TRANS->notify_send( 'status', $AWC['IN']['userid'] );
}
}
}
function verify( $pid ){
global $vbulletin, $vbphrase, $AWC, $BASE, $TRANS;
//if ($AWC['IN']['receiver_email']===$vbulletin->options[$AWC['IN']['sid'].'_paypal_email'] || $vbulletin->options[$AWC['IN']['sid'].'_paypal_bypass']){
if ( $AWC['IN']['txn_type'] = 'subscr_signup' ){
$AWC['IN']['payment_status'] = 'Completed';
$AWC['IN']['mc_gross'] = $AWC['IN']['mc_amount3'];
}
unset( $AWC['IN']['do'] );
$items = array();
( $hook = vBulletinHook::fetch_hook( 'awc_payment_methods' ) ) ? eval( $hook ) : false;
if ( in_array( $AWC['IN']['item_number'], $items ) ){
//if ($TRANS->var_check('payment_status','Pending') || $TRANS->var_check('payment_status','Processed') || $TRANS->var_check('payment_status','Completed')){
if ( $AWC['IN']['payment_status'] == 'Completed' ){
$payment_sql = $vbulletin->db->query_read("
SELECT txn_id
FROM `".TABLE_PREFIX."awc_payments`
WHERE txn_id = '".$pid."'
");
if ( $vbulletin->db->num_rows( $payment_sql ) == 0 ){
$db_string = null;
$db_string = $BASE->compile_db_insert_string( $AWC['IN'] );
$vbulletin->db->query_write("
INSERT INTO `".TABLE_PREFIX."awc_payments`
(".$db_string['FIELD_NAMES'].")
VALUES
(".$db_string['FIELD_VALUES'].")
");
$AWC['IN']['id'] = $vbulletin->db->insert_id();
} else {
$db_string = null;
$db_string = $BASE->compile_db_update_string( $AWC['IN'] );
$vbulletin->db->query_write("
UPDATE `".TABLE_PREFIX."awc_payments`
SET ".$db_string."
WHERE txn_id = '".$pid."'
");
}
if ( $AWC['IN']['payment_status'] == 'Completed' && $AWC['IN']['userid'] > 0 ){
$TRANS->updates();
}
if ( $vbulletin->options['awc_ns_en'] ){
if ( $vbulletin->options['awc_ns_tn_en'] ){
$msg_rec_ids = explode( ",", $vbulletin->options['awc_ns_tn_rec'] );
foreach ( $msg_rec_ids AS $msg_rec_id ){
$TRANS->notify_send( 'new', $msg_rec_id );
}
}
if ( $AWC['IN']['userid'] > 0 ){
if ( $AWC['IN']['payment_status'] == 'Completed' ){
if ( $vbulletin->options['awc_ns_tt_en'] ){
$TRANS->notify_send( 'thanks', $AWC['IN']['userid'] );
}
} else {
if ( $vbulletin->options['awc_ns_ts_en'] ){
$TRANS->notify_send( 'status', $AWC['IN']['userid'] );
}
}
}
}
}
}
//}
}
function process($postipn){
global $vbulletin, $vbphrase, $AWC, $BASE, $TRANS;
header( "Status: 200 OK" );
if ( !isset( $AWC['IN']['ipnkey'] ) || $AWC['IN']['ipnkey'] != $vbulletin->options[$AWC['IN']['sid'].'_paypal_ipnkey'] ){
if ( $vbulletin->options[$AWC['IN']['sid'].'_paypal_test'] == 1 ){
$domain = "ssl://www.sandbox.paypal.com";
$host = 'www.sandbox.paypal.com';
} else {
$domain = "ssl://www.paypal.com";
$host = 'www.paypal.com';
}
set_time_limit( 60 );
$socket = fsockopen( $domain, "443", $errno, $errstr, 30 );
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "User-Agent: PHP/".phpversion()."\r\n";
$header .= "Referer: ".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].$_SERVER['QUERY_STRING']."\r\n";
$header .= "Server: ".$_SERVER['SERVER_SOFTWARE']."\r\n";
$header .= "Host: ".$host."\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen( $postipn )."\r\n";
$header .= "Accept: */*\r\n\r\n";
if ( !$socket ){
if ( phpversion() >= '4.3.0' && function_exists( 'file_get_contents' ) ){
} else {
function file_get_contents( $ipnget ){
$ipnget = file( $ipnget );
return $ipnget[0];
}
}
$response = file_get_contents( $domain.':443/cgi-bin/webscr?'.$postipn );
} else {
fputs ( $socket, $header.$postipn."\r\n\r\n" );
while ( !feof( $socket ) ){
$response = fgets( $socket, 1024 );
}
}
$response = trim( $response );
if ( strcmp( $response, "VERIFIED" ) && strcmp( $response, "INVALID" ) ){
if ( $vbulletin->options[$AWC['IN']['sid'].'_paypal_test'] == 1 ){
$domain = "www.sandbox.paypal.com";
} else {
$domain = "www.paypal.com";
}
set_time_limit( 60 );
$socket = fsockopen( $domain, "80", $errno, $errstr, 30 );
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "User-Agent: PHP/".phpversion()."\r\n";
$header .= "Referer: ".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].$_SERVER['QUERY_STRING']."\r\n";
$header .= "Server: ".$_SERVER['SERVER_SOFTWARE']."\r\n";
$header .= "Host: ".$domain."\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen( $postipn )."\r\n";
$header .= "Accept: */*\r\n\r\n";
if ( !$socket ){
if ( phpversion() >= '4.3.0' && function_exists( 'file_get_contents' ) ){
} else {
function file_get_contents( $ipnget ){
$ipnget = file( $ipnget );
return $ipnget[0];
}
}
$response = file_get_contents( 'http://'.$domain.':80/cgi-bin/webscr?'.$postipn );
} else {
fputs ( $socket, $header.$postipn."\r\n\r\n" );
while ( !feof( $socket ) ){
$response = fgets( $socket, 1024 );
}
}
$response = trim( $response );
}
if ( strcmp( $response, "VERIFIED" ) && strcmp( $response, "INVALID" ) ){
if ( $vbulletin->options[$AWC['IN']['sid'].'_paypal_test'] == 1 ){
$domain = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$domain = "https://www.paypal.com/cgi-bin/webscr";
}
$response = $curl_err = '';
$ch = curl_init();
curl_setopt ( $ch, CURLOPT_URL, $domain );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, Array( "Content-Type: application/x-www-form-urlencoded", "Content-Length: ".strlen( $req ) ) );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $ch, CURLOPT_URL, $domain );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 15 );
$response = @curl_exec( $ch );
$curl_err = curl_error( $ch );
curl_close( $ch );
}
if ( strcmp( $response, "VERIFIED" ) && strcmp( $response, "INVALID" ) ){
if ( $vbulletin->options[$AWC['IN']['sid'].'_paypal_test'] == 1 ){
$domain = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$domain = "https://www.paypal.com/cgi-bin/webscr";
}
$response = $curl_err = '';
$ch = curl_init();
curl_setopt ( $ch, CURLOPT_URL, $domain );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, Array( "Content-Type: application/x-www-form-urlencoded", "Content-Length: ".strlen( $req ) ) );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt ( $ch, CURLOPT_HTTPPROXYTUNNEL, TRUE );
curl_setopt ( $ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP );
curl_setopt ( $ch, CURLOPT_PROXY, "http://proxy.shr.secureserver.net:3128" );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $ch, CURLOPT_URL, $domain );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 15 );
$response = @curl_exec( $ch );
$curl_err = curl_error( $ch );
curl_close( $ch );
}
} else {
unset( $AWC['IN']['ipnkey'] );
$response = "VERIFIED";
}
if ( !strcmp( $response, "VERIFIED" ) ){
//if ($AWC['IN']['receiver_email']===$vbulletin->options[$AWC['IN']['sid'].'_paypal_email'] || $vbulletin->options[$AWC['IN']['sid'].'_paypal_bypass']){
unset( $AWC['IN']['do'], $AWC['IN']['currency_code'] );
$items = array();
( $hook = vBulletinHook::fetch_hook( 'awc_payment_methods' ) ) ? eval( $hook ) : false;
if ( in_array( $AWC['IN']['item_number'], $items ) ){
if ( $TRANS->var_check( 'payment_status', 'Pending' ) || $TRANS->var_check( 'payment_status', 'Processed' ) || $TRANS->var_check( 'payment_status', 'Completed' ) || $TRANS->var_check( 'payment_status', 'Canceled-Reversal' ) || $TRANS->var_check( 'payment_status', 'Refunded' ) || $TRANS->var_check( 'payment_status', 'Reversed' ) || $TRANS->var_check( 'payment_status', 'Denied' ) || $TRANS->var_check( 'payment_status', 'Failed' ) ){
if ( $TRANS->var_check( 'payment_status', 'Canceled-Reversal' ) ){
$AWC['IN']['txn_id'] = $AWC['IN']['parent_txn_id'];
$AWC['IN']['payment_status'] = 'Completed';
}
if ( $TRANS->var_check( 'payment_status', 'Refunded' ) || $TRANS->var_check( 'payment_status', 'Reversed' ) ){
$AWC['IN']['txn_id'] = $AWC['IN']['parent_txn_id'];
}
if ( $TRANS->var_check( 'payment_status', 'Pending' ) && $vbulletin->options[$AWC['IN']['sid'].'_paypal_approve_pending'] ){
$AWC['IN']['payment_status'] = 'Completed';
}
$payment_sql = $vbulletin->db->query_read("
SELECT txn_id
FROM `".TABLE_PREFIX."awc_payments`
WHERE txn_id = '".$AWC['IN']['txn_id']."'
");
if ( $vbulletin->db->num_rows( $payment_sql ) == 0 && $TRANS->var_check( 'payment_status', 'Refunded' ) === 0 && $TRANS->var_check( 'payment_status', 'Reversed' ) === 0 && $TRANS->var_check( 'payment_status', 'Denied' ) === 0 && $TRANS->var_check( 'payment_status', 'Failed' ) === 0 ){
$db_string = null;
$db_string = $BASE->compile_db_insert_string( $AWC['IN'] );
$vbulletin->db->query_write("
INSERT INTO `".TABLE_PREFIX."awc_payments`
(".$db_string['FIELD_NAMES'].")
VALUES
(".$db_string['FIELD_VALUES'].")
");
$AWC['IN']['id'] = $vbulletin->db->insert_id();
if ( $TRANS->var_check( 'payment_status', 'Completed' ) && $AWC['IN']['userid'] > 0 ){
$TRANS->updates();
}
if ( $vbulletin->options['awc_ns_en'] ){
if ( $vbulletin->options['awc_ns_tn_en'] ){
$msg_rec_ids = explode( ",", $vbulletin->options['awc_ns_tn_rec'] );
foreach ( $msg_rec_ids AS $msg_rec_id ){
$TRANS->notify_send( 'new', $msg_rec_id );
}
}
if ( $AWC['IN']['userid'] > 0 ){
if ( $TRANS->var_check( 'payment_status', 'Completed' ) ){
if ( $vbulletin->options['awc_ns_tt_en'] ){
$TRANS->notify_send( 'thanks', $AWC['IN']['userid'] );
}
} else {
if ( $vbulletin->options['awc_ns_ts_en'] ){
$TRANS->notify_send( 'status', $AWC['IN']['userid'] );
}
}
}
}
} else {
if ( $TRANS->var_check( 'payment_status', 'Refunded' ) || $TRANS->var_check( 'payment_status', 'Reversed' ) || $TRANS->var_check( 'payment_status', 'Denied' ) || $TRANS->var_check( 'payment_status', 'Failed' ) ){
$awc_delete_user = 0;
$payment_info = $AWC['IN'];
if ( !empty( $payment_info ) ){
if ( empty( $payment_info['mc_fee'] ) ){
$payment_info['mc_fee'] = 0;
}
if ( empty( $payment_info['mc_gross'] ) ){
$payment_info['mc_gross'] = 0;
}
$last_payment_sql = $vbulletin->db->query_read("
SELECT payment_date
FROM `".TABLE_PREFIX."awc_payments`
WHERE userid = ".$payment_info['userid']."
AND sid = '".$payment_info['sid']."'
AND ( txn_id <> '".$AWC['IN']['txn_id']."' || txn_id IS NULL )
ORDER BY payment_date DESC
LIMIT 0,1
");
if ( $vbulletin->db->num_rows( $last_payment_sql ) ){
$last_payment_info = $vbulletin->db->fetch_array( $last_payment_sql );
if ( empty( $payment_info['mc_fee'] ) ){
$payment_info['mc_fee'] = 0;
}
if ( empty( $payment_info['mc_gross'] ) ){
$payment_info['mc_gross'] = 0;
}
$vbulletin->db->query_write("
UPDATE `".TABLE_PREFIX."awc_users`
SET ugp_time = ".$last_payment_info['payment_date'].", total = total - ".$payment_info['mc_gross'].", fees = fees - ".$payment_info['mc_fee'].", times = times - 1
WHERE userid = ".$payment_info['userid']."
AND sid = '".$payment_info['sid']."'
");
if ( date( 'my', time() ) == date( 'my', $payment_info['payment_date'] ) ){
$vbulletin->db->query_write("
UPDATE `".TABLE_PREFIX."awc_users`
SET mtotal = mtotal - ".$payment_info['mc_gross'].", mfees = mfees - ".$payment_info['mc_fee'].", mtimes = mtimes - 1
WHERE userid = ".$payment_info['userid']."
AND sid = '".$payment_info['sid']."'
");
}
if ( date( 'y', time() ) == date( 'y', $payment_info['payment_date'] ) ){
$vbulletin->db->query_write("
UPDATE `".TABLE_PREFIX."awc_users`
SET ytotal = ytotal - ".$payment_info['mc_gross'].", yfees = yfees - ".$payment_info['mc_fee'].", ytimes = ytimes - 1
WHERE userid = ".$payment_info['userid']."
AND sid = '".$payment_info['sid']."'
");
}
} else {
$awc_delete_user = 1;
}
( $hook = vBulletinHook::fetch_hook( 'awc_admin_transdelete' ) ) ? eval( $hook ) : false;
}