~feathereye/feathereye/trunk

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
<?php

/**
* @desc shell wrapper to display all 
* directives that are associated with specifying logging locations: 
   (CustomLog|ErrorLog|ForensicLog)
* within all apache conf files
*/

exec( 
	//invoke list-apache-conf-files	
	dirname(__FILE__) . '/list-apache-conf-files.php '

	//pipe those conf file paths to grep to inversly match comment lines
	. '| xargs grep -h -v -E \'^[[:space:]]*#\' '

	//pipe uncommented lines to grep matching lines of logging directives
	. '| grep  -E  "^[[:space:]]*CustomLog|ErrorLog|ForensicLog" '

	//pipe thru sed to trim white-space
	. '| sed \'s/^[[:space:]]*\(.*\)[[:space:]]*$/\1/\' '

	//define the field delimter as white-space then cut and return the 2nd field
	. '| cut -d" " -f2',

	$outputLines
	);

//de-duplicate the lines
$outputLines = array_unique( $outputLines );

//print them out
foreach( $outputLines as $path )	
	{
	fwrite( STDOUT, $path . PHP_EOL );
	}	

//exit ok
exit( 0 );