Beispiel #1
0
    $possible_method = array("GET", "POST", "PUT", "DELETE");
    //$value = "An error has occurred";
    $value = array("Response" => "Error", "message" => "An error has occurred");
    $action = strtolower($_REQUEST["action_from_conducttr"]);
    switch ($action) {
        case "set_delay":
            if (isset($_REQUEST["delay"]) && isset($_REQUEST["project_id"])) {
                $value = $api->set_delay($_REQUEST["delay"], $_REQUEST["project_id"]);
            } else {
                $value = array("Response" => "Error", "message" => "Invalid arguments");
            }
            exit(json_encode($value));
            break;
        case "push":
            if (isset($_REQUEST["audience_email"]) && isset($_REQUEST["project_id"])) {
                $value = $api->push($_REQUEST["audience_email"], $_REQUEST["project_id"]);
            } else {
                $value = array("Response" => "Error", "message" => "Invalid arguments");
            }
            exit(json_encode($value));
            break;
    }
    exit(json_encode($value));
} else {
    if (isset($_REQUEST["action"])) {
        define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
        if (!IS_AJAX) {
            $result = array("Response" => array("status" => 401, "message" => "Access denied"));
            //return $result;
            exit(json_encode($result));
        }