You are here

function bueditor_cron in BUEditor 5

Implementation of hook_cron. Clean button script files for every 15 days

File

./bueditor.module, line 614

Code

function bueditor_cron() {
  if (variable_get('file_downloads', '') != FILE_DOWNLOADS_PRIVATE) {
    $now = time();
    $period = 15 * 24 * 60 * 60;
    $last = variable_get('bueditor_cron_last', 0);
    if ($now - $last > $period && is_dir($dir = file_directory_path() . '/bueditor') && ($handle = @opendir($dir))) {
      while (($file = readdir($handle)) !== FALSE) {
        if (substr($file, -3) == '.js') {
          @unlink($dir . '/' . $file);
        }
      }
      closedir($handle);
      variable_set('bueditor_cron_last', $now);
    }
  }
}