From e938b7e71ebc7c03087a4fb59271804e6b7d1677 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Feb 2019 14:57:19 -0800 Subject: [PATCH] file import issues, change min php version in setup --- Zotlabs/Module/Setup.php | 4 ++-- include/import.php | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index 0890a47a7..2634aa91a 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -392,8 +392,8 @@ class Setup extends \Zotlabs\Web\Controller { function check_php(&$phpath, &$checks) { $help = ''; - if(version_compare(PHP_VERSION, '5.5') < 0) { - $help .= t('PHP version 5.5 or greater is required.'); + if(version_compare(PHP_VERSION, '7.1') < 0) { + $help .= t('PHP version 7.1 or greater is required.'); $this->check_add($checks, t('PHP version'), false, false, $help); } diff --git a/include/import.php b/include/import.php index aa2bcf64c..9965c33df 100644 --- a/include/import.php +++ b/include/import.php @@ -1111,9 +1111,8 @@ function sync_files($channel, $files) { continue; if($f['attach']) { - $attachment_stored = false; foreach($f['attach'] as $att) { - + $attachment_stored = false; convert_oldfields($att,'data','content'); if($att['deleted']) { @@ -1201,12 +1200,14 @@ function sync_files($channel, $files) { // process/sync a remote rename/move operation - if($orig_attach['content'] !== $newfname) { + if($orig_attach && $orig_attach['content'] && $orig_attach['content'] !== $newfname) { + logger('rename: ' . $orig_attach['content'] . ' -> ' . $newfname); rename($orig_attach['content'],$newfname); } - if(! dbesc_array($att)) + if(! dbesc_array($att)) { continue; + } $str = ''; foreach($att as $k => $v) { @@ -1222,6 +1223,7 @@ function sync_files($channel, $files) { create_table_from_array('attach',$att); } + // is this a directory? if($att['filetype'] === 'multipart/mixed' && $att['is_dir']) { @@ -1230,6 +1232,7 @@ function sync_files($channel, $files) { continue; } else { + // it's a file // for the sync version of this algorithm (as opposed to 'offline import') // we will fetch the actual file from the source server so it can be @@ -1242,22 +1245,27 @@ function sync_files($channel, $files) { 'time' => $time, 'resource' => $att['hash'], 'revision' => 0, - 'signature' => zot_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey']) + 'signature' => Libzot::sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey']) ); $store_path = $newfname; + $fp = fopen($newfname,'w'); + if(! $fp) { logger('failed to open storage file.',LOGGER_NORMAL,LOG_ERR); continue; } + $redirects = 0; $headers = [ 'Accept' => 'application/x-zot+json', 'Sigtoken' => random_string() ]; $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], channel_url($channel),true,'sha512'); + $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); + fclose($fp); if($x['success']) {