1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-11-23 17:42:15 -05:00

[add] download database if sqlite is on

This commit is contained in:
Nicolas Lœuillet 2013-12-12 09:42:19 +01:00
parent 9e7c840b18
commit d460914f65
3 changed files with 28 additions and 0 deletions

View File

@ -249,4 +249,28 @@ class Tools
$lang = explode('.', $userlanguage); $lang = explode('.', $userlanguage);
return str_replace('_', '-', $lang[0]); 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;
}
} }

View File

@ -64,6 +64,8 @@ if (isset($_GET['login'])) {
$poche->updatePassword(); $poche->updatePassword();
} elseif (isset($_GET['import'])) { } elseif (isset($_GET['import'])) {
$import = $poche->import($_GET['from']); $import = $poche->import($_GET['from']);
} elseif (isset($_GET['download'])) {
Tools::download_db();;
} elseif (isset($_GET['export'])) { } elseif (isset($_GET['export'])) {
$poche->export(); $poche->export();
} elseif (isset($_GET['updatetheme'])) { } elseif (isset($_GET['updatetheme'])) {

View File

@ -109,5 +109,7 @@
</ul> </ul>
<h2>{% trans "Export your poche datas" %}</h2> <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> <p><a href="?export" target="_blank">{% trans "Click here" %}</a> {% trans "to export your poche datas." %}</p>
{% endblock %} {% endblock %}