diff options
-rwxr-xr-x | inc/poche/Poche.class.php | 24 | ||||
-rw-r--r-- | inc/poche/Tools.class.php | 1 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | themes/baggy/config.twig | 25 |
4 files changed, 38 insertions, 14 deletions
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 | |||
1068 | Tools::redirect(); | 1068 | Tools::redirect(); |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | $targetDefinition = 'IMPORT_' . strtoupper($from) . '_FILE'; | 1071 | $targetFile = CACHE . '/' . constant(strtoupper($from) . '_FILE'); |
1072 | $targetFile = constant($targetDefinition); | ||
1073 | |||
1074 | if (! defined($targetDefinition)) { | ||
1075 | $this->messages->add('e', _('Incomplete inc/poche/define.inc.php file, please define "' . $targetDefinition . '".')); | ||
1076 | Tools::redirect(); | ||
1077 | } | ||
1078 | 1072 | ||
1079 | if (! file_exists($targetFile)) { | 1073 | if (! file_exists($targetFile)) { |
1080 | $this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.')); | 1074 | $this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.')); |
@@ -1084,6 +1078,22 @@ class Poche | |||
1084 | $this->$providers[$from]($targetFile); | 1078 | $this->$providers[$from]($targetFile); |
1085 | } | 1079 | } |
1086 | 1080 | ||
1081 | public function uploadFile() { | ||
1082 | if(isset($_FILES['file'])) | ||
1083 | { | ||
1084 | $dir = CACHE . '/'; | ||
1085 | $file = basename($_FILES['file']['name']); | ||
1086 | if(move_uploaded_file($_FILES['file']['tmp_name'], $dir . $file)) { | ||
1087 | $this->messages->add('s', _('File uploaded. You can now execute import.')); | ||
1088 | } | ||
1089 | else { | ||
1090 | $this->messages->add('e', _('Error while importing file. Do you have access to upload it?')); | ||
1091 | } | ||
1092 | } | ||
1093 | |||
1094 | Tools::redirect('?view=config'); | ||
1095 | } | ||
1096 | |||
1087 | /** | 1097 | /** |
1088 | * export poche entries in json | 1098 | * export poche entries in json |
1089 | * @return json all poche entries | 1099 | * @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 | |||
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | |||
245 | public static function download_db() { | 244 | public static function download_db() { |
246 | header('Content-Disposition: attachment; filename="poche.sqlite.gz"'); | 245 | header('Content-Disposition: attachment; filename="poche.sqlite.gz"'); |
247 | self::status(200); | 246 | self::status(200); |
@@ -75,6 +75,8 @@ if (isset($_GET['login'])) { | |||
75 | $poche->updateTheme(); | 75 | $poche->updateTheme(); |
76 | } elseif (isset($_GET['updatelanguage'])) { | 76 | } elseif (isset($_GET['updatelanguage'])) { |
77 | $poche->updateLanguage(); | 77 | $poche->updateLanguage(); |
78 | } elseif (isset($_GET['uploadfile'])) { | ||
79 | $poche->uploadFile(); | ||
78 | } elseif (isset($_GET['feed'])) { | 80 | } elseif (isset($_GET['feed'])) { |
79 | if (isset($_GET['action']) && $_GET['action'] == 'generate') { | 81 | if (isset($_GET['action']) && $_GET['action'] == 'generate') { |
80 | $poche->generateToken(); | 82 | $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 @@ | |||
103 | {% endif %} | 103 | {% endif %} |
104 | 104 | ||
105 | <h2>{% trans "Import" %}</h2> | 105 | <h2>{% trans "Import" %}</h2> |
106 | <p>{% trans "Please execute the import script locally as it can take a very long time." %}</p> | 106 | <p>1. {% trans "Select a file on your computer and upload it." %}</p> |
107 | <p>{% trans "More info in the official documentation:" %} <a href="http://doc.wallabag.org/doku.php?id=users:migrate">wallabag.org</a></p> | 107 | <form method="post" action="?uploadfile" name="uploadfile" enctype="multipart/form-data"> |
108 | <fieldset class="w500p"> | ||
109 | <div class="row"> | ||
110 | <label class="col w150p" for="file">{% trans "File:" %}</label> | ||
111 | <input class="col" type="file" id="file" name="file" tabindex="4"> | ||
112 | </div> | ||
113 | <div class="row mts txtcenter"> | ||
114 | <button class="bouton" type="submit" tabindex="4">{% trans "Upload" %}</button> | ||
115 | </div> | ||
116 | </fieldset> | ||
117 | <input type="hidden" name="MAX_FILE_SIZE" value="1048576"> | ||
118 | <input type="hidden" name="returnurl" value="{{ referer }}"> | ||
119 | </form> | ||
120 | <p>2. {% trans "Then, click on the right link below." %}</p> | ||
108 | <ul> | 121 | <ul> |
109 | <li><a href="./?import&from=pocket">{% trans "Import from Pocket" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCKET_FILE')) }}</li> | 122 | <li><a href="./?import&from=pocket">{% trans "Import from Pocket" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('POCKET_FILE')) }}</li> |
110 | <li><a href="./?import&from=readability">{% trans "Import from Readability" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('READABILITY_FILE')) }}</li> | 123 | <li><a href="./?import&from=readability">{% trans "Import from Readability" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('READABILITY_FILE')) }}</li> |
111 | <li><a href="./?import&from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('INSTAPAPER_FILE')) }}</li> | 124 | <li><a href="./?import&from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('INSTAPAPER_FILE')) }}</li> |
112 | <li><a href="./?import&from=poche">{% trans "Import from wallabag" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCHE_FILE')) }}</li> | 125 | <li><a href="./?import&from=poche">{% trans "Import from wallabag" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('POCHE_FILE')) }}</li> |
113 | </ul> | 126 | </ul> |
114 | 127 | ||
115 | <h2>{% trans "Export your wallabag data" %}</h2> | 128 | <h2>{% trans "Export your wallabag data" %}</h2> |