Compare commits
1 Commits
main
...
obtener_ip
| Author | SHA1 | Date | |
|---|---|---|---|
| 97f3dfee15 |
|
|
@ -3,6 +3,36 @@ require_once "../modelos/Venta.php";
|
|||
if (strlen(session_id())<1)
|
||||
session_start();
|
||||
|
||||
// Obtener la IP del dispositivo que ingreso
|
||||
function getIp(): string
|
||||
{
|
||||
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||
} elseif (isset($_SERVER['REMOTE_ADDR']) === true) {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
if (preg_match('/^(?:127|10)\.0\.0\.[12]?\d{1,2}$/', $ip)) {
|
||||
if (isset($_SERVER['HTTP_X_REAL_IP'])) {
|
||||
$ip = $_SERVER['HTTP_X_REAL_IP'];
|
||||
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
if (in_array($ip, ['::1', '0.0.0.0', 'localhost'], true)) {
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
$filter = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||
if ($filter === false) {
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
$ip_autorizada ='127.0.0.1';
|
||||
|
||||
$venta = new Venta();
|
||||
|
||||
$idventa=isset($_POST["idventa"])? limpiarCadena($_POST["idventa"]):"";
|
||||
|
|
@ -78,6 +108,7 @@ switch ($_GET["op"]) {
|
|||
$rspta=$venta->listar();
|
||||
$data=Array();
|
||||
|
||||
if((getIp() == $ip_autorizada) || ($_SESSION['acceso']==1)) {
|
||||
while ($reg=$rspta->fetch_object()) {
|
||||
if ($reg->tipo_comprobante=='Ticket') {
|
||||
$url='../reportes/exTicket.php?id=';
|
||||
|
|
@ -95,6 +126,26 @@ switch ($_GET["op"]) {
|
|||
"6"=>$reg->total_venta,
|
||||
"7"=>($reg->estado=='Aceptado')?'<span class="label bg-green">Aceptado</span>':'<span class="label bg-red">Devuelto</span>'
|
||||
);
|
||||
}
|
||||
}else{
|
||||
while ($reg=$rspta->fetch_object()) {
|
||||
if ($reg->tipo_comprobante=='Ticket') {
|
||||
$url='../reportes/exTicket.php?id=';
|
||||
}else{
|
||||
$url='../reportes/exFactura.php?id=';
|
||||
}
|
||||
|
||||
$data[]=array(
|
||||
"0"=>'Sin Acceso',
|
||||
"1"=>$reg->fecha,
|
||||
"2"=>$reg->cliente,
|
||||
"3"=>$reg->usuario,
|
||||
"4"=>$reg->tipo_comprobante,
|
||||
"5"=>$reg->serie_comprobante. '-' .$reg->num_comprobante,
|
||||
"6"=>$reg->total_venta,
|
||||
"7"=>($reg->estado=='Aceptado')?'<span class="label bg-green">Aceptado</span>':'<span class="label bg-red">Devuelto</span>'
|
||||
);
|
||||
}
|
||||
}
|
||||
$results=array(
|
||||
"sEcho"=>1,//info para datatables
|
||||
|
|
|
|||
BIN
files/articulos/1732288097.jpg
Normal file
BIN
files/articulos/1732288097.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
if (strlen(session_id())<1)
|
||||
session_start();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
|
|||
|
|
@ -2,11 +2,41 @@
|
|||
//activamos almacenamiento en el buffer
|
||||
ob_start();
|
||||
session_start();
|
||||
|
||||
// Obtener la IP del dispositivo que ingreso
|
||||
function getIp(): string
|
||||
{
|
||||
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||
} elseif (isset($_SERVER['REMOTE_ADDR']) === true) {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
if (preg_match('/^(?:127|10)\.0\.0\.[12]?\d{1,2}$/', $ip)) {
|
||||
if (isset($_SERVER['HTTP_X_REAL_IP'])) {
|
||||
$ip = $_SERVER['HTTP_X_REAL_IP'];
|
||||
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
if (in_array($ip, ['::1', '0.0.0.0', 'localhost'], true)) {
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
$filter = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||
if ($filter === false) {
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
$ip_autorizada ='127.0.0.1';
|
||||
|
||||
if (!isset($_SESSION['nombre'])) {
|
||||
header("Location: login.html");
|
||||
}else{
|
||||
|
||||
|
||||
require 'header.php';
|
||||
|
||||
if ($_SESSION['ventas']==1) {
|
||||
|
|
@ -21,9 +51,16 @@ if ($_SESSION['ventas']==1) {
|
|||
<div class="col-md-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h1 class="box-title">Vales <button class="btn btn-success" onclick="mostrarform(true)"><i class="fa fa-plus-circle"></i>Agregar</button></h1>
|
||||
<h1 class="box-title">Vales</h1>
|
||||
<?php
|
||||
if((getIp() == $ip_autorizada) || ($_SESSION['acceso']==1)) {
|
||||
?>
|
||||
<button class="btn btn-success" onclick="mostrarform(true)"><i class="fa fa-plus-circle"></i>Agregar</button>
|
||||
<?php
|
||||
}
|
||||
echo 'Dirección IP: ' . getIp() . '?'; // !Echo de prueba para ver la IP, no utilizar en el programa final
|
||||
?>
|
||||
<div class="box-tools pull-right">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!--box-header-->
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user