thread_trade.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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: thread_trade.php 28348 2012-02-28 06:16:29Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(empty($_GET['do']) || $_GET['do'] == 'tradeinfo') {
  12. if($_GET['do'] == 'tradeinfo') {
  13. $_GET['pid'] = intval($_GET['pid']);
  14. } else {
  15. $_GET['pid'] = '';
  16. !$tradenum && $allowpostreply = FALSE;
  17. }
  18. $query = C::t('forum_trade')->fetch_all_thread_goods($_G['tid'], $_GET['pid']);
  19. $trades = $tradesstick = array();$tradelist = 0;
  20. if(empty($_GET['do'])) {
  21. $sellerid = 0;
  22. $listcount = count($query);
  23. $tradelist = $tradenum - $listcount;
  24. }
  25. $tradesaids = $tradespids = array();
  26. foreach($query as $trade) {
  27. if($trade['expiration']) {
  28. $trade['expiration'] = ($trade['expiration'] - TIMESTAMP) / 86400;
  29. if($trade['expiration'] > 0) {
  30. $trade['expirationhour'] = floor(($trade['expiration'] - floor($trade['expiration'])) * 24);
  31. $trade['expiration'] = floor($trade['expiration']);
  32. } else {
  33. $trade['expiration'] = -1;
  34. }
  35. }
  36. $tradesaids[] = $trade['aid'];
  37. $tradespids[] = $trade['pid'];
  38. if($trade['displayorder'] < 0) {
  39. $trades[$trade['pid']] = $trade;
  40. } else {
  41. $tradesstick[$trade['pid']] = $trade;
  42. }
  43. }
  44. if(empty($_GET['do'])) {
  45. $tradepostlist = C::t('forum_post')->fetch_all('tid:'.$_G['tid'], $tradespids);
  46. }
  47. $trades = $tradesstick + $trades;
  48. unset($trade);
  49. if($tradespids) {
  50. foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$_G['tid'], 'pid', $tradespids) as $attach) {
  51. if($attach['isimage'] && is_array($tradesaids) && in_array($attach['aid'], $tradesaids)) {
  52. $trades[$attach['pid']]['attachurl'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];
  53. $trades[$attach['pid']]['thumb'] = $attach['thumb'] ? getimgthumbname($trades[$attach['pid']]['attachurl']) : $trades[$attach['pid']]['attachurl'];
  54. $trades[$attach['pid']]['width'] = $attach['thumb'] && $_G['setting']['thumbwidth'] < $attach['width'] ? $_G['setting']['thumbwidth'] : $attach['width'];
  55. }
  56. }
  57. }
  58. if($_GET['do'] == 'tradeinfo') {
  59. $trade = $trades[$_GET['pid']];
  60. unset($trades);
  61. $post = C::t('forum_post')->fetch('tid:'.$_G['tid'], $_GET['pid']);
  62. if($post) {
  63. $post = array_merge(C::t('common_member_status')->fetch($post['authorid']), C::t('common_member_profile')->fetch($post['authorid']),
  64. $post, getuserbyuid($post['authorid']));
  65. if($_G['setting']['verify']['enabled']) {
  66. $post = array_merge($post, C::t('common_member_verify')->fetch($post['authorid']));
  67. }
  68. }
  69. $postlist[$post['pid']] = viewthread_procpost($post, $lastvisit, $ordertype);
  70. $usertrades = $userthreads = array();
  71. if(!$_G['inajax']) {
  72. $limit = 6;
  73. $query = C::t('forum_trade')->fetch_all_for_seller($_G['forum_thread']['authorid'], $limit + 1, $_G['tid']);
  74. $usertradecount = 0;
  75. foreach($query as $usertrade) {
  76. if($usertrade['pid'] == $post['pid']) {
  77. continue;
  78. }
  79. $usertradecount++;
  80. $usertrades[] = $usertrade;
  81. if($usertradecount == $limit) {
  82. break;
  83. }
  84. }
  85. }
  86. if($_G['forum_attachpids'] && !defined('IN_ARCHIVER')) {
  87. require_once libfile('function/attachment');
  88. parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist, array($trade['aid']));
  89. }
  90. $post = $postlist[$_GET['pid']];
  91. $post['buyerrank'] = 0;
  92. if($post['buyercredit']){
  93. foreach($_G['setting']['ec_credit']['rank'] AS $level => $credit) {
  94. if($post['buyercredit'] <= $credit) {
  95. $post['buyerrank'] = $level;
  96. break;
  97. }
  98. }
  99. }
  100. $post['sellerrank'] = 0;
  101. if($post['sellercredit']){
  102. foreach($_G['setting']['ec_credit']['rank'] AS $level => $credit) {
  103. if($post['sellercredit'] <= $credit) {
  104. $post['sellerrank'] = $level;
  105. break;
  106. }
  107. }
  108. }
  109. $navtitle = $trade['subject'];
  110. if($post['authorid']) {
  111. $online = $sessioninfo = C::app()->session->fetch_by_uid($post['authorid']) && empty($sessioninfo['invisible']) ? 1 : 0;
  112. }
  113. include template('forum/trade_info');
  114. exit;
  115. }
  116. }
  117. ?>