<?php 
header('Content-Type: application/json');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

$filtered_widget = filter_input(INPUT_GET, 'widget', FILTER_SANITIZE_STRING);
$filtered_param  = preg_replace('/[^a-zA-Z0-9]+/', 
                                '', 
                                filter_input(INPUT_GET, 
                                             'param', 
                                             FILTER_SANITIZE_STRING)
                                );

if ($filtered_widget !== '') {
    if ($filtered_param !== '') {
        echo shell_exec(sprintf('./json_api_nix.sh %s %s',
                                $filtered_widget,
                                $filtered_param
                                )
                        );
    } else {
        echo shell_exec(sprintf('./json_api_nix.sh %s',
                                $filtered_widget
                                )
                        );
    }
} else {
    echo '{}';
}
