I can not store the variables - PHP

0

I am currently working on a code where I extract the content that I do not need from a URL when it is loaded, I leave the content that I need and then I store it in a variable, but it only does it with the first variable with the rest it does not , when my url does not bring the content that I need to extract but it comes "clean" all the variables are stored, I will leave an example of a clean url and the other that I need to clean and store it in the variable. Next I leave the code:

<?php
ob_start();


header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Pragma: no-cache" );


include("../directory/file1.php");
include("../directory/file2.php");
include("../directory/file3.php");


header("Content-Type: image/gif");

$fecha = date("Y-m-d");
$hora = date("H:i:s");    
$ip = $_SERVER{'REMOTE_ADDR'};
$navegador =  $_SERVER["HTTP_USER_AGENT"];
$navegador = stripslashes($navegador);

$ID = ereg_replace("\|", "", $ID);

$adminId = preg_replace('/^3D/', '', stripslashes(trim($_REQUEST['A'])));
$listaId = preg_replace('/^3D/', '', stripslashes(trim($_REQUEST['L'])));
$campanaId = preg_replace('/^3D/', '', stripslashes(trim($_REQUEST['C'])));
$emailId = preg_replace('/^3d/', '', strtolower(stripslashes(trim($_REQUEST['ID']))));
$linksId = preg_replace('/^3d/', '', strtolower(stripslashes(trim($_REQUEST['U']))));
$redirect = preg_replace('/^3D/', '', stripslashes(trim($redirect)));

echo $adminId;//Solo se llena esta variable
echo $listaId;//De aqui en adelante el resto de las variables estan vacias
echo $campanaId;
echo $emailId;

Clean URL: link Note: With this URL the variables are stored without problems

URL with extra content: link Note: With this URL I can only store the first variable.

Edition requested by the community:

Printing the GET I brought the following:

Array ([A] => 3D796 [amp; L] => 3D37803 [amp] => C = 3D177392 [amp; ID] = > [email protected]) The admin Id is: 796 The Id list is: The Id Bell is: The Email Id is: The Id Id link is: The Id redirect is:

    
asked by Luis Alfredo Serrano Díaz 17.12.2018 в 15:14
source

1 answer

0

I do not know if there is a function or configuration that solves the problem directly, while you can use this to clean the data:

<?php
// capturamos los parámetros mediante las variables de servidor; NO VALIDO PARA SCRIPTS DE CONSOLA
$parametros_raw = $_SERVER['QUERY_STRING'];
// limpiamos las incidencias conocidas
// Si no hace falta str_replace esto usaremos solo html_entity_decode 
$parametros_raw = str_replace('&amp=;', '&', $parametros_raw);
$parametros_raw = html_entity_decode($parametros_raw);

// prepramos la variale para recibir los datos
$parametros = array();
// parseamos el texto y convertimos a valores en el array
parse_str( $parametros_raw, $parametros);     
/*
// verificamos visualmente los datos
echo '<pre>';
print_r($parametros);
echo '</pre>';
*/

$adminId = !empty($parametros['A'])?preg_replace('/^3D/', '', stripslashes(trim($parametros['A']))):null;
$listaId = !empty($parametros['L'])?preg_replace('/^3D/', '', stripslashes(trim($parametros['L']))):null;
$campanaId = !empty($parametros['C'])?preg_replace('/^3D/', '', stripslashes(trim($parametros['C']))):null;
$emailId =!empty($parametros['ID'])? preg_replace('/^3d/', '', strtolower(stripslashes(trim($parametros['ID'])))):null;
$linksId = !empty($parametros['U'])?preg_replace('/^3d/', '', strtolower(stripslashes(trim($parametros['U'])))):null;
$redirect = !empty($parametros)?preg_replace('/^3D/', '', stripslashes(trim($parametros))):null;
?>

You have more information about the parser in the official php documentation: link

    
answered by 17.12.2018 в 17:30