<?php
$brainDir = 'C:/Users/HP/.gemini/antigravity-ide/brain';

function scan_dir_for_logs($dir) {
    $found = [];
    if (!is_dir($dir)) return $found;
    $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
    foreach ($it as $file) {
        if ($file->isFile() && $file->getFilename() === 'transcript.jsonl') {
            $found[] = $file->getPathname();
        }
    }
    return $found;
}

$logFiles = scan_dir_for_logs($brainDir);

foreach ($logFiles as $logPath) {
    $handle = fopen($logPath, 'r');
    if (!$handle) continue;
    
    $lineNum = 0;
    while (($line = fgets($handle)) !== false) {
        $lineNum++;
        // If the line contains "stripe" and "drive.google.com" or a gdrive link
        if (stripos($line, 'stripe') !== false && (stripos($line, 'drive.google.com') !== false || stripos($line, 'lh3.googleusercontent.com') !== false)) {
            $data = json_decode($line, true);
            if ($data) {
                $content = $data['content'] ?? '';
                // If it's a model or user input containing links
                if (!empty($content)) {
                    echo "=== Found in " . basename(dirname(dirname($logPath))) . " Line $lineNum ===\n";
                    echo $content . "\n";
                    echo "--------------------------------------------------\n";
                }
            }
        }
    }
    fclose($handle);
}
