-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added dbcontroller; added logs trace
- Loading branch information
Showing
15 changed files
with
1,357 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
# iocuMap | ||
A map based CMS where it is possibile to associate one ore more widget to a marker. The map can be an OpenStreetMap layer or a static image. The leaflet (https://leafletjs.com/) library is used to develop the interactive map. | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Luigi Grillo | ||
* File: add.php | ||
* Last update: 10/07/2019 | ||
* Todo: | ||
* 1. Check for authorization and paramenters | ||
* | ||
* DESCRIPTION: | ||
* Add new post to a marker. If the marker does not exists a new one will be saved on the database | ||
* { "name": "widget name", | ||
* "html": "widget definition to be loaded from form.json" | ||
* } | ||
* | ||
*/ | ||
|
||
require_once("dbcontroller.php"); | ||
$db_handle = new DBController(); | ||
|
||
if(!empty($_POST["lng"])) { | ||
// TODO check authorization - check parameters | ||
|
||
/* | ||
* If the POI (lat,lng) does not exist it creates a new one. | ||
* Return the POI's id | ||
* TODO: to implement a function around() to accept a delta difference of the coordinates | ||
function getPOIid($lat,$lng) { | ||
return $result; | ||
} | ||
*/ | ||
|
||
$lat = $_GET["lat"]; | ||
$lng = $_GET["lng"]; | ||
$data = $_GET["data"]; | ||
$description = $_GET["description"]; | ||
$widget = $_GET["widget"]; | ||
|
||
$db_handle->log("add.php","PARAMETERS GET = lat: $lat lng:$lng data:$data widget:$widget decription:$description\n"); | ||
|
||
// check the marker, or create a new one if it does not exists | ||
$sql = "select id from poi where lat=".$lat." and lng=".$lng; | ||
$idPOI = $db_handle->runSelectQuery($sql); | ||
if (!$idPOI) { // The POI does not exists | ||
$idPOI = $db_handle->insertPOI($lat,$lng,$description); | ||
} else { | ||
|
||
$sql = "INSERT INTO poi (lat,lng,description) VALUES ('" .$_POST["lat"] . "','" . $_POST["lng"] ."','" . $_POST["description"] . "')"; | ||
$poi = $db_handle->executeInsert($sql); | ||
// TODO The POI exists already | ||
} | ||
|
||
$sql = 'select id from widgets where name="'.$widget.'"'; | ||
$idWidget = $db_handle->runSelectQuery($sql); // TODO CHECK result | ||
|
||
$db_handle->insertPOST($idPOI,$idWidget[0],$data); | ||
|
||
// TODO check query result | ||
|
||
|
||
echo $poi; | ||
|
||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
|
||
|
||
|
||
|
||
|
||
$lat = $_GET["lat"]; | ||
$lng = $_GET["lng"]; | ||
$data = $_GET["data"]; | ||
$description = $_GET["description"]; | ||
$widget = $_GET["widget"]; | ||
|
||
|
||
$conn = ""; | ||
$host = "89.46.111.49"; | ||
$user = "Sql1127014"; | ||
$dbname = "Sql1127014_5"; | ||
$password = "827r224040"; | ||
|
||
// Create connection | ||
$conn = new mysqli($host, $user, $password, $dbname); | ||
// Check connection | ||
if ($conn->connect_error) { | ||
die("Connection failed: " . $conn->connect_error); | ||
} | ||
|
||
$sql = 'INSERT INTO poi (id ,lat,lng,description,dataRegistration,userID) | ||
VALUES (NULL , '.$lat.', '.$lng.',"'.mysqli_real_escape_string($conn,$description).'", CURRENT_TIMESTAMP , NULL);'; | ||
|
||
if ($conn->query($sql) === TRUE) { | ||
echo "New record created successfully"; | ||
} else { | ||
echo "Error: " . $sql . "<br>" . $conn->error; | ||
} | ||
|
||
$conn->close(); | ||
|
||
|
||
|
||
|
||
?> |
Oops, something went wrong.