人人商城

logs.ctrl.php 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. $_W['page']['title'] = '查看日志 - 系统管理';
  10. $params = array();
  11. $where = '';
  12. $order = ' ORDER BY `id` DESC';
  13. if ($_GPC['time']) {
  14. $starttime = strtotime($_GPC['time']['start']);
  15. $endtime = strtotime($_GPC['time']['end']);
  16. $timewhere = ' AND `createtime` >= :starttime AND `createtime` < :endtime';
  17. $params[':starttime'] = $starttime;
  18. $params[':endtime'] = $endtime + 86400;
  19. }
  20. if ($do == 'wechat') {
  21. $path = IA_ROOT . '/data/logs/';
  22. $files = glob($path . '*');
  23. if (!empty($_GPC['searchtime'])) {
  24. $searchtime = $_GPC['searchtime'] . '.log';
  25. } else {
  26. $searchtime = date('Ymd', time()) . '.log';
  27. }
  28. $tree = array();
  29. foreach ($files as $key => $file) {
  30. if (!preg_match('/\/[0-9]+\.log/', $file)) {
  31. continue;
  32. }
  33. $pathinfo = pathinfo($file);
  34. array_unshift($tree, $pathinfo['filename']);
  35. if (strexists($file, $searchtime)) {
  36. $contents = file_get_contents($file);
  37. }
  38. }
  39. }
  40. if ($do == 'system') {
  41. $pindex = max(1, intval($_GPC['page']));
  42. $psize = 10;
  43. $where .= " WHERE `type` = '1'";
  44. $sql = 'SELECT * FROM ' . tablename('core_performance') . " $where $timewhere $order LIMIT " . ($pindex - 1) * $psize .','. $psize;
  45. $list = pdo_fetchall($sql, $params);
  46. foreach ($list as $key => $value) {
  47. $list[$key]['type'] = '系统日志';
  48. $list[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
  49. }
  50. $total = pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename('core_performance'). $where . $timewhere , $params);
  51. $pager = pagination($total, $pindex, $psize);
  52. }
  53. if ($do == 'database') {
  54. $pindex = max(1, intval($_GPC['page']));
  55. $psize = 10;
  56. $where .= " WHERE `type` = '2'";
  57. $sql = 'SELECT * FROM ' . tablename('core_performance') . " $where $timewhere $order LIMIT " . ($pindex - 1) * $psize .','. $psize;
  58. $list = pdo_fetchall($sql, $params);
  59. foreach ($list as $key => $value) {
  60. $list[$key]['type'] = '数据库日志';
  61. $list[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
  62. }
  63. $total = pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename('core_performance'). $where . $timewhere , $params);
  64. $pager = pagination($total, $pindex, $psize);
  65. }
  66. if ($do == 'sms') {
  67. if (!empty($_GPC['mobile'])) {
  68. $timewhere .= ' AND `mobile` LIKE :mobile ';
  69. $params[':mobile'] = "%{$_GPC['mobile']}%";
  70. }
  71. $pindex = max(1, intval($_GPC['page']));
  72. $psize = 40;
  73. $params[':uniacid'] = $_W['uniacid'];
  74. $sql = "SELECT * FROM". tablename('core_sendsms_log'). " WHERE uniacid = :uniacid ". $timewhere. " ORDER BY id DESC LIMIT ". ($pindex-1)*$psize . ','. $psize;
  75. $list = pdo_fetchall($sql, $params);
  76. $total = pdo_fetchcolumn("SELECT COUNT(*) FROM". tablename('core_sendsms_log'). " WHERE uniacid = :uniacid". $timewhere, $params);
  77. $pager = pagination($total, $pindex, $psize);
  78. }
  79. template('system/logs');