Before you even start to think read this. Logfile doesnt have any special delimiter but only spaces!
Each logfile on FTP contains 0-XXX daily lines.
All logfiles have the same style of output, divided by space.
example of one logfile:
2007669 08:49:46 05-01-17 CODE-1 NUMERIC 760 text message and so on
1223353 08:49:47 05-01-17 CODE-4 ALPHA 760 text message and so on
1223354 08:49:54 05-01-17 CODE-4 ALPHA 760 text message and so on
1223353 08:53:00 05-01-17 CODE-4 NUMERIC 760 labore et dolore
1227355 08:57:02 05-01-17 CODE-1 ALPHA 760 consectetur adipiscing elit, sed do eiusmod tempor incididunt
1223353 08:58:51 05-01-17 CODE-3 ALPHA 760 Lorem ipsum dolor sit amet, sed do
what I would need in database is:
6 tables extracted from logfiles
example how TABLES should be built from last line of logfile
table1 contains 1223353 (unique number)
table2 contains 08:58:51 (time)
table3 contains 05-01-17 (date)
table4 contains CODE-3 (code[1-4])
table5 contains ALPHA 760 (ALPHA 760 or NUMERIC 760)
table6 contains Lorem ipsum dolor sit amet, sed do (text utf-8)
logfile names by date examples:
[login to view URL] - (2017 april 20)
[login to view URL] - (2017 april 19)
[login to view URL] - (2017 april 18)
working script on which you can continue to build on or create own:
foreach (glob("/path/to/logfiles/*.log") as $file) {
$file_handle = fopen($file, "r");
while (!feof($file_handle)) {
$line = fgets($file_handle);
echo $line;?>
<br />
<?php
}
fclose($file_handle);
}
Script at the moment only reads all logfiles and output them as text on website.
build php script that displays same results as this, just from mySQL ordered by date and time DESCENDING (newer first). All logfiles export to mySQL should happen on click of a button and cron job (1 min run) I will do cron job alone,
Filter the logs which are already in mySQL, so it does not upload them twice/multiple times when I click button (site load is slow). Caution last log file of a day is still updating/being written to (todays [login to view URL]).