<?php
include __DIR__."/classes/Main.php";

$main = new Main();

$json_data_dir = __DIR__."/../jsons/data/";
$json_failed_dir = __DIR__."/../jsons/failed/";
$json_non200_dir = __DIR__."/../jsons/non200/";
$json_nonindex_dir = __DIR__."/../jsons/nonindex/";

while(true) {
    $data_file = "";
    $non200_file = "";
    $nonindex_file = "";

    $data_file = $main->getFile($json_data_dir);
    if(!empty($data_file)) {
        $main->importJsonFile($json_data_dir, $data_file, "auditor");
    }

    $failed_file = $main->getFile($json_failed_dir);
    if(!empty($failed_file)) {
        $main->importJsonFile($json_failed_dir, $failed_file, "auditor_failed");
    }

    $non200_file = $main->getFile($json_non200_dir);
    if(!empty($non200_file)) {
        $main->importJsonFile($json_non200_dir, $non200_file, "auditor_non200");
    }

    $nonindex_file = $main->getFile($json_nonindex_dir);
    if(!empty($nonindex_file)) {
        $main->importJsonFile($json_nonindex_dir, $nonindex_file, "auditor_nonindex");
    }
    sleep(2);
    $main->chkMongoFinishError($json_data_dir, $json_failed_dir, $json_non200_dir, $json_nonindex_dir);
}
