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 6da53023..63916582 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -226,4 +226,28 @@ class Tools
226 $lang = explode('.', $userlanguage); 226 $lang = explode('.', $userlanguage);
227 return str_replace('_', '-', $lang[0]); 227 return str_replace('_', '-', $lang[0]);
228 } 228 }
229
230 public static function status($status_code)
231 {
232 if (strpos(php_sapi_name(), 'apache') !== false) {
233
234 header('HTTP/1.0 '.$status_code);
235 }
236 else {
237
238 header('Status: '.$status_code);
239 }
240 }
241
242
243 public static function download_db() {
244 header('Content-Disposition: attachment; filename="poche.sqlite.gz"');
245 self::status(200);
246
247 header('Content-Transfer-Encoding: binary');
248 header('Content-Type: application/octet-stream');
249 echo gzencode(file_get_contents(STORAGE_SQLITE));
250
251 exit;
252 }
229} 253}
diff --git a/index.php b/index.php
index 836730bf..145da772 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 %}