modcp_log.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: modcp_log.php 25246 2011-11-02 03:34:53Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
  9. exit('Access Denied');
  10. }
  11. if(!isset($_G['cache']['forums'])) {
  12. loadcache('forums');
  13. }
  14. $language = lang('forum/misc');
  15. $lpp = empty($_GET['lpp']) ? 20 : intval($_GET['lpp']);
  16. $lpp = min(200, max(5, $lpp));
  17. $logdir = DISCUZ_ROOT.'./data/log/';
  18. $logfiles = get_log_files($logdir, 'modcp');
  19. $logs = array();
  20. foreach($logfiles as $logfile) {
  21. $logs = array_merge($logs, file($logdir.$logfile));
  22. }
  23. $page = max(1, intval($_G['page']));
  24. $start = ($page - 1) * $lpp;
  25. $logs = array_reverse($logs);
  26. if(!empty($_GET['keyword'])) {
  27. foreach($logs as $key => $value) {
  28. if(strpos($value, $_GET['keyword']) === FALSE) {
  29. unset($logs[$key]);
  30. }
  31. }
  32. } else {
  33. $_GET['keyword'] = '';
  34. }
  35. $num = count($logs);
  36. $multipage = multi($num, $lpp, $page, "$cpscript?mod=modcp&action=log&lpp=$lpp&keyword=".rawurlencode($_GET['keyword']));
  37. $logs = array_slice($logs, $start, $lpp);
  38. $keyword = isset($_GET['keyword']) ? dhtmlspecialchars($_GET['keyword']) : '';
  39. $usergroup = array();
  40. $filters = '';
  41. $loglist = array();
  42. foreach($logs as $logrow) {
  43. $log = explode("\t", $logrow);
  44. if(empty($log[1])) {
  45. continue;
  46. }
  47. $log[1] = dgmdate($log[1], 'y-n-j H:i');
  48. if(strtolower($log[2]) == strtolower($_G['member']['username'])) {
  49. $log[2] = '<a href="home.php?mod=space&username='.rawurlencode($log[2]).'" target="_blank"><b>'.$log[2].'</b></a>';
  50. }
  51. $log[5] = trim($log[5]);
  52. $check = 'modcp_logs_action_'.$log[5];
  53. $log[5] = isset($language[$check]) ? $language[$check] : $log[5];
  54. $log[7] = intval($log[7]);
  55. $log[7] = !empty($log[7]) ? '<a href="forum.php?mod=forumdisplay&fid='.$log[7].'" target="_blank">'.strip_tags("{$_G['cache']['forums'][$log[7]]['name']}").'</a>' : '';
  56. $log[8] = str_replace(array('GET={};', 'POST={};', 'mod=modcp;', 'action='.$log[5].';', 'diy=;', 'op='.$log[6].';'), '', $log[8]);
  57. $log[8] = cutstr($log['8'], 60);
  58. $loglist[] = $log;
  59. }
  60. function get_log_files($logdir='', $action='action') {
  61. $dir = opendir($logdir);
  62. $files = array();
  63. while($entry = readdir($dir)) {
  64. $files[] = $entry;
  65. }
  66. closedir($dir);
  67. sort($files);
  68. $logfile = $action;
  69. $logfiles = array();
  70. foreach($files as $file) {
  71. if(strpos($file, $logfile) !== FALSE) {
  72. $logfiles[] = $file;
  73. }
  74. }
  75. $logfiles = array_slice($logfiles, -2, 2);
  76. return $logfiles;
  77. }
  78. ?>