diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index 7abb724..d73e7c5 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -22,6 +22,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context){ Location.getCurrentLocation(); + Location.getData(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); return ChangeNotifierProvider( create: (context) => CardProvider(), diff --git a/Sources/dafl_project_flutter/lib/position/location.dart b/Sources/dafl_project_flutter/lib/position/location.dart index c7e6884..906f252 100644 --- a/Sources/dafl_project_flutter/lib/position/location.dart +++ b/Sources/dafl_project_flutter/lib/position/location.dart @@ -1,5 +1,7 @@ import 'package:geolocator/geolocator.dart'; import 'package:tuple/tuple.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; class Location { static Future> getCurrentLocation() async { @@ -13,10 +15,16 @@ class Location { } } Position current = await Geolocator.getCurrentPosition(); - return Tuple2(current.longitude,current.latitude); + return Tuple2(current.longitude, current.latitude); } -} + static Future getData() async { + var url = 'http://localhost:63342/phpLocation/get.php'; + http.Response response = await http.get(Uri.parse(url)); + var data = jsonDecode(response.body); + print(data.toString()); + } +} diff --git a/Sources/dafl_project_flutter/pubspec.lock b/Sources/dafl_project_flutter/pubspec.lock index d545915..8665903 100644 --- a/Sources/dafl_project_flutter/pubspec.lock +++ b/Sources/dafl_project_flutter/pubspec.lock @@ -206,7 +206,7 @@ packages: source: hosted version: "0.15.1" http: - dependency: transitive + dependency: "direct main" description: name: http url: "https://pub.dartlang.org" diff --git a/Sources/dafl_project_flutter/pubspec.yaml b/Sources/dafl_project_flutter/pubspec.yaml index d3934b9..a4cad09 100644 --- a/Sources/dafl_project_flutter/pubspec.yaml +++ b/Sources/dafl_project_flutter/pubspec.yaml @@ -44,6 +44,7 @@ dependencies: vibration: ^1.7.6 geolocator: ^9.0.2 tuple: ^2.0.1 + http: ^0.13.5 dev_dependencies: diff --git a/Sources/phpLocation/.idea/php.xml b/Sources/phpLocation/.idea/php.xml index 8524502..c99cae5 100644 --- a/Sources/phpLocation/.idea/php.xml +++ b/Sources/phpLocation/.idea/php.xml @@ -5,6 +5,68 @@ + + + + + + + + + + + C:\xampp\php\php.ini + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sources/phpLocation/composer.json b/Sources/phpLocation/composer.json index 7a73a41..deff593 100644 --- a/Sources/phpLocation/composer.json +++ b/Sources/phpLocation/composer.json @@ -1,2 +1,6 @@ { + "require": { + "ext-pdo": "*", + "ext-json": "*" + } } \ No newline at end of file diff --git a/Sources/phpLocation/composer.lock b/Sources/phpLocation/composer.lock index a964422..7f8e8fd 100644 --- a/Sources/phpLocation/composer.lock +++ b/Sources/phpLocation/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d751713988987e9331980363e24189ce", + "content-hash": "a2d4189def32689f5efd66efe44864eb", "packages": [], "packages-dev": [], "aliases": [], @@ -12,7 +12,10 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "ext-pdo": "*", + "ext-json": "*" + }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/Sources/phpLocation/db.php b/Sources/phpLocation/db.php new file mode 100644 index 0000000..c7dd900 --- /dev/null +++ b/Sources/phpLocation/db.php @@ -0,0 +1,11 @@ +getMessage(); + echo $error; +} diff --git a/Sources/phpLocation/distance.php b/Sources/phpLocation/distance.php index 3bd8552..977256f 100644 --- a/Sources/phpLocation/distance.php +++ b/Sources/phpLocation/distance.php @@ -1,8 +1,10 @@ meters($lat1,$lng1,45.777222,3.087025); - if ($dist <= 100 ){ - $listUser[] = $userID; + $db=0; + require_once('db.php'); + $query = 'SELECT * FROM gps'; + $stm = $db->prepare($query); + $stm->execute(); + $row = $stm->fetchAll(PDO::FETCH_ASSOC); + $listUser = []; + $lat1=0; + $lng1=0; + Foreach ($row as $col) { + if ($col['id']==1){ //1 est lid de l'user qui execute la commande le recup grâce à driko + $lat1=$col['latitude']; + $lng1=$col['longitude']; + }if ($lat1==0 && $lng1==0){ + print ("ERROR No user found in the database (normally not supposed to happen)"); + exit(666); + } + } + Foreach ($row as $col) { + if ($col['id']!=1) { //1 est lid de l'user qui execute la commande le recup grâce à driko + $lat2 = $col['latitude']; + $lng2 = $col['longitude']; + $userID = $col['id']; + $dist = (new distance)->meters($lat1, $lng1, $lat2, $lng2); + if ($dist <= 100) { + $listUser[] = $userID; + } + } } return $listUser; } } - -echo "Normalement pas bcp = "; -echo (new distance)->meters(45.762595,3.108837,45.762524,3.1088743); /* +echo "Normalement pas beaucoup = "; +echo (new distance)->meters(45.762595,3.108837,45.762524,3.1088743); + echo "Normalement pas beaucoup = "; echo (new distance)->distentre2co(45.891773, 4.662613,45.777222,3.087025); */ diff --git a/Sources/phpLocation/vendor/autoload.php b/Sources/phpLocation/vendor/autoload.php index d28b5a6..cab2f9f 100644 --- a/Sources/phpLocation/vendor/autoload.php +++ b/Sources/phpLocation/vendor/autoload.php @@ -2,6 +2,24 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, $err); + } elseif (!headers_sent()) { + echo $err; + } + } + trigger_error( + $err, + E_USER_ERROR + ); +} + require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitbc6bd6ca3c265db981beab030b3c3065::getLoader(); +return ComposerAutoloaderInitb9a8ed3d52e4b6a9baf9b46866decacf::getLoader(); diff --git a/Sources/phpLocation/vendor/composer/InstalledVersions.php b/Sources/phpLocation/vendor/composer/InstalledVersions.php index d50e0c9..c6b54af 100644 --- a/Sources/phpLocation/vendor/composer/InstalledVersions.php +++ b/Sources/phpLocation/vendor/composer/InstalledVersions.php @@ -21,12 +21,14 @@ use Composer\Semver\VersionParser; * See also https://getcomposer.org/doc/07-runtime.md#installed-versions * * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final */ class InstalledVersions { /** * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null */ private static $installed; @@ -37,7 +39,7 @@ class InstalledVersions /** * @var array[] - * @psalm-var array}> + * @psalm-var array}> */ private static $installedByVendor = array(); @@ -241,7 +243,7 @@ class InstalledVersions /** * @return array - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} */ public static function getRootPackage() { @@ -255,7 +257,7 @@ class InstalledVersions * * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} */ public static function getRawData() { @@ -278,7 +280,7 @@ class InstalledVersions * Returns the raw data of all installed.php which are currently loaded for custom implementations * * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ public static function getAllRawData() { @@ -301,7 +303,7 @@ class InstalledVersions * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data */ public static function reload($data) { @@ -311,7 +313,7 @@ class InstalledVersions /** * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ private static function getInstalled() { diff --git a/Sources/phpLocation/vendor/composer/autoload_classmap.php b/Sources/phpLocation/vendor/composer/autoload_classmap.php index b26f1b1..0fb0a2c 100644 --- a/Sources/phpLocation/vendor/composer/autoload_classmap.php +++ b/Sources/phpLocation/vendor/composer/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/Sources/phpLocation/vendor/composer/autoload_namespaces.php b/Sources/phpLocation/vendor/composer/autoload_namespaces.php index b7fc012..15a2ff3 100644 --- a/Sources/phpLocation/vendor/composer/autoload_namespaces.php +++ b/Sources/phpLocation/vendor/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/Sources/phpLocation/vendor/composer/autoload_psr4.php b/Sources/phpLocation/vendor/composer/autoload_psr4.php index b265c64..3890ddc 100644 --- a/Sources/phpLocation/vendor/composer/autoload_psr4.php +++ b/Sources/phpLocation/vendor/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/Sources/phpLocation/vendor/composer/autoload_real.php b/Sources/phpLocation/vendor/composer/autoload_real.php index 47f313d..519a629 100644 --- a/Sources/phpLocation/vendor/composer/autoload_real.php +++ b/Sources/phpLocation/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitbc6bd6ca3c265db981beab030b3c3065 +class ComposerAutoloaderInitb9a8ed3d52e4b6a9baf9b46866decacf { private static $loader; @@ -22,31 +22,12 @@ class ComposerAutoloaderInitbc6bd6ca3c265db981beab030b3c3065 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitbc6bd6ca3c265db981beab030b3c3065', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInitbc6bd6ca3c265db981beab030b3c3065', 'loadClassLoader')); - - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitbc6bd6ca3c265db981beab030b3c3065::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + spl_autoload_register(array('ComposerAutoloaderInitb9a8ed3d52e4b6a9baf9b46866decacf', 'loadClassLoader'), true, true); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); + spl_autoload_unregister(array('ComposerAutoloaderInitb9a8ed3d52e4b6a9baf9b46866decacf', 'loadClassLoader')); + + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticInitb9a8ed3d52e4b6a9baf9b46866decacf::getInitializer($loader)); $loader->register(true); diff --git a/Sources/phpLocation/vendor/composer/autoload_static.php b/Sources/phpLocation/vendor/composer/autoload_static.php index 0ad4906..43d9041 100644 --- a/Sources/phpLocation/vendor/composer/autoload_static.php +++ b/Sources/phpLocation/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitbc6bd6ca3c265db981beab030b3c3065 +class ComposerStaticInitb9a8ed3d52e4b6a9baf9b46866decacf { public static $classMap = array ( 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', @@ -13,7 +13,7 @@ class ComposerStaticInitbc6bd6ca3c265db981beab030b3c3065 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->classMap = ComposerStaticInitbc6bd6ca3c265db981beab030b3c3065::$classMap; + $loader->classMap = ComposerStaticInitb9a8ed3d52e4b6a9baf9b46866decacf::$classMap; }, null, ClassLoader::class); } diff --git a/Sources/phpLocation/vendor/composer/installed.php b/Sources/phpLocation/vendor/composer/installed.php index 67108ca..257a2b7 100644 --- a/Sources/phpLocation/vendor/composer/installed.php +++ b/Sources/phpLocation/vendor/composer/installed.php @@ -1,22 +1,22 @@ array( + 'name' => '__root__', 'pretty_version' => 'dev-master', 'version' => 'dev-master', + 'reference' => 'd170a1f611384a4eb6ce43b894e3a936a3828ad1', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => 'bfb85958dcd85dd31e01117a46da4cd26baa5252', - 'name' => '__root__', 'dev' => true, ), 'versions' => array( '__root__' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', + 'reference' => 'd170a1f611384a4eb6ce43b894e3a936a3828ad1', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => 'bfb85958dcd85dd31e01117a46da4cd26baa5252', 'dev_requirement' => false, ), ),