<?php
function track($apiKey, $path) {
    $url = "http://127.0.0.1/" . $path . "/track.php";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array(
        'action' => 'visit',
        'metadata' => array(
            'api_key' => $apiKey,
            'visitor_id' => 'sim_' . bin2hex(random_bytes(8))
        )
    )));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    $res = curl_exec($ch);
    curl_close($ch);
    return $res;
}

$sites = array(
    'sk_a94cfaab9db35f9dab17432b00176522' => 'df',
    'sk_24e4df44c6adf8d1899abc9d3b8fbd4c' => 'go',
    'sk_2b0b286cbbbc3471afd8f7f8fabd629e' => 'mg',
    'sk_44a6f2bcd139f8a03d93fba22836e770' => 'ms',
    'sk_d075bbd508de4fe85e871f61a10d210e' => 'mt',
    'sk_216c9c3a2c8a289af1b287ec369b1376' => 'pr',
    'sk_1d41b7a41218854dd740d4bdfb05dce1' => 'rj',
    'sk_625413ec171d3f6d302b1c257c5cb6b7' => 'rs',
    'sk_8714ac9bf3145ea27c8b8118bfa11291' => 'sc'
);

foreach ($sites as $key => $path) {
    echo "Simulando " . $path . "... ";
    echo track($key, $path) . "\n";
    usleep(500000);
}
