obtener_ip_para_autorizar_prestamos
This commit is contained in:
parent
bb4589ded4
commit
97f3dfee15
|
|
@ -3,6 +3,36 @@ require_once "../modelos/Venta.php";
|
||||||
if (strlen(session_id())<1)
|
if (strlen(session_id())<1)
|
||||||
session_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';
|
||||||
|
|
||||||
$venta = new Venta();
|
$venta = new Venta();
|
||||||
|
|
||||||
$idventa=isset($_POST["idventa"])? limpiarCadena($_POST["idventa"]):"";
|
$idventa=isset($_POST["idventa"])? limpiarCadena($_POST["idventa"]):"";
|
||||||
|
|
@ -78,6 +108,7 @@ switch ($_GET["op"]) {
|
||||||
$rspta=$venta->listar();
|
$rspta=$venta->listar();
|
||||||
$data=Array();
|
$data=Array();
|
||||||
|
|
||||||
|
if((getIp() == $ip_autorizada) || ($_SESSION['acceso']==1)) {
|
||||||
while ($reg=$rspta->fetch_object()) {
|
while ($reg=$rspta->fetch_object()) {
|
||||||
if ($reg->tipo_comprobante=='Ticket') {
|
if ($reg->tipo_comprobante=='Ticket') {
|
||||||
$url='../reportes/exTicket.php?id=';
|
$url='../reportes/exTicket.php?id=';
|
||||||
|
|
@ -96,6 +127,26 @@ switch ($_GET["op"]) {
|
||||||
"7"=>($reg->estado=='Aceptado')?'<span class="label bg-green">Aceptado</span>':'<span class="label bg-red">Devuelto</span>'
|
"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(
|
$results=array(
|
||||||
"sEcho"=>1,//info para datatables
|
"sEcho"=>1,//info para datatables
|
||||||
"iTotalRecords"=>count($data),//enviamos el total de registros al datatable
|
"iTotalRecords"=>count($data),//enviamos el total de registros al datatable
|
||||||
|
|
|
||||||
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
|
<?php
|
||||||
if (strlen(session_id())<1)
|
if (strlen(session_id())<1)
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,41 @@
|
||||||
//activamos almacenamiento en el buffer
|
//activamos almacenamiento en el buffer
|
||||||
ob_start();
|
ob_start();
|
||||||
session_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'])) {
|
if (!isset($_SESSION['nombre'])) {
|
||||||
header("Location: login.html");
|
header("Location: login.html");
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
|
||||||
require 'header.php';
|
require 'header.php';
|
||||||
|
|
||||||
if ($_SESSION['ventas']==1) {
|
if ($_SESSION['ventas']==1) {
|
||||||
|
|
@ -21,9 +51,16 @@ if ($_SESSION['ventas']==1) {
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<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 class="box-tools pull-right">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--box-header-->
|
<!--box-header-->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user