-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
108 lines (82 loc) · 3.3 KB
/
Copy pathindex.php
File metadata and controls
108 lines (82 loc) · 3.3 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
declare(strict_types=1);
use App\BareUI;
use App\Http\Controllers\IndexController;
use App\Http\Middleware\RedirectIfAuthenticated;
use App\Scripts;
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager;
use Psr\Http\Message\ResponseInterface;
use function App\get_exception_handler;
require_once __DIR__ . '/bootstrap/app.php';
$manager = Container::getInstance()->get(Manager::class);
$redirectIfAuthenticated = Container::getInstance()->get(RedirectIfAuthenticated::class);
$indexController = Container::getInstance()->get(IndexController::class);
$response = Container::getInstance()->call($redirectIfAuthenticated->process(...), ['handler' => $indexController]);
if ($response instanceof ResponseInterface) {
foreach ($response->getHeaders() as $name => $values) {
header("$name: " . join(', ', $values));
}
echo $response->getBody();
}
/*======================================
= LÓGICA INICIAL =
======================================*/
include __DIR__ . '/templates/head.php';
Scripts::push($script);
if (!empty($_SESSION['userID'])) $_SESSION['userID'] = $admin['id'];
try {
$manager::table('carrito_venta')->delete();
$manager::table('carrito_compra')->delete();
} catch (PDOException $exception) {
get_exception_handler()($exception);
}
function verificarCopiaDeSeguridad(): void
{
if (file_exists(__DIR__ . '/backup/backup.sql'))
Scripts::pushSrcOnce('./resources/build/restaurarBD.js');
}
$bareUi = Container::getInstance()->get(BareUI::class);
$bareUi::config('params', $GLOBALS);
/*---------- Si no hay negocios, solicita registro ----------*/
if (!isset($mostrarLoader) and !$negocios):
verificarCopiaDeSeguridad();
echo $bareUi::render(
'templates/registrarNegocio.php',
['mostrarRegistro' => true],
);
Scripts::pushSrcOnce('./resources/build/registrarNegocio.js');
/*---------- Si no hay administrador, solicita registro ----------*/
elseif (!isset($mostrarLoader) and !$admin):
verificarCopiaDeSeguridad();
echo $bareUi::render(
'templates/registrarAdmin.php',
['mostrarRegistro' => true],
);
Scripts::pushSrcOnce('./resources/build/registrarAdmin.js');
/*---------- Si el administrador no tiene preguntas secretas, solicita registro ----------*/
elseif (!isset($mostrarLoader) and !$admin['pre1']):
verificarCopiaDeSeguridad();
echo $bareUi::render(
'templates/registroPreguntasRespuestas.php',
['mostrarRegistro' => true],
);
Scripts::pushSrcOnce('./resources/build/registrarPreguntasRespuestas.js');
/*---------- Muestra el login ----------*/
elseif (!isset($mostrarLoader)):
$bareUi::setParam('mostrarLogin', true);
echo $bareUi::render('templates/login.php');
echo $bareUi::render('templates/consultarPreguntasRespuestas.php');
if (isset($_SESSION['showQuestions']))
echo $bareUi::render('templates/preguntasRespuestas.php');
if (isset($_SESSION['changePassword']))
echo $bareUi::render('templates/cambiarClave.php');
Scripts::pushSrcOnce('./resources/libs/typedjs/typed.min.js');
Scripts::pushSrcOnce('./resources/build/reloj.js');
Scripts::pushSrcOnce('./resources/build/login.js');
Scripts::pushSrcOnce('./resources/build/recuperarClave.js');
endif;
echo $bareUi::render('templates/footer.php', [
'mostrarLoader' => $mostrarLoader ?? '',
'script' => $script ?? '',
]);