Search for: (wildcards * and ? are allowed)
/> Ignore case
/> Search in last segment only



File name database is currently being updated.
Search results may be inaccurate.

'; } $ret = array(); $command = 'locate ' . ($ignoreCase ? '-i "' : '"') . SEARCH_ROOT . '*' . $searchString . '*"'; exec($command, $ret); $word = str_replace(array("?", "*"), array(".", ".+"), $searchString); foreach ($ret as $line) { if($lastSegmentSearch && !foundInLastSegment($line, $word, $ignoreCase)) { continue; } $find = highlight($line, $word, $ignoreCase); if(defined("VIEW_SYMLINK_PREFIX")) { $link = str_replace(SEARCH_STRING, VIEW_SYMLINK_PREFIX, $line); print '[View] '; } print "$find
\n"; } } function showDatabaseState() { if(updateLocatorIsRunning()) { print 'File name database is currently being updated.'; return; } else { clearstatcache(); date_default_timezone_set('UTC'); $dbtime = date("D, d.m.Y, H:i:s", filemtime(LOCATE_DB_FILE)); print 'File name database was last updated on ' . $dbtime . ''; } } function updateDatabase() { if(updateLocatorIsRunning()) { print 'File name database is already being updated!'; return; } $command = UPDATE_SCRIPT_LAUNCHER . " > /dev/null 2>&1 &"; exec($command); sleep(1); if(updateLocatorIsRunning()) { print 'Started updating file name database.'; } else { print 'File name database updator failed to start.'; } } function updateLocatorIsRunning() { $ret = array(); $command = "ps -U nobody -o command"; exec($command, $ret); foreach ($ret as $line) { if(strstr($line, "locate.updatedb")) { return true; } } return false; } function foundInLastSegment($line, $searchString, $ignoreCase) { $search = '/(?=[^\/]+$)' . $searchString . ($ignoreCase ? '/i' : '/'); return preg_match($search, $line); } function highlight($text, $word, $ignoreCase) { return preg_replace("/($word)/U" . ($ignoreCase ? "i" : ""), "$1", $text); } ?>