Gestion de la compression pour l'envoi de données via URL
This commit is contained in:
parent
3962c7036b
commit
4375083dc3
10
Medecins.php
10
Medecins.php
|
@ -5,13 +5,19 @@ if(!Authentification::checkUser(0)){
|
|||
die();
|
||||
};
|
||||
|
||||
|
||||
function customCompression($input, $compression){
|
||||
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
|
||||
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
|
||||
}
|
||||
|
||||
/* REPONSE DU MANAGER */
|
||||
$managerStatus = (isset($_GET['status'])) ? $_GET['status'] : null;
|
||||
$managerTitle = (isset($_GET['title'])) ? $_GET['title'] : 'Oups!';
|
||||
$managerMessage = (isset($_GET['message'])) ? $_GET['message'] : 'Erreur interne!';
|
||||
|
||||
// on récupère la liste des médecins si donnée
|
||||
$medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode(base64_decode($_GET['medecins']), true) : [];
|
||||
$medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode( customCompression($_GET['medecins'], false) , true) : [];
|
||||
|
||||
?>
|
||||
|
||||
|
@ -42,7 +48,7 @@ $medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode(base64_decode($_GET
|
|||
<div>
|
||||
<h3><?php echo $managerTitle; ?></h3>
|
||||
<p><?php echo $managerMessage; ?></p>
|
||||
<a href='?medecins=<?php echo base64_encode(json_encode($medecinsSearch)); ?>'><input type='button' value='Fermer'></a>
|
||||
<a href='?medecins=<?php echo customCompression(json_encode($medecinsSearch), true); ?>'><input type='button' value='Fermer'></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
11
Patients.php
11
Patients.php
|
@ -5,14 +5,19 @@ if(!Authentification::checkUser(0)){
|
|||
die();
|
||||
};
|
||||
|
||||
|
||||
function customCompression($input, $compression){
|
||||
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
|
||||
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
|
||||
}
|
||||
|
||||
/* REPONSE DU MANAGER */
|
||||
$managerStatus = (isset($_GET['status'])) ? $_GET['status'] : null;
|
||||
$managerTitle = (isset($_GET['title'])) ? $_GET['title'] : 'Oups!';
|
||||
$managerMessage = (isset($_GET['message'])) ? $_GET['message'] : 'Erreur interne!';
|
||||
|
||||
// on récupère la liste des médecins si donnée
|
||||
$patientsSearch = ( isset($_GET['patients']) ) ? json_decode(base64_decode($_GET['patients']), true) : [];
|
||||
|
||||
$patientsSearch = ( isset($_GET['patients']) ) ? json_decode( customCompression($_GET['patients'], false) , true) : [];
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
@ -42,7 +47,7 @@ $patientsSearch = ( isset($_GET['patients']) ) ? json_decode(base64_decode($_GET
|
|||
<div>
|
||||
<h3><?php echo $managerTitle; ?></h3>
|
||||
<p><?php echo $managerMessage; ?></p>
|
||||
<a href='?patients=<?php echo base64_encode(json_encode($patientsSearch)); ?>'><input type='button' value='Fermer'></a>
|
||||
<a href='?patients=<?php echo customCompression( json_encode($patientsSearch), true ); ?>'><input type='button' value='Fermer'></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
function customCompression($input, $compression){
|
||||
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
|
||||
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
|
||||
}
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: seekdasky
|
||||
|
@ -54,7 +57,7 @@ class Medecin
|
|||
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message, 'medecins' => $_medecins ]));
|
||||
else{
|
||||
$response = new Response();
|
||||
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&medecins='.base64_encode(json_encode($_medecins)));
|
||||
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&medecins='.customCompression(json_encode($_medecins), true));
|
||||
$response->send();
|
||||
}
|
||||
}else{
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
function customCompression($input, $compression){
|
||||
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
|
||||
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
|
@ -68,7 +72,8 @@ class Patient
|
|||
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message, 'patients' => $_patients ]));
|
||||
else{
|
||||
$response = new Response();
|
||||
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&patients='.base64_encode(json_encode($_patients)));
|
||||
// $response->write("patients=".$compressed_json);
|
||||
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&patients='.customCompression( json_encode($_patients), true));
|
||||
$response->send();
|
||||
}
|
||||
}else{
|
||||
|
|
79
test.php
79
test.php
|
@ -7,4 +7,81 @@
|
|||
*/
|
||||
require_once('autoloader.php');
|
||||
|
||||
Response::quickResponse(200,'lol');
|
||||
// Response::quickResponse(200,'lol');
|
||||
$json = [
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
],
|
||||
|
||||
[
|
||||
"nom" => "Alex",
|
||||
"prenom" => "Alex",
|
||||
]
|
||||
];
|
||||
|
||||
$compressed = compress( json_encode($json) );
|
||||
$uncompressed = uncompress( $compressed );
|
||||
|
||||
echo $compressed.'<br><br>';
|
||||
echo $uncompressed.'<br><br>';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function customCompression($input, compression){
|
||||
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
|
||||
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
|
||||
}
|
||||
|
||||
function uncompress($input){
|
||||
|
||||
}
|
Loading…
Reference in New Issue