1 | <?php |
---|
2 | |
---|
3 | /***************************************************************************\ |
---|
4 | * SPIP, Systeme de publication pour l'internet * |
---|
5 | * * |
---|
6 | * Copyright (c) 2001-2015 * |
---|
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 | |
---|
38 | $f = basename($file); |
---|
39 | // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
---|
40 | header('Content-Type: application/octet-stream'); |
---|
41 | |
---|
42 | header("Content-Disposition: attachment; filename=\"$f\";"); |
---|
43 | header("Content-Transfer-Encoding: binary"); |
---|
44 | |
---|
45 | // fix for IE catching or PHP bug issue |
---|
46 | header("Pragma: public"); |
---|
47 | header("Expires: 0"); // set expiration time |
---|
48 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
49 | |
---|
50 | if ($cl = filesize($file)) { |
---|
51 | header("Content-Length: " . $cl); |
---|
52 | } |
---|
53 | |
---|
54 | readfile($file); |
---|
55 | } else { |
---|
56 | http_status(404); |
---|
57 | include_spip('inc/minipres'); |
---|
58 | echo minipres(_T('erreur') . ' 404', |
---|
59 | _T('info_acces_interdit')); |
---|
60 | } |
---|
61 | |
---|
62 | // et on finit comme ca d'un coup |
---|
63 | exit; |
---|
64 | } |
---|
65 | |
---|
66 | ?> |
---|