LogAction.class.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 LogAction extends CommonAction{
  10. public function index()
  11. {
  12. if(trim($_REQUEST['log_info'])!='')
  13. {
  14. $map['log_info'] = array('like','%'.trim($_REQUEST['log_info']).'%');
  15. }
  16. $log_begin_time = trim($_REQUEST['log_begin_time'])==''?0:to_timespan($_REQUEST['log_begin_time']);
  17. $log_end_time = trim($_REQUEST['log_end_time'])==''?0:to_timespan($_REQUEST['log_end_time']);
  18. if($log_end_time==0)
  19. {
  20. $map['log_time'] = array('gt',$log_begin_time);
  21. }
  22. else
  23. $map['log_time'] = array('between',array($log_begin_time,$log_end_time));
  24. $this->assign("default_map",$map);
  25. parent::index();
  26. }
  27. public function foreverdelete() {
  28. /*//彻底删除指定记录
  29. $ajax = intval($_REQUEST['ajax']);
  30. $id = $_REQUEST ['id'];
  31. if (isset ( $id )) {
  32. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  33. $list = M(MODULE_NAME)->where ( $condition )->delete();
  34. if ($list!==false) {
  35. save_log(l("FOREVER_DELETE_SUCCESS"),1);
  36. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  37. } else {
  38. save_log(l("FOREVER_DELETE_FAILED"),0);
  39. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  40. }
  41. } else {
  42. $this->error (l("INVALID_OPERATION"),$ajax);
  43. }*/
  44. }
  45. public function claer_log() {
  46. //彻底删除指定记录
  47. $ajax = intval($_REQUEST['ajax']);
  48. $table = DB_PREFIX . 'log_history';
  49. $res = $GLOBALS['db']->getRow("SHOW TABLES LIKE'$table'");
  50. if (!$res) {
  51. $sql= "CREATE TABLE `$table` (
  52. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  53. `log_info` text NOT NULL COMMENT '日志信息',
  54. `log_time` int(11) NOT NULL COMMENT '日志时间',
  55. `log_admin` int(11) NOT NULL COMMENT '日志管理',
  56. `log_ip` varchar(255) NOT NULL COMMENT '日志IP',
  57. `log_status` tinyint(1) NOT NULL COMMENT '日志状态',
  58. `module` varchar(255) NOT NULL COMMENT '模块',
  59. `action` varchar(255) NOT NULL COMMENT '方法',
  60. PRIMARY KEY (`id`)
  61. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='系统日志历史表';";
  62. $res = $GLOBALS['db']->query($sql);
  63. }
  64. $fields = " log_info,log_time,log_admin,log_ip,log_status,module,action ";
  65. $sql = "insert into ".DB_PREFIX."log_history(".$fields.") select ".$fields." from ".DB_PREFIX."log ";
  66. $res = $GLOBALS['db']->query($sql);
  67. if ($res!==false) {
  68. $sql= "delete from ".DB_PREFIX."log ";
  69. $GLOBALS['db']->query($sql);
  70. save_log('清除日志成功',1);
  71. $this->success ('清除日志成功',$ajax);
  72. } else {
  73. save_log('清除日志失败',0);
  74. $this->error ('清除日志失败',$ajax);
  75. }
  76. }
  77. }
  78. ?>