Hide password and host to the database by updating .drone.yaml
continuous-integration/drone/push Build was killed Details

remotes/origin/mvc-implementation
Dorian HODIN 2 years ago
parent 3a0c62040e
commit 1744754dd4

@ -75,3 +75,20 @@ steps:
COMMAND: create COMMAND: create
OVERWRITE: true OVERWRITE: true
depends_on: [ php_script ] depends_on: [ php_script ]
#database container
- name: deploy-php-database
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: innodb
CONTAINERNAME: location_php_database
COMMAND: create
PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_INNONDB_HOST:
from_secret: db_host
CODEFIRST_CLIENTDRONE_ENV_INNODB_DATABASE:
from_secret: db_database
CODEFIRST_CLIENTDRONE_ENV_INNODB_USER:
from_secret: db_user
CODEFIRST_CLIENTDRONE_ENV_INNODB_PASSWORD:
from_secret: db_password

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4"> <module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true"> <component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
@ -7,7 +12,9 @@
<excludeFolder url="file://$MODULE_DIR$/Sources/dafl_project_flutter/.pub" /> <excludeFolder url="file://$MODULE_DIR$/Sources/dafl_project_flutter/.pub" />
<excludeFolder url="file://$MODULE_DIR$/Sources/dafl_project_flutter/.dart_tool" /> <excludeFolder url="file://$MODULE_DIR$/Sources/dafl_project_flutter/.dart_tool" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="Android API 33, extension level 3 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component> </component>
</module> </module>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpProjectSharedConfiguration" php_language_level="8.1">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
</project>

@ -1,8 +1,8 @@
<?php <?php
$username="dafldev"; $username=CODEFIRST_CLIENTDRONE_ENV_INNODB_USER;
$host="89.83.53.34"; $host=CODEFIRST_CLIENTDRONE_ENV_INNONDB_HOST;
$password="wrap"; $password=CODEFIRST_CLIENTDRONE_ENV_INNODB_PASSWORD;
$db_name="positiondaflmusic"; $db_name=CODEFIRST_CLIENTDRONE_ENV_INNODB_DATABASE;
$connect=mysqli_connect($host,$username,$password,$db_name); $connect=mysqli_connect($host,$username,$password,$db_name);
/* /*

@ -1,7 +1,7 @@
<?php <?php
$dns = 'mysql:host=89.83.53.34;dbname=positiondaflmusic'; $dns = 'mysql:host='.CODEFIRST_CLIENTDRONE_ENV_INNONDB_HOST.';dbname='.CODEFIRST_CLIENTDRONE_ENV_INNODB_DATABASE;
$user = 'dafldev'; $user = CODEFIRST_CLIENTDRONE_ENV_INNODB_USER;
$password = 'wrap'; $password = CODEFIRST_CLIENTDRONE_ENV_INNODB_PASSWORD;
try{ try{
$db = new PDO ($dns, $user, $password); $db = new PDO ($dns, $user, $password);
}catch( PDOException $e){ }catch( PDOException $e){

@ -1,24 +1,20 @@
<?php <?php
function meters($lat1, $lng1, $lat2, $lng2): float
class distance
{ {
public function meters($lat1, $lng1, $lat2, $lng2): float // Radius of the Earth in meters :
{ $earth_radius = 6378137;
// Radius of the Earth in meters : // Calculation of the distance between 2 GPS coordinates:
$earth_radius = 6378137; $rlo1 = deg2rad($lng1);
// Calculation of the distance between 2 GPS coordinates: $rla1 = deg2rad($lat1);
$rlo1 = deg2rad($lng1); $rlo2 = deg2rad($lng2);
$rla1 = deg2rad($lat1); $rla2 = deg2rad($lat2);
$rlo2 = deg2rad($lng2); $dlo = ($rlo2 - $rlo1) / 2;
$rla2 = deg2rad($lat2); $dla = ($rla2 - $rla1) / 2;
$dlo = ($rlo2 - $rlo1) / 2; $a = (sin($dla) * sin($dla)) + cos($rla1) * cos($rla2) * (sin($dlo) * sin($dlo));
$dla = ($rla2 - $rla1) / 2; $d = 2 * atan2(sqrt($a), sqrt(1 - $a));
$a = (sin($dla) * sin($dla)) + cos($rla1) * cos($rla2) * (sin($dlo) * sin($dlo)); // Return the distance in meters between 2 GPS points
$d = 2 * atan2(sqrt($a), sqrt(1 - $a)); return round($earth_radius * $d);
// Return the distance in meters between 2 GPS points
return round($earth_radius * $d);
}
} }
$db=0; $db=0;
@ -50,7 +46,7 @@ Foreach ($row as $col) {
$lng2 = $col['longitude']; $lng2 = $col['longitude'];
$userID = $col['id']; $userID = $col['id'];
$idMusic = $col['idMusic']; $idMusic = $col['idMusic'];
$dist = (new distance)->meters($lat1, $lng1, $lat2, $lng2); $dist = meters($lat1, $lng1, $lat2, $lng2);
if ($dist <= 100) { if ($dist <= 100) {
$listUser[] = ['user' => $userID, 'music' => $idMusic]; } $listUser[] = ['user' => $userID, 'music' => $idMusic]; }
} }

@ -1,5 +0,0 @@
<?php
echo "Hello world Dafl for PHP"
?>
Loading…
Cancel
Save