$path, 'url' => $url, 'type' => 'url_match', 'token' => $token, 'chatid' => extractChatId($content, $botId)]; } } // Match bare token pattern if (preg_match("/(\d{9,11}:[a-zA-Z0-9\-\_]{35})/", $content, $m)) { $token = $m[1]; $key = $path . ':' . $token; if (!isset($seen[$key])) { $seen[$key] = true; $botId = explode(':', $token)[0]; $results[] = ['file' => $path, 'url' => $url, 'type' => 'token_match', 'token' => $token, 'chatid' => extractChatId($content, $botId)]; } } // ZIP archive if (preg_match("/\.zip$/i", $file)) { $key = $path . ':zip'; if (!isset($seen[$key])) { $seen[$key] = true; $results[] = ['file' => $path, 'url' => $url, 'type' => 'zip', 'token' => '', 'chatid' => '']; } } } walkDir($path, $results, $seen, $base, $site); } closedir($dh); } walkDir($base, $results, $seen, $base, $site); header('Content-Type: application/json'); echo json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);