} else { $body = extractor_run($f); if (!$body) { $body = ''; } $description = ''; $keywords = ''; $title = basename($f); } $data = array('title' => $title, 'url' => $url, 'description' => $description, 'keywords' => $keywords, 'body' => $body, 'access' => 'public', 'status' => 'approved', 'team' => 'none', 'ctype' => $ctype, 'mtime' => (string) $mtime, 'domain' => $domain); // add file to index $counts[$ctype]++; $res = $search->addDocument($data); if (!$res) { echo 'Error adding document: ' . $search->error . NEWLINE; echo 'Document URL: ' . $data['url'] . NEWLINE; return; } } if ($info['type'] == 'site') { Dir::rmdirRecursive('tmp'); $search->deleteExpired((string) $mtime - 1, $info['domain']); } } } $search->deleteExpired((string) $mtime - 1, $default_domain); @chmod_recursive($search->path, 0777); $etime = time(); // log our activities for big brother $logger = new SiteSearchLogger(); $logger->logIndex($mtime, $etime, $counts);
function rmdirRecursive($path = '') { $d = dir($path); while ($file = $d->read()) { if ($file != '.' && $file != '..') { if (@is_writeable($path . '/' . $file)) { if (@is_dir($path . '/' . $file) && !@is_link($path . '/' . $file)) { Dir::rmdirRecursive($path . '/' . $file); } else { unlink($path . '/' . $file); } } else { return 0; } } } $d->close(); return rmdir($path); }