]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
[add] download database if sqlite is on
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Thu, 12 Dec 2013 08:42:19 +0000 (09:42 +0100)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Thu, 12 Dec 2013 08:42:19 +0000 (09:42 +0100)
inc/poche/Tools.class.php
index.php
themes/default/config.twig

index 750553f1202637eeb4886a569c2586604530d547..9d8e1fd655175e81b243523829988cc0018b619e 100644 (file)
@@ -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;
+    }
 }
index 96f28a72936368b47352e875eb08de6fd76cb7e1..d2b363b0342bb044e44595abc89dacc60fe618dd 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 %}