summaryrefslogtreecommitdiffstats
path: root/apps/contacts/import.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/contacts/import.php')
-rw-r--r--apps/contacts/import.php15
1 files changed, 6 insertions, 9 deletions
diff --git a/apps/contacts/import.php b/apps/contacts/import.php
index 93c47ef2667..ed1b80e132a 100644
--- a/apps/contacts/import.php
+++ b/apps/contacts/import.php
@@ -12,7 +12,6 @@ OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('contacts');
session_write_close();
-$cr = "\r";
$nl = "\n";
global $progresskey;
@@ -31,7 +30,7 @@ writeProgress('10');
$view = $file = null;
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
$view = OCP\Files::getStorage('contacts');
- $file = $view->file_get_contents('/' . $_POST['file']);
+ $file = $view->file_get_contents('/imports/' . $_POST['file']);
} else {
$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
}
@@ -49,17 +48,15 @@ if(isset($_POST['method']) && $_POST['method'] == 'new'){
}else{
$id = $_POST['id'];
if(!$id) {
- OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.')));
+ OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.', 'file'=>$_POST['file'])));
exit();
}
OC_Contacts_App::getAddressbook($id); // is owner access check
}
//analyse the contacts file
writeProgress('40');
+$file = str_replace(array("\r","\n\n"), array("\n","\n"), $file);
$lines = explode($nl, $file);
-if(count($lines) == 1) { // Mac eol
- $lines = explode($cr, $file);
-}
$inelement = false;
$parts = array();
@@ -82,7 +79,7 @@ writeProgress('70');
$imported = 0;
$failed = 0;
if(!count($parts) > 0) {
- OCP\JSON::error(array('data' => array('message' => 'No contacts to import in .'.$_POST['file'].' Please check if the file is corrupted.')));
+ OCP\JSON::error(array('data' => array('message' => 'No contacts to import in '.$_POST['file'].'. Please check if the file is corrupted.', 'file'=>$_POST['file'])));
exit();
}
foreach($parts as $part){
@@ -105,8 +102,8 @@ writeProgress('100');
sleep(3);
OC_Cache::remove($progresskey);
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
- if(!$view->unlink('/' . $_POST['file'])) {
+ if(!$view->unlink('/imports/' . $_POST['file'])) {
OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR);
}
}
-OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed)));
+OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed, 'file'=>$_POST['file'])));