$Date: 2007-09-19 15:37:29 -0400 (Wed, 19 Sep 2007) $ | > $Revision: 1107 $ | > $Author: bfarber $ +--------------------------------------------------------------------------- | | > Glue between IPB and Payment modules | > Module written by Matt Mecham | > Date started: Wednesday 31st March 2005 (15:23) | +-------------------------------------------------------------------------- */ if ( ! defined( 'IN_IPB' ) ) { print "
"; print_r( $this->results ); print ""; } //-------------------------------------- // Got a member? //-------------------------------------- if ( ! $this->member['id'] ) { $this->do_log("{$this->class_gateway->i_am}: Could not locate a member id to upgrade"); if ( $this->class_gateway->no_postback ) { $this->ipsclass->boink_it( GW_URL_PAYDONE ); } else { $this->class_gateway->core_print_status_message(); } exit(); } //-------------------------------------- // Got a new subs package? //-------------------------------------- $this->new_sub = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'subscriptions', 'where' => 'sub_id='.intval($this->results['purchase_package_id']) ) ); if ( ! $this->new_sub['sub_id'] ) { $this->do_log("{$this->class_gateway->i_am}: Tried to return validate but failed: No start sub package found"); if ( $this->class_gateway->no_postback ) { $this->ipsclass->boink_it( GW_URL_PAYDONE ); } else { $this->class_gateway->core_print_status_message(); } } //-------------------------------------- // Check for txn_id - if already used, this // is a dupe from a repeated form submit //-------------------------------------- $this->trans = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'subtrans_id', 'from' => 'subscription_trans', 'where' => "subtrans_trxid='".addslashes($this->results['transaction_id'])."'" ) ); if ( $this->trans['subtrans_id'] ) { //-------------------------------------- // Is this a reversal? //-------------------------------------- if ( $this->results['payment_status'] == 'REFUND' OR $this->results['payment_status'] == 'CANCEL' ) { //----------------------------- // Update trans for the refund //----------------------------- $this->ipsclass->DB->do_update( 'subscription_trans', array( 'subtrans_state' => "failed" ), "subtrans_id={$this->trans['subtrans_id']}" ); $this->do_failed_member($this->new_sub, $this->member, $this->trans['subtrans_id']); //----------------------------- // Write Log //----------------------------- $this->do_log("{$this->class_gateway->i_am}: Reversal / Subscription cancellation completed"); if ( $this->class_gateway->no_postback ) { $this->ipsclass->boink_it( GW_URL_PAYDONE ); } else { $this->class_gateway->core_print_status_message(); } exit(); } else { $this->do_log("{$this->class_gateway->i_am}: Duplicate transaction ID - failing and exiting transaction"); if ( $this->class_gateway->no_postback ) { $this->ipsclass->boink_it( GW_URL_PAYDONE ); } else { $this->class_gateway->core_print_status_message(); } exit(); } } //-------------------------------------- // UPGRADE //-------------------------------------- if ( $this->results['current_package_id'] > 0 ) { //-------------------------------------- // Get current details //-------------------------------------- $this->cur_details = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'subscription_trans', 'where' => 'subtrans_member_id='.intval($this->member['id']) . ' AND subtrans_state="paid" AND subtrans_sub_id='.$this->results['current_package_id']) ); //-------------------------------------- // Check //-------------------------------------- if ( ! $this->cur_details['subtrans_id'] ) { $this->do_log("{$this->class_gateway->i_am}: Tried to return validate but failed: Upgrade, but no original package found"); } if ( $this->results['currency_code'] != $pay_method['sub_use_currency'] ) { $this->do_log("{$this->class_gateway->i_am}: Tried to return validate but failed: Wrong currency ({$this->results['currency_code']})"); } //-------------------------------------- // What to do... //-------------------------------------- if ( $this->results['payment_status'] == 'RECURRING' ) { $this->_process_recurring_upgrade( $pay_method ); } else if ( $this->results['payment_status'] == 'ONEOFF' ) { $this->_process_normal_upgrade( $pay_method ); } else { $this->do_log("{$this->class_gateway->i_am}: Subscription Start. Unknown trx_type: {$_POST['txn_type']}"); } } //-------------------------------------- // NON-UPGRADE //-------------------------------------- else { if ( $this->results['currency_code'] != $pay_method['submethod_use_currency'] ) { $this->do_log("{$this->class_gateway->i_am}: Tried to return validate but failed: Wrong currency ($this->results['currency_code'])"); } if ( $this->results['payment_status'] == 'RECURRING' ) { $this->_process_recurring( $pay_method ); } else if ( $this->results['payment_status'] == 'ONEOFF' ) { $this->_process_normal( $pay_method ); } } if ( $this->class_gateway->no_postback ) { $this->ipsclass->boink_it( GW_URL_PAYDONE ); } else { $this->class_gateway->core_print_status_message(); } exit(); } /*-------------------------------------------------------------------------*/ // Process normal upgrade /*-------------------------------------------------------------------------*/ function _process_normal_upgrade( $pay_method ) { //-------------------------------------- // SUBSCRIPTION //-------------------------------------- $balance = ( $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ) - $this->cur_details['subtrans_paid']; $this->new_sub['sub_cost'] = $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']; $results = $this->class_gateway->gw_do_normal_payment_check( sprintf( "%.2f", $balance ), sprintf( "%.2f", $this->new_sub['sub_cost'] ), $this->cur_details['subtrans_id'] ); if ( $this->class_gateway->error ) { //-------------------------------------- // Log and exit //-------------------------------------- $this->do_log( "{$this->class_gateway->i_am}: ".$this->class_gateway->error ); exit(); } $this->existing_sub = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'subscriptions', 'where' => 'sub_id='.intval($this->cur_details['subtrans_sub_id']) ) ); //-------------------------------------- // Update subscription //-------------------------------------- $this->update['subtrans_paid'] = $results['amount_paid'] * $this->def_currency['subcurrency_exchange']; $this->update['subtrans_trxid'] = $this->results['transaction_id']; $this->update['subtrans_sub_id'] = $this->new_sub['sub_id']; $this->update['subtrans_subscrid'] = $this->results['subscription_id']; $this->update['subtrans_state'] = strtolower( $results['state'] ); //-------------------------------------- // Deal with lifetime subs //-------------------------------------- if ( $this->new_sub['sub_unit'] == 'x' ) { $this->update['subtrans_end_date'] = 9999999999; } //-------------------------------------- // Else increase their sub //-------------------------------------- else { $this->update['subtrans_end_date'] = $this->cur_details['subtrans_end_date'] + ( $this->new_sub['sub_length'] * $this->day_to_seconds[ $this->new_sub['sub_unit'] ] ); $this->update['subtrans_end_date'] -= ($this->existing_sub['sub_length'] * $this->day_to_seconds[ $this->existing_sub['sub_unit'] ] ); } //-------------------------------------- // Update DB //-------------------------------------- if ( $this->update['subtrans_paid'] > 0.00 ) { $this->update['subtrans_cumulative'] = $this->cur_details['subtrans_cumulative'] + $this->update['subtrans_paid']; } $this->ipsclass->DB->do_update( 'subscription_trans', $this->update, "subtrans_id=".$this->cur_details['subtrans_id'] ); //-------------------------------------- // UPDATE MEMBER //-------------------------------------- if ( $this->update['subtrans_state'] == 'paid' ) { $this->do_paid_member($this->new_sub, $this->member, $this->cur_details['subtrans_id']); } else { $this->do_failed_member($this->new_sub, $this->member, $this->cur_details['subtrans_id']); } $this->do_log("{$this->class_gateway->i_am}: Subscription upgrade (one off payment). Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } /*-------------------------------------------------------------------------*/ // Process recurring upgrade /*-------------------------------------------------------------------------*/ function _process_recurring_upgrade( $pay_method ) { //-------------------------------------- // SUBSCRIPTION //-------------------------------------- $balance = ( $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ) - $this->cur_details['subtrans_paid']; $this->new_sub['sub_cost'] = $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']; $results = $this->class_gateway->gw_do_recurring_payment_check( sprintf( "%.2f", $balance ), sprintf( "%.2f", $this->new_sub['sub_cost'] ) ); if ( $this->class_gateway->error ) { //-------------------------------------- // Log and exit //-------------------------------------- $this->do_log( "{$this->class_gateway->i_am}: ".$this->class_gateway->error ); exit(); } $this->existing_sub = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'subscriptions', 'where' => 'sub_id='.intval($this->cur_details['subtrans_sub_id']) ) ); //-------------------------------------- // Update subscription //-------------------------------------- $this->update['subtrans_paid'] = $results['amount_paid'] * $this->def_currency['subcurrency_exchange']; $this->update['subtrans_trxid'] = $this->results['transaction_id']; $this->update['subtrans_sub_id'] = $this->new_sub['sub_id']; $this->update['subtrans_subscrid'] = $this->results['subscription_id']; $this->update['subtrans_state'] = strtolower( $results['state'] ); //-------------------------------------- // Deal with lifetime subs //-------------------------------------- if ( $this->new_sub['sub_unit'] == 'x' ) { $this->update['subtrans_end_date'] = 9999999999; } //-------------------------------------- // Else increase their sub //-------------------------------------- else { $this->update['subtrans_end_date'] = $this->cur_details['subtrans_end_date'] + ( $this->new_sub['sub_length'] * $this->day_to_seconds[ $this->new_sub['sub_unit'] ] ); $this->update['subtrans_end_date'] -= ($this->existing_sub['sub_length'] * $this->day_to_seconds[ $this->existing_sub['sub_unit'] ] ); } //-------------------------------------- // Update DB //-------------------------------------- if ( $this->update['subtrans_paid'] > 0.00 ) { $this->update['subtrans_cumulative'] = $this->cur_details['subtrans_cumulative'] + $this->update['subtrans_paid']; } $this->ipsclass->DB->do_update( 'subscription_trans', $this->update, "subtrans_id=".$this->cur_details['subtrans_id'] ); //-------------------------------------- // UPDATE MEMBERS //-------------------------------------- if ( $this->update['subtrans_state'] == 'paid' ) { $this->do_paid_member($this->new_sub, $this->member, $this->cur_details['subtrans_id']); } else { $this->do_failed_member($this->new_sub, $this->member, $this->cur_details['subtrans_id']); } $this->do_log("{$this->class_gateway->i_am}: Subscription upgrade. Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } /*-------------------------------------------------------------------------*/ // Process normal NON UPGRADE /*-------------------------------------------------------------------------*/ function _process_normal( $pay_method ) { //-------------------------------------- // SUBSCRIPTION //-------------------------------------- $balance = ( $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ) - $this->cur_details['subtrans_paid']; $this->new_sub['sub_cost'] = $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']; $results = $this->class_gateway->gw_do_normal_payment_check( sprintf( "%.2f", $balance ), sprintf( "%.2f", $this->new_sub['sub_cost'] ), $this->cur_details['subtrans_id'] ); if ( $this->class_gateway->error ) { //-------------------------------------- // Log and exit //-------------------------------------- $this->do_log( "{$this->class_gateway->i_am}: ".$this->class_gateway->error ); exit(); } //-------------------------------------- // Does the verification key match? //-------------------------------------- if( $this->results['verification'] != md5( intval($this->member['id']) . $this->results['purchase_package_id'] . $this->ipsclass->vars['sql_pass'] ) ) { $this->do_log( "{$this->class_gateway->i_am}: Unable to verify payment - verification key mismatch" ); exit(); } //-------------------------------------- // Update subscription //-------------------------------------- $old_group = ($this->new_sub[ 'sub_new_group' ] > 0) ? $this->member['mgroup'] : 0; $this->update['subtrans_paid'] = $results['amount_paid'] * $this->def_currency['subcurrency_exchange']; $this->update['subtrans_trxid'] = $this->results['transaction_id']; $this->update['subtrans_sub_id'] = $this->new_sub['sub_id']; $this->update['subtrans_subscrid'] = $this->results['subscription_id']; $this->update['subtrans_state'] = strtolower( $results['state'] ); $this->update['subtrans_cumulative'] = $this->update['subtrans_paid']; $this->update['subtrans_member_id'] = $this->member['id']; $this->update['subtrans_old_group'] = $old_group; $this->update['subtrans_start_date'] = time(); //-------------------------------------- // Deal with lifetime subs //-------------------------------------- if ( $this->new_sub['sub_unit'] == 'x' ) { $this->update['subtrans_end_date'] = 9999999999; } else { $this->update['subtrans_end_date'] = time() + ( $this->new_sub['sub_length'] * $this->day_to_seconds[ $this->new_sub['sub_unit'] ] ); } //-------------------------------------- // Just updating a subscription //-------------------------------------- if ( $this->results['current_package_id'] ) { $subid = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'subscription_trans', 'where' => "subtrans_sub_id={$this->new_sub['sub_id']} and subtrans_state='pending'" ) ); if ( $subid['subtrans_id'] ) { //-------------------------------------- // Okay, existing subscription we're updating, so... //-------------------------------------- unset($this->update['subtrans_start_date']); unset($this->update['subtrans_end_date']); unset($this->update['subtrans_old_group']); unset($this->update['subtrans_cumulative']); $this->ipsclass->DB->do_update( 'subscription_trans', $this->update, "subtrans_subscrid='".addslashes($this->update['subtrans_subscrid'])."'" ); } } else { $this->ipsclass->DB->do_insert( 'subscription_trans', $this->update ); $newid = $this->ipsclass->DB->get_insert_id(); //-------------------------------------- // Mark all old subs as dead //-------------------------------------- $this->ipsclass->DB->do_update( 'subscription_trans', array( 'subtrans_state' => 'dead' ), "subtrans_state='paid' AND subtrans_member_id={$this->member['id']} AND subtrans_id != $newid" ); } //-------------------------------------- // UPDATE MEMBERS //-------------------------------------- if ( $this->update['subtrans_state'] == 'paid' ) { $this->do_paid_member($this->new_sub, $this->member, $subid['subtrans_id']); $this->do_log("{$this->class_gateway->i_am}: Subscription started (non recurring). Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } else { $this->do_failed_member($this->new_sub, $this->member, $subid['subtrans_id']); $this->do_log("{$this->class_gateway->i_am}: Subscription FAILED (not set to pod) (non recurring). Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } } /*-------------------------------------------------------------------------*/ // Process recurring NON UPGRADE /*-------------------------------------------------------------------------*/ function _process_recurring( $pay_method ) { //-------------------------------------- // SUBSCRIPTION //-------------------------------------- $balance = ( $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ) - $this->cur_details['subtrans_paid']; $this->new_sub['sub_cost'] = $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']; $results = $this->class_gateway->gw_do_recurring_payment_check( sprintf( "%.2f", $balance ), sprintf( "%.2f", $this->new_sub['sub_cost'] ) ); if ( $this->class_gateway->error ) { //-------------------------------------- // Log and exit //-------------------------------------- $this->do_log( "{$this->class_gateway->i_am}: ".$this->class_gateway->error ); exit(); } //-------------------------------------- // Does the verification key match? //-------------------------------------- if( $this->results['verification'] != md5( intval($this->member['id']) . $this->results['purchase_package_id'] . $this->ipsclass->vars['sql_pass'] ) ) { $this->do_log( "{$this->class_gateway->i_am}: Unable to verify payment - verification key mismatch" ); exit(); } //-------------------------------------- // Update subscription //-------------------------------------- $this->update['subtrans_paid'] = $results['amount_paid'] * $this->def_currency['subcurrency_exchange']; $this->update['subtrans_trxid'] = $this->results['transaction_id']; $this->update['subtrans_sub_id'] = $this->new_sub['sub_id']; $this->update['subtrans_subscrid'] = $this->results['subscription_id']; $this->update['subtrans_state'] = strtolower( $results['state'] ); $this->update['subtrans_cumulative'] = $this->update['subtrans_paid']; $this->update['subtrans_member_id'] = $this->member['id']; $this->update['subtrans_old_group'] = $this->member['mgroup']; $this->update['subtrans_start_date'] = time(); //-------------------------------------- // Deal with lifetime subs //-------------------------------------- if ( $this->new_sub['sub_unit'] == 'x' ) { $this->update['subtrans_end_date'] = 9999999999; } else { $this->update['subtrans_end_date'] = time() + ( $this->new_sub['sub_length'] * $this->day_to_seconds[ $this->new_sub['sub_unit'] ] ); } //-------------------------------------- // Just updating a subscription //-------------------------------------- if ( $this->results['current_package_id'] ) { $subid = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'subscription_trans', 'where' => "subtrans_subscrid='".addslashes($this->update['subtrans_subscrid'])."'" ) ); if ( $subid['subtrans_id'] ) { //-------------------------------------- // Okay, existing subscription we're updating, so... //-------------------------------------- unset($this->update['subtrans_start_date']); unset($this->update['subtrans_end_date']); unset($this->update['subtrans_old_group']); unset($this->update['subtrans_cumulative']); $this->ipsclass->DB->do_update( 'subscription_trans', $this->update, "subtrans_subscrid='".addslashes($this->update['subtrans_subscrid'])."'" ); } } else { $this->ipsclass->DB->do_insert( 'subscription_trans', $this->update ); $newid = $this->ipsclass->DB->get_insert_id(); //-------------------------------------- // Mark all old subs as dead //-------------------------------------- $this->ipsclass->DB->do_update( 'subscription_trans', array( 'subtrans_state' => 'dead' ), "subtrans_state='paid' AND subtrans_member_id={$this->member['id']} AND subtrans_id != $newid" ); } //-------------------------------------- // UPDATE MEMBERS //-------------------------------------- if ( $this->update['subtrans_state'] == 'paid' ) { $this->do_paid_member($this->new_sub, $this->member, $subid['subtrans_id']); $this->do_log("{$this->class_gateway->i_am}: Subscription started. Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } else { $this->do_failed_member($this->new_sub, $this->member, $subid['subtrans_id']); $this->do_log("{$this->class_gateway->i_am}: Subscription FAILED. Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } } /*-------------------------------------------------------------------------*/ // PAID MEMBER UPGRADE YEAH BABY /*-------------------------------------------------------------------------*/ function do_paid_member($new_sub, $member, $cur_trx_id="") { //-------------------------------------- // INIT //-------------------------------------- $end_date = 0; $email_end_date = 0; //-------------------------------------- // Make sure we have enough member info //-------------------------------------- if ( ! $member['email'] ) { $member = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'members', 'where' => 'id='.intval($member['id']) ) ); } define( 'IPB_CALLED', 1 ); //-------------------------------------- // Lifetime... //-------------------------------------- if ( $new_sub['sub_unit'] == 'x' ) { $end_date = 9999999999; $email_end_date = $this->ipsclass->lang['no_expire']; } else { if ( $cur_trx_id ) { //-------------------------------------- // Upgrading... //-------------------------------------- $end_date = 'sub_end'; $email_end_date = $this->ipsclass->get_date( $member['sub_end'], 'DATE' ); } else { //-------------------------------------- // New... //-------------------------------------- $end_date = time() + ( $new_sub['sub_length'] * $this->class_gateway->day_to_seconds[ $new_sub['sub_unit'] ] ); $email_end_date = $this->ipsclass->get_date( $end_date, 'DATE' ); } } $update_fields = array(); $update_fields['sub_end'] = $end_date; if ( $new_sub['sub_new_group'] AND !$cur_trx_id ) { $update_fields['mgroup'] = $new_sub['sub_new_group']; } $this->ipsclass->DB->do_update( "members", $update_fields, "id=".$member['id'] ); //-------------------------------------- // Running Custom code? //-------------------------------------- $name = preg_replace( "/[^a-zA-Z0-9\-\_]/", "" , $new_sub['sub_run_module'] ); if ( $name != "" ) { if ( @file_exists( ROOT_PATH . 'sources/classes/paymentgateways/custom/cus_'.$name.'.php' ) ) { require_once( ROOT_PATH . 'sources/classes/paymentgateways/custom/cus_'.$name.'.php' ); $this->customsubs = new customsubs(); $this->customsubs->subs_paid($new_sub, $member, $cur_trx_id); } } //-------------------------------------- // Running IPB custom code? //-------------------------------------- if ( USE_MODULES == 1 ) { require ROOT_PATH."modules/ipb_member_sync.php"; $this->modules = new ipb_member_sync(); $this->modules->register_class($this); $this->modules->on_group_change($member['id'], $new_sub['sub_new_group']); } //-------------------------------------- // Send an email? //-------------------------------------- require_once( ROOT_PATH."sources/classes/class_email.php" ); $this->email = new emailer(); $this->email->ipsclass =& $this->ipsclass; $this->email->email_init(); $this->email->get_template("new_subscription"); $this->email->build_message( array( 'PACKAGE' => $new_sub['sub_title'], 'EXPIRES' => $email_end_date, 'LINK' => $this->ipsclass->vars['board_url'].'/index.'.$this->ipsclass->vars['php_ext'].'?act=paysubs&CODE=index', ) ); $this->email->to = trim( $member['email'] ); $this->email->send_mail(); } /*-------------------------------------------------------------------------*/ // FAILED MEMBER UPGRADE YEAH BABY /*-------------------------------------------------------------------------*/ function do_failed_member($new_sub, $member, $cur_trx_id="") { define( 'IPB_CALLED', 1 ); $update_fields = array(); $update_fields['sub_end'] = 0; // We want to move them back to the member group if the payment // failed, but not if they cancelled a subscription - bug 2008 if ( $cur_trx_id AND !$this->results['payment_status'] == 'CANCEL' ) { $this->ipsclass->DB->cache_add_query( 'mod_failed_member', array( 'cur_trx_id' => $cur_trx_id ), 'sql_subsm_queries' ); $this->ipsclass->DB->cache_exec_query(); $r = $this->ipsclass->DB->fetch_row(); $mgroup = $r['g_id'] ? $r['g_id'] : $this->ipsclass->vars['member_group']; $update_fields['mgroup'] = $mgroup; } $this->ipsclass->DB->do_update( "members", $update_fields, "id=".$member['id'] ); //-------------------------------------- // Running Custom code? //-------------------------------------- $name = preg_replace( "/[^a-zA-Z0-9\-\_]/", "" , $new_sub['sub_run_module'] ); if ( $name != "" ) { if ( @file_exists( ROOT_PATH . 'sources/classes/paymentgateways/custom/cus_'.$name.'.php' ) ) { require_once( ROOT_PATH . 'sources/classes/paymentgateways/custom/cus_'.$name.'.php' ); $this->customsubs = new customsubs(); $this->customsubs->subs_failed($new_sub, $member, $cur_trx_id); } } //-------------------------------------- // Running IPB custom code? //-------------------------------------- if ( USE_MODULES == 1 ) { require ROOT_PATH."modules/ipb_member_sync.php"; $this->modules = new ipb_member_sync(); $this->modules->register_class($this); $this->modules->on_group_change($member['id'], $mgroup); } } /*-------------------------------------------------------------------------*/ // Captains log: Unix date: 1002343439 /*-------------------------------------------------------------------------*/ function do_log($msg) { $extra = ""; foreach( $_POST as $k => $v ) { if ( $k == 'ccnum' ) { $v = 'xxxx xxxx xxxx xxxx'; } else if ( $k == 'ccid' ) { $v = 'xxx'; } $extra .= "\n$k = $v;"; } if ( is_array( $_GET ) ) { foreach( $_GET as $k => $v ) { if ( $k == 'ccnum' ) { $v = 'xxxx xxxx xxxx xxxx'; } else if ( $k == 'ccid' ) { $v = 'xxx'; } $extra .= "\n$k = $v;"; } } $extra = htmlentities( strip_tags( str_replace( '\\', '', $extra ) ) ); //-------------------------------------- // Add to DB //-------------------------------------- $this->ipsclass->DB->do_insert( 'subscription_logs', array( 'sublog_date' => time(), 'sublog_data' => $msg, 'sublog_ipaddress' => $this->ip_address, 'sublog_postdata' => $extra ) ); //-------------------------------------- // Debug? //-------------------------------------- $this->class_gateway->_write_debug_message( "MSG:\n$msg\nPost contents\n$extra\n" ); } } ?>