You are here

function filelog_cron in File Log 7

Same name and namespace in other branches
  1. 8 filelog.module \filelog_cron()
  2. 6.2 filelog.module \filelog_cron()
  3. 6 filelog.module \filelog_cron()
  4. 2.0.x filelog.module \filelog_cron()

Implementation of hook_cron().

File

./filelog.module, line 47
Writes logging messages into files.

Code

function filelog_cron() {
  $f = _filelog_get_conf();
  if ($f['daily_files'] && ($days = $f['delete_files'])) {
    if ($files = file_scan_directory(filelog_directory(), '/.+/')) {
      $limit = format_date(REQUEST_TIME - $days * 24 * 3600, 'custom', 'Ymd');
      foreach ($files as $filename => $info) {
        $parts = explode('.', $filename);
        array_shift($parts);
        if (array_shift($parts) < $limit) {
          file_unmanaged_delete($filename);
        }
      }
    }
  }
}