information.inc.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $where = " where a.uniacid=:uniacid";
  5. $data[':uniacid'] = $_W['uniacid'];
  6. $type = isset($_GPC['type']) ? $_GPC['type'] : 'wait';
  7. $tztype = pdo_getall('zhtc_type', array('uniacid' => $_W['uniacid']));
  8. $state = $_GPC['state'];
  9. if ($type == 'wait') {
  10. $state = 1;
  11. }
  12. if (isset($_GPC['keywords'])) {
  13. $where .= " and (a.user_name LIKE concat('%', :name,'%') || a.user_tel LIKE concat('%', :name,'%') || a.details LIKE concat('%', :name,'%') || a.cityname LIKE concat('%', :name,'%') || a.user_name LIKE concat('%', :name,'%')) ";
  14. $data[':name'] = $_GPC['keywords'];
  15. $type = 'all';
  16. } else {
  17. if ($state) {
  18. $where .= " and a.state=:state";
  19. $data[':state'] = $state;
  20. }
  21. }
  22. if (!empty($_GPC['time'])) {
  23. $start = strtotime($_GPC['time']['start']);
  24. $end = strtotime($_GPC['time']['end']);
  25. $where .= " and a.time >={$start} and a.time<={$end}";
  26. }
  27. if ($_GPC['type_id'] > 0) {
  28. $where .= " and a.type_id=" . $_GPC['type_id'];
  29. }
  30. if ($_GPC['top']) {
  31. $where .= " and a.top=:top";
  32. $data[':top'] = $_GPC['top'];
  33. }
  34. $pageindex = max(1, intval($_GPC['page']));
  35. $pagesize = 10;
  36. $sql = "select a.*,b.type,c.type_name from" . tablename('zhtc_information') . " a" . " left join " . tablename("zhtc_top") . " b on b.id=a.top_type left join " . tablename("zhtc_type") . " c on c.id=a.type_id" . $where . " ORDER BY a.id DESC";
  37. $total = pdo_fetchcolumn("select count(*) from" . tablename('zhtc_information') . " a" . " left join " . tablename("zhtc_top") . " b on b.id=a.top_type" . $where, $data);
  38. $select_sql = $sql . " LIMIT " . ($pageindex - 1) * $pagesize . "," . $pagesize;
  39. $list = pdo_fetchall($select_sql, $data);
  40. $pager = pagination($total, $pageindex, $pagesize);
  41. if ($_GPC['op'] == 'delete') {
  42. $res = pdo_delete('zhtc_information', array('id' => $_GPC['id']));
  43. if ($res) {
  44. message('删除成功!', $this->createWebUrl('information', array('type' => $_GPC['type'], 'page' => $_GPC['page'])), 'success');
  45. } else {
  46. message('删除失败!', '', 'error');
  47. }
  48. }
  49. if ($_GPC['op'] == 'tg') {
  50. $tz = pdo_get('zhtc_information', array('id' => $_GPC['id']));
  51. if (!$tz['sh_time']) {
  52. if ($tz['top_type'] == 1) {
  53. $time = time() + 24 * 60 * 60;
  54. } elseif ($tz['top_type'] == 2) {
  55. $time = time() + 24 * 60 * 60 * 7;
  56. } elseif ($tz['top_type'] == 3) {
  57. $time = time() + 24 * 60 * 60 * 30;
  58. }
  59. $res = pdo_update('zhtc_information', array('state' => 2, 'sh_time' => time(), 'dq_time' => $time), array('id' => $_GPC['id']));
  60. } else {
  61. $res = pdo_update('zhtc_information', array('state' => 2), array('id' => $_GPC['id']));
  62. }
  63. if ($res) {
  64. file_get_contents("" . $_W['siteroot'] . "app/index.php?i=" . $_W['uniacid'] . "&c=entry&a=wxapp&do=tgMessage&m=zh_tcwq&information_id=" . $_GPC['id']);//模板消息
  65. $this->increaseScore($tz['user_id']);
  66. message('通过成功!', $this->createWebUrl('information', array('type' => $_GPC['type'], 'page' => $_GPC['page'])), 'success');
  67. } else {
  68. message('通过失败!', '', 'error');
  69. }
  70. }
  71. if ($_GPC['op'] == 'jj') {
  72. $tz = pdo_get('zhtc_information', array('id' => $_GPC['id']));
  73. $res = pdo_update('zhtc_information', array('state' => 3, 'sh_time' => time()), array('id' => $_GPC['id']));
  74. if ($res) {
  75. message('拒绝成功!', $this->createWebUrl('information', array('type' => $_GPC['type'], 'page' => $_GPC['page'])), 'success');
  76. } else {
  77. message('拒绝失败!', '', 'error');
  78. }
  79. }
  80. if ($_GPC['op'] == 'defriend') {
  81. $res4 = pdo_update("zhtc_user", array('state' => 2), array('id' => $_GPC['id']));
  82. if ($res4) {
  83. message('拉黑成功!', $this->createWebUrl('information', array('type' => $_GPC['type'], 'page' => $_GPC['page'])), 'success');
  84. } else {
  85. message('拉黑失败!', '', 'error');
  86. }
  87. }
  88. if ($_GPC['op'] == 'relieve') {
  89. $res4 = pdo_update("zhtc_user", array('state' => 1), array('id' => $_GPC['id']));
  90. if ($res4) {
  91. message('取消成功!', $this->createWebUrl('information', array('type' => $_GPC['type'], 'page' => $_GPC['page'])), 'success');
  92. } else {
  93. message('取消失败!', '', 'error');
  94. }
  95. }
  96. if(checksubmit('export_submit', true)) {
  97. if($_GPC['time']['start']==$_GPC['time']['end']){
  98. $dcstart=strtotime(date('Y-m-d 00:00:00'));
  99. $dcend=strtotime(date('Y-m-d 23:59:59'));
  100. $note=$_GPC['time']['start']."帖子数据";
  101. }else{
  102. $dcstart=strtotime($_GPC['time']['start']." 00:00:00");
  103. $dcend=strtotime($_GPC['time']['end']." 23:59:59");
  104. $note=$_GPC['time']['start']."至".$_GPC['time']['end']."帖子数据";
  105. }
  106. $count = pdo_fetchcolumn("SELECT COUNT(*) FROM". tablename("zhtc_information")." WHERE uniacid={$_W['uniacid']} and state=2 and time>={$dcstart} and time<={$dcend}");
  107. $pagesize = ceil($count/5000);
  108. //array_unshift( $names, '活动名称');
  109. $header = array(
  110. 'id'=>'帖子id',
  111. 'img' => '图片',
  112. 'user_name' => '联系人',
  113. 'user_tel' => '联系电话',
  114. 'user_id' => '用户id',
  115. 'type_name' => '一级分类',
  116. 'nTypeName' => '二级分类',
  117. 'money' => '发布金额',
  118. 'time' => '发布时间',
  119. 'hot' => '是否热门',
  120. 'top' => '是否置顶',
  121. );
  122. $keys = array_keys($header);
  123. $html = "\xEF\xBB\xBF";
  124. foreach ($header as $li) {
  125. $html .= $li . "\t ,";
  126. }
  127. $html .= "\n";
  128. for ($j = 1; $j <= $pagesize; $j++) {
  129. $sql = "select a.*,b.type_name,c.name as nTypeName from " . tablename("zhtc_information")." a" . " left join " . tablename("zhtc_type")." b on a.type_id=b.id left join " . tablename("zhtc_type2")." c on a.type2_id=c.id WHERE a.uniacid={$_W['uniacid']} and a.state=2 and a.time>={$dcstart} and a.time<={$dcend} limit " . ($j - 1) * 5000 . ",5000 ";
  130. $list = pdo_fetchall($sql);
  131. if (!empty($list)) {
  132. $size = ceil(count($list) / 500);
  133. for ($i = 0; $i < $size; $i++) {
  134. $buffer = array_slice($list, $i * 500, 500);
  135. $user = array();
  136. foreach ($buffer as $k =>$row) {
  137. $row['img']=str_replace(',','#',$row['img']);
  138. if($row['hot']==1){
  139. $row['hot']='是';
  140. }else{
  141. $row['hot']='否';
  142. }
  143. if($row['top']==1){
  144. $row['top']='是';
  145. }else{
  146. $row['top']='否';
  147. }
  148. $row['time']=date('Y-m-d H:i:s',$row['time']);
  149. $row['cityname']=$row['cityname']?:'全国';
  150. foreach ($keys as $key) {
  151. $data5[] = $row[$key];
  152. }
  153. $user[] = implode("\t ,", $data5) . "\t ,";
  154. unset($data5);
  155. }
  156. $html .= implode("\n", $user) . "\n";
  157. }
  158. }
  159. }
  160. header("Content-type:text/csv");
  161. header("Content-Disposition:attachment; filename=".$note.".csv");
  162. echo $html;
  163. exit();
  164. }
  165. include $this->template('web/information');