From d377d8b5dba4bf41a57dc2c5721e12f1daa19978 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 13:53:13 +0100 Subject: [PATCH 01/32] .drone.yml + Dockerfile creation --- .drone.yml | 50 +++++++++++++++++++++++++++++++++++++++++++ .idea/php.xml | 2 +- Source/API/Dockerfile | 4 ++++ Source/API/a | 0 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Source/API/Dockerfile delete mode 100644 Source/API/a diff --git a/.drone.yml b/.drone.yml index e69de29..ab3f59e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -0,0 +1,50 @@ +kind: pipeline +type: docker +name: Témoignages_Formulaire + + +trigger: + event: + - push + +steps: + + # docker image build + - name: set_api_form + image: plugins/docker + settings: + dockerfile: ./Source/API/Dockerfile + context: Source/API + registry: hub.codefirst.iut.uca.fr + repo: hub.codefirst.iut.uca.fr/dorian.hodin/sae4.01_formulaire + username: + from_secret: SECRET_USERNAME + password: + from_secret: SECRET_PASSWD + + # conteneur deployment + - name: deploy_api_form + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + environment: + IMAGENAME: hub.codefirst.iut.uca.fr/dorian.hodin/sae4.01_formulaire:latest + CONTAINERNAME: deploy_api_form + COMMAND: create + OVERWRITE: true + depends_on: [ set_api_form ] + + # database container deployment + - name: db_form + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + environment: + IMAGENAME: mariadb:10.5 + CONTAINERNAME: db_form + COMMAND: create + CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: + from_secret: db_root_password + CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE: + from_secret: db_database + CODEFIRST_CLIENTDRONE_ENV_MARIADB_USER: + from_secret: db_user + CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: + from_secret: db_password + depends_on: [ deploy_api_form ] diff --git a/.idea/php.xml b/.idea/php.xml index b2ca53c..639f74d 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -9,7 +9,7 @@ - + diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile new file mode 100644 index 0000000..6dadb6c --- /dev/null +++ b/Source/API/Dockerfile @@ -0,0 +1,4 @@ +FROM php:8.1-apache +RUN apt-get update && apt-get upgrade -y +RUN docker-php-ext-install mysqli +COPY ./script /var/www/html \ No newline at end of file diff --git a/Source/API/a b/Source/API/a deleted file mode 100644 index e69de29..0000000 From 293081eb80eedbabc1c7d5ebbbfe147725299a2f Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 13:56:48 +0100 Subject: [PATCH 02/32] Add a tmp.php file in Script to test Dockerfile --- .idea/git_toolbox_prj.xml | 15 +++++++++++++++ Source/API/script/tmp.php | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 .idea/git_toolbox_prj.xml create mode 100644 Source/API/script/tmp.php diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml new file mode 100644 index 0000000..02b915b --- /dev/null +++ b/.idea/git_toolbox_prj.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/Source/API/script/tmp.php b/Source/API/script/tmp.php new file mode 100644 index 0000000..d4f7467 --- /dev/null +++ b/Source/API/script/tmp.php @@ -0,0 +1,3 @@ +HEY"; \ No newline at end of file From fb1dc465990efab965722fbbbbb21f139bc938cd Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:23:09 +0100 Subject: [PATCH 03/32] Add file in API/Script (class Connection and config.php) --- .drone.yml | 11 +++++++++ Source/API/script/APIController.php | 0 Source/API/script/Connection.php | 38 +++++++++++++++++++++++++++++ Source/API/script/config.php | 19 +++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 Source/API/script/APIController.php create mode 100644 Source/API/script/Connection.php create mode 100644 Source/API/script/config.php diff --git a/.drone.yml b/.drone.yml index ab3f59e..a06abc8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,6 +30,16 @@ steps: CONTAINERNAME: deploy_api_form COMMAND: create OVERWRITE: true + CODEFIRST_CLIENTDRONE_ENV_HOST: + from_secret: db_host + CODEFIRST_CLIENTDRONE_ENV_DATABASE: + from_secret: db_database + CODEFIRST_CLIENTDRONE_ENV_USER: + from_secret: db_user + CODEFIRST_CLIENTDRONE_ENV_PASSWORD: + from_secret: db_password + CODEFIRST_CLIENTDRONE_ENV_ROOT_PASSWORD: + from_secret: db_root_password depends_on: [ set_api_form ] # database container deployment @@ -39,6 +49,7 @@ steps: IMAGENAME: mariadb:10.5 CONTAINERNAME: db_form COMMAND: create + OVERWRITE: true CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: from_secret: db_root_password CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE: diff --git a/Source/API/script/APIController.php b/Source/API/script/APIController.php new file mode 100644 index 0000000..e69de29 diff --git a/Source/API/script/Connection.php b/Source/API/script/Connection.php new file mode 100644 index 0000000..4ecf492 --- /dev/null +++ b/Source/API/script/Connection.php @@ -0,0 +1,38 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + + + /** * @param string $query + * @param array $parameters * + * @return bool Returns `true` on success, `false` otherwise + */ + public function executeQuery(string $query, array $parameters = []): bool + { + $this->stmt = parent::prepare($query); + foreach ($parameters as $name => $value) { + $this->stmt->bindValue($name, $value[0], $value[1]); + } + + return $this->stmt->execute(); + } + + public function getResults(): array + { + return $this->stmt->fetchAll(); + + } +} \ No newline at end of file diff --git a/Source/API/script/config.php b/Source/API/script/config.php new file mode 100644 index 0000000..018e0df --- /dev/null +++ b/Source/API/script/config.php @@ -0,0 +1,19 @@ + Date: Mon, 30 Jan 2023 14:27:34 +0100 Subject: [PATCH 04/32] Modify the call of Connection class --- .drone.yml | 1 - Source/API/script/Connection.php | 5 ----- Source/API/script/config.php | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index a06abc8..b9f2a10 100644 --- a/.drone.yml +++ b/.drone.yml @@ -49,7 +49,6 @@ steps: IMAGENAME: mariadb:10.5 CONTAINERNAME: db_form COMMAND: create - OVERWRITE: true CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: from_secret: db_root_password CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE: diff --git a/Source/API/script/Connection.php b/Source/API/script/Connection.php index 4ecf492..a7f8a20 100644 --- a/Source/API/script/Connection.php +++ b/Source/API/script/Connection.php @@ -1,10 +1,5 @@ Date: Mon, 30 Jan 2023 14:29:58 +0100 Subject: [PATCH 05/32] Host set; connection should work --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index b9f2a10..5e74eb1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -58,3 +58,4 @@ steps: CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: from_secret: db_password depends_on: [ deploy_api_form ] + From 16c221cb6854a51fcba7ef380e39293ee35578e5 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:33:20 +0100 Subject: [PATCH 06/32] Test connection --- Source/API/script/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/script/config.php b/Source/API/script/config.php index 41f0f11..c7c0b94 100644 --- a/Source/API/script/config.php +++ b/Source/API/script/config.php @@ -2,7 +2,7 @@ require_once "./Connection.php"; -$dsn = "mysql:host=".$_ENV["HOST"].";dbname=".$_ENV["DATABASE"].";"; +$dsn = "mysql:host=codefirst.iut.uca.fr/containers/Temoignages-db_form;dbname=".$_ENV["DATABASE"].";"; $login = $_ENV["USER"]; $password = $_ENV["PASSWORD"]; From 04eb12d806e89c72acfbf3e909c00a21ab7efee1 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:35:29 +0100 Subject: [PATCH 07/32] Test connection --- Source/API/script/config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/API/script/config.php b/Source/API/script/config.php index c7c0b94..8b1894c 100644 --- a/Source/API/script/config.php +++ b/Source/API/script/config.php @@ -13,7 +13,7 @@ try { echo "Connection OK !"; }catch (PDOException $PDOException){ - - echo "Connection Error"; - return http_response_code(404); + echo $PDOException->getMessage(); + echo $PDOException->getCode(); + return http_response_code(404); } From 5ecbe9f91b6a1b9db5e2a98b1ac247269b949845 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:39:05 +0100 Subject: [PATCH 08/32] Dockerfile update, downloading driver --- Source/API/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 6dadb6c..796e84e 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,4 +1,5 @@ FROM php:8.1-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli +RUN apt-get install php8.1-mysql COPY ./script /var/www/html \ No newline at end of file From 1f4e42df13879ed50009e37d7ffa6a3f93df5826 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:40:34 +0100 Subject: [PATCH 09/32] Dockerfile update, downloading driver (good command now) --- Source/API/Dockerfile | 2 +- Source/API/script/config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 796e84e..13bd362 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,5 @@ FROM php:8.1-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install php8.1-mysql +RUN apt-get install php8.0-mysql COPY ./script /var/www/html \ No newline at end of file diff --git a/Source/API/script/config.php b/Source/API/script/config.php index 8b1894c..40160c4 100644 --- a/Source/API/script/config.php +++ b/Source/API/script/config.php @@ -2,7 +2,7 @@ require_once "./Connection.php"; -$dsn = "mysql:host=codefirst.iut.uca.fr/containers/Temoignages-db_form;dbname=".$_ENV["DATABASE"].";"; +$dsn = "mysql:host=".$_ENV["HOST"].";dbname=".$_ENV["DATABASE"].";"; $login = $_ENV["USER"]; $password = $_ENV["PASSWORD"]; From abc00b3c9cea964ef62b809557eed95b38084935 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:42:15 +0100 Subject: [PATCH 10/32] Dockerfile update, downloading driver try 3 --- Source/API/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 13bd362..528f9c5 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,5 @@ -FROM php:8.1-apache +FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install php8.0-mysql +RUN apt-get install php-mysql COPY ./script /var/www/html \ No newline at end of file From 3d464a3d11e95e9b50f1b1afd6e9d7ba2d875c54 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:43:41 +0100 Subject: [PATCH 11/32] Dockerfile update, downloading driver try 4 --- Source/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 528f9c5..c68d0f0 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,5 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install php-mysql +RUN apt-get install php5-mysql COPY ./script /var/www/html \ No newline at end of file From 8b6c9e3a6cd3b65ffb3e9df289e72a24f0d97b7f Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:45:20 +0100 Subject: [PATCH 12/32] Dockerfile update, downloading driver try 5 --- .idea/php.xml | 2 +- Source/API/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.idea/php.xml b/.idea/php.xml index 639f74d..b673eaa 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -9,7 +9,7 @@ - + diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index c68d0f0..8898aa4 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,5 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install php5-mysql +RUN apt-get install php7.4-mysql COPY ./script /var/www/html \ No newline at end of file From ff32242b84a0e49cb94c036bc6eacdb5eccf1b79 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:47:08 +0100 Subject: [PATCH 13/32] Dockerfile update, downloading driver try 6 --- Source/API/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 8898aa4..b8c3c22 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,6 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install php7.4-mysql +RUN add-apt-repository ppa:ondrej/php +RUN apt-get install php5.6-mysql COPY ./script /var/www/html \ No newline at end of file From 653a5eddc05c09b43d6e244b6c022d8456ef16dc Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:48:12 +0100 Subject: [PATCH 14/32] Dockerfile update, downloading driver try 7 --- Source/API/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index b8c3c22..2a3a364 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,6 +1,5 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN add-apt-repository ppa:ondrej/php RUN apt-get install php5.6-mysql COPY ./script /var/www/html \ No newline at end of file From 0015dc5ccffff2f9603dad407129d5b8f605e1a9 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:49:45 +0100 Subject: [PATCH 15/32] Dockerfile update, downloading driver try 7 --- Source/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 2a3a364..c40a11c 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,5 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install php5.6-mysql +RUN apt-get install php7.0-mysql COPY ./script /var/www/html \ No newline at end of file From dca57f23455660c42a4dcc53a3133f69206825b9 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:50:55 +0100 Subject: [PATCH 16/32] Dockerfile update, downloading driver try 9 --- Source/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index c40a11c..b080b9f 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,5 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install php7.0-mysql +RUN apt-get install lamp-server^ -y COPY ./script /var/www/html \ No newline at end of file From 7aff9722992ac174dd455f340ca3ffda688b452b Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:52:23 +0100 Subject: [PATCH 17/32] Dockerfile update, downloading driver try 10 --- Source/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index b080b9f..0368774 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,5 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install lamp-server^ -y +RUN apt-get install lamp-server -y COPY ./script /var/www/html \ No newline at end of file From 1ecd0006836abb8c8a9343756a705e60e7dda3a6 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:54:46 +0100 Subject: [PATCH 18/32] Dockerfile update, downloading driver try 11 --- Source/API/Dockerfile | 1 - Source/API/script/config.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 0368774..b12cfe6 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,5 +1,4 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y RUN docker-php-ext-install mysqli -RUN apt-get install lamp-server -y COPY ./script /var/www/html \ No newline at end of file diff --git a/Source/API/script/config.php b/Source/API/script/config.php index 40160c4..05f8884 100644 --- a/Source/API/script/config.php +++ b/Source/API/script/config.php @@ -15,5 +15,6 @@ try { }catch (PDOException $PDOException){ echo $PDOException->getMessage(); echo $PDOException->getCode(); + phpinfo(); return http_response_code(404); } From 3c3bdc8dde75d662e123992ac13998ecc8f0e42f Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 14:56:58 +0100 Subject: [PATCH 19/32] Dockerfile update, downloading driver try 12 --- Source/API/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index b12cfe6..f0e6842 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,4 +1,3 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y -RUN docker-php-ext-install mysqli COPY ./script /var/www/html \ No newline at end of file From 19599ff03f17080fa55c04dab8ce322306abf15a Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 15:19:05 +0100 Subject: [PATCH 20/32] Change Connection.php class, PDO->MySQLI --- Source/API/Dockerfile | 1 + Source/API/script/Connection.php | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index f0e6842..b12cfe6 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,3 +1,4 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y +RUN docker-php-ext-install mysqli COPY ./script /var/www/html \ No newline at end of file diff --git a/Source/API/script/Connection.php b/Source/API/script/Connection.php index a7f8a20..2b72d59 100644 --- a/Source/API/script/Connection.php +++ b/Source/API/script/Connection.php @@ -1,33 +1,28 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } + private $connection; + private $query; - /** * @param string $query - * @param array $parameters * - * @return bool Returns `true` on success, `false` otherwise - */ - public function executeQuery(string $query, array $parameters = []): bool + public function __construct(string $host, string $username, string $password, string $dbname) { - $this->stmt = parent::prepare($query); - foreach ($parameters as $name => $value) { - $this->stmt->bindValue($name, $value[0], $value[1]); - } + $connection=mysqli_connect($host, $username, $password,$dbname); + } - return $this->stmt->execute(); + public function executeQuery(string $query): void + { + $this->query=mysqli_query($this->getConnection(),$query); } public function getResults(): array { - return $this->stmt->fetchAll(); + return $this->query; + } + public function getConnection(){ + return $this->connection; } } \ No newline at end of file From df96fb5b946446f1035670efc46c6202b5d5b9ef Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 15:38:57 +0100 Subject: [PATCH 21/32] Update Connection.php --- Source/API/script/Connection.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Source/API/script/Connection.php b/Source/API/script/Connection.php index 2b72d59..a7f8a20 100644 --- a/Source/API/script/Connection.php +++ b/Source/API/script/Connection.php @@ -1,28 +1,33 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - public function executeQuery(string $query): void + + /** * @param string $query + * @param array $parameters * + * @return bool Returns `true` on success, `false` otherwise + */ + public function executeQuery(string $query, array $parameters = []): bool { - $this->query=mysqli_query($this->getConnection(),$query); + $this->stmt = parent::prepare($query); + foreach ($parameters as $name => $value) { + $this->stmt->bindValue($name, $value[0], $value[1]); + } + + return $this->stmt->execute(); } public function getResults(): array { - return $this->query; - } + return $this->stmt->fetchAll(); - public function getConnection(){ - return $this->connection; } } \ No newline at end of file From 556183e820621146a2dfc90b5768d21b485cf697 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 15:57:20 +0100 Subject: [PATCH 22/32] Dockerfile check Docker Computer Version --- Source/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index b12cfe6..8961cca 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,4 +1,4 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y -RUN docker-php-ext-install mysqli +RUN uname -r COPY ./script /var/www/html \ No newline at end of file From e804b5af355f5417e070a890e7972f0430f1fc46 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 15:59:29 +0100 Subject: [PATCH 23/32] Dockerfile driver install --- Source/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 8961cca..2f8df7a 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,4 +1,4 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y -RUN uname -r +RUN docker-php-ext-install pdo pdo_mysql \ COPY ./script /var/www/html \ No newline at end of file From 8f49d13d1472d59066525d43384a71ddbc727261 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 15:59:44 +0100 Subject: [PATCH 24/32] Dockerfile driver install --- Source/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile index 2f8df7a..8a4ee87 100644 --- a/Source/API/Dockerfile +++ b/Source/API/Dockerfile @@ -1,4 +1,4 @@ FROM php:8.0-apache RUN apt-get update && apt-get upgrade -y -RUN docker-php-ext-install pdo pdo_mysql \ +RUN docker-php-ext-install pdo pdo_mysql COPY ./script /var/www/html \ No newline at end of file From ed8ab0d398865f5dc3bc1acbe39638b1572ead15 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 16:18:50 +0100 Subject: [PATCH 25/32] Add APIController.php , delete tmp.php, create some directories to organise the API and finalize the connection to the database --- Source/API/script/APIController.php | 29 +++++++++++++++++++ Source/API/script/{ => Config}/Connection.php | 0 Source/API/script/Config/config.php | 22 ++++++++++++++ Source/API/script/config.php | 20 ------------- Source/API/script/tmp.php | 3 -- 5 files changed, 51 insertions(+), 23 deletions(-) rename Source/API/script/{ => Config}/Connection.php (100%) create mode 100644 Source/API/script/Config/config.php delete mode 100644 Source/API/script/config.php delete mode 100644 Source/API/script/tmp.php diff --git a/Source/API/script/APIController.php b/Source/API/script/APIController.php index e69de29..f394218 100644 --- a/Source/API/script/APIController.php +++ b/Source/API/script/APIController.php @@ -0,0 +1,29 @@ +$action(); // Si oui, on appelle cette fonction + } + } + + } catch (PDOException) { + return http_response_code(404); + } + exit(0); + } + +} \ No newline at end of file diff --git a/Source/API/script/Connection.php b/Source/API/script/Config/Connection.php similarity index 100% rename from Source/API/script/Connection.php rename to Source/API/script/Config/Connection.php diff --git a/Source/API/script/Config/config.php b/Source/API/script/Config/config.php new file mode 100644 index 0000000..c5f00a2 --- /dev/null +++ b/Source/API/script/Config/config.php @@ -0,0 +1,22 @@ +getMessage(); - echo $PDOException->getCode(); - phpinfo(); - return http_response_code(404); -} diff --git a/Source/API/script/tmp.php b/Source/API/script/tmp.php deleted file mode 100644 index d4f7467..0000000 --- a/Source/API/script/tmp.php +++ /dev/null @@ -1,3 +0,0 @@ -HEY"; \ No newline at end of file From b671710be15e1ef6bed718c5dab3c612ec13fa8b Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 16:57:20 +0100 Subject: [PATCH 26/32] SonarQube first try --- .drone.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 5e74eb1..93fa193 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,6 +8,17 @@ trigger: - push steps: + - name: setup_PHP_for_SonarQube + image: php:8.1 + + commands: + - export SONAR_SCANNER_VERSION=4.7.0.2747 + - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux + - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip + - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + - export PATH=$SONAR_SCANNER_HOME/bin:$PATH + - export SONAR_SCANNER_OPTS="-server" + - sonar-scanner -D sonar.projectKey=SAE4.01_FORMULAIRE -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar # docker image build - name: set_api_form @@ -58,4 +69,3 @@ steps: CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: from_secret: db_password depends_on: [ deploy_api_form ] - From c9a59d482c2f74dd3acb9e4fec2d5286e9a5ad20 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 16:59:05 +0100 Subject: [PATCH 27/32] .drone.yml (SonarQube) --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 93fa193..3b98e30 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,6 +12,7 @@ steps: image: php:8.1 commands: + - apt-get update && apt-get install -y unzip - export SONAR_SCANNER_VERSION=4.7.0.2747 - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip From 7fe4e97dfaec51834e7dc01afe1c0805e8afd8db Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 17:03:22 +0100 Subject: [PATCH 28/32] .drone.yml update (SonarQube) --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 3b98e30..1495a7f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,7 +10,8 @@ trigger: steps: - name: setup_PHP_for_SonarQube image: php:8.1 - + environment: + SONAR_TOKEN: squ_9c3077de9c4cd738c450732a1d230c0bda513a5e commands: - apt-get update && apt-get install -y unzip - export SONAR_SCANNER_VERSION=4.7.0.2747 From 72a21965e4696ad82d4011fb32b3075a842eb5a0 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 17:15:35 +0100 Subject: [PATCH 29/32] .drone.yml update (SonarQube) --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 1495a7f..864eaff 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,8 @@ steps: - name: setup_PHP_for_SonarQube image: php:8.1 environment: - SONAR_TOKEN: squ_9c3077de9c4cd738c450732a1d230c0bda513a5e + SONAR_TOKEN: + from_secret: SONARQ_TOKEN commands: - apt-get update && apt-get install -y unzip - export SONAR_SCANNER_VERSION=4.7.0.2747 From a01fb47c79f489ecd8cd89e52944e31a506a2bd2 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 17:18:36 +0100 Subject: [PATCH 30/32] Add Header Test --- Source/API/script/APIController.php | 2 +- Source/API/script/Config/Connection.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/API/script/APIController.php b/Source/API/script/APIController.php index f394218..5e85c66 100644 --- a/Source/API/script/APIController.php +++ b/Source/API/script/APIController.php @@ -26,4 +26,4 @@ class APIController exit(0); } -} \ No newline at end of file +} diff --git a/Source/API/script/Config/Connection.php b/Source/API/script/Config/Connection.php index a7f8a20..b7555cb 100644 --- a/Source/API/script/Config/Connection.php +++ b/Source/API/script/Config/Connection.php @@ -1,3 +1,4 @@ + stmt->fetchAll(); } -} \ No newline at end of file +} From 9a95a5edf5187ecfa4a110eb8895144f3f8b573a Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Mon, 30 Jan 2023 17:22:11 +0100 Subject: [PATCH 31/32] Add Header Test 2 --- Source/API/script/Config/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/API/script/Config/Connection.php b/Source/API/script/Config/Connection.php index b7555cb..04a1f95 100644 --- a/Source/API/script/Config/Connection.php +++ b/Source/API/script/Config/Connection.php @@ -1,4 +1,4 @@ - + Date: Mon, 30 Jan 2023 17:23:28 +0100 Subject: [PATCH 32/32] Delete Header Test --- Source/API/script/Config/Connection.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/API/script/Config/Connection.php b/Source/API/script/Config/Connection.php index 04a1f95..942a479 100644 --- a/Source/API/script/Config/Connection.php +++ b/Source/API/script/Config/Connection.php @@ -1,4 +1,3 @@ -