current status
This commit is contained in:
commit
03b6c2a98b
|
@ -0,0 +1,172 @@
|
|||
:root {
|
||||
/* Set sans-serif & mono fonts */
|
||||
--sans-font: "IBM Plex Sans","Roboto",-apple-system,BlinkMacSystemFont,"Nimbus Sans L",Avenir,"Noto Sans", "Segoe UI",Arial,Helvetica,"Helvetica Neue",sans-serif;
|
||||
--mono-font: "IBM Plex Mono","Roboto Mono","Ubuntu Mono","Fira Code","Overpass Mono", Monaco,"Droid Sans Mono",monospace;
|
||||
/* Body font size. By default, effectively 18.4px, based on 16px as 'root em' */
|
||||
--base-fontsize: 1.2rem;
|
||||
/* Major third scale progression - see https://type-scale.com/ */
|
||||
--header-scale: 1.185;
|
||||
/* Line height is set to the "Golden ratio" for optimal legibility */
|
||||
--line-height: 1.618;
|
||||
/*This is my dark themed color scheme*/
|
||||
--bg: #FFFFFF;
|
||||
--accent-bg: #F2F4F8;
|
||||
--text: #4c566a;
|
||||
--text-light: #4c566a;
|
||||
--border: #3b4252;
|
||||
--accent: #5e81ac;
|
||||
--accent-light: #5e81ac;
|
||||
--code: #2e3440;
|
||||
--code-bg: #e5e9f0;
|
||||
}
|
||||
@media (prefers-color-scheme:dark) {
|
||||
:root {
|
||||
--bg: #242933;
|
||||
--accent-bg: #3b4252;
|
||||
--text: #eceff4;
|
||||
--text-light: #d8dee9;
|
||||
--border: #88c0d0;
|
||||
--accent: #a3be8c;
|
||||
--accent-light: #bf616a;
|
||||
--code: #ebcb8b;
|
||||
--code-bg: #2e3440;
|
||||
}
|
||||
}
|
||||
html{
|
||||
font-family: var(--sans-font);
|
||||
}
|
||||
hr{
|
||||
color: var(--border);
|
||||
}
|
||||
header{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
margin: 1rem 0;
|
||||
|
||||
}
|
||||
body {
|
||||
padding: 20px;
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
font-size: 1.1rem;
|
||||
line-height: var(--line-height);
|
||||
margin: 0 auto;
|
||||
max-width: 50rem;
|
||||
}
|
||||
main img, main video, embed {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
opacity: 0.8;
|
||||
border-radius: 5px;
|
||||
}
|
||||
figure {
|
||||
margin: 0;
|
||||
}
|
||||
figcaption {
|
||||
font-size: .9rem;
|
||||
color: var(--text-light);
|
||||
text-align: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
blockquote {
|
||||
color: var(--text-light);
|
||||
font-style: italic;
|
||||
|
||||
}
|
||||
a {
|
||||
color: var(--accent);
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: none
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.3rem;
|
||||
color: var(--border);
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
h2, h3, h4, h5, h6 {
|
||||
font-size: 1.2rem;
|
||||
color: var(--accent-light);
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
p {
|
||||
padding: 0px;
|
||||
}
|
||||
code, pre, pre span, kbd, samp {
|
||||
font-family: var(--mono-font);
|
||||
color: var(--code);
|
||||
background: var(--code-bg);
|
||||
border-radius: 5px;
|
||||
padding: 0.12rem 0.3rem;
|
||||
}
|
||||
kbd {
|
||||
border: 1px solid var(--preformatted);
|
||||
border-bottom: 3px solid var(--preformatted);
|
||||
border-radius: 5px;
|
||||
padding: .1rem;
|
||||
}
|
||||
pre {
|
||||
padding: 1rem 1.4rem;
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
overflow-x: auto;
|
||||
background: var(--code-bg);
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
}
|
||||
pre code {
|
||||
font-family: var(--mono-font);
|
||||
background: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
svg {
|
||||
width: 36px;
|
||||
}
|
||||
/* Format navigation */
|
||||
nav a {
|
||||
background: var(--code-bg);
|
||||
margin: 1rem 0 0 .5rem;
|
||||
color: var(--border) !important;
|
||||
border-radius: 8px;
|
||||
display: inline-block;
|
||||
padding: .1rem .6rem;
|
||||
text-decoration: none;
|
||||
transition: .4s;
|
||||
}
|
||||
nav a.nav-current {
|
||||
background: var(--border);
|
||||
color: var(--bg) !important;
|
||||
font-weight: 700;
|
||||
opacity: 1;
|
||||
}
|
||||
nav a:hover {
|
||||
color: var(--bg) !important;
|
||||
border-color: var(--border);
|
||||
background: var(--border);
|
||||
}
|
||||
header h1{
|
||||
color: var(--accent) !important;
|
||||
display: inline-block;
|
||||
}
|
||||
header nav {
|
||||
display: inline-block;
|
||||
/*position: relative;*/
|
||||
}
|
||||
|
||||
a button,
|
||||
button,
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="button"] {
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
text-decoration: none;
|
||||
padding: .7rem .9rem;
|
||||
margin: .5rem .1rem;
|
||||
transition: .4s;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
session_start();
|
||||
$login = $_POST['loginname'];
|
||||
$userpassword = $_POST['userpassword'];
|
||||
$servername = "localhost";
|
||||
$username = "pi2";
|
||||
$password = "emb20";
|
||||
$database = "parking_lot";
|
||||
$conn = mysqli_connect($servername,$username,$password,$database);
|
||||
|
||||
if(!$conn){
|
||||
echo "Connection failed";
|
||||
die("Conection failed: ". mysqli_connect_error());
|
||||
}
|
||||
|
||||
$results = $conn->query("select * from users where username ="."'$login'");
|
||||
$results -> data_seek(0);
|
||||
$fila = $results->fetch_assoc();
|
||||
if($login == $fila['username'] && $userpassword == $fila['password']){
|
||||
$_SESSION['user_id'] = $fila['id'];
|
||||
header("Location: /parking/vip/");
|
||||
}
|
||||
|
||||
else{
|
||||
header("Location: login/");
|
||||
}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login attempted</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Login check</h3>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/python3
|
||||
import pymysql
|
||||
import sys
|
||||
|
||||
db = pymysql.connect(host='localhost', user='pi2', passwd='emb20', db='parking_lot')
|
||||
cur = db.cursor()
|
||||
|
||||
def output_query(sql):
|
||||
query = sql
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
values = cur.fetchall()
|
||||
if sql == available:
|
||||
if len(values) != 0:
|
||||
print("Estos son los espacios disponibles")
|
||||
else:
|
||||
print("Estos son los espacios ocupados")
|
||||
|
||||
if sql == all_values:
|
||||
print("Hay {0} espacios en uso".format(len(values)))
|
||||
|
||||
if len(values) != 0:
|
||||
print("""<br>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Fecha</th>
|
||||
<th>Hora de llegada</th>
|
||||
<th>Hora de salida</th>
|
||||
<th>Estado</th>
|
||||
</tr>""")
|
||||
for m in values:
|
||||
id_s = m[0]
|
||||
date= m[1]
|
||||
startime= m[2]
|
||||
endtime= m[3]
|
||||
reserved= m[5]
|
||||
if int(m[4])== 1:
|
||||
estado = "Ocupado"
|
||||
elif int(m[4]) == 0:
|
||||
estado = "Libre"
|
||||
if (int(m[5] == 1)):
|
||||
estado = "Reservado"
|
||||
print( "<tr><td>{0}</td> <td>{1}</td> <td>{2}</td> <td>{3}</td><td>{4}</td></tr>".format(id_s, date,startime, endtime, estado))
|
||||
|
||||
print("</table>")
|
||||
|
||||
# print(values)
|
||||
# print("### Latest 10 values ###\n")
|
||||
|
||||
available="select * from spaces where usedID = False"
|
||||
all_values="select * from spaces where usedID = True"
|
||||
# last_value="select * from sensor where id_SENSOR = (select max(id_SENSOR) from sensor)"
|
||||
# last_10 = "SELECT * FROM (select * from sensor order by ID_sensor DESC LIMIT 10) section order by ID_sensor ASC"
|
||||
|
||||
print("<h1> Espacios libres </h1>")
|
||||
output_query(available)
|
||||
print("<h1> Espacios en uso </h1>")
|
||||
output_query(all_values)
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Parking Lot Database</title>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<link rel="stylesheet" href="/assets/custom.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Estacionamiento</h1>
|
||||
<?php
|
||||
if($_POST['entrance'] and $_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
|
||||
$command = escapeshellcmd("sudo ./parking.py 2");
|
||||
$output = shell_exec($command);
|
||||
echo "$output";
|
||||
}
|
||||
|
||||
if($_POST['space_num'] and $_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
$v = $_POST['space_num'];
|
||||
$command2 = escapeshellcmd("sudo ./parking.py 1 $v");
|
||||
$output2 = shell_exec($command2);
|
||||
echo "$output2";
|
||||
}
|
||||
?>
|
||||
<p>Bienvenido al registro de estacionamiento. Actualiza la pagina para checar si hay espacios disponibles</p>
|
||||
<p>Si eres un cliente frecuente, <a href="login/">inicia sesión aqui</a>.</p>
|
||||
<form action="index.php" method="POST">
|
||||
<input type="submit" value="Actualizar datos">
|
||||
</form>
|
||||
|
||||
<p>Si quieres ingresar al estacionamiento, presiona el boton para asignarte un espacio y permitir la entrada</p>
|
||||
<form action="index.php" method="POST">
|
||||
<input type="submit" value="Access parking lot" name="entrance" id="entrance">
|
||||
</form>
|
||||
<p>Si quieres salir del estacionamiento, ingresa el lugar que se te asigno.</p>
|
||||
<form action="index.php" method="POST" autocomplete="off">
|
||||
<input type="number" id="space_num" name="space_num" >
|
||||
<input type="submit" value="Exit parking lot">
|
||||
</form>
|
||||
<?php
|
||||
$command = escapeshellcmd("sudo ./database_output.py");
|
||||
$output = shell_exec($command);
|
||||
echo "$output <br>";
|
||||
?>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Acceso VIP estacionamiento</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Iniciar sesión</h1>
|
||||
|
||||
<form method="POST" action="/parking/auth/" name="reg-form">
|
||||
<label>User</label><br>
|
||||
<input type="text" name="loginname" pattern="[a-zA-Z0-9]+" required/><br>
|
||||
<label>Password</label><br>
|
||||
<input type="password" name="userpassword" required/><br>
|
||||
<button type="submit" name="register" value="registro">Iniciar sesión</button>
|
||||
</form>
|
||||
<p><a href="/web/register/">Registrar usuario frecuente</a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina hija</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina hija</h3>
|
||||
<a href="padre.php">Link a la pagina padre</a><br>
|
||||
<a href="hijo.php">Link a la pagina hijo</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])){
|
||||
echo "Inicie sesión primero para acceder";
|
||||
echo '<br><a href="padre.php">Inicie sesión</a>';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina hijo</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina hijo</h3>
|
||||
<a href="padre.php">Link a la pagina principal</a><br>
|
||||
<a href="hija.php">Link a la pagina hija</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
session_start();
|
||||
$login = $_POST['loginname'];
|
||||
$userpassword = $_POST['userpassword'];
|
||||
$servername = "localhost";
|
||||
$username = "pi2";
|
||||
$password = "emb20";
|
||||
$database = "embebidos";
|
||||
$conn = mysqli_connect($servername,$username,$password,$database);
|
||||
|
||||
if(!$conn){
|
||||
echo "Connection failed";
|
||||
die("Conection failed: ". mysqli_connect_error());
|
||||
}
|
||||
|
||||
$results = $conn->query("select * from users where username ="."'$login'");
|
||||
$results -> data_seek(0);
|
||||
$fila = $results->fetch_assoc();
|
||||
if($login == $fila['username'] && $userpassword == $fila['password']){
|
||||
$_SESSION['user_id'] = $fila['id'];
|
||||
echo "Hola mundo";
|
||||
header("Location: hijo.php");
|
||||
}
|
||||
|
||||
else{
|
||||
echo "Adios mundo";
|
||||
header("Location: padre.php");
|
||||
}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login attempted</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Login check</h3>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,21 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina principal</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina principal</h3>
|
||||
|
||||
<form method="POST" action="login.php" name="reg-form">
|
||||
<label>User</label><br>
|
||||
<input type="text" name="loginname" pattern="[a-zA-Z0-9]+" require /><br>
|
||||
<label>Password</label><br>
|
||||
<input type="password" name="userpassword" require /><br>
|
||||
<button type="submit" name="register" value="registro"> Registro </button>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
|
@ -0,0 +1,104 @@
|
|||
#!/usr/bin/python3
|
||||
import RPi.GPIO as GPIO
|
||||
import pymysql
|
||||
import sys
|
||||
import os
|
||||
import time as t
|
||||
from gtts import gTTS as gt
|
||||
from datetime import datetime as dt
|
||||
|
||||
def angle_to_duty(angle):
|
||||
return (angle / 18 + 2)
|
||||
|
||||
def allow_entrance():
|
||||
servo.start(0)
|
||||
for i in range(0,91):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.004)
|
||||
t.sleep(1)
|
||||
for i in range(90,-1, -1):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.006)
|
||||
t.sleep(0.5)
|
||||
|
||||
|
||||
pressed = int(sys.argv[1])
|
||||
|
||||
db = pymysql.connect(host='localhost', user='pi2', passwd='emb20', db='parking_lot')
|
||||
cur = db.cursor()
|
||||
|
||||
servo_pin = 4
|
||||
pwm_freq = 50 # Nos referimos a un rango en Hz
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(servo_pin, GPIO.OUT)
|
||||
servo = GPIO.PWM(servo_pin, pwm_freq)
|
||||
|
||||
if pressed == 1:
|
||||
try:
|
||||
space_num = int(sys.argv[2])
|
||||
pressed = 0
|
||||
query= "select spaceID from spaces where usedID = True"
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
if (len(spaces)) == 0:
|
||||
output="There are no cars inside"
|
||||
print(output)
|
||||
else:
|
||||
spaceID = space_num
|
||||
query= "select usedID from spaces where spaceID = {0}".format(spaceID)
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
if spaces[0][0] == True:
|
||||
print("<h2>Have a nice day!</h2>")
|
||||
print("<p>We hope to see you again!</p>")
|
||||
now = dt.now()
|
||||
date = now.date()
|
||||
time = now.time().replace(microsecond=0)
|
||||
query = "update spaces set date = '{0}', endTime = '{1}', usedID = False where spaceID = {2}".format(date, time, spaceID)
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
allow_entrance()
|
||||
else:
|
||||
print("<h2>This place is already empty!</h2>")
|
||||
output = "<p>Please input a valid number.</p>"
|
||||
print(output)
|
||||
pressed = 1
|
||||
except IndexError:
|
||||
print("<h2>This number is out of bounds!</h2>")
|
||||
output = "Please, input the spot you were assigned when you entered."
|
||||
print("<script>alert('{0}')</script>".format(output))
|
||||
|
||||
print(output)
|
||||
|
||||
pressed = 1
|
||||
|
||||
elif pressed == 2:
|
||||
try:
|
||||
pressed = 0
|
||||
query = "select spaceID from spaces where usedID = False and reserved = False order by spaceID desc"
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
status= "<p>Estacionese en el lugar <b>{0}</b>.".format(spaces[0][0])
|
||||
print("<h2>Disfrute su visita!</h2>")
|
||||
print(status)
|
||||
print("Bienvenido!</p>")
|
||||
|
||||
now = dt.now()
|
||||
date = now.date()
|
||||
time = now.time().replace(microsecond=0)
|
||||
query = "update spaces set date = '{0}', startTime = '{1}', endTime= NULL, usedID = True where spaceID = {2}".format(date, time, spaces[0][0])
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
allow_entrance()
|
||||
except IndexError:
|
||||
status ="<script>alert('Lo sentimos, ya no hay espacios disponibles')</script>"
|
||||
print(status)
|
||||
|
||||
servo.stop()
|
||||
GPIO.cleanup()
|
||||
db.close()
|
||||
sys.exit(0)
|
|
@ -0,0 +1,19 @@
|
|||
<head>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<link rel="stylesheet" href="custom.css">
|
||||
</head>
|
||||
<?php
|
||||
|
||||
$v = $_POST['usuario'];
|
||||
$v2 = $_POST['u2'];
|
||||
$v3 = $_POST['u3'];
|
||||
$v4 = $_POST['u4'];
|
||||
$command = escapeshellcmd("sudo ./servo.py $v");
|
||||
$output = shell_exec($command);
|
||||
|
||||
echo "This is a test, you turned your servo to $v degrees <br>";
|
||||
echo "you also added $v2, $v3 and $v4"
|
||||
|
||||
//header("Location:ejemplo1.html");
|
||||
|
||||
?>
|
|
@ -0,0 +1,22 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale =1'>
|
||||
<title>Titulo de pagina </title>
|
||||
<link rel='stylesheet' type='text/css' href='main.css'>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="login.html"> Home</a></li>
|
||||
<li><a href="#"> About</a></li>
|
||||
<li><a href="#"> Sensores</a></li>
|
||||
<li><a href="#"> GPIO</a></li>
|
||||
<li><a href="#"> Actuadores</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
</nav>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale =1'>
|
||||
<title>Titulo de pagina </title>
|
||||
<link rel='stylesheet' type='text/css' href='main.css'>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="#"> Home</a></li>
|
||||
<li><a href="#"> About</a></li>
|
||||
<li><a href="#"> Sensores</a></li>
|
||||
<li><a href="#"> GPIO</a></li>
|
||||
<li><a href="#"> Actuadores</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
</nav>
|
||||
<main>
|
||||
<form>
|
||||
<label class="title">sistemas embebidos</label>
|
||||
<div>
|
||||
<label>username</label>
|
||||
<input type="text" name="login" required>
|
||||
</div>
|
||||
<div>
|
||||
<label>password</label>
|
||||
<input type="password" name="passwd" required>
|
||||
</div>
|
||||
<button type="submit" name="register">Registro</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,108 @@
|
|||
:root {
|
||||
--sans-font: "IBM Plex Sans","Roboto",-apple-system,BlinkMacSystemFont,"Nimbus Sans L",Avenir,"Noto Sans", "Segoe UI",Arial,Helvetica,"Helvetica Neue",sans-serif;
|
||||
--mono-font: "IBM Plex Mono","Roboto Mono","Ubuntu Mono","Fira Code","Overpass Mono", Monaco,"Droid Sans Mono",monospace;
|
||||
--base-fontsize: 1.35rem;
|
||||
--header-scale: 1.185; --line-height: 1.618;
|
||||
--bg: #FFFFFF;
|
||||
--accent-bg: #F2F4F8;
|
||||
--text: #4c566a;
|
||||
--text-light: #4c566a;
|
||||
--border: #3b4252;
|
||||
--accent: #5e81ac;
|
||||
--accent-light: #5e81ac;
|
||||
--code: #2e3440;
|
||||
--code-bg: #e5e9f0;
|
||||
}
|
||||
@media (prefers-color-scheme:dark) {
|
||||
:root {
|
||||
--bg: #242933;
|
||||
--accent-bg: #3b4252;
|
||||
--text: #eceff4;
|
||||
--text-light: #d8dee9;
|
||||
--border: #88c0d0;
|
||||
--accent: #a3be8c;
|
||||
--accent-light: #bf616a;
|
||||
--code: #ebcb8b;
|
||||
--code-bg: #2e3440;
|
||||
}
|
||||
}
|
||||
|
||||
*{
|
||||
font-family: var(--sans-font);
|
||||
}
|
||||
body{
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
width: 100%;
|
||||
}
|
||||
nav a {
|
||||
background: var(--code-bg);
|
||||
margin: 1rem 0 0 .5rem;
|
||||
color: var(--border) !important;
|
||||
border-radius: 8px;
|
||||
display: inline-block;
|
||||
padding: .1rem .9rem;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
transition: .4s;
|
||||
width: 7rem;
|
||||
}
|
||||
nav{
|
||||
/*margin: 0 auto;*/
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
nav a:hover {
|
||||
color: var(--bg) !important;
|
||||
border-color: var(--border);
|
||||
background: var(--border);
|
||||
}
|
||||
|
||||
ul{
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
li{
|
||||
/*float: left;*/
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.title{
|
||||
/*width: 250px;*/
|
||||
text-align: center;
|
||||
font-family: monospace;
|
||||
}
|
||||
label{
|
||||
width: 90px;
|
||||
display: inline-block;
|
||||
}
|
||||
form{
|
||||
margin: 25px auto;
|
||||
padding: 20px;
|
||||
max-width: 30rem;
|
||||
border: 1px solid var(--border);
|
||||
background-color: var(--code-bg);
|
||||
border-radius: 9px;
|
||||
}
|
||||
|
||||
a button,
|
||||
button,
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="button"] {
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
text-decoration: none;
|
||||
padding: .7rem .9rem;
|
||||
margin: .5rem .1rem;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
p.success, p.error{
|
||||
color: var(--accent);
|
||||
background-color: var(--accent);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina hija</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina hija</h3>
|
||||
<a href="padre.php">Link a la pagina padre</a><br>
|
||||
<a href="hijo.php">Link a la pagina hijo</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])){
|
||||
echo "Inicie sesión primero para acceder";
|
||||
echo '<br><a href="padre.php">Inicie sesión</a>';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina hijo</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina hijo</h3>
|
||||
<a href="padre.php">Link a la pagina principal</a><br>
|
||||
<a href="hija.php">Link a la pagina hija</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
session_start();
|
||||
$login = $_POST['loginname'];
|
||||
$userpassword = $_POST['userpassword'];
|
||||
$servername = "localhost";
|
||||
$username = "pi2";
|
||||
$password = "emb20";
|
||||
$database = "embebidos";
|
||||
$conn = mysqli_connect($servername,$username,$password,$database);
|
||||
|
||||
if(!$conn){
|
||||
echo "Connection failed";
|
||||
die("Conection failed: ". mysqli_connect_error());
|
||||
}
|
||||
|
||||
$results = $conn->query("select * from users where username ="."'$login'");
|
||||
$results -> data_seek(0);
|
||||
$fila = $results->fetch_assoc();
|
||||
if($login == $fila['username'] && $userpassword == $fila['password']){
|
||||
$_SESSION['user_id'] = $fila['id'];
|
||||
echo "Hola mundo";
|
||||
header("Location: hijo.php");
|
||||
}
|
||||
|
||||
else{
|
||||
echo "Adios mundo";
|
||||
header("Location: padre.php");
|
||||
}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login attempted</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Login check</h3>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,21 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina principal</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina principal</h3>
|
||||
|
||||
<form method="POST" action="login.php" name="reg-form">
|
||||
<label>User</label><br>
|
||||
<input type="text" name="loginname" pattern="[a-zA-Z0-9]+" require /><br>
|
||||
<label>Password</label><br>
|
||||
<input type="password" name="userpassword" require /><br>
|
||||
<button type="submit" name="register" value="registro"> Registro </button>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||
<head>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!--<link rel="stylesheet" href="custom.css">-->
|
||||
</head>
|
||||
|
||||
<?php
|
||||
$command = escapeshellcmd("sudo ./parking.py 2");
|
||||
$output = shell_exec($command);
|
||||
|
||||
echo "$output";
|
||||
|
||||
?>
|
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina hija</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina hija</h3>
|
||||
<a href="padre.php">Link a la pagina padre</a><br>
|
||||
<a href="hijo.php">Link a la pagina hijo</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])){
|
||||
echo "Inicie sesión primero para acceder";
|
||||
echo '<br><a href="padre.php">Inicie sesión</a>';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina hijo</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina hijo</h3>
|
||||
<a href="padre.php">Link a la pagina principal</a><br>
|
||||
<a href="hija.php">Link a la pagina hija</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
session_start();
|
||||
$login = $_POST['loginname'];
|
||||
$userpassword = $_POST['userpassword'];
|
||||
$servername = "localhost";
|
||||
$username = "pi2";
|
||||
$password = "emb20";
|
||||
$database = "embebidos";
|
||||
$conn = mysqli_connect($servername,$username,$password,$database);
|
||||
|
||||
if(!$conn){
|
||||
echo "Connection failed";
|
||||
die("Conection failed: ". mysqli_connect_error());
|
||||
}
|
||||
|
||||
$results = $conn->query("select * from users where username ="."'$login'");
|
||||
$results -> data_seek(0);
|
||||
$fila = $results->fetch_assoc();
|
||||
if($login == $fila['username'] && $userpassword == $fila['password']){
|
||||
$_SESSION['user_id'] = $fila['id'];
|
||||
echo "Hola mundo";
|
||||
header("Location: hijo.php");
|
||||
}
|
||||
|
||||
else{
|
||||
echo "Adios mundo";
|
||||
header("Location: padre.php");
|
||||
}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login attempted</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Login check</h3>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,21 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pagina principal</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h3>Pagina principal</h3>
|
||||
|
||||
<form method="POST" action="login.php" name="reg-form">
|
||||
<label>User</label><br>
|
||||
<input type="text" name="loginname" pattern="[a-zA-Z0-9]+" require /><br>
|
||||
<label>Password</label><br>
|
||||
<input type="password" name="userpassword" require /><br>
|
||||
<button type="submit" name="register" value="registro"> Registro </button>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Parking Lot Database</title>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<!--<link rel="stylesheet" href="custom.css">-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>Welcome to the parking lot.</p>
|
||||
|
||||
<form action="entering.php" method="POST" id="entrance">
|
||||
<input type="submit" value="Access parking lot">
|
||||
</form>
|
||||
<form action="data.php" method="POST">
|
||||
<input type="submit" value="View available spots">
|
||||
</form>
|
||||
|
||||
<form action="parking.php" method="POST">
|
||||
<input type="text" id="space_num" name="space_num" legend="Ingrese el numero del que proviene">
|
||||
<input type="submit" value="Exit parking lot">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,12 @@
|
|||
<head>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<!--<link rel="stylesheet" href="custom.css">-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
|
||||
<?php
|
||||
$v = $_POST['space_num'];
|
||||
$command = escapeshellcmd("sudo ./parking.py 1 $v");
|
||||
$output = shell_exec($command);
|
||||
echo "$output";
|
||||
?>
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/python3
|
||||
import sys
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
|
||||
def angleToDuty(angle):
|
||||
return (angle / 18 + 2)
|
||||
|
||||
angle2 = int(sys.argv[1])
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
servoPin=4
|
||||
pwm_freq = 50
|
||||
GPIO.setup(servoPin, GPIO.OUT)
|
||||
servo = GPIO.PWM(servoPin, pwm_freq)
|
||||
|
||||
servo.start(0)
|
||||
servo.ChangeDutyCycle(angleToDuty(angle2))
|
||||
time.sleep(1)
|
||||
servo.stop()
|
||||
GPIO.cleanup()
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,107 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Usuarios frecuentes</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
input[type="time"]::-webkit-calendar-picker-indicator{
|
||||
filter: invert(90%) sepia(13%) saturate(3207%) hue-rotate(130deg) brightness(95%) contrast(80%);
|
||||
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Pagina de usuarios frecuentes</h1>
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])){
|
||||
echo '<p><a href="/parking/login/">Inicie sesión</a> para acceder a esta pagina</p>';
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
echo "Sesion actual: ", $_SESSION['user_id'];
|
||||
}
|
||||
|
||||
$id = $_SESSION['user_id'];
|
||||
$servername = "localhost";
|
||||
$username = "pi2";
|
||||
$password = "emb20";
|
||||
$database = "parking_lot";
|
||||
$conn = mysqli_connect($servername,$username,$password,$database);
|
||||
if(!$conn){
|
||||
echo "Connection failed";
|
||||
die("Connection failed: ". mysqli_connect_error());
|
||||
}
|
||||
// Buscar espacios ya reservados por el usuario
|
||||
$existing = $conn->query("select place from users where place is not NULL and id = $id");
|
||||
$existing -> data_seek(0);
|
||||
$fila_exists = $existing->fetch_assoc();
|
||||
|
||||
// Si no ha reservado nada, dar la opcion de reservar
|
||||
if(sizeOf($fila_exists['place'])==0 ){
|
||||
$query_available = "select spaceID from spaces where usedID = 0 and reserved = 0";
|
||||
$available = $conn->query($query_available);
|
||||
$available_spaces = $available->fetch_all();
|
||||
echo '<h2>Apartar un lugar</h2>
|
||||
<p>Adquiere derecho a un espacio de estacionamiento en una hora deseada.</p>
|
||||
<form method="POST" action="/parking/vip/" name="reg-form">
|
||||
<label for="spaces">Espacio</label><br>
|
||||
<select id="spaces" name="spacenum" required>';
|
||||
for ($i = 0; $i < sizeOf($available_spaces); $i++){
|
||||
echo "<option value='",$available_spaces[$i][0],"'>", $available_spaces[$i][0], "</option>";
|
||||
}
|
||||
echo '</select> <br>
|
||||
<label>Hora de inicio</label><br>
|
||||
<input type="time" name="starttime" value="00:00:00" required/><br>
|
||||
<button type="submit" name="register" value="registro">Apartar espacio</button>
|
||||
</form>';
|
||||
|
||||
if($_POST['spacenum'] and $_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
echo "This is something else";
|
||||
$time = $_POST['starttime'];
|
||||
$num = $_POST['spacenum'];
|
||||
$reserve = $conn->query("update spaces set startTime = '$time', reserved = True where spaceID = $num");
|
||||
$reserve = $conn->query("update users set time = '$time', place = $num where id = $id");
|
||||
header("Location:/parking/vip/");
|
||||
}
|
||||
}
|
||||
|
||||
$reserved = $conn->query("select spaceID from spaces where spaceID = (select place from users where place is not NULL and id = $id)");
|
||||
$reserved -> data_seek(0);
|
||||
$fila = $reserved->fetch_assoc();
|
||||
$selected = $fila['spaceID'];
|
||||
|
||||
$secret = $conn->query("select password from users where id = $id");
|
||||
$secret -> data_seek(0);
|
||||
$secret = $secret->fetch_assoc();
|
||||
$code = $secret['password'];
|
||||
|
||||
if (sizeOf($fila['spaceID']) != 0){
|
||||
echo "<h2>Liberar un lugar</h2>";
|
||||
echo "Tienes apartado el lugar: ", $fila['spaceID'];
|
||||
echo '<p>Libera un espacio apartado que deseas cancelar.</p>
|
||||
<form method="POST" action="/parking/vip/" name="reg-form">
|
||||
<button type="submit" name="freenum" value="registro">Cancelar apartado actual</button> </form>
|
||||
<p>Utiliza este codigo QR para validar tu reservación al entrar al estacionamiento</p>';
|
||||
|
||||
$url = "'http://192.168.1.130/parking/vip/validate.php?number=$selected&userid=$id&secret=$code'";
|
||||
exec('sudo qrencode -s 30 -o file.png '. $url);
|
||||
echo '<img src="file.png">';
|
||||
}
|
||||
if($_POST['freenum'] and $_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
$cancelled = $_POST['freenum'];
|
||||
if (sizeOf($fila['spaceID']) != 0){
|
||||
$request = $conn->query("update spaces set reserved = 0, startTime = NULL, endTime = NULL where spaceID = $cancelled");
|
||||
$request = $conn->query("update users set place = NULL, time = NULL where id = '$id'");
|
||||
mysqli_close($conn);
|
||||
header("Location:/parking/vip/");
|
||||
}
|
||||
}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/python3
|
||||
import RPi.GPIO as GPIO
|
||||
import pymysql
|
||||
import sys
|
||||
import os
|
||||
import time as t
|
||||
from datetime import datetime as dt
|
||||
|
||||
pressed = int(sys.argv[1])
|
||||
|
||||
db = pymysql.connect(host='localhost', user='pi2', passwd='emb20', db='parking_lot')
|
||||
cur = db.cursor()
|
||||
|
||||
try:
|
||||
query = "select spaceID from spaces where usedID = False"
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
now = dt.now()
|
||||
date = now.date()
|
||||
query = "update spaces set date = '{0}', startTime = '{1}', endTime= NULL, usedID = True where spaceID = {2}".format(date, time, spaces[0][0])
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
except IndexError:
|
||||
status ="<script>alert('Sorry, but there are no spaces left')</script>"
|
||||
print(status)
|
||||
|
||||
db.close()
|
||||
sys.exit(0)
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id']) or $_SESSION['user_id'] != 1){
|
||||
echo '<p><a href="/web/login/">Inicie sesión</a> con la cuenta de administrador para acceder a esta pagina</p>';
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
echo "Tu sesion es: ", $_SESSION['user_id'],"<br>";
|
||||
$reserved_space = $_GET['number'];
|
||||
$iduser = $_GET['userid'];
|
||||
$secret = $_GET['secret'];
|
||||
echo "Asignando el espacio: ", $reserved_space;
|
||||
echo "<br>Al usuario con id: ", $iduser;
|
||||
$servername = "localhost";
|
||||
$username = "pi2";
|
||||
$password = "emb20";
|
||||
$database = "parking_lot";
|
||||
$conn = mysqli_connect($servername,$username,$password,$database);
|
||||
if(!$conn){
|
||||
echo "Connection failed";
|
||||
die("Connection failed: ". mysqli_connect_error());
|
||||
}
|
||||
|
||||
$query = "update spaces set usedID = True where spaceID = (select place from users where id = $iduser and password = '$secret')";
|
||||
$validate = $conn->query($query);
|
||||
//$query = "update users set place = NULL where id = $iduser";
|
||||
//$validate = $conn->query($query);
|
||||
//sudo
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue