TipoffAction.class.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 TipoffAction extends CommonAction{
  10. public function index()
  11. {
  12. $now=get_gmtime();
  13. if(trim($_REQUEST['video_id'])!='')
  14. {
  15. $map[DB_PREFIX.'tipoff.video_id'] = array('like','%'.trim($_REQUEST['video_id']).'%');
  16. }
  17. if(trim($_REQUEST['from_user_id'])!='')
  18. {
  19. $user=M("User")->where("nick_name like '%".trim($_REQUEST['from_user_id'])."%' ")->findAll();
  20. $user_arr_id = array();
  21. foreach($user as $k=>$v){
  22. $user_arr_id[$k] =intval($v['id']);
  23. }
  24. $map[DB_PREFIX.'tipoff.from_user_id'] = array('in',$user_arr_id);
  25. }
  26. if(trim($_REQUEST['to_user_id'])!='')
  27. {
  28. $user=M("User")->where("nick_name like '%".trim($_REQUEST['to_user_id'])."%' ")->findAll();
  29. $user_arr_id = array();
  30. foreach($user as $k=>$v){
  31. $user_arr_id[$k] =intval($v['id']);
  32. }
  33. $map[DB_PREFIX.'tipoff.to_user_id'] = array('in',$user_arr_id);
  34. }
  35. if(intval($_REQUEST['tipoff_type_id'])>0)
  36. {
  37. $map[DB_PREFIX.'tipoff.tipoff_type_id'] = intval($_REQUEST['tipoff_type_id']);
  38. }
  39. $create_time_2=empty($_REQUEST['create_time_2'])?to_date($now,'Y-m-d'):strim($_REQUEST['create_time_2']);
  40. $create_time_2=to_timespan($create_time_2)+24*3600;
  41. if(trim($_REQUEST['create_time_1'])!='' )
  42. {
  43. $map[DB_PREFIX.'tipoff.create_time'] = array('between',array(to_timespan($_REQUEST['create_time_1']),$create_time_2));
  44. }
  45. if (method_exists ( $this, '_filter' )) {
  46. $this->_filter ( $map );
  47. }
  48. $name=$this->getActionName();
  49. $model = D ($name);
  50. if (! empty ( $model )) {
  51. $this->_list ( $model, $map );
  52. }
  53. //举报类型
  54. $condition['is_effect'] = 1;
  55. $tipoff = M('TipoffType')->where($condition)->findAll();
  56. $this->assign ( 'tipoff', $tipoff );
  57. $this->display ();
  58. }
  59. public function edit() {
  60. $id = intval($_REQUEST ['id']);
  61. $condition['id'] = $id;
  62. $vo = M(MODULE_NAME)->where($condition)->find();
  63. $vo['from_user_name'] = emoji_decode(M("User")->where("id = ".$vo['from_user_id'])->getField("nick_name"));
  64. $vo['to_user_name'] = emoji_decode(M("User")->where("id = ".$vo['to_user_id'])->getField("nick_name"));
  65. $this->assign ( 'vo', $vo );
  66. $tipoff_condition['is_effect'] = 1;
  67. $tipoff = M('TipoffType')->where($tipoff_condition)->findAll();
  68. $this->assign ( 'tipoff', $tipoff );
  69. $this->display ();
  70. }
  71. public function update() {
  72. B('FilterString');
  73. $data = M(MODULE_NAME)->create();
  74. $log_info = M(MODULE_NAME)->where("id=".intval($data['id']))->getField("id");
  75. //开始验证有效性
  76. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  77. // 更新数据
  78. $list=M(MODULE_NAME)->save ($data);
  79. if (false !== $list) {
  80. //成功提示
  81. save_log($log_info.L("UPDATE_SUCCESS"),1);
  82. clear_auto_cache("get_help_cache");
  83. $this->success(L("UPDATE_SUCCESS"));
  84. } else {
  85. //错误提示
  86. save_log($log_info.L("UPDATE_FAILED"),0);
  87. $this->error(L("UPDATE_FAILED"),0,$log_info.L("UPDATE_FAILED"));
  88. }
  89. }
  90. public function foreverdelete() {
  91. //彻底删除指定记录
  92. $ajax = intval($_REQUEST['ajax']);
  93. $id = $_REQUEST ['id'];
  94. if (isset ( $id )) {
  95. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  96. $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  97. foreach($rel_data as $data)
  98. {
  99. $info[] = $data['from_user_id'].'举报'.$data['to_user_id'];
  100. }
  101. if($info) $info = implode(",",$info);
  102. $list = M(MODULE_NAME)->where ( $condition )->delete();
  103. //删除相关预览图
  104. // foreach($rel_data as $data)
  105. // {
  106. // @unlink(get_real_path().$data['preview']);
  107. // }
  108. if ($list!==false) {
  109. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  110. clear_auto_cache("get_help_cache");
  111. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  112. } else {
  113. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  114. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  115. }
  116. } else {
  117. $this->error (l("INVALID_OPERATION"),$ajax);
  118. }
  119. }
  120. }
  121. ?>