From d460914f65254d201911a8346792d680218c8dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 12 Dec 2013 09:42:19 +0100 Subject: [add] download database if sqlite is on --- inc/poche/Tools.class.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'inc') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 750553f1..9d8e1fd6 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -249,4 +249,28 @@ class Tools $lang = explode('.', $userlanguage); return str_replace('_', '-', $lang[0]); } + + public static function status($status_code) + { + if (strpos(php_sapi_name(), 'apache') !== false) { + + header('HTTP/1.0 '.$status_code); + } + else { + + header('Status: '.$status_code); + } + } + + + public static function download_db() { + header('Content-Disposition: attachment; filename="poche.sqlite.gz"'); + self::status(200); + + header('Content-Transfer-Encoding: binary'); + header('Content-Type: application/octet-stream'); + echo gzencode(file_get_contents(STORAGE_SQLITE)); + + exit; + } } -- cgit v1.2.3