servidor php

develop
Gerardo 2024-09-12 08:45:45 +02:00
parent 9d539eb9da
commit 072777d466
5 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,41 @@
<?php
require_once 'config.php';
require_once 'helper.php';
if(isset($_GET))
{
$res=$res_default;
$sel=0;
$nombre=isset($_GET['nombre']) ? trim($_GET['nombre']): null;
//isset($_GET['nombre']) ? trim($_GET['nombre']): null;
foreach ($denegados as $pc)
{
if($pc==$nombre)
{ $res='NO';
$sel=1;
break;
}
}
if($sel == 0)
{
foreach ($permitidos as $pc)
{
if($pc==$nombre)
{ $res='OK';
$sel=1;
break;
}
}
}
$datos=date('Y-m-d H:i:s').';'.getUserIP().';'.$nombre.';'.$res. PHP_EOL;
$logfile = date('Y-m-d') . '.csv';
$file1 = fopen("log/" . $logfile, "a");
fwrite($file1, $datos);
fclose($file1);
echo $res;
}

View File

@ -0,0 +1,7 @@
<?php
$res_default="NO";
//$res_default="NO"
#$denegados= array("batman", "spiderman", "spirit");
$denegados= array();
#$permitidos= array("pepe", "manuel");
$permitidos= array();

View File

@ -0,0 +1,27 @@
<?php
function getUserIP()
{
// Get real visitor IP behind CloudFlare network
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
return $ip;
}

View File

@ -0,0 +1,3 @@
<?php
require_once 'autoriza.php';

View File

@ -0,0 +1,6 @@
<?php
echo "<h1>".$_POST['nombre']."<h1>";
echo "<h1>".$_POST['apellidos']."<h1>";
var_dump($_POST);