prueba
This commit is contained in:
commit
9cf9201462
27
z1/docker-compose.yml
Normal file
27
z1/docker-compose.yml
Normal file
@ -0,0 +1,27 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
php:
|
||||
build:
|
||||
context: ./php/
|
||||
container_name: programwithgio-app
|
||||
restart: always
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
nginx:
|
||||
build:
|
||||
context: ./nginx/
|
||||
container_name: programwithgio-nginx
|
||||
restart: always
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
depends_on:
|
||||
- php
|
||||
ports:
|
||||
- 8080:80
|
||||
mysql:
|
||||
image: mysql:latest
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
volumes:
|
||||
- ./data:/var/lib/mysql
|
13
z1/includes/config/database.php
Normal file
13
z1/includes/config/database.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
function conectarDB(){
|
||||
$host = 'mysql';
|
||||
$port = '3306';
|
||||
$db = mysqli_connect($host,'root','password','notas',$port);
|
||||
//$db->set_charset('utf8');
|
||||
if(!$db){
|
||||
echo 'Error no se pudo conectar';
|
||||
exit;
|
||||
}
|
||||
return $db;
|
||||
}
|
18
z1/includes/create.php
Normal file
18
z1/includes/create.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require "config/database.php";
|
||||
$db =conectarDB();
|
||||
|
||||
if ($db->connect_errno) {
|
||||
// Print the connection error message
|
||||
echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
||||
// You can also log the error message to a file or other logging mechanism
|
||||
// error_log("Failed to connect to MySQL: " . mysqli_connect_error());
|
||||
exit(); // Exit the script if there's a connection error
|
||||
}
|
||||
if($_POST){
|
||||
$note = mysqli_real_escape_string($db,$_POST['note']);;
|
||||
$query = "insert into nota (noteContent) values ('$note')";
|
||||
mysqli_query($db,$query);
|
||||
}
|
||||
mysqli_close($db);
|
||||
header("Location:../index.php");
|
20
z1/includes/delete.php
Normal file
20
z1/includes/delete.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
require "config/database.php";
|
||||
$db =conectarDB();
|
||||
|
||||
if ($db->connect_errno) {
|
||||
// Print the connection error message
|
||||
echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
||||
// You can also log the error message to a file or other logging mechanism
|
||||
// error_log("Failed to connect to MySQL: " . mysqli_connect_error());
|
||||
exit(); // Exit the script if there's a connection error
|
||||
}
|
||||
|
||||
|
||||
if($_POST){
|
||||
$noteID = $_POST['id'];;
|
||||
$query = "delete from nota where id = $noteID";
|
||||
mysqli_query($db,$query);
|
||||
}
|
||||
mysqli_close($db);
|
||||
header("Location:../index.php");
|
44
z1/index.php
Normal file
44
z1/index.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
require "includes/config/database.php";
|
||||
$db =conectarDB();
|
||||
if ($db->connect_errno) {
|
||||
// Print the connection error message
|
||||
echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
||||
// You can also log the error message to a file or other logging mechanism
|
||||
// error_log("Failed to connect to MySQL: " . mysqli_connect_error());
|
||||
exit(); // Exit the script if there's a connection error
|
||||
}
|
||||
|
||||
$getNotes = "select * from notag" ;
|
||||
$notes = mysqli_query($db,$getNotes);
|
||||
mysqli_close($db);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="src/prueba.css">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="contenedor">
|
||||
|
||||
<h1>Notes manager</h1>
|
||||
<form class="addNote"id="myForm" method="post" action="includes/create.php">
|
||||
<label for="note"></label>
|
||||
<input name="note" id="note" type="text">
|
||||
<input class="button greenButton" type="submit" value="add">
|
||||
</form>
|
||||
<?php while($row=mysqli_fetch_array($notes)){?>
|
||||
<div class="note">
|
||||
<p><?php echo $row['noteContent'] ?></p>
|
||||
<form action="includes/delete.php" method="post">
|
||||
<input type="hidden" name="id" value="<?php echo $row['id']?>"> <!-- Aquí puedes poner el ID del elemento a eliminar -->
|
||||
<input class="button redButton" type="submit" name="delete" value="delete">
|
||||
</form>
|
||||
</div>
|
||||
<?php }?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
2
z1/nginx/Dockerfile
Normal file
2
z1/nginx/Dockerfile
Normal file
@ -0,0 +1,2 @@
|
||||
FROM nginx:alpine
|
||||
COPY ./default.conf /etc/nginx/conf.d/default.conf
|
38
z1/nginx/default.conf
Normal file
38
z1/nginx/default.conf
Normal file
@ -0,0 +1,38 @@
|
||||
server {
|
||||
|
||||
listen 80 default_server;
|
||||
root /var/www/html;
|
||||
index index.html index.php;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
access_log off;
|
||||
error_log /var/log/nginx/error.log error;
|
||||
|
||||
sendfile off;
|
||||
|
||||
client_max_body_size 100m;
|
||||
|
||||
location ~ .php$ {
|
||||
fastcgi_split_path_info ^(.+.php)(/.+)$;
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_intercept_errors off;
|
||||
fastcgi_buffer_size 16k;
|
||||
fastcgi_buffers 4 16k;
|
||||
}
|
||||
|
||||
location ~ /.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
3
z1/php/Dockerfile
Normal file
3
z1/php/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM php:fpm-alpine
|
||||
|
||||
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
|
1
z1/sh/remove-app.sh
Normal file
1
z1/sh/remove-app.sh
Normal file
@ -0,0 +1 @@
|
||||
docker-compose down
|
2
z1/sh/start-app.sh
Normal file
2
z1/sh/start-app.sh
Normal file
@ -0,0 +1,2 @@
|
||||
echo 'starting app...'
|
||||
docker-compose up -d
|
1
z1/sh/stop-app.sh
Normal file
1
z1/sh/stop-app.sh
Normal file
@ -0,0 +1 @@
|
||||
docker-compose stop
|
43
z1/src/prueba.css
Normal file
43
z1/src/prueba.css
Normal file
@ -0,0 +1,43 @@
|
||||
/* Utilities*/
|
||||
.button{
|
||||
display: inl;
|
||||
color:white;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
border-radius: 2rem;
|
||||
text-transform: uppercase;
|
||||
margin: 1rem 1rem;
|
||||
border: none;
|
||||
}
|
||||
.greenButton{
|
||||
background-color: green;
|
||||
}
|
||||
.redButton{
|
||||
background-color: red;
|
||||
width: -moz-available;
|
||||
}
|
||||
input[type="text"]{
|
||||
padding: 1rem;
|
||||
border-radius: 2rem
|
||||
}
|
||||
|
||||
.contenedor{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.note{
|
||||
background-color: bisque;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2,1fr);
|
||||
align-items: center;
|
||||
width: 20rem;
|
||||
padding:1rem;
|
||||
border-radius: 2rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.addNote{
|
||||
width: 20rem;
|
||||
}
|
Loading…
Reference in New Issue
Block a user