check.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. pc_base::load_app_class('admin', 'admin', 0);
  4. class check extends admin {
  5. //数据库连接
  6. private $comment_check_db,$comment_db,$comment;
  7. function __construct() {
  8. $this->comment_data_db = pc_base::load_model('comment_data_model');
  9. $this->comment_check_db = pc_base::load_model('comment_check_model');
  10. parent::__construct();
  11. $this->comment = pc_base::load_app_class('comment');
  12. }
  13. public function checks() {
  14. $total = $this->comment_check_db->count(array('siteid'=>$this->get_siteid()));
  15. $comment_check_data = $this->comment_check_db->select(array('siteid'=>$this->get_siteid()), '*', '20', 'id desc');
  16. if (empty($comment_check_data)) showmessage(L('no_check_comments').'<script>window.top.$("#display_center_id").css("display","none");</script>');
  17. pc_base::load_sys_class('format','', 0);
  18. $show_header = true;
  19. include $this->admin_tpl('comment_check');
  20. }
  21. public function ajax_checks() {
  22. $id = isset($_GET['id']) && $_GET['id'] ? $_GET['id'] : (isset($_GET['form']) ? showmessage(L('please_chose_comment'), HTTP_REFERER) : exit('0'));
  23. $type = isset($_GET['type']) && intval($_GET['type']) ? intval($_GET['type']) : exit('0');
  24. $commentid = isset($_GET['commentid']) && trim($_GET['commentid']) ? safe_replace(trim($_GET['commentid'])) : exit('0');
  25. if (is_array($id)) {
  26. foreach ($id as $v) {
  27. if (!$v = intval($v)) {
  28. continue;
  29. }
  30. $this->comment->status($commentid, $v, $type);
  31. }
  32. showmessage(L('operation_success'), HTTP_REFERER);
  33. } else {
  34. $id = intval($id) ? intval($id) : exit('0');
  35. $this->comment->status($commentid, $id, $type);
  36. }
  37. if ($comment->msg_code != 0) {
  38. exit($comment->get_error());
  39. } else {
  40. exit('1');
  41. }
  42. }
  43. public function public_get_one() {
  44. $total = $this->comment_check_db->count(array('siteid'=>$this->get_siteid()));
  45. $comment_check_data = $this->comment_check_db->select(array('siteid'=>$this->get_siteid()), '*', '19,1', 'id desc');
  46. $comment_check_data = $comment_check_data[0];
  47. $r = array();
  48. if (is_array($comment_check_data) && !empty($comment_check_data)) {
  49. $this->comment_data_db->table_name($comment_check_data['tableid']);
  50. $r = $this->comment_data_db->get_one(array('id'=>$comment_check_data['comment_data_id'], 'siteid'=>$this->get_siteid()));
  51. pc_base::load_sys_class('format','', 0);
  52. $r['creat_at'] = format::date($r['creat_at'], 1);
  53. if (pc_base::load_config('system','charset')=='gbk') {
  54. foreach ($r as $k=>$v) {
  55. $r[$k] = iconv('gbk', 'utf-8', $v);
  56. }
  57. }
  58. }
  59. echo json_encode(array('total'=>$total, 'data'=>$r));
  60. }
  61. }