-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver-log-ajax.php
More file actions
39 lines (33 loc) · 973 Bytes
/
server-log-ajax.php
File metadata and controls
39 lines (33 loc) · 973 Bytes
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
<?php if ( !defined( 'STUZZPANEL' ) ) exit; ?>
<?php
require_once 'server-log-shared.php';
$log = array();
$l = 0;
foreach ( file( 'server.log' ) as $line ) {
$l++;
if ( $l <= $_GET['line'] )
continue;
$class = '';
$line = ansi_colors( htmlspecialchars( rtrim( $line ) ) );
if ( preg_match( '/^\tat |^\S+Exception$/', $line ) ) {
$class = 'error';
} elseif ( preg_match( '/^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d \[([A-Z]+)\]/', $line, $level ) ) {
$class = strtolower( $level[1] );
}
$log[] = array( $class, $line );
}
if ( $l < $_GET['line'] )
$l = -1;
?>
(function($) {
$.each( <?php echo json_encode( $log ); ?>, function( _, entry ) {
$( '.server-log' ).append( $( '<div>' ).addClass( entry[0] ).html( entry[1] ) );
})
<?php if ( $log ) { ?>
$( '.server-log' )[0].scrollTop = 1e20;
<?php } ?>
logline = <?php echo $l; ?>;
<?php if ( $_GET['key'] != $session_key ) { ?>
$( '#req_key' ).val( '<?php echo $session_key; ?>' );
<?php } ?>
})(jQuery)