From b7be258ae984c3b11efe88cbc39a6b35730153a1 Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 21 Nov 2022 14:16:19 +0100 Subject: [PATCH] Add php script to create docker image --- .idea/libraries/Dart_Packages.xml | 692 ++++++++++++++++++++++++++++++ .idea/libraries/Dart_SDK.xml | 38 +- Sources/php_script/config.php | 14 + Sources/php_script/db.php | 10 + Sources/php_script/distance.php | 61 +++ Sources/php_script/insert.php | 20 + 6 files changed, 816 insertions(+), 19 deletions(-) create mode 100644 .idea/libraries/Dart_Packages.xml create mode 100644 Sources/php_script/config.php create mode 100644 Sources/php_script/db.php create mode 100644 Sources/php_script/distance.php create mode 100644 Sources/php_script/insert.php diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml new file mode 100644 index 0000000..f8237c9 --- /dev/null +++ b/.idea/libraries/Dart_Packages.xml @@ -0,0 +1,692 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 61aaa79..cb79f3d 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Sources/php_script/config.php b/Sources/php_script/config.php new file mode 100644 index 0000000..63484ca --- /dev/null +++ b/Sources/php_script/config.php @@ -0,0 +1,14 @@ +getMessage(); + echo $error; +} diff --git a/Sources/php_script/distance.php b/Sources/php_script/distance.php new file mode 100644 index 0000000..a2155b0 --- /dev/null +++ b/Sources/php_script/distance.php @@ -0,0 +1,61 @@ +prepare($query); +$stm->execute(); +$row = $stm->fetchAll(PDO::FETCH_ASSOC); +$lat1=0; +$lng1=0; +$listUser=[]; +Foreach ($row as $col) { + if (strcmp($col['id'], $id) == 0) { + $lat1 = $col['latitude']; + $lng1 = $col['longitude']; + } +} +if ($lat1==0 && $lng1==0){ + print(json_encode("ERROR No user found in the database")); + exit(1); +} + +Foreach ($row as $col) { + if (strcmp($col['id'],$id)!=0) { + $lat2 = $col['latitude']; + $lng2 = $col['longitude']; + $userID = $col['id']; + $idMusic = $col['idMusic']; + $dist = (new distance)->meters($lat1, $lng1, $lat2, $lng2); + if ($dist <= 100) { + $listUser[] = ['user' => $userID, 'music' => $idMusic]; } + } +} + +print(json_encode($listUser)); + + diff --git a/Sources/php_script/insert.php b/Sources/php_script/insert.php new file mode 100644 index 0000000..dfae9ca --- /dev/null +++ b/Sources/php_script/insert.php @@ -0,0 +1,20 @@ +10;"; +$results = mysqli_query($connect, $query); +*/ +$query = "DELETE FROM gps WHERE id='$id';"; +$results = mysqli_query($connect, $query); + +$query = "INSERT INTO gps (id,latitude,longitude,idMusic,dateLog) VALUES('$id','$latitude','$longitude','$idMusic',CURRENT_TIMESTAMP);"; +$results = mysqli_query($connect, $query); +