Merge branch 'dev' into login
This commit is contained in:
commit
f0843d2248
15
README.md
15
README.md
|
@ -19,6 +19,21 @@ Estructura del archivo de configuración:
|
|||
}
|
||||
```
|
||||
|
||||
## Archivo de configuración del cliente de correo electrónico
|
||||
|
||||
Por defecto, `Nabu` escanea el archivo `email-config.json` dentro de la carpeta raíz del proyecto.
|
||||
|
||||
Estructura del archivo de configuración:
|
||||
|
||||
```json
|
||||
{
|
||||
"smtp": "smtp.gmail.com",
|
||||
"port": 587,
|
||||
"address": "foo@gmail.com",
|
||||
"password": "xxxxx"
|
||||
}
|
||||
```
|
||||
|
||||
## Licencia
|
||||
|
||||
```text
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'models/adminModel.php';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'models/articlesModel.php';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'models/blogModel.php';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'models/communityModel.php';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'models/profilesModel.php';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'models/searchModel.php';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'models/usersModel.php';
|
||||
|
||||
|
@ -8,14 +8,6 @@ class usersController {
|
|||
private const cost = array('cost' => 12);
|
||||
private const hash = 'sha256';
|
||||
|
||||
static public function login() {
|
||||
require_once 'views/pages/login.php';
|
||||
}
|
||||
|
||||
static public function logout() {
|
||||
//
|
||||
}
|
||||
|
||||
// Renderiza la página de registro de usuarios
|
||||
// y registra un usuario con el método POST.
|
||||
static public function signup() {
|
||||
|
@ -36,19 +28,59 @@ class usersController {
|
|||
array('password', 'exists' => true, 'min_lenght' => 6, 'max_lenght' => 255, 'not_spaces' => true, 'equal' => $_POST['confirm-password'])
|
||||
));
|
||||
|
||||
// Formatea en minúsculas la dirección de e-mail.
|
||||
$data['email'] = strtolower($data['email']);
|
||||
|
||||
$usersModel = new usersModel();
|
||||
|
||||
$users = $usersModel -> find($data['username'], $data['email']);
|
||||
|
||||
$msg = 'Existe una cuenta registrada con el mismo apodo o dirección de correo electrónico, por favor inténtelo de nuevo';
|
||||
|
||||
// Valida si la cuenta es única y elimina cuentas expiradas.
|
||||
foreach ($users as $user) {
|
||||
// Valida si es una cuenta activa o inactiva con registro de datos de usuario.
|
||||
if (empty($user['hash_expiration'])) {
|
||||
messages::add($msg);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Valida si es una cuenta expirada.
|
||||
if (time() > $user['hash_expiration']) {
|
||||
$usersModel -> delete($user['id']);
|
||||
}
|
||||
else {
|
||||
messages::add($msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messages::exist(NABU_ROUTES['signup']);
|
||||
|
||||
// Genera una llave aleatoria de verificación de dirección de e-mail.
|
||||
$key = bin2hex(random_bytes(32));
|
||||
|
||||
// Formatea en minúsculas la dirección de e-mail.
|
||||
$data['email'] = strtolower($data['email']);
|
||||
|
||||
// Hash de verificación de e-mail.
|
||||
$hash = hash_hmac(self::hash, $data['email'], $key);
|
||||
|
||||
require_once 'libs/emails.php';
|
||||
|
||||
$emails = new emails();
|
||||
$emails -> prepare($data['email'], $data['name']);
|
||||
|
||||
// Genera una URL de verificación de dirección de e-mail.
|
||||
$url = NABU_ROUTES['verifications'] . '&user=' . urlencode($data['username']) . '&key=' . $key;
|
||||
|
||||
$username = utils::escape($data['username']);
|
||||
|
||||
$body = require_once 'views/emails/verifications.php';
|
||||
|
||||
// Envía primero la URL de verificación de dirección de e-mail antes de registrar el usuario.
|
||||
if (!$emails -> send('¡Ya casi está listo!', $body)) {
|
||||
messages::errors('tuvimos un problema al enviar tu mensaje de verificación de e-mail', 500);
|
||||
}
|
||||
|
||||
// Cifra la contraseña.
|
||||
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT, self::cost);
|
||||
|
||||
|
@ -60,14 +92,34 @@ class usersController {
|
|||
|
||||
$user = $usersModel -> get('username', $data['username']);
|
||||
|
||||
unset($usersModel);
|
||||
|
||||
$verification = array(
|
||||
'id' => $user['id'],
|
||||
'hash' => $hash,
|
||||
'expiration' => time() + 60 * 60
|
||||
);
|
||||
|
||||
require_once 'models/verificationsModel.php';
|
||||
|
||||
$verificationsModel = new verificationsModel();
|
||||
|
||||
// Registra el hash de verificación de dirección de e-mail.
|
||||
$usersModel -> verification($verification);
|
||||
$verificationsModel -> save($verification);
|
||||
|
||||
messages::add('Su cuenta se ha registrado correctamente, por favor verifica tu dirección de correo electrónico');
|
||||
|
||||
utils::redirect(NABU_ROUTES['signup']);
|
||||
}
|
||||
}
|
||||
|
||||
static public function login() {
|
||||
$token = csrf::generate();
|
||||
$messages = messages::get();
|
||||
require_once 'views/pages/login.php';
|
||||
}
|
||||
|
||||
static public function logout() {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,48 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'models/verificationsModel.php';
|
||||
|
||||
class verificationsController {
|
||||
public static function verifications() {
|
||||
//
|
||||
if (empty($_GET['user']) || empty($_GET['key'])) {
|
||||
utils::redirect(NABU_ROUTES['home']);
|
||||
}
|
||||
|
||||
$verificationsModel = new verificationsModel();
|
||||
|
||||
// Busca los datos de verificación del usuario.
|
||||
$user = $verificationsModel -> get($_GET['user']);
|
||||
|
||||
if (empty($user['hash']) || empty($user['hash_expiration'])) {
|
||||
utils::redirect(NABU_ROUTES['home']);
|
||||
}
|
||||
|
||||
// Reconstruye el hash con la llave de verificación de la URL.
|
||||
$hash = hash_hmac('sha256', $user['email'], $_GET['key']);
|
||||
|
||||
// Valida la autentificación del hash.
|
||||
if (!hash_equals($user['hash'], $hash)) {
|
||||
utils::redirect(NABU_ROUTES['home']);
|
||||
}
|
||||
|
||||
// Valida si el hash está expirado y elimina el usuario.
|
||||
if (time() > $user['hash_expiration']) {
|
||||
require_once 'models/usersModel.php';
|
||||
|
||||
$usersModel = new usersModel();
|
||||
$usersModel -> delete($user['id']);
|
||||
|
||||
messages::add('Tu cuenta ha expirado, por favor vuelva a registrarse');
|
||||
utils::redirect(NABU_ROUTES['signup']);
|
||||
}
|
||||
|
||||
// Activa la cuenta del usuario y crea su perfil.
|
||||
$verificationsModel -> activate($user['id']);
|
||||
|
||||
messages::add('Tu dirección de correo electrónico se ha verificado correctamente');
|
||||
|
||||
utils::redirect(NABU_ROUTES['login']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
define('NABU_URL', 'http://localhost:8000');
|
||||
|
||||
|
@ -33,7 +33,7 @@ define('NABU_DEFAULT', array(
|
|||
date_default_timezone_set('America/Mexico_City');
|
||||
|
||||
/*
|
||||
// Nivel de reporte de errores.
|
||||
// Nivel de reporte de errores (todos los errores).
|
||||
ini_set('error_reporting', E_ALL);
|
||||
|
||||
// No muestra en pantalla todos los errores.
|
||||
|
@ -45,7 +45,7 @@ ini_set('display_startup_errors', false);
|
|||
// No registra mensajes repetidos.
|
||||
ini_set('ignore_repeated_errros', true);
|
||||
|
||||
// Configura los registros de errores en 'error_log' (manejador de errores de PHP).
|
||||
// Selecciona el manejador de errores de PHP 'error_log'.
|
||||
ini_set('log_errors', true);
|
||||
|
||||
// Define la ruta del archivo de registro de errores para 'error_log'.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
session_start();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
return array(
|
||||
'admin' => array('route' => 'admin', 'controller' => 'adminController', 'view' => 'admin'),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
// Realiza la conexión con la base de datos.
|
||||
class connection {
|
||||
|
@ -50,7 +50,7 @@ class connection {
|
|||
// Define la codificación de caracteres para el cliente del SGBD y los resultados de las consultas.
|
||||
$this -> pdo -> exec('SET CHARSET ' . $config['charset']);
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
catch (PDOException $e) {
|
||||
exit($e -> getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
// Valida formularios contra ataques CSRF.
|
||||
class csrf {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit();
|
||||
|
||||
require_once 'libs/php-smtp-2.0.4/Email.php';
|
||||
|
||||
use Snipworks\Smtp\Email;
|
||||
|
||||
// Envía mesajes de e-mail en formato HTML.
|
||||
class emails {
|
||||
private $mail;
|
||||
|
||||
private function errors(string $error) {
|
||||
messages::errors($error, 400);
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
if (!file_exists(NABU_DIRECTORY['email'])) {
|
||||
$this -> errors('Create a e-mail config file');
|
||||
}
|
||||
|
||||
// Carga el archivo de configuración del cliente de e-mail.
|
||||
$config = file_get_contents(NABU_DIRECTORY['email']);
|
||||
|
||||
if ($config === false) {
|
||||
$this -> errors('The e-mail config file is invalid');
|
||||
}
|
||||
|
||||
$config = json_decode($config, true);
|
||||
|
||||
$keys = array('smtp', 'port', 'address', 'password');
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (empty($config[$key])) {
|
||||
$this -> errors('Set "' . $key . '" in e-mail config file');
|
||||
}
|
||||
}
|
||||
|
||||
// Configura el cliente del e-mail.
|
||||
$this -> mail = new Email($config['smtp'], $config['port']);
|
||||
$this -> mail -> setProtocol(Email::TLS);
|
||||
$this -> mail -> setLogin($config['address'], $config['password']);
|
||||
$this -> mail -> setFrom($config['address'], NABU_DEFAULT['website-name']);
|
||||
}
|
||||
|
||||
// Define el destinatario del mensaje.
|
||||
public function prepare(string $destinatary, string $name) {
|
||||
$this -> mail -> addTo($destinatary, $name);
|
||||
}
|
||||
|
||||
// Envía un mensaje de e-mail HTML.
|
||||
public function send(string $subject, string $body) {
|
||||
$this -> mail -> setSubject($subject);
|
||||
$this -> mail -> setHtmlMessage($body);
|
||||
return $this -> mail -> send();
|
||||
}
|
||||
}
|
|
@ -1,21 +1,23 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
// Administra mensajes sobre advertencias, avisos y errores en las páginas.
|
||||
class messages {
|
||||
// Agrega mensajes sobre advertencias o avisos.
|
||||
static public function add(string $message) {
|
||||
if (empty($_SESSION['messages']))
|
||||
if (empty($_SESSION['messages'])) {
|
||||
$_SESSION['messages'] = array();
|
||||
}
|
||||
|
||||
array_push($_SESSION['messages'], $message);
|
||||
}
|
||||
|
||||
// @return un array de mensajes.
|
||||
static public function get() {
|
||||
if (empty($_SESSION['messages']))
|
||||
if (empty($_SESSION['messages'])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$messages = $_SESSION['messages'];
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
// Colección de herramientas propias de Nabu.
|
||||
class utils {
|
||||
// Redirecciona a una página web y termina la ejecución de todos los scripts de PHP.
|
||||
static public function redirect(string $route) {
|
||||
header('Location: ' . $route);
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
|
||||
// @return la fecha actual.
|
||||
|
@ -16,6 +16,6 @@ class utils {
|
|||
}
|
||||
|
||||
static public function escape($str) {
|
||||
//
|
||||
return htmlentities($str, ENT_COMPAT | ENT_HTML5, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
// Valida los campos de un formulario.
|
||||
class validations {
|
||||
|
@ -96,8 +96,9 @@ class validations {
|
|||
$data = array();
|
||||
|
||||
foreach ($options as $option) {
|
||||
if (empty($option[0]) || !is_string($option[0]))
|
||||
if (empty($option[0]) || !is_string($option[0])) {
|
||||
$this -> errors('Not found field name');
|
||||
}
|
||||
|
||||
$type = 'string';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
class adminModel extends connection {
|
||||
public function __construct() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
class articlesModel extends connection {
|
||||
public function __construct() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
class blogModel extends connection {
|
||||
public function __construct() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
class communityModel extends connection {
|
||||
public function __construct() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
class profilesModel extends connection {
|
||||
public function __construct() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
class searchModel extends connection {
|
||||
public function __construct() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
class usersModel extends connection {
|
||||
public function __construct() {
|
||||
|
@ -9,7 +9,7 @@ class usersModel extends connection {
|
|||
|
||||
// @return un lista de arrays asociativos con los datos de usuarios.
|
||||
public function find(string $username, string $email) {
|
||||
$query = 'SELECT u.id, u.role_id AS role, u.username, u.email, u.password, u.activated, u.creation_date,' .
|
||||
$query = 'SELECT u.id, u.username, u.email, u.password, u.activated, u.creation_date,' .
|
||||
'v.hash, v.expiration AS hash_expiration FROM users AS u ' .
|
||||
'LEFT JOIN verifications AS v on u.id = v.id ' .
|
||||
'WHERE u.username = ? OR u.email = ? LIMIT 2';
|
||||
|
@ -27,7 +27,7 @@ class usersModel extends connection {
|
|||
|
||||
return $users;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
catch (PDOException $e) {
|
||||
$this -> errors($e -> getMessage(), 'tuvimos un problema para validar si tu apodo y dirección de correo electrónico son únicos');
|
||||
}
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ class usersModel extends connection {
|
|||
try {
|
||||
$this -> pdo -> prepare($query) -> execute($data);
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
catch (PDOException $e) {
|
||||
$this -> errors($e -> getMessage(), 'tuvimos un problema para registrar tu cuenta de usuario');
|
||||
}
|
||||
}
|
||||
|
||||
// @return un array asociativo con los datos de un solo usuario.
|
||||
public function get(string $column, $pattern) {
|
||||
$query = 'SELECT u.id, u.role_id AS role, u.username, u.email, u.password, u.activated, u.creation_date,' .
|
||||
$query = 'SELECT u.id, u.username, u.email, u.password, u.activated, u.creation_date,' .
|
||||
'v.hash, v.expiration AS hash_expiration FROM users AS u ' .
|
||||
'LEFT JOIN verifications AS v on u.id = v.id ' .
|
||||
'WHERE u.' . $column . ' = ? LIMIT 1';
|
||||
|
@ -59,26 +59,26 @@ class usersModel extends connection {
|
|||
|
||||
$user = $prepare -> fetch();
|
||||
|
||||
if ($user !== false) {
|
||||
$user['role'] = $this -> role_format($user['role']);
|
||||
if (empty($user)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
catch (PDOException $e) {
|
||||
$this -> errors($e -> getMessage(), 'tuvimos un problema para buscar tu cuenta de usuario');
|
||||
}
|
||||
}
|
||||
|
||||
// Registra el 'hash de verificación de dirección de e-mail' con tiempo de expiración.
|
||||
public function verification(array $verification) {
|
||||
$query = 'INSERT INTO verifications(id, hash, expiration) VALUES(:id, :hash, :expiration)';
|
||||
// Elimina un usuario.
|
||||
public function delete(int $id) {
|
||||
$query = 'DELETE FROM users WHERE id = ?';
|
||||
|
||||
try {
|
||||
$this -> pdo -> prepare($query) -> execute($verification);
|
||||
$this -> pdo -> prepare($query) -> execute(array($id));
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
$this -> errors($e -> getMessage(), 'tuvimos un problema para registrar tu clave de verificación de dirección de correo electrónico');
|
||||
catch (PDOException) {
|
||||
$this -> errors($e -> getMessage(), 'tuvimos un problema para eliminar una cuenta de usuario');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,67 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit;
|
||||
defined('NABU') || exit();
|
||||
|
||||
class verificationsModel extends connection {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// Registra el 'hash de verificación de dirección de e-mail' con tiempo de expiración.
|
||||
public function save(array $verification) {
|
||||
$query = 'INSERT INTO verifications(id, hash, expiration) VALUES(:id, :hash, :expiration)';
|
||||
|
||||
try {
|
||||
$this -> pdo -> prepare($query) -> execute($verification);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$this -> errors($e -> getMessage(), 'tuvimos un problema para registrar tu clave de verificación de dirección de correo electrónico');
|
||||
}
|
||||
}
|
||||
|
||||
// @return un array asociativo con los datos de verificación de un usuario.
|
||||
public function get(string $username) {
|
||||
$query = 'SELECT u.id, u.email, v.hash, v.expiration as hash_expiration ' .
|
||||
'FROM users AS u LEFT JOIN verifications AS v ON u.id = v.id ' .
|
||||
'WHERE u.username = ? LIMIT 1';
|
||||
|
||||
try {
|
||||
$prepare = $this -> pdo -> prepare($query);
|
||||
|
||||
$prepare -> execute(array($username));
|
||||
|
||||
$user = $prepare -> fetch();
|
||||
|
||||
if (empty($user)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$this -> errors($e -> getMessage(), 'tuvimos un problema para validar tu dirección de correo electrónico');
|
||||
}
|
||||
}
|
||||
|
||||
// Activa la cuenta, elimina la verificación y
|
||||
// crea el perfil de un usuario.
|
||||
public function activate(int $id) {
|
||||
$query_activate = 'UPDATE users SET activated = TRUE WHERE id = ?';
|
||||
$query_delete = 'DELETE FROM verifications WHERE id = ?';
|
||||
$query_profile = 'INSERT INTO profiles(id) VALUES(?)';
|
||||
|
||||
$id = array($id);
|
||||
|
||||
try {
|
||||
$this -> pdo -> prepare($query_activate) -> execute($id);
|
||||
$this -> pdo -> prepare($query_delete) -> execute($id);
|
||||
$this -> pdo -> prepare($query_profile) -> execute($id);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$this -> errors($e -> getMessage(), 'tuvimos un problema para activar tu cuenta de ususario');
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
parent::__destruct();
|
||||
$this -> pdo = null;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Administración' ?>
|
||||
<?php $styles = array(
|
||||
'admin/dashboard/dashboard.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Editar artículo' ?>
|
||||
<?php $styles = array(
|
||||
'admin/edit-article/edit-article.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Artículos publicados' ?>
|
||||
<?php $styles = array(
|
||||
'admin/published-articles/published-articles.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Usuarios registrados' ?>
|
||||
<?php $styles = array(
|
||||
'admin/users/users.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $username = $_SESSION['user']['username'] ?>
|
||||
|
||||
<header>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
|
||||
<article class="card">
|
||||
<picture class="banner">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="rights">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
|
||||
<!-- Muestra mensajes sobre advertencias o avisos. -->
|
||||
<?php if (!empty($messages)): ?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
|
||||
<div class="overlay"></div>
|
||||
<nav class="nav">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
|
||||
<a href="<?= $view . '&page=' . $page - 1 ?>">Anterior</a>
|
||||
<span><?= $page ?></span>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
|
||||
<form method="POST" action="<?= NABU_ROUTES['home'] ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $token ?>">
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
defined('NABU') || exit();
|
||||
|
||||
return '<p>¡Hola ' . $username . '!, espero que estés bien. Para completar tu registro en ' . NABU_DEFAULT['website-name'] .
|
||||
', por favor confirma tu dirección de correo electrónico con el siguiente enlace:</p>' .
|
||||
'<div><a href="' . $url . '">Confirmar mi dirección de e-mail</a></div>' .
|
||||
'<p>Puedes ignorar este mensaje si no realizaste esta solicitud.</p>';
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Muro' ?>
|
||||
<?php $styles = array(
|
||||
'pages/all-articles/all-articles.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Artículo' ?>
|
||||
<?php $styles = array(
|
||||
'pages/article/article.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Categoría' ?>
|
||||
<?php $styles = array(
|
||||
'pages/category/category.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Confirmar contraseña' ?>
|
||||
<?php $styles = array(
|
||||
'pages/confirm-password/confirm-password.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Editar artículo' ?>
|
||||
<?php $styles = array(
|
||||
'pages/edit-article/edit-article.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Editar perfil' ?>
|
||||
<?php $styles = array(
|
||||
'pages/edit-profile/edit-profile.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Error' ?>
|
||||
<?php $styles = array(
|
||||
'pages/errors/errors.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Artículos favoritos' ?>
|
||||
<?php $styles = array(
|
||||
'pages/favorites/favorites.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = NABU_DEFAULT['website-name'] ?>
|
||||
<?php $styles = array(
|
||||
'components/articles/articles.css',
|
||||
|
@ -42,6 +42,7 @@
|
|||
<section class="recent__posts">
|
||||
<h2 class="recent-posts__title">Posts más recientes</h2>
|
||||
<section class="recent-cards__container">
|
||||
<?php $articles = $recent_articles ?>
|
||||
<?php require 'views/components/articles.php' ?>
|
||||
<?php require 'views/components/articles.php' ?>
|
||||
<?php require 'views/components/articles.php' ?>
|
||||
|
@ -57,7 +58,5 @@
|
|||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<?php $articles = $recent_articles ?>
|
||||
<!-- <?php require 'views/components/articles.php' ?> -->
|
||||
|
||||
<?php require_once 'views/components/footer.php' ?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Iniciar sesión' ?>
|
||||
<?php $styles = array(
|
||||
'components/footer/footer.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Publicar un artículo' ?>
|
||||
<?php $styles = array(
|
||||
'pages/post-article/post-article.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Perfil' ?>
|
||||
<?php $styles = array(
|
||||
'pages/profile/profile.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Búsquedas' ?>
|
||||
<?php $styles = array(
|
||||
'pages/search/search.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Artículos enviados' ?>
|
||||
<?php $styles = array(
|
||||
'pages/sent-articles/sent-articles.css',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php defined('NABU') || exit ?>
|
||||
<?php defined('NABU') || exit() ?>
|
||||
<?php $head_title = 'Crea una cuenta' ?>
|
||||
<?php $styles = array(
|
||||
'components/footer/footer.css',
|
||||
|
@ -19,14 +19,16 @@
|
|||
<img src="<?= NABU_DIRECTORY['images'] ?>/nabu-logo.svg" alt="Logo de nabu" class="header__logo">
|
||||
</picture>
|
||||
</header>
|
||||
|
||||
|
||||
<main class="sign-up">
|
||||
<section class="sign-up__title">
|
||||
<h1 class="sign-up__text">Registrate en <strong>Nabu</strong></h1>
|
||||
<span class="sign-up__plane"></span>
|
||||
</section>
|
||||
<section class="form__container">
|
||||
<form class="form__sign-up" action="POST" action="<?= NABU_ROUTES['signup'] ?>">
|
||||
<form class="form__sign-up" method="POST" action="<?= NABU_ROUTES['signup'] ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $token ?>">
|
||||
|
||||
<label for="name">
|
||||
<input class="sign-up__input" type="text" minlength="5" maxlength="255" id="name" name="name" required autofocus aria-label="Ingresa tu nombre completo" autocomplete="name">
|
||||
<span class="name__field">Nombre completo</span>
|
||||
|
@ -52,16 +54,16 @@
|
|||
<input class="sign-up__input" type="password" id="confirm-password" name="confirm-password" minlength="6" maxlength="255" required aria-label="Confirma tu contraseña">
|
||||
<span class="name__field">Confirmar contraseña</span>
|
||||
</label>
|
||||
|
||||
|
||||
<div class="sign-up__container">
|
||||
<input class="sign-up__button"type="submit" name="signup-submit" value="Registrarme" aria-label="Registrar">
|
||||
<span></span>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="form__already">¿Ya tienes cuenta?
|
||||
<a href="<?= NABU_ROUTES['login'] ?>">Inicia sesión</a>.
|
||||
</p>
|
||||
|
||||
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
|
@ -72,35 +74,3 @@
|
|||
</picture>
|
||||
</div>
|
||||
<?php require_once 'views/components/footer.php' ?>
|
||||
|
||||
<!--
|
||||
<form method="POST" action="<?= NABU_ROUTES['signup'] ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $token ?>">
|
||||
<div>
|
||||
<label for="name">Nombre completo</label>
|
||||
<input type="text" id="name" name="name" minlength="5" maxlength="255" autofocus required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="username">Apodo</label>
|
||||
<input type="text" id="username" name="username" minlength="1" maxlength="255" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="email">Correo institucional</label>
|
||||
<input type="email" id="email" name="email" minlength="5" maxlength="255" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="password">Constraseña</label>
|
||||
<input type="password" id="password" name="password" minlength="6" maxlength="255" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="confirm-password">Confirmar contraseña</label>
|
||||
<input type="password" id="confirm-password" name="confirm-password" minlength="6" maxlength="255" required>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" name="signup-submit" value="Registrarme">
|
||||
<p>¿Ya tienes cuenta? <a href="<?= NABU_ROUTES['login'] ?>">Inicia sesión</a>.</p>
|
||||
</div>
|
||||
</form>
|
||||
-->
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue