From: Nicolas LÅ“uillet Date: Fri, 28 Feb 2014 19:36:32 +0000 (+0100) Subject: [add] upload form for import X-Git-Tag: 1.6.0^2~41^2~2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=31a10069a52c2fd2aca3a835a7bdc1accae197f5;p=github%2Fwallabag%2Fwallabag.git [add] upload form for import --- diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 49651c52..026b0b4e 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -1068,13 +1068,7 @@ class Poche Tools::redirect(); } - $targetDefinition = 'IMPORT_' . strtoupper($from) . '_FILE'; - $targetFile = constant($targetDefinition); - - if (! defined($targetDefinition)) { - $this->messages->add('e', _('Incomplete inc/poche/define.inc.php file, please define "' . $targetDefinition . '".')); - Tools::redirect(); - } + $targetFile = CACHE . '/' . constant(strtoupper($from) . '_FILE'); if (! file_exists($targetFile)) { $this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.')); @@ -1084,6 +1078,22 @@ class Poche $this->$providers[$from]($targetFile); } + public function uploadFile() { + if(isset($_FILES['file'])) + { + $dir = CACHE . '/'; + $file = basename($_FILES['file']['name']); + if(move_uploaded_file($_FILES['file']['tmp_name'], $dir . $file)) { + $this->messages->add('s', _('File uploaded. You can now execute import.')); + } + else { + $this->messages->add('e', _('Error while importing file. Do you have access to upload it?')); + } + } + + Tools::redirect('?view=config'); + } + /** * export poche entries in json * @return json all poche entries diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 4ed28ed1..eed7afbd 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -241,7 +241,6 @@ class Tools } } - public static function download_db() { header('Content-Disposition: attachment; filename="poche.sqlite.gz"'); self::status(200); diff --git a/index.php b/index.php index 9f5d0ade..ecae9119 100644 --- a/index.php +++ b/index.php @@ -75,6 +75,8 @@ if (isset($_GET['login'])) { $poche->updateTheme(); } elseif (isset($_GET['updatelanguage'])) { $poche->updateLanguage(); +} elseif (isset($_GET['uploadfile'])) { + $poche->uploadFile(); } elseif (isset($_GET['feed'])) { if (isset($_GET['action']) && $_GET['action'] == 'generate') { $poche->generateToken(); diff --git a/themes/baggy/config.twig b/themes/baggy/config.twig index b37ac115..4026bf28 100644 --- a/themes/baggy/config.twig +++ b/themes/baggy/config.twig @@ -103,13 +103,26 @@ {% endif %}

{% trans "Import" %}

-

{% trans "Please execute the import script locally as it can take a very long time." %}

-

{% trans "More info in the official documentation:" %} wallabag.org

+

1. {% trans "Select a file on your computer and upload it." %}

+
+
+
+ + +
+
+ +
+
+ + +
+

2. {% trans "Then, click on the right link below." %}

{% trans "Export your wallabag data" %}