logs.ctrl.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. $dos = array('wechat', 'system', 'database','sms');
  8. $do = in_array($do, $dos) ? $do : 'wechat';
  9. $params = array();
  10. $where = '';
  11. $order = ' ORDER BY `id` DESC';
  12. if ($_GPC['time']) {
  13. $starttime = strtotime($_GPC['time']['start']);
  14. $endtime = strtotime($_GPC['time']['end']);
  15. $timewhere = ' AND `createtime` >= :starttime AND `createtime` < :endtime';
  16. $params[':starttime'] = $starttime;
  17. $params[':endtime'] = $endtime + 86400;
  18. }
  19. if ($do == 'wechat') {
  20. $path = IA_ROOT . '/data/logs/';
  21. $files = glob($path . '*');
  22. if (!empty($_GPC['searchtime'])) {
  23. $searchtime = $_GPC['searchtime'] . '.php';
  24. } else {
  25. $searchtime = date('Ymd', time()) . '.php';
  26. }
  27. $tree = array();
  28. foreach ($files as $key => $file) {
  29. if (!preg_match('/\/[0-9]+\.php/', $file)) {
  30. continue;
  31. }
  32. $pathinfo = pathinfo($file);
  33. array_unshift($tree, $pathinfo['filename']);
  34. if (strexists($file, $searchtime)) {
  35. $contents = file_get_contents($file);
  36. }
  37. }
  38. }
  39. if ($do == 'system') {
  40. $pindex = max(1, intval($_GPC['page']));
  41. $psize = 10;
  42. $where .= " WHERE `type` = '1'";
  43. $sql = 'SELECT * FROM ' . tablename('core_performance') . " $where $timewhere $order LIMIT " . ($pindex - 1) * $psize .','. $psize;
  44. $list = pdo_fetchall($sql, $params);
  45. foreach ($list as $key => $value) {
  46. $list[$key]['type'] = '系统日志';
  47. $list[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
  48. }
  49. $total = pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename('core_performance'). $where . $timewhere , $params);
  50. $pager = pagination($total, $pindex, $psize);
  51. }
  52. if ($do == 'database') {
  53. $pindex = max(1, intval($_GPC['page']));
  54. $psize = 10;
  55. $where .= " WHERE `type` = '2'";
  56. $sql = 'SELECT * FROM ' . tablename('core_performance') . " $where $timewhere $order LIMIT " . ($pindex - 1) * $psize .','. $psize;
  57. $list = pdo_fetchall($sql, $params);
  58. foreach ($list as $key => $value) {
  59. $list[$key]['type'] = '数据库日志';
  60. $list[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
  61. }
  62. $total = pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename('core_performance'). $where . $timewhere , $params);
  63. $pager = pagination($total, $pindex, $psize);
  64. }
  65. if ($do == 'sms') {
  66. if (!empty($_GPC['mobile'])) {
  67. $timewhere .= ' AND `mobile` LIKE :mobile ';
  68. $params[':mobile'] = "%{$_GPC['mobile']}%";
  69. }
  70. $pindex = max(1, intval($_GPC['page']));
  71. $psize = 40;
  72. $params[':uniacid'] = $_W['uniacid'];
  73. $sql = "SELECT * FROM". tablename('core_sendsms_log'). " WHERE uniacid = :uniacid ". $timewhere. " ORDER BY id DESC LIMIT ". ($pindex-1)*$psize . ','. $psize;
  74. $list = pdo_fetchall($sql, $params);
  75. $total = pdo_fetchcolumn("SELECT COUNT(*) FROM". tablename('core_sendsms_log'). " WHERE uniacid = :uniacid". $timewhere, $params);
  76. $pager = pagination($total, $pindex, $psize);
  77. }
  78. template('system/logs');