bheyde
10/3/2014 - 9:42 PM

Log X Forwarded For to CSV

Log X Forwarded For to CSV

<mvt:assign name="g.filename" 	value="'ip_log.csv'" />
<mvt:assign name="g.filepath" 	value="'/'" />
<mvt:assign name="g.newline" 	value="asciichar(10) $ asciichar(13)" />

 
<mvt:assign name="g.headerrow" 	value="'Date / Time,IP Address' $ g.newline" />
<mvt:assign name="g.data" 		value="s.dyn_time_t $ ',' $ s.http_x_forwarded_for $ g.newline" />
 
<mvt:assign name="g.file_exists" value="sexists(g.filepath $ g.filename)" />
 
<mvt:if expr="g.file_exists EQ 1">
 
		<mvt:assign name="g.file_created" value="file_append(g.filepath $ g.filename,'script', g.data)" />
 
<mvt:else>
 
	<mvt:assign name="g.file_created" value="file_create(g.filepath $ g.filename,'script', g.headerrow)" />
	<mvt:assign name="g.file_created" value="file_append(g.filepath $ g.filename,'script', g.data)" />
 
</mvt:if>