]> git.wh0rd.org - tt-rss.git/commitdiff
fix import_export plugin for open_basedir; add missing closing form tags to import_ex...
authorAndrew Dolgov <fox@fakecake.org>
Thu, 11 Apr 2013 16:31:24 +0000 (20:31 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Thu, 11 Apr 2013 16:31:24 +0000 (20:31 +0400)
plugins/googlereaderimport/init.php
plugins/import_export/init.php

index f7d876b9082509d568352ffddcddae5e85f58b80..d25d3288f4cebc423db34e6b7f431f2338174853 100644 (file)
@@ -374,6 +374,7 @@ class GoogleReaderImport extends Plugin {
                        <button dojoType=\"dijit.form.Button\" onclick=\"return starredImport();\" type=\"submit\">" .
                        __('Import my Starred items') . "</button>";
 
+               print "</form>";
 
                print "</div>"; #pane
        }
index 1d7a8e55f96527858322272b00bd43cc0f3f7061..a01a612a40b1fad9575365bbe8e12d73686ded6d 100644 (file)
@@ -83,6 +83,7 @@ class Import_Export extends Plugin implements IHandler {
                        <button dojoType=\"dijit.form.Button\" onclick=\"return importData();\" type=\"submit\">" .
                        __('Import') . "</button>";
 
+               print "</form>";
 
                print "</div>"; # pane
        }
@@ -416,13 +417,35 @@ class Import_Export extends Plugin implements IHandler {
 
                print "<div style='text-align : center'>";
 
-               if (is_file($_FILES['export_file']['tmp_name'])) {
+               if ($_FILES['export_file']['error'] != 0) {
+                       print_error(T_sprintf("Upload failed with error code %d",
+                               $_FILES['export_file']['error']));
+                       return;
+               }
+
+               $tmp_file = false;
 
-                       $this->perform_data_import($this->link, $_FILES['export_file']['tmp_name'], $_SESSION['uid']);
+               if (is_uploaded_file($_FILES['export_file']['tmp_name'])) {
+                       $tmp_file = tempnam(CACHE_DIR . '/upload', 'export');
 
+                       $result = move_uploaded_file($_FILES['export_file']['tmp_name'],
+                               $tmp_file);
+
+                       if (!$result) {
+                               print_error(__("Unable to move uploaded file."));
+                               return;
+                       }
                } else {
-                       print "<p>" . T_sprintf("Could not upload file. You might need to adjust upload_max_filesize in PHP.ini (current value = %s)", ini_get("upload_max_filesize")) . " or use CLI import tool.</p>";
+                       print_error(__('Error: please upload OPML file.'));
+                       return;
+               }
 
+               if (is_file($tmp_file)) {
+                       $this->perform_data_import($this->link, $tmp_file, $_SESSION['uid']);
+                       unlink($tmp_file);
+               } else {
+                       print_error(__('No file uploaded.'));
+                       return;
                }
 
                print "<button dojoType=\"dijit.form.Button\"