aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/netscape
diff options
context:
space:
mode:
Diffstat (limited to 'application/netscape')
-rw-r--r--application/netscape/NetscapeBookmarkUtils.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/application/netscape/NetscapeBookmarkUtils.php b/application/netscape/NetscapeBookmarkUtils.php
index 8557cca2..b150f649 100644
--- a/application/netscape/NetscapeBookmarkUtils.php
+++ b/application/netscape/NetscapeBookmarkUtils.php
@@ -6,6 +6,7 @@ use DateTime;
6use DateTimeZone; 6use DateTimeZone;
7use Exception; 7use Exception;
8use Katzgrau\KLogger\Logger; 8use Katzgrau\KLogger\Logger;
9use Psr\Http\Message\UploadedFileInterface;
9use Psr\Log\LogLevel; 10use Psr\Log\LogLevel;
10use Shaarli\Bookmark\Bookmark; 11use Shaarli\Bookmark\Bookmark;
11use Shaarli\Bookmark\BookmarkServiceInterface; 12use Shaarli\Bookmark\BookmarkServiceInterface;
@@ -79,20 +80,20 @@ class NetscapeBookmarkUtils
79 /** 80 /**
80 * Imports Web bookmarks from an uploaded Netscape bookmark dump 81 * Imports Web bookmarks from an uploaded Netscape bookmark dump
81 * 82 *
82 * @param array $post Server $_POST parameters 83 * @param array $post Server $_POST parameters
83 * @param array $files Server $_FILES parameters 84 * @param UploadedFileInterface $file File in PSR-7 object format
84 * 85 *
85 * @return string Summary of the bookmark import status 86 * @return string Summary of the bookmark import status
86 */ 87 */
87 public function import($post, $files) 88 public function import($post, UploadedFileInterface $file)
88 { 89 {
89 $start = time(); 90 $start = time();
90 $filename = $files['filetoupload']['name']; 91 $filename = $file->getClientFilename();
91 $filesize = $files['filetoupload']['size']; 92 $filesize = $file->getSize();
92 $data = file_get_contents($files['filetoupload']['tmp_name']); 93 $data = (string) $file->getStream();
93 94
94 if (preg_match('/<!DOCTYPE NETSCAPE-Bookmark-file-1>/i', $data) === 0) { 95 if (preg_match('/<!DOCTYPE NETSCAPE-Bookmark-file-1>/i', $data) === 0) {
95 return self::importStatus($filename, $filesize); 96 return $this->importStatus($filename, $filesize);
96 } 97 }
97 98
98 // Overwrite existing bookmarks? 99 // Overwrite existing bookmarks?