' . $type . ''; $r .= '
';
	$r .= ( $headers === true ) ? 'Regex: ' . $regex . "\n" : '';
	$r .= ( $headers === true ) ? 'Log  : ' . $logs . "\n" : '';
	$r .= ( $headers === true ) ? "\n" : '';

	$logs   = array_reverse( explode( "\n" , $logs ) );
	$rank   = 0;
	$size   = count( strval( count($logs) ) ) + 2;
	$blan   = str_pad( '' , $size );
	$buffer = array();

	foreach( $logs as $log ) {

		$tokens = LogParser::parseLine( $regex , $match , $log , $types );

		if ( is_array( $tokens ) ) {
			$rank++;
			$disp = ( $headers ) ? '' : str_pad( '#' . $rank , $size );

			$maxlength = 0;
			foreach ( $tokens as $token => $value ) $maxlength = max( $maxlength , strlen( $token ) );

			$r .= ( $headers ) ? '' : '' . $disp . $log . "\n";

			foreach ( $tokens as $token => $value ) {
				if ( substr( $token , 0 , 3 ) === 'pml' ) continue;

				$r .= $blan . '' . str_pad( $token , $maxlength ) . ': ' . $value;

				if ( $token === $multiline ) {
					if ( count( $buffer ) > 0 ) {
						$buffer = array_reverse( $buffer );
						foreach ( $buffer as $append ) {
							$r .= "\n" . $blan . str_pad( '' , $maxlength ) . '  ' . $append;
						}
					}
				}

				$r .= "\n";
			}

			$r .= "\n";
			$buffer = array();
		}

		else {
			$buffer[] = $log;
		}

	}

	$r .= '
'; return $r; } /** * Ajax return for regexp tester */ if ( ( @$_POST['action'] === 'regextest' ) && ( file_exists( $access_file ) ) ) { $return = array(); $match = @json_decode( $_POST['m'] , true ); $types = @json_decode( $_POST['t'] , true ); $regex = $_POST['r']; $log = $_POST['l']; $multiline = $_POST['u']; if ( ! is_array( $match ) ) { $return['err'] = 'inputMatch'; $return['msg'] = '
' . __('Error') . ' '. __('Match is not a valid associative array') . '
'; echo json_encode( $return ); die(); } if ( ! is_array( $types ) ) { $return['err'] = 'inputTypes'; $return['msg'] = '
' . __('Error') . ' '. __('Types is not a valid associative array') . '
'; echo json_encode( $return ); die(); } if ( @preg_match( $regex , 'this is just a test !' ) === false ) { $return['err'] = 'inputRegEx'; $return['msg'] = '
' . __('Error') . ' '. __('RegEx is not a valid PHP PCRE regular expression') . '
'; echo json_encode( $return ); die(); } header('Content-type: application/json'); $return['msg'] = test( '' , $regex , $match, $types, $log , false , $multiline ); echo json_encode( $return ); die(); } ////////////////////// // Javascript Lemma // ////////////////////// $lemma = array( "configuration_copied" => __( "Configuration array has been copied to your clipboard!" ), ); ?><?php echo TITLE;?>

'; echo '
'; echo __( 'This page is protected for security reasons.'); echo '
'; if ( Sentinel::isAuthSet() ) { echo sprintf( __('%sSign in%s as an administrator to view this page or follow instructions below.') , '' , '' ) . '
'; } echo '
' . __('To grant access, please create this temporary file on your server:'); echo '

'; echo '
'; echo '
touch \'' . dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $access_file . '\'
'; echo '
' . __('Copy to clipboard') . '
'; echo '
'; echo '
' . __("Then reload this page.") . '

'; echo ''; echo '
'; echo '
'; } else { ?>

';?>
 
1, 'IP' => 4, 'Log' => 5, 'Severity' => 2, 'Referer' => 7, ); echo test( $type , $regex , $match , $types , $log ); $type = 'Error Apache 2.2 server restart'; $log = '[Thu Nov 28 14:03:10 2013] [notice] SIGHUP received. Attempting to restart'; echo test( $type , $regex , $match , $types , $log ); $type = 'Error Apache 2.2 without referer'; $log = '[Wed Nov 27 09:30:11 2013] [error] [client 127.0.0.1] PHP 1. {main}() /Users/potsky/Private/Work/GitHub/PHPApacheLogViewer/inc/get_logs.php:0'; echo test( $type , $regex , $match , $types , $log ); $type = 'Error Apache 2.4 with referer and without module name'; $log = "[Fri Oct 11 04:41:06.897613 2013] [:error] [pid 61939] [client 192.168.207.71:44171] script '/usr/local/www/apache24/data/test.php' not found or unable to stat, referer: [localhost]"; $regex = '|^\[(.*) (.*) (.*) (.*):(.*):(.*)\.(.*) (.*)\] \[(.*):(.*)\] \[pid (.*)\] .*\[client (.*):(.*)\] (.*)(, referer: (.*))*$|U'; $match = array( 'Date' => array( 'M' => 2, 'd' => 3, 'H' => 4, 'i' => 5, 's' => 6, 'Y' => 8, ), 'IP' => 12, 'Log' => 14, 'Severity' => 10, 'Referer' => 16, ); echo test( $type , $regex , $match , $types , $log ); $type = 'Error Apache 2.4 without referer and without module name'; $log = "[Fri Oct 11 04:41:06.897613 2013] [:error] [pid 61939] [client 192.168.207.71:44171] script '/usr/local/www/apache24/data/test.php' not found or unable to stat"; echo test( $type , $regex , $match , $types , $log ); $type = 'Error Apache 2.4 with referer and with module name'; $log = "[Sat Nov 24 23:24:18.318257 2012] [authz_core:debug] [pid 21841:tid 140204006696704] mod_authz_core.c(802): [client 80.8.82.242:62269] AH01626: authorization result of Require all granted: granted, referer: http://www.adza.com/"; $match = array( 'Date' => array( 'M' => 2, 'd' => 3, 'H' => 4, 'i' => 5, 's' => 6, 'Y' => 8, ), 'IP' => 12, 'Log' => array( ' >>> ' , 9 , 14), 'Severity' => 10, 'Referer' => 16, ); echo test( $type , $regex , $match , $types , $log ); $type = 'Access Apache 2.2 with referer and user agent'; $log = '127.0.0.1 - - [27/Nov/2013:10:20:40 +0100] "GET /~potsky/PHPApacheLogViewer/inc/get_logs.php?ldv=false&file=access&max=27 HTTP/1.1" 200 33 "http://localhost/~potsky/PHPApacheLogViewer/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9) AppleWebKit/537.71 (KHTML, like Gecko) Version/7.0 Safari/537.71"'; $regex = '|^((\S*) )*(\S*) (\S*) (\S*) \[(.*)\] "(\S*) (.*) (\S*)" ([0-9]*) (.*)( "(.*)" "(.*)"( [0-9]*/([0-9]*))*)*$|U'; $match = array( 'CMD' => 7, 'Code' => 10, 'Date' => 6, 'IP' => 3, 'Referer' => 13, 'Size' => 11, 'UA' => 14, 'URL' => 8, 'User' => 5, 'Time' => 16, ); echo test( $type , $regex , $match , $types , $log ); $type = 'Access Apache 2.2 with virtual host referer and user agent'; $log = 'potsky.com 62.129.4.154 - rb [19/Dec/2013:16:11:22 +0100] "POST /P1mpmyL0g-dev/inc/getlog.pml.php?1387465882519 HTTP/1.1" 200 7660 "https://home.potsky.com/P1mpmyL0g-dev/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11"'; echo test( $type , $regex , $match , $types , $log ); $type = 'Access Apache 2.2 with tuning options'; $log = '62.129.4.154 - - [29/Nov/2013:18:13:22 +0100] "GET /PimpMyLogs/inc/getlog.pml.php?ldv=true&file=access&max=20 HTTP/1.1" 500 96 "http://www.potsky.com/PimpMyLogs/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9) AppleWebKit/537.71 (KHTML, like Gecko) Version/7.0 Safari/537.71" 10/10003980'; echo test( $type , $regex , $match , $types , $log ); $type = 'Access Apache 2.2 dummy SSL connection'; $log = '::1 - - [27/Nov/2013:12:02:08 +0100] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.25 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1e DAV/2 PHP/5.3.27 (internal dummy connection)"'; echo test( $type , $regex , $match , $types , $log ); ?>
= 0 ) {
											echo json_encode( $files , JSON_PRETTY_PRINT );
										} else {
											echo json_indent( json_encode( $logs ) );
										}
									?>

get_config_file_path(), ); if ( is_array( @$files ) ) { foreach ( $files as $fileid => $file ) { $paths[ '--> ' . $fileid ] = @$file['path']; $dir_name = realpath( $file['path'] ); if ( file_exists( $dir_name ) ) { while ( $dir_name != dirname( $dir_name ) ) { $dir_name = dirname( $dir_name ); $paths[ $dir_name ] = $dir_name; } } } } echo '
'; echo ''; echo ''; foreach ( $paths as $id => $file ) { set_error_handler( function($errno, $errstr, $errfile, $errline, array $errcontext) {}); if ( is_readable($file) ) { $r = __('Yes'); $rc = 'success'; } else { $r = __('No'); $rc = 'danger'; } if ( is_writable($file) ) { $w = __('Yes'); $wc = 'success'; } else { $w = __('No'); $wc = 'danger'; } $rp = realpath($file); restore_error_handler(); if ( empty( $rp ) ) { $rc = 'default'; $wc = 'default'; $rp = __('Not allowed by open_basedir restriction'); } echo ''; } echo ''; echo '
'.__('Read').''.__('Write').'ID'.__('Path').''.__('Real path').'
'. $r .' '. $w .' '.$id.' '.$file.' '.$rp.'
'; ?>
'; echo '
  • '; if ( MB_SUPPORT === true ) { echo 'Multibyte String ' . __('Yes') . ''; } else { echo 'Multibyte String ' . __('No') . ''; echo ' (' . sprintf( __('Follow instructions %shere%s to enable') , '' , '' ) . ')'; } echo '
  • '; echo '
  • '; if ( GETTEXT_SUPPORT === true ) { echo 'Gettext ' . __('Yes') . ''; } else { echo 'Gettext ' . __('No') . ''; echo ' (' . sprintf( __('Follow instructions %shere%s to enable') , '' , '' ) . ')'; } echo '
  • '; echo ''; ?>
    (.*?).*?(.*)%s', ob_get_clean(), $matches); echo $matches[2]; ?>
    '; } else if ( $_POST['password'] !== $_POST['password2'] ) { $return = '
    '; } else if ( mb_strlen( $_POST['password'] ) < 6 ) { $return = '
    '; } else { Sentinel::setAdmin( $_POST['username'] , $_POST['password'] ); Sentinel::save(); $return = '
    '; } } ?>



    rm ''
    ' . __('Copy to clipboard') . '
    ';?>






    ' . sprintf( __('User %s does not exist!') , '' . $_POST['username'] . '' ) . '
    '; } else if ( $_POST['password'] !== $_POST['password2'] ) { echo ''; } else if ( mb_strlen( $_POST['password'] ) < 6 ) { echo ''; } else { Sentinel::setUser( $_POST['username'] , $_POST['password'] ); Sentinel::save(); echo ''; } } ?>