@ zyspec:
That fputcsv guide me pefectly to this brief code in 5 minutes:
// form, elements, headers
list($form, $elements, $headers) = $logsetObj->logForm($options);
// START export
if ($opentry == "export" && !empty($export) ) {
switch ($export) {
case 'csv':
$delimiter = ";";
$fp = fopen($Userlog->getConfig("logfilepath") . "/" . USERLOG_DIRNAME . "/export/" . $export . "/" . "total_ " . $totalLogs . "_" . time() . ".csv", 'w');
fputcsv($fp, $headers, $delimiter);
foreach($logs as $thisRow) {
fputcsv($fp, $thisRow, $delimiter);
}
fclose($fp);
redirect_header("logs.php?op=" . $query_entry . (!empty($query_page) ? "&" . $query_page : ''), 1, _AM_USERLOG_LOG_EXPORT_SUCCESS);
break;
default :
break;
}
}
// END export
Thank you.
I will work on the above to be less hard-code, have more options like export selected lines and whole pages.
Do you think export to csv would be enough?
Also i used JSON in this module so exporting to JSON will not need anything.
I hope You could take a look at this module. I try to write it very understandable.
I more need to have ideas from some experts like you about the performance of this module.
@ Mamba:
You sent me an important email but i missed it.
I will try to discuss about them here.
Quote:
- I have now 306 files, each 1 MB. How would it be possible to "merge" them together, if I would want to do some analytics (e.g. to find out where people go the most, or to retrace steps of a hacker)
1- That 1MB is
just a threshold when you want to view files directly using Cpanel. but in general i cannot see any issue to have larger files like 10MB.
2- I can implement a merge tool too. it would be very easy as simple as combining files.
I used JSON method and it is more understandable for human reading than serialize so you dont need any special tool.
Quote:
- how can we have a cron job zipping them together into one file?
It is very easy too.
we can have a separate file browser tab and define merge, zip and ...
Also a cron job can be done in the module or outside the module in Cpanel with some guide lines.
honestly this module is not for very basic webmasters. so I assume webmaster could do some jobs himself.
Quote:
- maybe there could be another part of the application that could do some analytics, with charts (e.g. showing which continent/country people coming from, which module is the most popular)
yes. Honestly right now i only did 20% of what i had in my mind in this module. I did the setting section and storing logs and browsing them. several usages of these logs can be very amazing.
And finally those would be just my mind other minds have many other nice things too.
Also the form in logs.php is just a very first attempt. you can see all of them are text boxes. i will improve them to more understandable elements:
eg: radio YES/No for isAdmin?
module checkbox and ...