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:
array An array of tokens
Overrides ProfilerStorageInterface::find
public function find($ip, $url, $limit, $method) {
$file = $this
->getIndexFilename();
if (!file_exists($file)) {
return array();
}
$file = fopen($file, 'r');
fseek($file, 0, SEEK_END);
$result = array();
while ($limit > 0) {
$line = $this
->readLineFromFile($file);
if (false === $line) {
break;
}
if ($line === '') {
continue;
}
list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = str_getcsv($line);
if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method)) {
continue;
}
$result[$csvToken] = array(
'token' => $csvToken,
'ip' => $csvIp,
'method' => $csvMethod,
'url' => $csvUrl,
'time' => $csvTime,
'parent' => $csvParent,
);
--$limit;
}
fclose($file);
return array_values($result);
}