diff --git a/DB.php b/DB.php new file mode 100644 index 0000000..eab85c4 --- /dev/null +++ b/DB.php @@ -0,0 +1,26 @@ + + + + Cours PHP / MySQL + + + + +

Bases de données MySQL

+ connect_error){ + die('Erreur : ' .$conn->connect_error); + } + echo 'Connexion réussie'; + ?> + + diff --git a/H3campus-dev.php b/H3campus-dev.php new file mode 100644 index 0000000..1268ec8 --- /dev/null +++ b/H3campus-dev.php @@ -0,0 +1,273 @@ + + + + + Serveurs BTS NDRC + + + + + + + + +
+

Service Informatique H3 Campus



+ + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + if(array_key_exists('NameWP', $_POST)) { FnCreateWP($host); } + if(array_key_exists('WP_X', $_POST)) { FnDeleteWP($host); } + if(array_key_exists('NamePresta', $_POST)) { FnCreatePresta($host); } + if(array_key_exists('Presta_X', $_POST)) { FnDeletePresta($host); } + + /**************************************** WORDPRESS function PHP **************************************** */ + function FnCreateWP($hostaddr) { + if ($_POST['NameWP']==="cancel") {exit;} + /* Variables */ + $port=8000; //port de départ... + $dockerlxc="/root/WP/".$_POST["NameWP"].".yml"; //Nom fichier compose + $sqlfile ="/root/WP/sql.sql"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen('192.168.150.233', $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/WP/wp.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/wordpress1/".$_POST["NameWP"]."/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"echo 'CREATE DATABASE IF NOT EXISTS ".$_POST["NameWP"].";'> $sqlfile" ); + $Result=ssh_command($hostaddr,"echo 'GRANT ALL PRIVILEGES ON ".$_POST["NameWP"].".* TO 'wp_user'@'localhost';'>> $sqlfile"); + + /* Création de la table correspondante dans la base de donnée */ + $Result=ssh_command($hostaddr,"docker-compose -f /root/WP/db.yml exec -T db mysql -uroot -plinux wordpress < $sqlfile"); + sleep(15); + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=120 && docker-compose -f $dockerlxc up -d &"); + sleep(20); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NameWP"]); + header("Refresh:0"); + } + + function FnDeleteWP($host) { + $dockerName=$_POST['WP_X']; + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); + } + /**************************************** PRESTASHOP function PHP **************************************** */ + function FnCreatePresta($hostaddr) { + $dockerName=$_POST['NamePresta']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=7000; //port de départ... + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/PS/sql.sql"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/PS/ps.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/prestashop1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export DOCKER_CLIENT_TIMEOUT=120 && export DOCKER_HTTP_TIMEOUT=120"); + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=120 && docker-compose -f $dockerlxc up -d &"); + sleep(20); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NamePresta"]); + header("Refresh:0"); + } + + function FnDeletePresta($host) { + $dockerName=$_POST['Presta_X']; + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); + } + ?> + + +

+ + + + +
+
+
+ + + +
+
+ +

Wordpress - Prestashop

+ + + +NULL) and ($Result2<>NULL)) +{ + echo << + Serveurs de bases de données + Bases de données Wordpress & Prestashop fonctionnelles + + + TABLEAU; +} +else echo "Attention les bases de données ne sont pas lancés correctement !

"; +?> + + + + + + + +
"; + } + } + } + ?> +
Serveurs Wordpress +
+ + + + +
+
".$value ." Accéder à $value
+ + + + + + +
"; + } + } + } + ?> +
Serveurs Prestashop +
+ + + + +
+
".$value ." Accéder à $value
+ +
+ + + + +




+

+

+ +
+

+ + + + +HTML; +?> + + + diff --git a/H3campus.php b/H3campus.php new file mode 100644 index 0000000..2350fec --- /dev/null +++ b/H3campus.php @@ -0,0 +1,356 @@ + + + + + Serveurs BTS NDRC + + + + + + + + +
+

Service Informatique H3 Campus



+ + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + //Paris + if(array_key_exists('NameWP', $_POST)) { FnCreateWP($host); } + if(array_key_exists('WP_X', $_POST)) { FnDeleteWP($host); } + if(array_key_exists('NamePresta', $_POST)) { FnCreatePresta($host); } + if(array_key_exists('Presta_X', $_POST)) { FnDeletePresta($host); } + //Poissy + if(array_key_exists('NameWP_POI', $_POST)) { FnCreateWP($host_poi); } + if(array_key_exists('WP_X_POI', $_POST)) { FnDeleteWP($host_poi); } + if(array_key_exists('NamePresta_POI', $_POST)) { FnCreatePresta($host_poi); } + if(array_key_exists('Presta_X_POI', $_POST)) { FnDeletePresta($host_poi); } + + /**************************************** WORDPRESS function PHP POISSY **************************************** */ + function FnCreateWP_POI($hostaddr) { + if ($_POST['NameWP_POI']==="cancel") {exit;} + /* Variables */ + $port=8000; //port de départ... + $dockerName= $_POST["NameWP_POI"]; + $dockerlxc="/root/WP/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/WP/sql/$dockerName-sql.sql"; + + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/WP/wp.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/wordpress1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"echo 'CREATE DATABASE IF NOT EXISTS $dockerName;'> $sqlfile" ); + $Result=ssh_command($hostaddr,"echo 'GRANT ALL PRIVILEGES ON $dockerName.* TO 'wp_user'@'localhost';'>> $sqlfile >$sqlfile.log"); + + /* Création de la table correspondante dans la base de donnée */ + $Result=ssh_command($hostaddr,"docker-compose -f /root/WP/db.yml exec -T db mysql -uroot -plinux wordpress < $sqlfile"); + sleep(10); + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=240 && docker-compose -f $dockerlxc up -d >$dockerlxc.log"); + + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NameWP_POI"]); + header("Refresh:0"); + } + + function FnDeleteWP_POI($host) { + $dockerName=$_POST['WP_X_POI']; + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); + } + /**************************************************************************************************************** */ + + /**************************************** PRESTASHOP function PHP POISSY **************************************** */ + function FnCreatePresta_POI($hostaddr) { + $dockerName=$_POST['NamePresta_POI']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=7000; //port de départ... + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/PS/sql.log"; + + //recherche du premiephp refresh page port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/PS/ps.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/prestashop1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export DOCKER_CLIENT_TIMEOUT=120 && export DOCKER_HTTP_TIMEOUT=120"); + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=120 && docker-compose -f $dockerlxc up -d &"); + sleep(20); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NamePresta_POI"]); + header("Refresh:0"); + } + + function FnDeletePresta_POI($host) { + $dockerName=$_POST['Presta_X_POI']; + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); + } + + /************************************************************************************************************** */ + + /**************************************** WORDPRESS function PHP PARIS **************************************** */ + function FnCreateWP($hostaddr) { + $dockerName=$_POST['NameWP']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=8000; //port de départ... + $dockerlxc="/root/WP/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/WP/sql/$dockerName-sql.log"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/WP/wp.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/wordpress1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"echo 'CREATE DATABASE IF NOT EXISTS $dockerName;'> $sqlfile" ); + $Result=ssh_command($hostaddr,"echo 'GRANT ALL PRIVILEGES ON $dockerName.* TO 'wp_user'@'localhost';'>> $sqlfile"); + + /* Création de la table correspondante dans la base de donnée */ + $Result=ssh_command($hostaddr,"docker-compose -f /root/WP/db.yml exec -T db mysql -uroot -plinux wordpress < $sqlfile >$sqlfile.log"); + sleep(10); + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=240 && docker-compose -f $dockerlxc up -d >$dockerlxc.log"); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NameWP"]); + header("Refresh:0"); + } + + function FnDeleteWP($host) { + $dockerName=$_POST['WP_X']; + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); + } +/*************************************************************************************************************** */ + +/**************************************** PRESTASHOP function PHP PARIS **************************************** */ +function FnCreatePresta($hostaddr) { + $dockerName=$_POST['NamePresta']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=7000; //port de départ... + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/PS/sql.sql"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/PS/ps.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/prestashop1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export DOCKER_CLIENT_TIMEOUT=120 && export DOCKER_HTTP_TIMEOUT=120"); + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=120 && docker-compose -f $dockerlxc up -d &"); + sleep(20); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NamePresta"]); + header("Refresh:0"); + } + +function FnDeletePresta($host) { + $dockerName=$_POST['Presta_X']; + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); + } + +// ******************************************************************************************************************* + +?> + + +

+ +

Wordpress - Prestashop

+ + + +NULL) and ($Result2<>NULL)) +{ + echo << + Serveurs de bases de données + Bases de données Wordpress & Prestashop fonctionnelles + + + TABLEAU; +} +else echo "Attention les bases de données ne sont pas lancés correctement !

"; +?> +

+ + + + + + + +
+ + + + + + + + "; + echo ""; + echo ""; + } + } + } + ?> +
PARIS
Nom du Wordpress +
+ + + + +
+
".$value ." Accéder à $value
+
+ + + + + + + + "; + echo ""; + echo ""; + } + } + } + ?> +
POISSY
Nom du Wordpress +
+ + + + +
+
".$value ." Accéder à $value
+ +
+ +
+ + + + +




+ + + + + +HTML; +?> + + + diff --git a/H3campus2.php b/H3campus2.php new file mode 100644 index 0000000..2367fd9 --- /dev/null +++ b/H3campus2.php @@ -0,0 +1,242 @@ + + + + + Serveurs BTS NDRC + + + + + + + + +
+

Service Informatique H3 Campus



+ + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + if(array_key_exists('NameWP', $_POST)) { FnCreateWP($host); } + if(array_key_exists('WP_X', $_POST)) { FnDeleteWP($host); } + if(array_key_exists('NamePresta', $_POST)) { FnCreatePresta($host); } + if(array_key_exists('Presta_X', $_POST)) { FnDeletePresta($host); } + + /**************************************** WORDPRESS function PHP **************************************** */ + function FnCreateWP($hostaddr) { + if ($_POST['NameWP']==="cancel") {exit;} + /* Variables */ + $port=8000; //port de départ... + $dockerlxc="/root/WP/".$_POST["NameWP"].".yml"; //Nom fichier compose + $sqlfile ="/root/WP/sql.sql"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen('192.168.150.233', $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/WP/wp.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/wordpress1/".$_POST["NameWP"]."/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"echo 'CREATE DATABASE IF NOT EXISTS ".$_POST["NameWP"].";'> $sqlfile" ); + $Result=ssh_command($hostaddr,"echo 'GRANT ALL PRIVILEGES ON ".$_POST["NameWP"].".* TO 'wp_user'@'localhost';'>> $sqlfile"); + + /* Création de la table correspondante dans la base de donnée */ + $Result=ssh_command($hostaddr,"docker-compose -f /root/WP/db.yml exec -T db mysql -uroot -plinux wordpress < $sqlfile"); + sleep(15); + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=120 && docker-compose -f $dockerlxc up -d &"); + sleep(20); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NameWP"]); + header("Refresh:0"); + } + + function FnDeleteWP($host) { + $dockerName=$_POST['WP_X']; + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); + } + /**************************************** PRESTASHOP function PHP **************************************** */ + function FnCreatePresta($hostaddr) { + $dockerName=$_POST['NamePresta']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=7000; //port de départ... + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/PS/sql.sql"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/PS/ps.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/prestashop1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export DOCKER_CLIENT_TIMEOUT=120 && export DOCKER_HTTP_TIMEOUT=120"); + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=120 && docker-compose -f $dockerlxc up -d &"); + sleep(20); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NamePresta"]); + header("Refresh:0"); + } + + function FnDeletePresta($host) { + $dockerName=$_POST['Presta_X']; + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); + } + ?> + + +

+ + + + +
+
+
+ + + +
+
+ +

Wordpress - Prestashop

+ + + +NULL) and ($Result2<>NULL)) +{ + echo << + Serveurs de bases de données + Bases de données Wordpress & Prestashop fonctionnelles + + + TABLEAU; +} +else echo "Attention les bases de données ne sont pas lancés correctement !

"; +?> + + + + + + + +
"; + } + } + } + ?> +
Serveurs Wordpress +
+ + + + +
+
".$value ." Accéder à $value
+ + + +
+ + + + +




+ + + + + +HTML; +?> + + + diff --git a/PS_Paris.php b/PS_Paris.php new file mode 100644 index 0000000..8341b30 --- /dev/null +++ b/PS_Paris.php @@ -0,0 +1,169 @@ + + + + + Serveurs BTS NDRC + + + + + + + + +
+

Service Informatique H3 Campus

+ + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + if(array_key_exists('NamePresta', $_POST)) { FnCreatePresta($host); } + if(array_key_exists('Presta_X', $_POST)) { FnDeletePresta($host); } + +/**************************************** PRESTASHOP function PHP **************************************** */ +function FnCreatePresta($hostaddr) { + $dockerName=$_POST['NamePresta']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=7000; //port de départ... + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/PS/ps.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/prestashop1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export DOCKER_CLIENT_TIMEOUT=240 && export DOCKER_HTTP_TIMEOUT=240 && export COMPOSE_HTTP_TIMEOUT=240 && docker-compose -f $dockerlxc up -d >PS_$dockerName.log"); + sleep(20); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NamePresta"]); + header("Refresh:0"); + } + +function FnDeletePresta($host) { + $dockerName=$_POST['Presta_X']; + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName >>PS_$dockerName.log"); + $Result=ssh_command($host, "docker rm $dockerName >>PS_$dockerName.log"); + header("Refresh:0"); + } + ?> + + + +

Prestashop PARIS

+ + + +NULL) +{ + echo << + Serveurs de bases de données + Bases de données Prestashop fonctionnelles + + + TABLEAU; +} +else echo "Attention les bases de données ne sont pas lancées correctement !

"; +?> +
+ + + + + + "; + echo ""; + echo ""; + } + } + } + ?> +
Serveurs Prestashop +
+ + + + +
+
$value Accéder à $value
+ +
+ + + + +




+ +s + + + + +HTML; +?> + + + diff --git a/PS_Poissy.php b/PS_Poissy.php new file mode 100644 index 0000000..e1e08a7 --- /dev/null +++ b/PS_Poissy.php @@ -0,0 +1,168 @@ + + + + + Serveurs BTS NDRC + + + + + + + + +
+

Service Informatique H3 Campus

+ + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + if(array_key_exists('NamePresta', $_POST)) { FnCreatePresta($host); } + if(array_key_exists('Presta_X', $_POST)) { FnDeletePresta($host); } + +/**************************************** PRESTASHOP function PHP **************************************** */ +function FnCreatePresta($hostaddr) { + $dockerName=$_POST['NamePresta']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=7000; //port de départ... + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/PS/ps.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/prestashop1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export DOCKER_CLIENT_TIMEOUT=240 && export DOCKER_HTTP_TIMEOUT=240 && export COMPOSE_HTTP_TIMEOUT=240 && docker-compose -f $dockerlxc up -d >PS_$dockerName.log"); + sleep(20); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NamePresta"]); + header("Refresh:0"); + } + +function FnDeletePresta($host) { + $dockerName=$_POST['Presta_X']; + $dockerlxc="/root/PS/$dockerName.yml"; //Nom fichier compose + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName >>PS_$dockerName.log"); + $Result=ssh_command($host, "docker rm $dockerName >>PS_$dockerName.log"); + header("Refresh:0"); + } + ?> + + + +

Prestashop POISSY

+ + + +NULL) +{ + echo << + Serveurs de bases de données + Bases de données Prestashop fonctionnelles + + + TABLEAU; +} +else echo "Attention les bases de données ne sont pas lancées correctement !

"; +?> +
+ + + + + + + "; + echo ""; + echo ""; + } + } + } + ?> +
Serveurs Prestashop +
+ + + + +
+
$value Accéder à $value
+ +
+ + + + +




+ + + + + +HTML; +?> + + + diff --git a/WPC.php b/WPC.php new file mode 100644 index 0000000..2caf8c4 --- /dev/null +++ b/WPC.php @@ -0,0 +1,57 @@ + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + //Paris + if(array_key_exists('NameWP', $_POST)) { FnCreateWP($host); } + if(array_key_exists('WP_X', $_POST)) { FnDeleteWP($host); } + +/************************************************************************************************************** */ + +/**************************************** WORDPRESS function PHP PARIS **************************************** */ +function FnCreateWP($hostaddr) { + $dockerName=$_POST['NameWP']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=8000; //port de départ... + $dockerlxc="/root/WP/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/WP/sql/$dockerName-sql"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/WP/wp.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/wordpress1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"echo 'CREATE DATABASE IF NOT EXISTS $dockerName;'> $sqlfile" ); + $Result=ssh_command($hostaddr,"echo 'GRANT ALL PRIVILEGES ON $dockerName.* TO 'wp_user'@'localhost';'>> $sqlfile"); + + /* Création de la table correspondante dans la base de donnée */ + $Result=ssh_command($hostaddr,"docker-compose -f /root/WP/db.yml exec -T db mysql -uroot -plinux wordpress < $sqlfile >$sqlfile.log"); + sleep(10); + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=240 && docker-compose -f $dockerlxc up -d >$dockerlxc.log"); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NameWP"]); + header("Refresh:0"); +} + +function FnDeleteWP($host) { + $dockerName=$_POST['WP_X']; + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); +} + +/*************************************************************************************************************** */ +?> \ No newline at end of file diff --git a/WP_Paris.php b/WP_Paris.php new file mode 100644 index 0000000..624342f --- /dev/null +++ b/WP_Paris.php @@ -0,0 +1,175 @@ + + + + + Serveurs BTS NDRC + + + + + + + + +
+

Service Informatique H3 Campus



+ + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + //Paris + if(array_key_exists('NameWP', $_POST)) { FnCreateWP($host); } + if(array_key_exists('WP_X', $_POST)) { FnDeleteWP($host); } + +/************************************************************************************************************** */ + +/**************************************** WORDPRESS function PHP PARIS **************************************** */ +function FnCreateWP($hostaddr) { + $dockerName=$_POST['NameWP']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=8000; //port de départ... + $dockerlxc="/root/WP/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/WP/sql/$dockerName-sql"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/WP/wp.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/wordpress1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"echo 'CREATE DATABASE IF NOT EXISTS $dockerName;'> $sqlfile" ); + $Result=ssh_command($hostaddr,"echo 'GRANT ALL PRIVILEGES ON $dockerName.* TO 'wp_user'@'localhost';'>> $sqlfile"); + + /* Création de la table correspondante dans la base de donnée */ + $Result=ssh_command($hostaddr,"docker-compose -f /root/WP/db.yml exec -T db mysql -uroot -plinux wordpress < $sqlfile >$sqlfile.log"); + sleep(10); + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=240 && docker-compose -f $dockerlxc up -d >$dockerlxc.log"); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NameWP"]); + header("Refresh:0"); +} + +function FnDeleteWP($host) { + $dockerName=$_POST['WP_X']; + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); +} + +/*************************************************************************************************************** */ +?> + +

Wordpress Paris

+ + + +NULL) +{ + echo << + Serveurs de bases de données + Bases de données Wordpress fonctionnelles + + + TABLEAU; +} +else echo "Attention les bases de données ne sont pas lancées correctement !

"; +?> + +

+ + + + + + + + + + + "; + echo ""; + echo ""; + } + } + } + ?> +
PARIS
Nom du Wordpress +
+ + + + +
+
$value Accéder à $value
+ + +
+ + + + +




+ + + + + +HTML; +?> + + + diff --git a/WP_Poissy.php b/WP_Poissy.php new file mode 100644 index 0000000..ee953b5 --- /dev/null +++ b/WP_Poissy.php @@ -0,0 +1,175 @@ + + + + + Serveurs BTS NDRC + + + + + + + + +
+

Service Informatique H3 Campus



+ + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + //Poissy + if(array_key_exists('NameWP', $_POST)) { FnCreateWP($host); } + if(array_key_exists('WP_X', $_POST)) { FnDeleteWP($host); } + +/************************************************************************************************************** */ + +/**************************************** WORDPRESS function PHP PARIS **************************************** */ +function FnCreateWP($hostaddr) { + $dockerName=$_POST['NameWP']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=8000; //port de départ... + $dockerlxc="/root/WP/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/WP/sql/$dockerName-sql"; + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/WP/wp.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/wordpress1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"echo 'CREATE DATABASE IF NOT EXISTS $dockerName;'> $sqlfile" ); + $Result=ssh_command($hostaddr,"echo 'GRANT ALL PRIVILEGES ON $dockerName.* TO 'wp_user'@'localhost';'>> $sqlfile"); + + /* Création de la table correspondante dans la base de donnée */ + $Result=ssh_command($hostaddr,"docker-compose -f /root/WP/db.yml exec -T db mysql -uroot -plinux wordpress < $sqlfile >$sqlfile.log"); + sleep(10); + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=240 && docker-compose -f $dockerlxc up -d >$dockerlxc.log"); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NameWP"]); + header("Refresh:0"); +} + +function FnDeleteWP($host) { + $dockerName=$_POST['WP_X']; + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); +} + +/*************************************************************************************************************** */ +?> + +

Wordpress Poissy

+ + + +NULL) +{ + echo << + Serveurs de bases de données + Bases de données Wordpress fonctionnelles + + + TABLEAU; +} +else echo "Attention les bases de données ne sont pas lancées correctement !

"; +?> + +

+ + + + + + + + + + + "; + echo ""; + echo ""; + } + } + } + ?> +
POISSY
Nom du Wordpress +
+ + + + +
+
$value Accéder à $value
+ + +
+ + + + +




+ + + + + +HTML; +?> + + + diff --git a/WP_Poissy2.php b/WP_Poissy2.php new file mode 100644 index 0000000..b2c56f4 --- /dev/null +++ b/WP_Poissy2.php @@ -0,0 +1,200 @@ + + + + + Serveurs BTS NDRC + + + + + + + + + + + + + + +
+ +

Service Informatique H3 Campus



+ + + + + if(array_key_exists('Reset', $_POST)) { FnReset($host); } + //Paris + if(array_key_exists('NameWP', $_POST)) { FnCreateWP($host); } + if(array_key_exists('WP_X', $_POST)) { FnDeleteWP($host); } + +/************************************************************************************************************** */ + +/**************************************** WORDPRESS function PHP PARIS **************************************** */ +function FnCreateWP($hostaddr) { + $dockerName=$_POST['NameWP']; + if ($dockerName==="cancel") {exit;} + /* Variables */ + $port=8000; //port de départ... + $dockerlxc="/root/WP/$dockerName.yml"; //Nom fichier compose + $sqlfile ="/root/WP/sql/$dockerName-sql"; + + + //recherche du premier port disponible + $connection = @fsockopen($hostaddr, $port); + while (is_resource($connection)) { $port++; fclose($connection);$connection = @fsockopen($hostaddr, $port,$errno,$errstr,10); } + + + /* Création des fichiers compose et db */ + $Result=ssh_command($hostaddr,"cp /root/WP/wp.yml.save ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/wordpress1/$dockerName/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"sed -i 's/8001/$port/g' ".$dockerlxc); + $Result=ssh_command($hostaddr,"echo 'CREATE DATABASE IF NOT EXISTS $dockerName;'> $sqlfile" ); + $Result=ssh_command($hostaddr,"echo 'GRANT ALL PRIVILEGES ON $dockerName.* TO 'wp_user'@'localhost';'>> $sqlfile"); + + /* Création de la table correspondante dans la base de donnée */ + $Result=ssh_command($hostaddr,"docker-compose -f /root/WP/db.yml exec -T db mysql -uroot -plinux wordpress < $sqlfile >$sqlfile.log"); + sleep(10); + //création du conteneur docker... + $Result=ssh_command($hostaddr, "export COMPOSE_HTTP_TIMEOUT=240 && docker-compose -f $dockerlxc up -d >$dockerlxc.log"); + + // Vide l'instruction de créer une machine et puis refresh + unset($_POST["NameWP"]); + header("Refresh:0"); +} + +function FnDeleteWP($host) { + $dockerName=$_POST['WP_X']; + if ($dockerName==="cancel") {exit;} + $Result=ssh_command($host, "docker stop $dockerName"); + $Result=ssh_command($host, "docker rm $dockerName"); + header("Refresh:0"); +} + +/*************************************************************************************************************** */ +?> + + + +
+
+ + Chargement en cours... +
+ +
+ +
+

Wordpress Poissy

+ + + +NULL) +{ + echo << + Serveurs de bases de données + Bases de données Wordpress fonctionnelles + + + TABLEAU; +} +else echo "Attention les bases de données ne sont pas lancés correctement !

"; +?> + +

+ + + + + + + + + + + "; + echo ""; + echo ""; + } + } + } + ?> +
POISSY
Nom du Wordpress +
+ + + + +
+
$value Accéder à $value
+ + +
+ + + +




+ + + + + +HTML; +?> + + + + diff --git a/accueil.php b/accueil.php new file mode 100644 index 0000000..ed0b6e9 --- /dev/null +++ b/accueil.php @@ -0,0 +1,19 @@ + + + + + + + + + + +



+ +
+ +
+ + + + \ No newline at end of file diff --git a/fonction.php b/fonction.php new file mode 100644 index 0000000..efa0658 --- /dev/null +++ b/fonction.php @@ -0,0 +1,60 @@ + "ssh-rsa")); + if(!$connection) + { + return false; + } + + /* le fingerprint n'est pas teste, c'est voulu, il est juste affiche */ + $fingerprint=@ssh2_fingerprint($connection, + SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX); + + /* Utilisation de public/private key */ + if(@ssh2_auth_pubkey_file($connection, "user", + "public_key", "private_key", "passphrase")) + { + return array($connection,$fingerprint); + } else { + return false; + } + } + + + /* Executer une commande, retour les flux stderr et stdout de la commande */ + function ssh_command($connection, $cmd) + { + /* Exec commande */ + $stdout_stream=@ssh2_exec($connection, $cmd); + if(!$stdout_stream) + { + return false; + } + + /* Extrait le flux stderr, a l'origine mixe dans stdout */ + $stderr_stream=@ssh2_fetch_stream($stdout_stream, + SSH2_STREAM_STDERR); + if(!$stderr_stream) + { + return false; + } + + /* Les flux sont bloquant pour lire le contenu ensuite l'afficher */ + if(!@stream_set_blocking($stdout_stream, true)) + { + return false; + } + if(!@stream_set_blocking($stderr_stream, true)) + { + return; + } + return array($stdout_stream, $stderr_stream); + } + +?> \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..766401d --- /dev/null +++ b/index.html @@ -0,0 +1,368 @@ + + + + + + Apache2 Debian Default Page: It works + + + +
+ + +
+ + +
+
+ It works! +
+
+

+ This is the default welcome page used to test the correct + operation of the Apache2 server after installation on Debian systems. + If you can read this page, it means that the Apache HTTP server installed at + this site is working properly. You should replace this file (located at + /var/www/html/index.html) before continuing to operate your HTTP server. +

+ + +

+ If you are a normal user of this web site and don't know what this page is + about, this probably means that the site is currently unavailable due to + maintenance. + If the problem persists, please contact the site's administrator. +

+ +
+
+
+ Configuration Overview +
+
+

+ Debian's Apache2 default configuration is different from the + upstream default configuration, and split into several files optimized for + interaction with Debian tools. The configuration system is + fully documented in + /usr/share/doc/apache2/README.Debian.gz. Refer to this for the full + documentation. Documentation for the web server itself can be + found by accessing the manual if the apache2-doc + package was installed on this server. + +

+

+ The configuration layout for an Apache2 web server installation on Debian systems is as follows: +

+
+/etc/apache2/
+|-- apache2.conf
+|       `--  ports.conf
+|-- mods-enabled
+|       |-- *.load
+|       `-- *.conf
+|-- conf-enabled
+|       `-- *.conf
+|-- sites-enabled
+|       `-- *.conf
+          
+
    +
  • + apache2.conf is the main configuration + file. It puts the pieces together by including all remaining configuration + files when starting up the web server. +
  • + +
  • + ports.conf is always included from the + main configuration file. It is used to determine the listening ports for + incoming connections, and this file can be customized anytime. +
  • + +
  • + Configuration files in the mods-enabled/, + conf-enabled/ and sites-enabled/ directories contain + particular configuration snippets which manage modules, global configuration + fragments, or virtual host configurations, respectively. +
  • + +
  • + They are activated by symlinking available + configuration files from their respective + *-available/ counterparts. These should be managed + by using our helpers + + a2enmod, + a2dismod, + + + a2ensite, + a2dissite, + + and + + a2enconf, + a2disconf + . See their respective man pages for detailed information. +
  • + +
  • + The binary is called apache2. Due to the use of + environment variables, in the default configuration, apache2 needs to be + started/stopped with /etc/init.d/apache2 or apache2ctl. + Calling /usr/bin/apache2 directly will not work with the + default configuration. +
  • +
+
+ +
+
+ Document Roots +
+ +
+

+ By default, Debian does not allow access through the web browser to + any file apart of those located in /var/www, + public_html + directories (when enabled) and /usr/share (for web + applications). If your site is using a web document root + located elsewhere (such as in /srv) you may need to whitelist your + document root directory in /etc/apache2/apache2.conf. +

+

+ The default Debian document root is /var/www/html. You + can make your own virtual hosts under /var/www. This is different + to previous releases which provides better security out of the box. +

+
+ +
+
+ Reporting Problems +
+
+

+ Please use the reportbug tool to report bugs in the + Apache2 package with Debian. However, check existing bug reports before reporting a new bug. +

+

+ Please report bugs specific to modules (such as PHP and others) + to respective packages, not to the web server itself. +

+
+ + + + +
+
+
+
+ + + diff --git a/loader.gif b/loader.gif new file mode 100644 index 0000000..3596a61 Binary files /dev/null and b/loader.gif differ diff --git a/menu.php b/menu.php new file mode 100644 index 0000000..01bbc14 --- /dev/null +++ b/menu.php @@ -0,0 +1,333 @@ + + + + \ No newline at end of file diff --git a/ports.php b/ports.php new file mode 100644 index 0000000..9cbdba3 --- /dev/null +++ b/ports.php @@ -0,0 +1,11 @@ +Port disponible : $port "; + +?> \ No newline at end of file diff --git a/progress.js b/progress.js new file mode 100644 index 0000000..e8d207d --- /dev/null +++ b/progress.js @@ -0,0 +1,40 @@ +document.onreadystatechange = function(e) +{ + if(document.readyState=="interactive") + { + var all = document.getElementsByTagName("*"); + for (var i=0, max=all.length; i < max; i++) + { + set_ele(all[i]); + } + } +} + +function check_element(ele) +{ + var all = document.getElementsByTagName("*"); + var totalele=all.length; + var per_inc=100/all.length; + + if($(ele).on()) + { + var prog_width=per_inc+Number(document.getElementById("progress_width").value); + document.getElementById("progress_width").value=prog_width; + $("#bar1").animate({width:prog_width+"%"},10,function(){ + if(document.getElementById("bar1").style.width=="100%") + { + $(".progress").fadeOut("slow"); + } + }); + } + + else + { + set_ele(ele); + } +} + +function set_ele(set_element) +{ + check_element(set_element); +} \ No newline at end of file diff --git a/progress_style.css b/progress_style.css new file mode 100644 index 0000000..df364ca --- /dev/null +++ b/progress_style.css @@ -0,0 +1,53 @@ +body +{ +margin:0px; auto; +padding:0px; +font-family:helvetica; +} +.progress +{ + position: fixed; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + z-index: 9999; + background-color: #F2F2F2; +} +.bar +{ + background-color: #819FF7; + width:0%; + height:5px; + border-radius: 3px; +} +.percent +{ + position:absolute; + display:inline-block; + top:3px; + left:48%; +} +#wrapper +{ + width:995px; + padding:0px; + margin:0px auto; + font-family:helvetica; + text-align:center; +} +h1 +{ + text-align:center; + font-size:35px; + margin-top:60px; + color:#A9BCF5; +} +h1 p +{ + text-align:center; + margin:0px; + font-size:18px; + text-decoration:underline; + color:grey; +} \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..a611de3 --- /dev/null +++ b/readme.md @@ -0,0 +1,7 @@ + +# Gestion des conteneurs dockers +--- + +## Wordpress + +## Prestashop diff --git a/security.jpeg b/security.jpeg new file mode 100644 index 0000000..4510cf9 Binary files /dev/null and b/security.jpeg differ diff --git a/sql.php b/sql.php new file mode 100644 index 0000000..1ab55c9 --- /dev/null +++ b/sql.php @@ -0,0 +1,20 @@ + + + + + + + diff --git a/webtools.php b/webtools.php new file mode 100644 index 0000000..d0e83c1 --- /dev/null +++ b/webtools.php @@ -0,0 +1,4 @@ +$output"; +?> \ No newline at end of file