Commit 886f416c authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Delete view visit log after processing it


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 6813eef4
......@@ -2380,7 +2380,8 @@ function cron_site_data_daily() {
));
// Process log file containing view visits
if ($fh = @fopen(get_config('dataroot') . 'views.log', 'r')) {
$viewlog = get_config('dataroot') . 'views.log';
if (rename($viewlog, $viewlog . '.temp') and $fh = @fopen($viewlog . '.temp', 'r')) {
// Read the new stuff out of the file
$latest = get_field('view_visit', 'MAX(ctime)');
......@@ -2425,6 +2426,8 @@ function cron_site_data_daily() {
foreach ($visitcounts as $viewid => $newvisits) {
execute_sql("UPDATE {view} SET visits = visits + ? WHERE id = ?", array($newvisits, $viewid));
}
unlink($viewlog . '.temp');
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment