spacecp_eccredit.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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: spacecp_eccredit.php 25246 2011-11-02 03:34:53Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('function/ec_credit');
  12. if($_GET['op'] == 'list') {
  13. $from = !empty($_GET['from']) && in_array($_GET['from'], array('buyer', 'seller', 'myself')) ? $_GET['from'] : '';
  14. $uid = !empty($_GET['uid']) ? intval($_GET['uid']) : $_G['uid'];
  15. $filter = !empty($_GET['filter']) ? $_GET['filter'] : '';
  16. switch($filter) {
  17. case 'thisweek':
  18. $dateline = intval($_G['timestamp'] - 604800);
  19. break;
  20. case 'thismonth':
  21. $dateline = intval($_G['timestamp'] - 2592000);
  22. break;
  23. case 'halfyear':
  24. $dateline = intval($_G['timestamp'] - 15552000);
  25. break;
  26. case 'before':
  27. $dateline = intval($_G['timestamp'] - 15552000);
  28. break;
  29. default:
  30. $dateline = false;
  31. }
  32. $level = !empty($_GET['level']) ? $_GET['level'] : '';
  33. switch($level) {
  34. case 'good':
  35. $score = 1;
  36. break;
  37. case 'soso':
  38. $score = 0;
  39. break;
  40. case 'bad':
  41. $score = -1;
  42. break;
  43. default:
  44. $score = false;
  45. }
  46. $page = max(1, intval($_GET['page']));
  47. $start_limit = ($page - 1) * 10;
  48. $num = C::t('forum_tradecomment')->count_list($from, $uid, $dateline, $score);
  49. $multipage = multi($num, 10, $page, "home.php?mod=spacecp&ac=list&uid=$uid".($from ? "&from=$from" : NULL).($filter ? "&filter=$filter" : NULL).($level ? "&level=$level" : NULL));
  50. $comments = array();
  51. foreach(C::t('forum_tradecomment')->fetch_all_list($from, $uid, $dateline, $score, $start_limit) as $comment) {
  52. $comment['expiration'] = dgmdate($comment['dateline'] + 30 * 86400, 'u');
  53. $comment['dbdateline'] = $comment['dateline'];
  54. $comment['dateline'] = dgmdate($comment['dateline'], 'u');
  55. $comment['baseprice'] = sprintf('%0.2f', $comment['baseprice']);
  56. $comments[] = $comment;
  57. }
  58. include template('home/spacecp_ec_list');
  59. } elseif($_GET['op'] == 'rate' && ($orderid = $_GET['orderid']) && isset($_GET['type'])) {
  60. require_once libfile('function/trade');
  61. $type = intval($_GET['type']);
  62. if(!$type) {
  63. $raterid = 'buyerid';
  64. $ratee = 'seller';
  65. $rateeid = 'sellerid';
  66. } else {
  67. $raterid = 'sellerid';
  68. $ratee = 'buyer';
  69. $rateeid = 'buyerid';
  70. }
  71. $order = C::t('forum_tradelog')->fetch($orderid);
  72. if(!$order || $order[$raterid] != $_G['uid']) {
  73. showmessage('eccredit_order_notfound');
  74. } elseif($order['ratestatus'] == 3 || ($type == 0 && $order['ratestatus'] == 1) || ($type == 1 && $order['ratestatus'] == 2)) {
  75. showmessage('eccredit_rate_repeat');
  76. } elseif(!trade_typestatus('successtrades', $order['status']) && !trade_typestatus('refundsuccess', $order['status'])) {
  77. showmessage('eccredit_nofound');
  78. }
  79. $uid = $_G['uid'] == $order['buyerid'] ? $order['sellerid'] : $order['buyerid'];
  80. if(!submitcheck('ratesubmit')) {
  81. include template('home/spacecp_ec_rate');
  82. } else {
  83. $score = intval($_GET['score']);
  84. $message = cutstr(dhtmlspecialchars($_GET['message']), 200);
  85. $level = $score == 1 ? 'good' : ($score == 0 ? 'soso' : 'bad');
  86. $pid = intval($order['pid']);
  87. $order = daddslashes($order, 1);
  88. C::t('forum_tradecomment')->insert(array(
  89. 'pid' => $pid,
  90. 'orderid' => $orderid,
  91. 'type' => $type,
  92. 'raterid' => $_G['uid'],
  93. 'rater' => $_G['username'],
  94. 'ratee' => $order[$ratee],
  95. 'rateeid' => $order[$rateeid],
  96. 'score' => $score,
  97. 'message' => $message,
  98. 'dateline' => $_G['timestamp']
  99. ));
  100. if(!$order['offline'] || $order['credit']) {
  101. if(C::t('forum_tradecomment')->get_month_score($_G['uid'], $type, $order[$rateeid]) < $_G['setting']['ec_credit']['maxcreditspermonth']) {
  102. updateusercredit($uid, $type ? 'sellercredit' : 'buyercredit', $level);
  103. }
  104. }
  105. if($type == 0) {
  106. $ratestatus = $order['ratestatus'] == 2 ? 3 : 1;
  107. } else {
  108. $ratestatus = $order['ratestatus'] == 1 ? 3 : 2;
  109. }
  110. C::t('forum_tradelog')->update($order['orderid'], array('ratestatus' => $ratestatus));
  111. if($ratestatus != 3) {
  112. notification_add($order[$rateeid], 'goods', 'eccredit', array(
  113. 'orderid' => $orderid,
  114. ), 1);
  115. }
  116. showmessage('eccredit_succeed', 'home.php?mod=space&uid='.$_G['uid'].'&do=trade&view=eccredit');
  117. }
  118. } elseif($_GET['op'] == 'explain' && $_GET['id']) {
  119. $id = intval($_GET['id']);
  120. $ajaxmenuid = $_GET['ajaxmenuid'];
  121. if(!submitcheck('explainsubmit', 1)) {
  122. include template('home/spacecp_ec_explain');
  123. } else {
  124. $comment = C::t('forum_tradecomment')->fetch($id);
  125. if(!$comment || $comment['rateeid'] != $_G['uid']) {
  126. showmessage('eccredit_nofound');
  127. } elseif($comment['explanation']) {
  128. showmessage('eccredit_reexplanation_repeat');
  129. } elseif($comment['dateline'] < TIMESTAMP - 30 * 86400) {
  130. showmessage('eccredit_reexplanation_closed');
  131. }
  132. $explanation = cutstr(dhtmlspecialchars($_GET['explanation']), 200);
  133. C::t('forum_tradecomment')->update($id, array('explanation' => $explanation));
  134. $language = lang('forum/misc');
  135. showmessage($language['eccredit_explain'].'&#58; '.$explanation, '', array(), array('msgtype' => 3, 'showmsg' => 1));
  136. }
  137. }
  138. ?>