Merge branch 'v1' into v3
[lhc/web/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')) {
14 return;
15 }
16
17 include_spip('inc/dump');
18 include_spip('inc/autoriser');
19
20 /**
21 * Telecharger un dump quand on est webmestre
22 *
23 * @param string $arg
24 */
25 function action_telecharger_dump_dist($arg = null) {
26 if (!$arg) {
27 $securiser_action = charger_fonction('securiser_action', 'inc');
28 $arg = $securiser_action();
29 }
30
31 $file = dump_repertoire() . basename($arg, '.sqlite') . '.sqlite';
32
33 if (
34 file_exists($file)
35 and autoriser('webmestre')
36 ) {
37 $f = basename($file);
38 // ce content-type est necessaire pour eviter des corruptions de zip dans ie6
39 header('Content-Type: application/octet-stream');
40
41 header("Content-Disposition: attachment; filename=\"$f\";");
42 header('Content-Transfer-Encoding: binary');
43
44 // fix for IE catching or PHP bug issue
45 header('Pragma: public');
46 header('Expires: 0'); // set expiration time
47 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
48
49 if ($cl = filesize($file)) {
50 header('Content-Length: ' . $cl);
51 }
52 readfile($file);
53 } else {
54 http_status(404);
55 include_spip('inc/minipres');
56 echo minipres(_T('erreur') . ' 404', _T('info_acces_interdit'));
57 }
58
59 // et on finit comme ca d'un coup
60 exit;
61 }