han_paysubscriptions.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,216 行 · 第 1/4 页
PHP
1,216 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.5| =============================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services, Inc.| | =============================================| Web: | Time: Wed, 01 Mar 2006 19:11:29 GMT| Release: | Licence Info: +---------------------------------------------------------------------------| > $Date: 2005-12-01 16:45:12 +0000 (Thu, 01 Dec 2005) $| > $Revision: 88 $| > $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 "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files."; exit();}class han_paysubscriptions{ # Global var $ipsclass; var $class_gateway; var $email; # Gateway var $gateway; # Error var $error; # Processing var $member; var $new_sub; var $trans; var $upgrade; var $results; var $customsubs; var $day_to_seconds = array( 'd' => 86400, 'w' => 604800, 'm' => 2592000, 'y' => 31536000, ); /*-------------------------------------------------------------------------*/ // SET UP /*-------------------------------------------------------------------------*/ function main_init() { //-------------------------------------------- // Get currencies... //-------------------------------------------- $this->ipsclass->DB->build_query( array( 'select' => '*', 'from' => 'subscription_currency' ) ); $this->ipsclass->DB->exec_query(); while ( $c = $this->ipsclass->DB->fetch_row() ) { $this->all_currency[ $c['subcurrency_code'] ] = $c; if ( $c['subcurrency_default'] ) { $this->def_currency = $c; } } if ( $this->ipsclass->input['currency'] ) { if ( is_array($this->all_currency[ $this->ipsclass->input['currency'] ]) ) { $this->cho_currency = $this->all_currency[ $this->ipsclass->input['currency'] ]; } else { $this->cho_currency = $this->def_currency; } } else { $this->cho_currency = $this->def_currency; } } /*-------------------------------------------------------------------------*/ // INIT /*-------------------------------------------------------------------------*/ function gateway_init() { //----------------------------------------- // INIT //----------------------------------------- $class = ""; //----------------------------------------- // Which class //----------------------------------------- if ( file_exists( ROOT_PATH . 'sources/classes/paymentgateways/class_gw_' . $this->gateway . '.php' ) ) { $class = 'class_gw_' . $this->gateway . '.php'; } else { $this->error = 'no_gateway'; return; } //----------------------------------------- // Define core //----------------------------------------- define( 'GW_CORE_INIT', 1 ); //----------------------------------------- // Define Language & Function strings //----------------------------------------- define( 'GW_URL_VALIDATE' , $this->ipsclass->base_url.'act=paysubs&CODE=incoming&type=' . $this->gateway ); define( 'GW_URL_PAYDONE' , $this->ipsclass->base_url.'act=paysubs&CODE=paydone&type=' . $this->gateway ); define( 'GW_URL_PAYCANCEL' , $this->ipsclass->base_url.'act=paysubs&CODE=paydone&type=' . $this->gateway ); //----------------------------------------- // Debug //----------------------------------------- define( 'GW_DEBUG_MODE_ON', FALSE ); define( 'GW_TEST_MODE_ON' , FALSE ); // MAKE SURE THIS IS OFF WHEN IN LIVE USE!! //----------------------------------------- // Load classes //----------------------------------------- require_once( ROOT_PATH . 'sources/classes/paymentgateways/class_gw_core.php' ); require_once( ROOT_PATH . 'sources/classes/paymentgateways/'.$class ); $this->class_gateway = new class_gw_module(); $this->class_gateway->ipsclass =& $this->ipsclass; //----------------------------------------- // Init class //----------------------------------------- $this->class_gateway->main_init(); } /*-------------------------------------------------------------------------*/ // SHOW UPGRADE PAYMENT SCREEN /*-------------------------------------------------------------------------*/ function show_upgrade_payment_screen($sub_current, $sub_upgrade, $pay_method, $extra) { //--------------------------------------- // Check we can do upgrades //--------------------------------------- if ( $this->class_gateway->can_do_upgrades != 1 ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'subs_no_upgrade' ) ); } //--------------------------------------- // Check we have current package details //--------------------------------------- if ( ! $sub_current['sub_id'] ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'subs_fail', 'EXTRA' => 'no_curid' ) ); } //--------------------------------------- // Check we have upgrade to package details //--------------------------------------- if ( ! $sub_upgrade['sub_id'] ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'subs_fail', 'EXTRA' => 'no_curid' ) ); } //-------------------------------------------- // We're upgrading!! Yay! - Get cur subs //-------------------------------------------- $this->ipsclass->DB->query("SELECT * FROM ibf_subscription_trans WHERE subtrans_member_id={$this->ipsclass->member['id']} AND subtrans_sub_id={$sub_current['sub_id']} AND subtrans_state='paid'"); if ( ! $cur_trans = $this->ipsclass->DB->fetch_row() ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'subs_no_curid' ) ); } //--------------------------------------- // Format the info string //--------------------------------------- $balance = ($sub_upgrade['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']) - $cur_trans['subtrans_paid']; $end_date = ( $sub_upgrade['sub_unit'] == 'x' or $sub_current['sub_unit'] == 'x' ) ? $this->ipsclass->lang['no_expire'] : $this->ipsclass->get_date( $cur_trans['subtrans_end_date'], 'JOINED' ); $this->ipsclass->lang['sc_upgrade_string'] = sprintf( $this->ipsclass->lang['sc_upgrade_string'], $sub_current['sub_title'], $sub_upgrade['sub_title'], $end_date, sprintf( "%.2f", $balance * $this->cho_currency['subcurrency_exchange'] ).' '.$this->cho_currency['subcurrency_code'] ); //--------------------------------------- // Time left to run //--------------------------------------- if ( $sub_current['sub_unit'] != 'x' ) { $time_left_to_run = $cur_trans['subtrans_end_date'] - time(); $time_left_to_run = ceil($time_left_to_run / 86400); $time_left_units = 'D'; if ( $time_left_to_run < 1 ) { $time_left_to_run = 1; } else if ( $time_left_to_run > 30 ) { $time_left_units = 'M'; $time_left_to_run = ceil($time_left_to_run / 30); } } else { $time_left_to_run = $sub_upgrade['sub_length']; $time_left_units = $sub_upgrade['sub_unit']; } if ( $extra['subextra_recurring'] == 1 AND $this->class_gateway->can_do_recurring_billing == 1 ) { //--------------------------------------- // Generate form fields //--------------------------------------- $form_fields = $this->class_gateway->gw_generate_hidden_fields_upgrade_recurring( array('currency_code' => $pay_method['submethod_use_currency'], 'member_unique_id' => $this->ipsclass->member['id'], 'member_name' => $this->ipsclass->member['members_display_name'], 'member_email' => $this->ipsclass->member['email'], 'package_cost' => sprintf( "%.2f", $sub_upgrade['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ), 'package_id' => $sub_upgrade['sub_id'], 'package_title' => $sub_upgrade['sub_title'], 'duration_int' => $sub_upgrade['sub_length'], 'duration_unit' => strtoupper($sub_upgrade['sub_unit']), 'company_email' => $pay_method['submethod_email'], 'ttr_int' => $time_left_to_run, 'ttr_unit' => $time_left_units, 'ttr_balance' => sprintf( "%.2f", $balance ), 'ttr_package_id' => $cur_trans['subtrans_sub_id'], 'vendor_id' => $pay_method['submethod_sid'], 'product_id' => $extra['subextra_product_id'], 'extra_1' => $pay_method['submethod_custom_1'], 'extra_2' => $pay_method['submethod_custom_2'], 'extra_3' => $pay_method['submethod_custom_3'], 'extra_4' => $pay_method['submethod_custom_4'], 'extra_5' => $pay_method['submethod_custom_5'] ) ); return $this->ipsclass->compiled_templates['skin_subscriptions']->do_generic_payscreen_with_button( array( 'formaction' => $this->class_gateway->gw_generate_upgrade_recurring_form_action(), 'formfields' => $form_fields, 'button' => $this->class_gateway->gw_generate_purchase_button(), 'lang_title' => $this->ipsclass->lang['sc_complete'], 'lang_explain' => $this->ipsclass->lang['sc_upgrade_explain'], 'lang_desc' => $this->ipsclass->lang['sc_upgrade_string'], 'lang_extra' => $this->ipsclass->lang['gw_' . $this->gateway ] ) ); } else { //--------------------------------------- // Generate form fields: NORMAL //--------------------------------------- $form_fields = $this->class_gateway->gw_generate_hidden_fields_upgrade( array('currency_code' => $pay_method['submethod_use_currency'], 'member_unique_id' => $this->ipsclass->member['id'], 'member_name' => $this->ipsclass->member['members_display_name'], 'member_email' => $this->ipsclass->member['email'], 'package_cost' => sprintf( "%.2f", $sub_upgrade['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ), 'package_id' => $sub_upgrade['sub_id'], 'package_title' => $sub_upgrade['sub_title'], 'duration_int' => $sub_upgrade['sub_length'], 'duration_unit' => strtoupper($sub_upgrade['sub_unit']), 'company_email' => $pay_method['submethod_email'], 'ttr_int' => $time_left_to_run,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?