| [c455d7b] | 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| 4 |
|
|---|
| 5 | This program is free software: you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 8 | (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This program is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | namespace GnuBoat;
|
|---|
| 20 |
|
|---|
| 21 | require_once(__DIR__ ."/../autoloader.php");
|
|---|
| 22 |
|
|---|
| 23 | class WebService
|
|---|
| 24 | {
|
|---|
| 25 | function __construct()
|
|---|
| 26 | {
|
|---|
| 27 | $this->_requests = array();
|
|---|
| 28 | $this->_requests["data"] = "GnuBoat\ServiceData";
|
|---|
| 29 | $this->_requests["shutdown"] = "GnuBoat\ServiceShutdown";
|
|---|
| 30 | $this->_requests["logfiles"] = "GnuBoat\ServiceLogFiles";
|
|---|
| 31 | $this->_requests["map"] = "GnuBoat\ServiceMap";
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | public function process()
|
|---|
| 35 | {
|
|---|
| 36 | $debug = 0;
|
|---|
| 37 | if(is_array($_GET) && array_key_exists("debug", $_GET))
|
|---|
| 38 | $debug = $_GET["debug"];
|
|---|
| 39 |
|
|---|
| 40 | $request = array_keys($this->_requests)[0];
|
|---|
| 41 | if(is_array($_GET) && array_key_exists("request", $_GET)){
|
|---|
| 42 | $request = $_GET["request"];
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | if(!array_key_exists($request, $this->_requests)){
|
|---|
| 46 | $result["error"] = 1;
|
|---|
| 47 | $result["errormessage"] = "Request ". $request ." not implemented";
|
|---|
| 48 |
|
|---|
| 49 | header('Content-Type: application/json');
|
|---|
| 50 | echo json_encode($result) ."\n";
|
|---|
| 51 | return;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| [12d7e6f] | 54 | call_user_func(array(new $this->_requests[$request], "processRequest"), $debug);
|
|---|
| [c455d7b] | 55 | }
|
|---|
| 56 |
|
|---|
| 57 | private $_requests;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | ?>
|
|---|