WeiboListAction.class.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class WeiboListAction extends CommonAction{
  10. public function index($type='')
  11. {
  12. $weibo = $this->get_weibo_list();
  13. $this->assign ( 'list', $weibo );
  14. $this->display ();
  15. }
  16. public function imagetext(){
  17. $weibo = $this->get_weibo_list('imagetext');
  18. $this->assign ( 'list', $weibo );
  19. $this->display ();
  20. }
  21. public function video(){
  22. $weibo = $this->get_weibo_list('video');
  23. $this->assign ( 'list', $weibo );
  24. $this->display ();
  25. }
  26. public function weixin(){
  27. $weibo = $this->get_weibo_list('weixin');
  28. $this->assign ( 'list', $weibo );
  29. $this->display ();
  30. }
  31. public function photo(){
  32. $weibo = $this->get_weibo_list('photo');
  33. $this->assign ( 'list', $weibo );
  34. $this->display ();
  35. }
  36. public function red_photo(){
  37. $weibo = $this->get_weibo_list('red_photo');
  38. $this->assign ( 'list', $weibo );
  39. $this->display ();
  40. }
  41. public function goods(){
  42. $weibo = $this->get_weibo_list('goods');
  43. $this->assign ( 'list', $weibo );
  44. $this->display ();
  45. }
  46. public function get_weibo_list($type='',$is_recommend=0){
  47. $now=get_gmtime();
  48. $condition = ' 1 = 1 ';
  49. if(intval($_REQUEST['weibo_id'])>0)
  50. {
  51. $condition .= " and id =". intval($_REQUEST['weibo_id']);
  52. }
  53. if(intval($_REQUEST['user_id'])>0)
  54. {
  55. $condition .= " and user_id =". intval($_REQUEST['user_id']);
  56. }
  57. if(!$type){
  58. $type = $_REQUEST['type'];
  59. }
  60. if(trim($type))
  61. {
  62. $condition .= " and type ='". trim($type)."'";
  63. }
  64. if(intval($is_recommend)){
  65. $condition .= " and is_recommend =". intval($is_recommend);
  66. }
  67. $create_time_2=empty($_REQUEST['create_time_2'])?to_date($now,'Y-m-d'):strim($_REQUEST['create_time_2']);
  68. $create_time_2=to_timespan($create_time_2)+24*3600;
  69. $create_time_2 = to_date($create_time_2,'Y-m-d H:i:s');
  70. if(trim($_REQUEST['create_time_1'])!='' )
  71. {
  72. // $map[DB_PREFIX.'weibo.create_time'] = array('between',array(to_timespan($_REQUEST['create_time_1']),$create_time_2));
  73. $condition .= " and create_time>'".$_REQUEST['create_time_1']."' and create_time<'".$create_time_2."'";
  74. }
  75. // echo $condition;
  76. $count = M('Weibo')->where($condition)->count();
  77. $p = new Page($count, $listRows = 20);
  78. //举报类型
  79. $weibo = M('Weibo')->where($condition)->order('id desc')->limit($p->firstRow . ',' . $p->listRows)->findAll();
  80. $page = $p->show();
  81. $this->assign("page", $page);
  82. return $weibo;
  83. }
  84. public function foreverdelete() {
  85. //彻底删除指定记录
  86. $ajax = intval($_REQUEST['ajax']);
  87. $id = $_REQUEST ['id'];
  88. if (isset ( $id )) {
  89. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  90. $rel_data = M('Weibo')->where($condition)->findAll();
  91. foreach($rel_data as $data)
  92. {
  93. $info[] = $data['user_id'].'的动态'.$data['id'];
  94. }
  95. if($info) $info = implode(",",$info);
  96. $list = M('Weibo')->where ( $condition )->delete();
  97. //删除相关预览图
  98. // foreach($rel_data as $data)
  99. // {
  100. // @unlink(get_real_path().$data['preview']);
  101. // }
  102. if ($list!==false) {
  103. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  104. clear_auto_cache("get_help_cache");
  105. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  106. } else {
  107. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  108. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  109. }
  110. } else {
  111. $this->error (l("INVALID_OPERATION"),$ajax);
  112. }
  113. }
  114. //推荐微博
  115. public function weibo_recommend(){
  116. $weibo = $this->get_weibo_list('',1);
  117. $this->assign ( 'list', $weibo );
  118. $this->display ();
  119. }
  120. //设置推荐
  121. public function set_recommend()
  122. {
  123. $id = intval($_REQUEST['id']);
  124. $c_is_effect = M('Weibo')->where("id=".$id)->getField("is_recommend"); //当前状态
  125. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  126. $result=M('Weibo')->where("id=".$id)->setField("is_recommend",$n_is_effect);
  127. // save_log("房间号".$id.l("SET_RECOMMEND_".$n_is_effect),1);
  128. $this->ajaxReturn($n_is_effect,l("SET_BAN_".$n_is_effect),1);
  129. }
  130. //设置推荐
  131. public function set_effect()
  132. {
  133. $id = intval($_REQUEST['id']);
  134. $c_is_effect = M('Weibo')->where("id=".$id)->getField("status"); //当前状态
  135. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  136. $result=M('Weibo')->where("id=".$id)->setField("status",$n_is_effect);
  137. $this->ajaxReturn($n_is_effect,l("SET_BAN_".$n_is_effect),1);
  138. }
  139. }
  140. ?>