]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #356 from inthepoche/tags
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Thu, 12 Dec 2013 09:48:24 +0000 (01:48 -0800)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Thu, 12 Dec 2013 09:48:24 +0000 (01:48 -0800)
Tags feature

inc/poche/Tools.class.php
index.php
themes/default/config.twig

index 6da530235a0c24ddc6b7a53b2cd9afcc696b00a5..6391658259bea3aeecd3e18c15fa0a157233a605 100644 (file)
@@ -226,4 +226,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;
+    }
 }
index 836730bfcfb1be02ed91e8df82e824b85c710ba7..145da772f5ca28238e993dc79340518e2822d583 100644 (file)
--- a/index.php
+++ b/index.php
@@ -64,6 +64,8 @@ if (isset($_GET['login'])) {
     $poche->updatePassword();
 } elseif (isset($_GET['import'])) {
     $import = $poche->import($_GET['from']);
+} elseif (isset($_GET['download'])) {
+    Tools::download_db();;
 } elseif (isset($_GET['export'])) {
     $poche->export();
 } elseif (isset($_GET['updatetheme'])) {
index 1d7fb562be628c6263dd6adb08deabb8e005c475..a1f46b8b3174835fff8ea899adce099cac40c5d2 100644 (file)
             </ul>
 
             <h2>{% trans "Export your poche datas" %}</h2>
+            {% if constant('STORAGE') == 'sqlite' %}
+            <p><a href="?download" target="_blank">{% trans "Click here" %}</a> {% trans "to download your database." %}</p>{% endif %}
             <p><a href="?export" target="_blank">{% trans "Click here" %}</a> {% trans "to export your poche datas." %}</p>
 {% endblock %}