showmessage('credits_addfunds_amount_invalid'); } if ($db->result_first("SELECT COUNT(*) FROM {$tablepre}orders WHERE uid='{$discuz_uid}' AND submitdate>='{$timestamp}'-180 LIMIT 1")) { showmessage('credits_addfunds_ctrl'); } if ($ec_maxcreditspermonth) { $query = $db->query("SELECT SUM(amount) FROM {$tablepre}orders WHERE uid='{$discuz_uid}' AND submitdate>='{$timestamp}'-2592000 AND status IN (2, 3)"); if ($db->result($query, 0) + $amount > $ec_maxcreditspermonth) { showmessage('credits_addfunds_toomuch'); } } $price = round($amount / $ec_ratio * 100 / 100, 1); $orderid = ''; //$apitype = 'tenpay'; require_once DISCUZ_ROOT . './include/trade.func.php'; $requesturl = credit_payurl($price, $orderid); $query = $db->query("SELECT orderid FROM {$tablepre}orders WHERE orderid='{$orderid}'"); if ($db->num_rows($query)) { showmessage('credits_addfunds_order_invalid'); } $db->query("INSERT INTO {$tablepre}orders (orderid, status, uid, amount, price, submitdate)\r\n\t\t\t\t\tVALUES ('{$orderid}', '1', '{$discuz_uid}', '{$amount}', '{$price}', '{$timestamp}')"); showmessage('credits_addfunds_succeed', '', 1); } } else { showmessage('action_closed', NULL, 'HALTED'); } } else { $extcredits_exchange = array(); if (!empty($extcredits)) { foreach ($extcredits as $key => $value) { if ($value['allowexchangein'] || $value['allowexchangeout']) {
$language = lang('forum/misc'); if ($_G['setting']['ec_mincredits'] && $amount < $_G['setting']['ec_mincredits'] || $_G['setting']['ec_maxcredits'] && $amount > $_G['setting']['ec_maxcredits']) { showmessage('credits_addfunds_amount_invalid', '', array('ec_maxcredits' => $_G['setting']['ec_maxcredits'], 'ec_mincredits' => $_G['setting']['ec_mincredits']), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true)); } if ($apitype == 'card' && C::t('forum_order')->count_by_search($_G['uid'], null, null, null, null, null, null, $_G['timestamp'] - 180)) { showmessage('credits_addfunds_ctrl', '', array(), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true)); } if ($_G['setting']['ec_maxcreditspermonth']) { if (C::t('forum_order')->sum_amount_by_uid_submitdate_status($_G['uid'], $_G['timestamp'] - 2592000, array(2, 3)) + $amount > $_G['setting']['ec_maxcreditspermonth']) { showmessage('credits_addfunds_toomuch', '', array('ec_maxcreditspermonth' => $_G['setting']['ec_maxcreditspermonth']), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true)); } } $price = round($amount / $_G['setting']['ec_ratio'] * 100 / 100, 2); $orderid = ''; require_once libfile('function/trade'); $requesturl = credit_payurl($price, $orderid, $_GET['bank_type']); if (C::t('forum_order')->fetch($orderid)) { showmessage('credits_addfunds_order_invalid', '', array(), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true)); } C::t('forum_order')->insert(array('orderid' => $orderid, 'status' => '1', 'uid' => $_G['uid'], 'amount' => $amount, 'price' => $price, 'submitdate' => $_G['timestamp'])); include template('common/header_ajax'); echo '<form id="payform" action="' . $requesturl . '" method="post"></form><script type="text/javascript" reload="1">$(\'payform\').submit();</script>'; include template('common/footer_ajax'); dexit(); } } else { if ($_G['setting']['card']['open'] && $_G['setting']['seccodestatus'] & 16) { $seccodecheck = 1; $secqaacheck = 0; } }
$settingsnew['ec_securitycode'] = $ec_securitycodemasknew == $ec_securitycodemask ? $ec_securitycode : $settingsnew['ec_securitycode']; $ec_contract = addslashes(authcode($settingsnew['ec_contract'] . "\t" . $settingsnew['ec_securitycode'] . "\t" . $settingsnew['ec_partner'] . "\t" . $settingsnew['ec_creditdirectpay'], 'ENCODE', $_G['config']['security']['authkey'])); DB::query("REPLACE INTO " . DB::table('common_setting') . " SET svalue='{$ec_contract}', skey='ec_contract'"); updatecache('setting'); cpmsg('alipay_succeed', 'action=ec&operation=alipay', 'succeed'); } } elseif ($operation == 'tenpay') { $settings = array(); $query = DB::query("SELECT skey, svalue FROM " . DB::table('common_setting') . " WHERE skey IN ('ec_tenpay_direct', 'ec_tenpay_account', 'ec_tenpay_bargainor', 'ec_tenpay_key', 'ec_tenpay_opentrans_chnid', 'ec_tenpay_opentrans_key')"); while ($setting = DB::fetch($query)) { $settings[$setting['skey']] = $setting['svalue']; } if (!empty($checktype)) { require_once DISCUZ_ROOT . './api/trade/api_tenpay.php'; if ($checktype == 'credit') { dheader('location: ' . credit_payurl(1, $orderid)); } elseif ($checktype == 'virtualgoods') { $pay = array('logistics_type' => 'VIRTUAL'); $trade = array('subject' => $lang['ec_tenpay_check_virtualgoodssubject'], 'itemtype' => 1, 'tenpayaccount' => $settings['ec_tenpay_opentrans_chnid']); $tradelog = array('orderid' => 'TEST' . dgmdate(TIMESTAMP, 'YmdHis') . random(18), 'baseprice' => 1, 'number' => 1, 'transportfee' => 0); dheader('location: ' . trade_payurl($pay, $trade, $tradelog)); } elseif ($checktype == 'goods') { $pay = array('logistics_type' => 'EMS', 'transport' => 'SELLER_PAY'); $trade = array('subject' => $lang['ec_tenpay_check_goodssubject'], 'itemtype' => 1, 'tenpayaccount' => $settings['ec_tenpay_opentrans_chnid']); $tradelog = array('orderid' => 'TEST' . dgmdate(TIMESTAMP, 'YmdHis') . random(18), 'baseprice' => 1, 'number' => 1, 'transportfee' => 0); dheader('location: ' . trade_payurl($pay, $trade, $tradelog)); } exit; } if (!submitcheck('tenpaysubmit')) { shownav('extended', 'nav_ec');
} if ($ec_maxcreditspermonth) { $query = $db->query("SELECT SUM(amount) FROM {$tablepre}orders WHERE uid='{$discuz_uid}' AND submitdate>='{$timestamp}'-2592000 AND status IN (2, 3)"); if ($db->result($query, 0) + $amount > $ec_maxcreditspermonth) { showmessage('credits_addfunds_toomuch'); } } $price = ceil($amount / $ec_ratio * 100) / 100; $orderid = gmdate('YmdHis', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) . random(18); $query = $db->query("SELECT orderid FROM {$tablepre}orders WHERE orderid='{$orderid}'"); if ($db->num_rows($query)) { showmessage('credits_addfunds_order_invalid'); } $db->query("INSERT INTO {$tablepre}orders (orderid, status, uid, amount, price, submitdate)\r\n\t\t\t\tVALUES ('{$orderid}', '1', '{$discuz_uid}', '{$amount}', '{$price}', '{$timestamp}')"); require_once DISCUZ_ROOT . './api/alipayapi.php'; showmessage('credits_addfunds_succeed', credit_payurl($price, $orderid)); } } else { showmessage('undefined_action', NULL, 'HALTED'); } } elseif ($action == 'creditslog') { if ($operation == 'paymentlog') { $page = max(1, intval($page)); $start_limit = ($page - 1) * $tpp; $query = $db->query("SELECT COUNT(*) FROM {$tablepre}paymentlog WHERE uid='{$discuz_uid}'"); $multipage = multi($db->result($query, 0), $tpp, $page, "memcp.php?action=creditslog&operation=paymentlog"); $loglist = array(); $query = $db->query("SELECT p.*, f.fid, f.name, t.subject, t.author, t.dateline AS tdateline FROM {$tablepre}paymentlog p\r\n\t\t\tLEFT JOIN {$tablepre}threads t ON t.tid=p.tid\r\n\t\t\tLEFT JOIN {$tablepre}forums f ON f.fid=t.fid\r\n\t\t\tWHERE p.uid='{$discuz_uid}' ORDER BY p.dateline DESC\r\n\t\t\tLIMIT {$start_limit}, {$tpp}"); while ($log = $db->fetch_array($query)) { $log['authorenc'] = rawurlencode($log['authorenc']); $log['dateline'] = gmdate("{$dateformat} {$timeformat}", $log['dateline'] + $timeoffset * 3600);