aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--inc/poche/Tools.class.php24
-rw-r--r--index.php2
-rw-r--r--themes/default/config.twig2
3 files changed, 28 insertions, 0 deletions
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
249 $lang = explode('.', $userlanguage); 249 $lang = explode('.', $userlanguage);
250 return str_replace('_', '-', $lang[0]); 250 return str_replace('_', '-', $lang[0]);
251 } 251 }
252
253 public static function status($status_code)
254 {
255 if (strpos(php_sapi_name(), 'apache') !== false) {
256
257 header('HTTP/1.0 '.$status_code);
258 }
259 else {
260
261 header('Status: '.$status_code);
262 }
263 }
264
265
266 public static function download_db() {
267 header('Content-Disposition: attachment; filename="poche.sqlite.gz"');
268 self::status(200);
269
270 header('Content-Transfer-Encoding: binary');
271 header('Content-Type: application/octet-stream');
272 echo gzencode(file_get_contents(STORAGE_SQLITE));
273
274 exit;
275 }
252} 276}
diff --git a/index.php b/index.php
index 96f28a72..d2b363b0 100644
--- a/index.php
+++ b/index.php
@@ -64,6 +64,8 @@ if (isset($_GET['login'])) {
64 $poche->updatePassword(); 64 $poche->updatePassword();
65} elseif (isset($_GET['import'])) { 65} elseif (isset($_GET['import'])) {
66 $import = $poche->import($_GET['from']); 66 $import = $poche->import($_GET['from']);
67} elseif (isset($_GET['download'])) {
68 Tools::download_db();;
67} elseif (isset($_GET['export'])) { 69} elseif (isset($_GET['export'])) {
68 $poche->export(); 70 $poche->export();
69} elseif (isset($_GET['updatetheme'])) { 71} elseif (isset($_GET['updatetheme'])) {
diff --git a/themes/default/config.twig b/themes/default/config.twig
index 1d7fb562..a1f46b8b 100644
--- a/themes/default/config.twig
+++ b/themes/default/config.twig
@@ -109,5 +109,7 @@
109 </ul> 109 </ul>
110 110
111 <h2>{% trans "Export your poche datas" %}</h2> 111 <h2>{% trans "Export your poche datas" %}</h2>
112 {% if constant('STORAGE') == 'sqlite' %}
113 <p><a href="?download" target="_blank">{% trans "Click here" %}</a> {% trans "to download your database." %}</p>{% endif %}
112 <p><a href="?export" target="_blank">{% trans "Click here" %}</a> {% trans "to export your poche datas." %}</p> 114 <p><a href="?export" target="_blank">{% trans "Click here" %}</a> {% trans "to export your poche datas." %}</p>
113{% endblock %} 115{% endblock %}