-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogViewer.php
executable file
·99 lines (88 loc) · 2.68 KB
/
logViewer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
include('config.php');
include_once( INSTALL_PATH . '/DBRecord.class.php' );
include_once( INSTALL_PATH . '/Smarty/Smarty.class.php' );
include_once( INSTALL_PATH . '/Settings.class.php' );
include_once( INSTALL_PATH . '/reclib.php' );
$settings = Settings::factory();
if( isset( $_GET['levels'] ) ){
$level0 = $level1 = $level2 = $level3 = FALSE;
foreach( explode( ',', $_GET['levels'] ) as $who_lv ){
switch( $who_lv ){
case '0':
$level0 = TRUE;
break;
case '1':
$level1 = TRUE;
break;
case '2':
$level2 = TRUE;
break;
case '3':
$level3 = TRUE;
break;
}
}
}else{
$level0 = isset($_POST['level0']);
$level1 = isset($_POST['level1']);
$level2 = isset($_POST['level2']);
$level3 = isset($_POST['level3']);
if( !$level0 && !$level1 && !$level2 && !$level3 )
$level0 = $level1 = $level2 = TRUE;
}
$log_levels = array(
0 => array( 'label' => '情報', 'view' => $level0 ),
1 => array( 'label' => '警告', 'view' => $level1 ),
2 => array( 'label' => 'エラー', 'view' => $level2 ),
3 => array( 'label' => 'DEBUG', 'view' => $level3 ),
);
$search = '';
foreach( $log_levels as $key => $level ){
if( $level['view'] ){
if( $search !== '' )
$search .= ',';
$search .= (string)$key;
}
}
$sql_que = 'level IN ('.$search.')';
$page = 1;
$full_mode = FALSE;
$separate_records = SEPARATE_RECORDS_LOGVIEW!==FALSE ? SEPARATE_RECORDS_LOGVIEW : SEPARATE_RECORDS;
if( $separate_records===FALSE || $separate_records<1 )
$full_mode = TRUE;
else
if( isset( $_GET['page']) ){
if( $_GET['page'] === '-' )
$full_mode = TRUE;
else
$page = (int)$_GET['page'];
}
if( $full_mode ){
$log_limit = '';
$pager = '';
}else{
$all_cnt = DBRecord::countRecords( LOG_TBL, $sql_que!=='' ? 'WHERE '.$sql_que : '' );
$log_limit = ' LIMIT '.(($page-1)*$separate_records).','.$separate_records;
$pager = make_pager( 'logViewer.php', $separate_records, $all_cnt, $page, 'levels='.$search.'&' ) ;
}
$log_obj = new DBRecord( LOG_TBL );
$arr = $log_obj->fetch_array( null, null, $sql_que.' ORDER BY logtime DESC, id DESC'.$log_limit );
$logs = array();
foreach( $arr as $low ){
$log = array();
$log['level'] = (int)$low['level'];
$log['label'] = $log_levels[$log['level']]['label'];
$log['logtime'] = $low['logtime'];
$log['message'] = $low['message'];
array_push( $logs, $log );
}
$smarty = new Smarty();
$smarty->assign( 'sitetitle' , 'epgrec動作ログ' );
$smarty->assign( 'logs', $logs );
$smarty->assign( 'log_levels', $log_levels );
$smarty->assign( 'pager', $pager );
$smarty->assign( 'menu_list', link_menu_create() );
$smarty->assign( 'spool_freesize', spool_freesize() );
$smarty->display( 'logTable.html' );
?>