| [6f38643] | 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Copyright (C) 2016 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 | $title = "Web Application";
|
|---|
| 20 | $headerJavascriptLinks = array("javascript/leaflet.js");
|
|---|
| 21 | $headerStylesheetLinks = array("css/leaflet.css");
|
|---|
| 22 |
|
|---|
| 23 | if(array_key_exists("mapFile", $_POST)){
|
|---|
| 24 | // upload new map to webservice
|
|---|
| 25 | if($_FILES["mapFile"]["error"] != UPLOAD_ERR_NO_FILE){
|
|---|
| 26 | // do some checks before using the uploaded file
|
|---|
| 27 | $error = false;
|
|---|
| 28 | switch($_FILES["mapFile"]["error"]){
|
|---|
| 29 | case UPLOAD_ERR_OK:
|
|---|
| 30 | break;
|
|---|
| 31 | case UPLOAD_ERR_NO_FILE:
|
|---|
| 32 | $errorToDisplay["title"] = "No file sent.";
|
|---|
| 33 | $error = true;
|
|---|
| 34 | break;
|
|---|
| 35 | case UPLOAD_ERR_INI_SIZE:
|
|---|
| 36 | case UPLOAD_ERR_FORM_SIZE:
|
|---|
| 37 | $errorToDisplay["title"] = "Exceeded filesize limit.";
|
|---|
| 38 | $error = true;
|
|---|
| 39 | default:
|
|---|
| 40 | $errorToDisplay["title"] = "Unknown errors.";
|
|---|
| 41 | $error = true;
|
|---|
| 42 | }
|
|---|
| 43 | $mapFile = sys_get_temp_dir() ."/map.mbtiles";
|
|---|
| 44 | if(!move_uploaded_file($_FILES["mapFile"]["tmp_name"], $mapFile)){
|
|---|
| 45 | $errorToDisplay["title"] = "Upload failed";
|
|---|
| 46 | }
|
|---|
| 47 | else{
|
|---|
| 48 | // send file to the webservice
|
|---|
| 49 | $upload_url = '../webservice/';
|
|---|
| 50 | $params = array(
|
|---|
| 51 | 'map'=>"@$mapFile"
|
|---|
| 52 | );
|
|---|
| 53 |
|
|---|
| 54 | $ch = curl_init();
|
|---|
| 55 | curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
|---|
| 56 | curl_setopt($ch, CURLOPT_URL, $upload_url);
|
|---|
| 57 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|---|
| 58 | curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
|---|
| 59 | $response = curl_exec($ch);
|
|---|
| 60 | curl_close($ch);
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | require_once("inc/header.php");
|
|---|
| 66 | ?>
|
|---|
| 67 | <h2 id="title" class="backgroundblue">GNUBoat</h2>
|
|---|
| 68 | <div id="display">
|
|---|
| 69 | <div id="speedthroughwater">
|
|---|
| 70 | <h2>STW</h2>
|
|---|
| 71 | <span id="value" class="important">-</span> kts
|
|---|
| 72 | </div>
|
|---|
| 73 | <div id="speedoverground">
|
|---|
| 74 | <h2>SOG</h2>
|
|---|
| 75 | <span id="value" class="important">-</span> kts
|
|---|
| 76 | </div>
|
|---|
| 77 | <div id="waterdepth">
|
|---|
| 78 | <h2>Depth</h2>
|
|---|
| 79 | <span id="value">-</span> m
|
|---|
| 80 | </div>
|
|---|
| 81 | <div id="watertemperature">
|
|---|
| 82 | <h2>Water</h2>
|
|---|
| 83 | <span id="value">-</span>°C
|
|---|
| 84 | </div>
|
|---|
| [4ab1c0a] | 85 | <div id="gpsfix">
|
|---|
| [6f38643] | 86 | <h2>Fix</h2>
|
|---|
| 87 | <span id="value">-</span>
|
|---|
| 88 | </div>
|
|---|
| 89 | </div>
|
|---|
| 90 | <div id="map"></div>
|
|---|
| 91 | <form method="post" action="./" enctype="multipart/form-data">
|
|---|
| 92 | <div class="formTable">
|
|---|
| 93 | <p>
|
|---|
| 94 | <label>Upload Map (mbtiles format):</label><br/>
|
|---|
| 95 | <input class="file" type="file" name="mapFile" value=""/>
|
|---|
| 96 | </p>
|
|---|
| 97 | </div>
|
|---|
| 98 | <div class="formButtons">
|
|---|
| 99 | <input type="submit" class="button buttonSubmit" name="buttonSendMap" value="Upload"/>
|
|---|
| 100 | </div>
|
|---|
| 101 | </form>
|
|---|
| 102 | <?php
|
|---|
| 103 | require_once("inc/footer.php");
|
|---|
| 104 | ?>
|
|---|