From 6bd90816dd76d5fbd2374f72ac302537bc1ef047 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 19 Jun 2015 16:39:03 -0700 Subject: very early attempt diaspora import from diaspora export file. Currently the json export has to be gunzipped prior to uploading and we're net yet adding connections (which should come soon) and we can't import items until they add guids to the export file - so consider it a work in progress. This first attempt should create a channel and get your profile details setup providing there isn't a nickname conflict on the server. That will also be handled later. --- mod/import.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'mod/import.php') diff --git a/mod/import.php b/mod/import.php index 088c5cb61..4542ef7a0 100644 --- a/mod/import.php +++ b/mod/import.php @@ -84,6 +84,13 @@ function import_post(&$a) { $data = json_decode($data,true); + if(array_key_exists('user',$data) && array_key_exists('aspects',$data)) { + require_once('include/Import/import_diaspora.php'); + import_diaspora($data); + return; + } + + // logger('import: data: ' . print_r($data,true)); // print_r($data); @@ -308,7 +315,7 @@ function import_post(&$a) { dbesc($photos[2]), dbesc($photos[3]), dbesc($photodate), - dbesc($xchan_hash) + dbesc($xchan['xchan_hash']) ); } -- cgit v1.2.3 From a6b9d1595e1a33d81fed5ecff6b049c1a0e55b14 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 19 Jun 2015 17:18:01 -0700 Subject: automatically gunzip Diaspora export files if we're on a *nix system --- mod/import.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mod/import.php') diff --git a/mod/import.php b/mod/import.php index 4542ef7a0..02f4133d5 100644 --- a/mod/import.php +++ b/mod/import.php @@ -38,6 +38,15 @@ function import_post(&$a) { if($src) { + + // This is OS specific and could also fail if your tmpdir isn't very large + // mostly used for Diaspora which exports gzipped files. + + if(strpos($filename,'.gz')){ + @rename($src,$src . '.gz'); + @system('gunzip ' . escapeshellarg($src . '.gz')); + } + if($filesize) { $data = @file_get_contents($src); } -- cgit v1.2.3 From 68534fd5dc6fdc879b075c32849d6cbc8a5fc905 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 21 Jun 2015 17:30:23 -0700 Subject: some diaspora import issues uncovered during dry-run tests --- mod/import.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mod/import.php') diff --git a/mod/import.php b/mod/import.php index 02f4133d5..85491bc5e 100644 --- a/mod/import.php +++ b/mod/import.php @@ -93,17 +93,16 @@ function import_post(&$a) { $data = json_decode($data,true); - if(array_key_exists('user',$data) && array_key_exists('aspects',$data)) { +// logger('import: data: ' . print_r($data,true)); +// print_r($data); + + + if(array_key_exists('user',$data) && array_key_exists('version',$data)) { require_once('include/Import/import_diaspora.php'); import_diaspora($data); return; } - -// logger('import: data: ' . print_r($data,true)); - -// print_r($data); - // import channel $channel = $data['channel']; @@ -515,6 +514,7 @@ function import_content(&$a) { '$common' => t('For either option, please choose whether to make this hub your new primary address, or whether your old location should continue this role. You will be able to post from either location, but only one can be marked as the primary location for files, photos, and media.'), '$label_import_primary' => t('Make this hub my primary location'), '$label_import_posts' => t('Import existing posts if possible'), + '$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'), '$email' => '', '$pass' => '', '$submit' => t('Submit') -- cgit v1.2.3 From 0ad71b3efa7de4eb1f4313ffe4562ec83743bdc1 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 21 Jun 2015 19:11:07 -0700 Subject: import: Improve the descriptive text for this feature --- mod/import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod/import.php') diff --git a/mod/import.php b/mod/import.php index 85491bc5e..12d44659d 100644 --- a/mod/import.php +++ b/mod/import.php @@ -505,7 +505,7 @@ function import_content(&$a) { $o = replace_macros(get_markup_template('channel_import.tpl'),array( '$title' => t('Import Channel'), - '$desc' => t('Use this form to import an existing channel from a different server/hub. You may retrieve the channel identity from the old server/hub via the network or provide an export file. Only identity and connections/relationships will be imported. Importation of content is not yet available.'), + '$desc' => t('Use this form to import an existing channel from a different server/hub. You may retrieve the channel identity from the old server/hub via the network or provide an export file.'), '$label_filename' => t('File to Upload'), '$choice' => t('Or provide the old server/hub details'), '$label_old_address' => t('Your old identity address (xyz@example.com)'), @@ -513,7 +513,7 @@ function import_content(&$a) { '$label_old_pass' => t('Your old login password'), '$common' => t('For either option, please choose whether to make this hub your new primary address, or whether your old location should continue this role. You will be able to post from either location, but only one can be marked as the primary location for files, photos, and media.'), '$label_import_primary' => t('Make this hub my primary location'), - '$label_import_posts' => t('Import existing posts if possible'), + '$label_import_posts' => t('Import existing posts if possible (experimental - limited by available memory'), '$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'), '$email' => '', '$pass' => '', -- cgit v1.2.3