notify_credit.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: notify_credit.php 34251 2013-11-25 03:10:11Z nemohou $
  7. */
  8. define('IN_API', true);
  9. define('CURSCRIPT', 'api');
  10. define('DISABLEXSSCHECK', true);
  11. require '../../source/class/class_core.php';
  12. require '../../source/function/function_forum.php';
  13. $discuz = C::app();
  14. $discuz->init();
  15. $apitype = empty($_GET['attach']) || !preg_match('/^[a-z0-9]+$/i', $_GET['attach']) ? 'alipay' : $_GET['attach'];
  16. require_once DISCUZ_ROOT.'./api/trade/api_'.$apitype.'.php';
  17. $PHP_SELF = $_SERVER['PHP_SELF'];
  18. $_G['siteurl'] = dhtmlspecialchars('http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api\/trade)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/');
  19. $notifydata = trade_notifycheck('credit');
  20. if($notifydata['validator']) {
  21. $orderid = $notifydata['order_no'];
  22. $postprice = $notifydata['price'];
  23. $order = C::t('forum_order')->fetch($orderid);
  24. $order = array_merge($order, C::t('common_member')->fetch_by_username($order['uid']));
  25. if($order && floatval($postprice) == floatval($order['price']) && ($apitype == 'tenpay' || strtolower($_G['setting']['ec_account']) == strtolower($_REQUEST['seller_email']))) {
  26. if($order['status'] == 1) {
  27. C::t('forum_order')->update($orderid, array('status' => '2', 'buyer' => "$notifydata[trade_no]\t$apitype", 'confirmdate' => $_G['timestamp']));
  28. updatemembercount($order['uid'], array($_G['setting']['creditstrans'] => $order['amount']), 1, 'AFD', $order['uid']);
  29. updatecreditbyaction($action, $uid = 0, $extrasql = array(), $needle = '', $coef = 1, $update = 1, $fid = 0);
  30. C::t('forum_order')->delete_by_submitdate($_G['timestamp']-60*86400);
  31. $submitdate = dgmdate($order['submitdate']);
  32. $confirmdate = dgmdate(TIMESTAMP);
  33. notification_add($order['uid'], 'credit', 'addfunds', array(
  34. 'orderid' => $order['orderid'],
  35. 'price' => $order['price'],
  36. 'value' => $_G['setting']['extcredits'][$_G['setting']['creditstrans']]['title'].' '.$order['amount'].' '.$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['unit']
  37. ), 1);
  38. }
  39. }
  40. }
  41. if($notifydata['location']) {
  42. $url = rawurlencode('home.php?mod=spacecp&ac=credit');
  43. if($apitype == 'tenpay') {
  44. echo <<<EOS
  45. <meta name="TENCENT_ONLINE_PAYMENT" content="China TENCENT">
  46. <html>
  47. <body>
  48. <script language="javascript" type="text/javascript">
  49. window.location.href='$_G[siteurl]forum.php?mod=misc&action=paysucceed';
  50. </script>
  51. </body>
  52. </html>
  53. EOS;
  54. } else {
  55. dheader('location: '.$_G['siteurl'].'forum.php?mod=misc&action=paysucceed');
  56. }
  57. } else {
  58. exit($notifydata['notify']);
  59. }
  60. ?>