aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Import.php81
-rw-r--r--Zotlabs/Module/Uexport.php17
2 files changed, 53 insertions, 45 deletions
diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php
index 52835c685..ea8fbf4a2 100644
--- a/Zotlabs/Module/Import.php
+++ b/Zotlabs/Module/Import.php
@@ -112,12 +112,12 @@ class Import extends \Zotlabs\Web\Controller {
// 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;
+ if(! array_key_exists('compatibility',$data)) {
+ call_hooks('import_foreign_channel_data',$data);
+ if($data['handled'])
+ return;
}
-
+
$moving = intval($_REQUEST['moving']);
if(array_key_exists('compatibility',$data) && array_key_exists('database',$data['compatibility'])) {
@@ -181,14 +181,15 @@ class Import extends \Zotlabs\Web\Controller {
if($completed < 3) {
- if($data['photo']) {
- require_once('include/photo/photo_driver.php');
- import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],$account_id,$channel['channel_id']);
- }
-
- if(is_array($data['profile']))
- import_profiles($channel,$data['profile']);
+ if(array_key_exists('channel',$data)) {
+ if($data['photo']) {
+ require_once('include/photo/photo_driver.php');
+ import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],$account_id,$channel['channel_id']);
+ }
+ if(is_array($data['profile']))
+ import_profiles($channel,$data['profile']);
+ }
logger('import step 3');
$_SESSION['import_step'] = 3;
}
@@ -207,31 +208,34 @@ class Import extends \Zotlabs\Web\Controller {
if($completed < 5) {
// create new hubloc for the new channel at this site
- $r = hubloc_store_lowlevel(
- [
- 'hubloc_guid' => $channel['channel_guid'],
- 'hubloc_guid_sig' => $channel['channel_guid_sig'],
- 'hubloc_hash' => $channel['channel_hash'],
- 'hubloc_addr' => channel_reddress($channel),
- 'hubloc_network' => 'zot',
- 'hubloc_primary' => (($seize) ? 1 : 0),
- 'hubloc_url' => z_root(),
- 'hubloc_url_sig' => base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])),
- 'hubloc_host' => \App::get_hostname(),
- 'hubloc_callback' => z_root() . '/post',
- 'hubloc_sitekey' => get_config('system','pubkey'),
- 'hubloc_updated' => datetime_convert()
- ]
- );
+ if(array_key_exists('channel',$data)) {
+ $r = hubloc_store_lowlevel(
+ [
+ 'hubloc_guid' => $channel['channel_guid'],
+ 'hubloc_guid_sig' => $channel['channel_guid_sig'],
+ 'hubloc_hash' => $channel['channel_hash'],
+ 'hubloc_addr' => channel_reddress($channel),
+ 'hubloc_network' => 'zot',
+ 'hubloc_primary' => (($seize) ? 1 : 0),
+ 'hubloc_url' => z_root(),
+ 'hubloc_url_sig' => base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])),
+ 'hubloc_host' => \App::get_hostname(),
+ 'hubloc_callback' => z_root() . '/post',
+ 'hubloc_sitekey' => get_config('system','pubkey'),
+ 'hubloc_updated' => datetime_convert()
+ ]
+ );
- // reset the original primary hubloc if it is being seized
+ // reset the original primary hubloc if it is being seized
- if($seize) {
- $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ",
- dbesc($channel['channel_hash']),
- dbesc(z_root())
- );
+ if($seize) {
+ $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ",
+ dbesc($channel['channel_hash']),
+ dbesc(z_root())
+ );
+ }
}
+
logger('import step 5');
$_SESSION['import_step'] = 5;
}
@@ -241,7 +245,7 @@ class Import extends \Zotlabs\Web\Controller {
// import xchans and contact photos
- if($seize) {
+ if(array_key_exists('channel',$data) && $seize) {
// replace any existing xchan we may have on this site if we're seizing control
@@ -327,9 +331,7 @@ class Import extends \Zotlabs\Web\Controller {
$_SESSION['import_step'] = 7;
}
-
-
-
+
// FIXME - ensure we have an xchan if somebody is trying to pull a fast one
if($completed < 8) {
@@ -478,6 +480,9 @@ class Import extends \Zotlabs\Web\Controller {
if(is_array($data['wiki']))
import_items($channel,$data['wiki'],false,$relocate);
+
+ if(is_array($data['webpages']))
+ import_items($channel,$data['webpages'],false,$relocate);
$addon = array('channel' => $channel,'data' => $data);
call_hooks('import_channel',$addon);
diff --git a/Zotlabs/Module/Uexport.php b/Zotlabs/Module/Uexport.php
index f36d77174..28c840ceb 100644
--- a/Zotlabs/Module/Uexport.php
+++ b/Zotlabs/Module/Uexport.php
@@ -9,10 +9,11 @@ class Uexport extends \Zotlabs\Web\Controller {
killme();
if(argc() > 1) {
+
+ $sections = (($_REQUEST['sections']) ? explode(',',$_REQUEST['sections']) : '');
+
$channel = \App::get_channel();
-
- require_once('include/channel.php');
-
+
if(argc() > 1 && intval(argv(1)) > 1900) {
$year = intval(argv(1));
}
@@ -30,15 +31,16 @@ class Uexport extends \Zotlabs\Web\Controller {
}
if(argc() > 1 && argv(1) === 'basic') {
- echo json_encode(identity_basic_export(local_channel()));
+ echo json_encode(identity_basic_export(local_channel(),$sections));
killme();
}
- // FIXME - this basically doesn't work in the wild with a channel more than a few months old due to memory and execution time limits.
- // It probably needs to be built at the CLI and offered to download as a tarball. Maybe stored in the members dav.
+ // Warning: this option may consume a lot of memory
if(argc() > 1 && argv(1) === 'complete') {
- echo json_encode(identity_basic_export(local_channel(),true));
+ $sections = get_default_export_sections();
+ $sections[] = 'items';
+ echo json_encode(identity_basic_export(local_channel(),$sections));
killme();
}
}
@@ -57,6 +59,7 @@ class Uexport extends \Zotlabs\Web\Controller {
'$basic' => t('Export your basic channel information to a file. This acts as a backup of your connections, permissions, profile and basic data, which can be used to import your data to a new server hub, but does not contain your content.'),
'$fulltitle' => t('Export Content'),
'$full' => t('Export your channel information and recent content to a JSON backup that can be restored or imported to another server hub. This backs up all of your connections, permissions, profile data and several months of posts. This file may be VERY large. Please be patient - it may take several minutes for this download to begin.'),
+
'$by_year' => t('Export your posts from a given year.'),
'$extra' => t('You may also export your posts and conversations for a particular year or month. Adjust the date in your browser location bar to select other dates. If the export fails (possibly due to memory exhaustion on your server hub), please try again selecting a more limited date range.'),