avm99963 | 1b63761 | 2018-12-28 01:03:44 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | require_once("config.php"); |
| 3 | |
| 4 | class write { |
| 5 | public static function output($json) { |
| 6 | print_r(json_encode($json)); |
| 7 | exit(); |
| 8 | } |
| 9 | |
| 10 | public static function error($n, $msg) { |
| 11 | self::output(["error" => $n, "msg" => $msg]); |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | function get_graph() { |
| 16 | global $conf; |
| 17 | return json_decode(file_get_contents($conf["apiurl"]), true); |
| 18 | } |
| 19 | |
| 20 | if (!isset($_GET["action"])) { |
| 21 | write::error(1, "No action provided"); |
| 22 | } |
| 23 | |
| 24 | switch ($_GET["action"]) { |
| 25 | case "getgraf": |
| 26 | $graf = file_get_contents($conf["apiurl"]); |
| 27 | echo $graf; |
| 28 | break; |
| 29 | |
| 30 | default: |
| 31 | write::error(2, "Unknown action"); |
| 32 | } |
| 33 | ?> |