Close #11; Download en js via 'ModuleRequest' fonctionnel passage par 2 fichiers temporaires (1: le script qui lance le téléchargement et affiche le contenu de l'autre; 2: Le contenu du fichier)
This commit is contained in:
parent
2373d2c5bc
commit
7083a7a9dc
|
@ -86,14 +86,15 @@
|
|||
//
|
||||
// }
|
||||
|
||||
|
||||
$req = new ModuleRequest('download/phone', array('subjects'=>array(273)));
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||
$req = new ModuleRequest('download/phone', array('subjects'=>array(1, 273, 341)));
|
||||
|
||||
$res = $req->download();
|
||||
|
||||
if( $res->error != ManagerError::Success )
|
||||
var_dump( ManagerError::explicit($res->error) );
|
||||
|
||||
var_dump($res);
|
||||
|
||||
/* [4] Analyse des performances de `lightdb`
|
||||
=========================================================*/
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
unlink( __FILE__ );
|
||||
|
||||
|
||||
?>
|
|
@ -199,6 +199,7 @@
|
|||
=========================================================*/
|
||||
if( $fromAjax ){
|
||||
|
||||
|
||||
$tmpfname = '/tmp/download_'.uniqid().'.php';
|
||||
|
||||
/* (1) On crée le fichier temporaire */
|
||||
|
@ -212,13 +213,17 @@
|
|||
fwrite($tmpfile, "header(\"$header: $value\");".PHP_EOL);
|
||||
|
||||
/* (3) Script qui écrira le contenu */
|
||||
$bodyWithoutQuotes = str_replace("'", "\\'", utf8_decode($returned['body']) );
|
||||
fwrite($tmpfile, "echo <<< EOF".PHP_EOL);
|
||||
fwrite($tmpfile, $bodyWithoutQuotes.PHP_EOL);
|
||||
fwrite($tmpfile, "EOF;".PHP_EOL);
|
||||
// 1) On écrit le contenu dans un fichier temporaire (et oui encore)
|
||||
$bodyfname = __ROOT__.'/tmp/content_'.uniqid().'.php';
|
||||
$bodyfile = fopen($bodyfname, 'w');
|
||||
fwrite($bodyfile, $returned['body']);
|
||||
fclose($bodyfile);
|
||||
|
||||
/* (4) Script qui supprimera le fichier */
|
||||
fwrite($tmpfile, 'unlink(__FILE__);'.PHP_EOL);
|
||||
fwrite($tmpfile, "readfile('$bodyfname');".PHP_EOL);
|
||||
|
||||
/* (4) Script qui supprimera les fichiers temporaires */
|
||||
fwrite($tmpfile, "unlink('$bodyfname');".PHP_EOL);
|
||||
fwrite($tmpfile, "unlink(__FILE__);".PHP_EOL);
|
||||
|
||||
fwrite($tmpfile, '?>'.PHP_EOL);
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
272
|
||||
408
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
{"1":{"line":0,"hash":"423bda798fbf4363a61d945e936c6a11ce9ac057"},"69":{"line":1,"hash":"785691cf7be9f8b18eb1a298db3187bdc86c4884"},"137":{"line":2,"hash":"47fc53f817eded81eecd15b2e042722d52bd8513"},"205":{"line":3,"hash":"0a296a89a05509be912fefda7fdcc2692a244208"}}
|
||||
{"1":{"line":0,"hash":"423bda798fbf4363a61d945e936c6a11ce9ac057"},"69":{"line":1,"hash":"785691cf7be9f8b18eb1a298db3187bdc86c4884"},"137":{"line":2,"hash":"47fc53f817eded81eecd15b2e042722d52bd8513"},"205":{"line":3,"hash":"0a296a89a05509be912fefda7fdcc2692a244208"},"273":{"line":4,"hash":"1b9c3317ae25f49f6cfdee6aa34fcbc381c3a7a7"},"341":{"line":5,"hash":"8857d8b1c8e7fbcb455847bdf3c9fd34e34ef217"}}
|
|
@ -1 +1 @@
|
|||
var exportDeflater=new FormDeflater(document.getElementById("export-form"),["input"],["data-name"]);$("#export-form #export-all").addEventListener("click",function(b){"1"==exportDeflater.deflate().phone&&api.send({path:"download/phone",subjects:[1,137]},function(a){if(0!=a.ModuleError)return!1;document.location=a.link})},!1);
|
||||
var exportDeflater=new FormDeflater(document.getElementById("export-form"),["input"],["data-name"]);$("#export-form #export-all").addEventListener("click",function(b){"1"==exportDeflater.deflate().phone&&api.send({path:"download/phone",subjects:[341]},function(a){if(0!=a.ModuleError)return!1;document.location=a.link})},!1);
|
||||
|
|
|
@ -16,7 +16,7 @@ $('#export-form #export-all').addEventListener('click', function(e){
|
|||
/* (1) Si téléchargement de données cellulaires */
|
||||
if( deflated.phone == '1' ){
|
||||
|
||||
api.send({ 'path': 'download/phone', 'subjects': [1, 137] }, function(res){
|
||||
api.send({ 'path': 'download/phone', 'subjects': [341] }, function(res){
|
||||
|
||||
// Si erreur
|
||||
if( res.ModuleError != 0 )
|
||||
|
|
Loading…
Reference in New Issue