<?php
    global $path;
    error_log("API v1 log-run REQUEST");
    foreach ($_POST as $param_name => $param_val) {
        error_log("    Param: $param_name; Value: $param_val");
    }
    if (isset($_POST["data"])){
        $data = $_POST["data"];
        if (json_decode($data) === null){
            echo ("ERROR: Invalid JSON");
            error_log("API v1 log-run REQUEST INVALID JSON");
        }
        else{
            error_log($_SERVER["DOCUMENT_ROOT"] . "/../application/bin/run-log.py " . escapeshellarg($data));
            exec($_SERVER["DOCUMENT_ROOT"] . "/../application/bin/run-log.py " . escapeshellarg($data));
        }
    }
    else{
        echo ("ERROR: No POST data");
        error_log("API v1 log-run REQUEST NO POST DATA");
    }
?>
