function filelog_ui_import_entries in File Log 6.2
1 call to filelog_ui_import_entries()
- filelog_ui_cron in ./
filelog_ui.module - Implementation of hook_cron().
3 string references to 'filelog_ui_import_entries'
- filelog_ui_enable in ./
filelog_ui.install - Implementation of hook_enable().
- filelog_ui_submit_import_all in ./
filelog_ui.admin.inc - filelog_ui_submit_import_new in ./
filelog_ui.admin.inc
File
- ./
filelog_ui.admin.inc, line 78
Code
function filelog_ui_import_entries() {
if (!($dir = filelog_directory(FALSE))) {
return FALSE;
}
$cbr = variable_get('filelog_check_base_url', 1);
if (!($reg = cache_get('filelog_path_registry', 'cache'))) {
$reg = array();
}
else {
$reg = $reg->data;
}
foreach ($reg as $path => $info) {
if (!file_exists($path)) {
unset($reg[$path]);
}
}
if ($files = file_scan_directory($dir, '.+\\.ui-log(.*)?')) {
foreach ($files as $path => $info) {
$size = filesize($path);
$mtime = filemtime($path);
if (isset($reg[$path]) && $size == $reg[$path]['size'] && $mtime == $reg[$path]['mtime']) {
continue;
}
if (strrpos($path, '.gz', strlen($path) - 3) === FALSE) {
$open = 'fopen';
$get = 'fgets';
$eof = 'feof';
$close = 'fclose';
}
else {
$open = 'gzopen';
$get = 'gzgets';
$eof = 'gzeof';
$close = 'gzclose';
}
if ($size && ($fh = $open($path, 'r'))) {
try {
$idx = 0;
while (!$eof($fh)) {
if ($line = $get($fh, 4096)) {
_filelog_ui_import_entry($line, $cbr, $path, $idx);
}
$idx++;
}
} catch (Exception $e) {
$close($fh);
}
}
$reg[$path] = array(
'size' => $size,
'mtime' => $mtime,
);
}
}
cache_set('filelog_path_registry', $reg, 'cache');
variable_set('filelog_last_import', time());
}