Finds profiler tokens for the given criteria.
string $ip The IP:
string $url The URL:
string $limit The maximum number of tokens to return:
string $method The request method:
int|null $start The start date to search from:
int|null $end The end date to search to:
array An array of tokens
Overrides ProfilerStorageInterface::find
public function find($ip, $url, $limit, $method, $start = null, $end = null) {
$file = $this
->getIndexFilename();
if (!file_exists($file)) {
return array();
}
$file = fopen($file, 'r');
fseek($file, 0, SEEK_END);
$result = array();
while (count($result) < $limit && ($line = $this
->readLineFromFile($file))) {
list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = str_getcsv($line);
$csvTime = (int) $csvTime;
if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method)) {
continue;
}
if (!empty($start) && $csvTime < $start) {
continue;
}
if (!empty($end) && $csvTime > $end) {
continue;
}
$result[$csvToken] = array(
'token' => $csvToken,
'ip' => $csvIp,
'method' => $csvMethod,
'url' => $csvUrl,
'time' => $csvTime,
'parent' => $csvParent,
);
}
fclose($file);
return array_values($result);
}