-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.php
85 lines (80 loc) · 4.27 KB
/
Index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
include("assets/php/Usuario.php");
include("assets/php/Subasta.php");
include("assets/php/Funciones.php");
session_start();
// MENSAJES DE ERROR
$log_error = "";
if(isset($_GET['mensaje'])&&($_GET['mensaje']=='error_formatoEmail')){$log_error = "<br><br>El formato del email es erroneo.";}
if(isset($_GET['mensaje'])&&($_GET['mensaje']=='error_enUso')){$log_error = "<br><br>Su usuario ya está en uso.";}
if(isset($_GET['mensaje'])&&($_GET['mensaje']=='error_datosMal')){$log_error = "<br><br>Su usuario o contraseña son incorrectos";}
if(isset($_GET['mensaje'])&&($_GET['mensaje']=='error_minima_puja')){$log_error = "<br><br>Su puja no se realizó. Tiene que pujar un 15% más que el precio actual.";}
if(isset($_GET['mensaje'])&&($_GET['mensaje']=='error_pobre')){$log_error = "<br><br>No tienes moneda suficiente para esa puja.";}
if(isset($_GET['mensaje'])&&($_GET['mensaje']=='sin_permiso')){$log_error = "<br><br>No tienes permiso para acceder a esta URL";}
if(isset($_GET['mensaje'])&&($_GET['mensaje']=='inicia')){$log_error = "<br><br>Registrado. Identificate ahora.";}
// ENVIO DE FORMULARIOS
if(isset($_POST['crear_usuario'])) {Usuario::crearUsuario($_POST['user'],$_POST['password']);}
if(isset($_POST['identificar'])) {Usuario::identificarUsuario($_POST['user'],$_POST['password']);}
if(isset($_POST['enviar'])) {Subasta::crearSubasta($_POST['sNombre'],$_POST['sPrecio'],$_POST['tiempo']);}
if(isset($_POST['pujar'])) {Subasta::pujar($_POST['sid'], $_POST['puja'], $_SESSION['username']);}
if(isset($_POST['agregarmoneda'])) {Usuario::addmoneda($_POST['addmoneda'], $_SESSION['uid']);}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/css/reset.css">
<link rel="stylesheet" href="assets/css/main.css">
<title>Subastas</title>
</head>
<body>
<!-- // Menu superior -->
<div class="header"><?php Funciones::menu();?></div>
<!-- // Caja de errores -->
<p style="width:100%; text-align:center; color:red"><?php echo $log_error; ?></p>
<!-- // Editor de subastas y usuarios -->
<?php if(!isset($_SESSION)) {
if($_SESSION['level'] == 1)?>
<?php } ?>
<!-- // Menu creacion de subastas -->
<?php if(isset($_GET['page'])&&($_GET['page']=='new_subasta')){ ?>
<div class="main">
<p>Creación de subasta</p> <br />
<form method="post">
<label for="sNombre">Nombre: </label>
<input type="text" name="sNombre" id="sPrecio">
<label for="sPrecio">Precio: </label>
<input name="sPrecio" id="sPrecio" type="number">
<select name="tiempo" id="timepo">
<option value="1day">1 día</option>
<option value="1week">1 mes</option>
<option value="1month">1 año</option>
</select>
<input type="submit" value="Enviar" name="enviar" class="btn">
</form>
</div>
<?php } ?>
<!-- // Muestra la tabla de subastas -->
<?php if(isset($_SESSION['level'])) { ?>
<div class="moneda"><br /><form method="post"><input type="number" name="addmoneda" placeholder="Añadir moneda"><input type="submit" value="Editar" name="agregarmoneda" class="btn"></form></div>
<div class="main">
<table>
<tr>
<?php if($_SESSION['level'] == 1) { ?><th>Id</th><?php } ?>
<th>Nombre</th>
<th>Fecha Inicio</th>
<th>Fecha Fin</th>
<th>Precio Salida</th>
<th>Precio Actual</th>
<th>Usuario</th>
<th>Cantidad</th>
<?php if($_SESSION['level'] == 1) { ?><th></th><th class="tac">¿Caducada?</th><?php } else { ?><th></th><?php } ?>
</tr>
<?php if($_SESSION['level'] == 1){Subasta::mostrarTodas();} else { Subasta::mostarSubastas();} ?>
</table>
<?php } else {echo '<p style="width: 100%" class="tac">Bienvenido. Esta es la página principal para las subastas, identifícate para poder ver la lista de subastas.</p>';} ?>
</div>
</body>
</html>