Beispiel #1
0
function monitorTestCase($testCase)
{
    // f**k scope
    $GLOBALS['testCase'] = $testCase;
    $duration = monitor(function () {
        $GLOBALS['actual'] = $GLOBALS['testCase']();
    });
    return [$GLOBALS['actual'], $duration];
}
Beispiel #2
0
    exit;
}
if (isset($_GET["proxy-settings"])) {
    section_architecture_tabs();
    exit;
}
if (isset($_GET["web-filtering"])) {
    web_filtering();
    exit;
}
if (isset($_GET["tasks"])) {
    tasks();
    exit;
}
if (isset($_GET["monitor"])) {
    monitor();
    exit;
}
if (isset($_GET["architecture-behavior"])) {
    proxy_behavior();
    exit;
}
if (isset($_POST["exclusive_reverse_proxy"])) {
    proxy_behavior_save();
    exit;
}
main_page();
function main_page()
{
    $page = CurrentPageName();
    $tplfile = "ressources/templates/endusers/index.html";
    $assignParams = array("method" => "POST", "ContactsListID" => $listID, "DataID" => $uploadID, "Method" => "addnoforce");
    $csvAssign = $mj->csvimport($assignParams);
    if ($mj->_response_code == 201) {
        echo "success - CSV data " . $uploadID . " assigned to contactslist " . $listID;
        return $csvAssign->Data[0]->ID;
    } else {
        exit("error - Couldn't assign contacts to list - code " . $mj->_response_code);
    }
}
function monitor($mj, $jobID)
{
    $monitorParmas = array("method" => "VIEW", "ID" => $jobID);
    $res = $mj->batchjob($monitorParmas);
    if ($mj->_response_code == 200) {
        echo "job " . $res->Data[0]->Status . "\n";
        return $res->Data[0]->Status;
    } else {
        exit("error - Couldn't monitor the job - code " . $mj->_response_code . "\n");
    }
}
$mj = new Mailjet('MJ_APIKEY_PUBLIC', 'MJ_APIKEY_PRIVATE');
/*
 *  Don't forget to change the $listID variable to suit your particular setup.
 *
 */
$listID = 45;
$CSVContent = file_get_contents('sample.csv');
$uploadID = uploadCSV($mj, $listID, $CSVContent);
$jobID = assignContactsToList($mj, $listID, $uploadID);
$status = monitor($mj, $jobID);