[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / plugins-dist / dump / action / telecharger_dump.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined("_ECRIRE_INC_VERSION")) return;
14
15 include_spip('inc/dump');
16 include_spip('inc/autoriser');
17
18 /**
19 * Telecharger un dump quand on est webmestre
20 *
21 * @param string $arg
22 */
23 function action_telecharger_dump_dist($arg=null){
24 if (!$arg) {
25 $securiser_action = charger_fonction('securiser_action', 'inc');
26 $arg = $securiser_action();
27 }
28
29 $file = dump_repertoire().basename($arg,'.sqlite').'.sqlite';
30
31 if (
32 file_exists($file)
33 AND autoriser('webmestre')){
34
35 $f = basename($file);
36 // ce content-type est necessaire pour eviter des corruptions de zip dans ie6
37 header('Content-Type: application/octet-stream');
38
39 header("Content-Disposition: attachment; filename=\"$f\";");
40 header("Content-Transfer-Encoding: binary");
41
42 // fix for IE catching or PHP bug issue
43 header("Pragma: public");
44 header("Expires: 0"); // set expiration time
45 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
46
47 if ($cl = filesize($file))
48 header("Content-Length: ". $cl);
49
50 readfile($file);
51 }
52 else{
53 http_status(404);
54 include_spip('inc/minipres');
55 echo minipres(_T('erreur').' 404',
56 _T('info_acces_interdit'));
57 }
58
59 // et on finit comme ca d'un coup
60 exit;
61 }
62
63 ?>