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