From ff2f599142348162b6459a02aa014c7dbca84f76 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 16 Jul 2016 19:25:44 -0400 Subject: Postpone remote folder import until filesystem mirroring matures. --- Zotlabs/Module/Webpages.php | 38 ++++++++++++++++++++++++++++++++++++-- include/text.php | 6 +++++- view/tpl/website_import_tools.tpl | 17 ++++++++++++++--- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index 766b4fc09..16ecb5386 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -211,7 +211,7 @@ class Webpages extends \Zotlabs\Web\Controller { function post() { - if(($_FILES) && array_key_exists('zip_file',$_FILES)) { + if(($_FILES) && array_key_exists('zip_file',$_FILES) && isset($_POST['w_upload'])) { $source = $_FILES["zip_file"]["tmp_name"]; $type = $_FILES["zip_file"]["type"]; $okay = false; @@ -256,7 +256,41 @@ class Webpages extends \Zotlabs\Web\Controller { if($elements) { rrmdir($website); // Delete the temporary decompressed files } - } + } + + return null; + } + + if (($_POST) && array_key_exists('url',$_POST) && isset($_POST['remotesubmit'])) { + $ret = []; + // Warning: Do not edit the following line. The first symbol is UTF-8 @ + $url = str_replace('@','@',notags(trim($_REQUEST['url']))); + if(! allowed_url($url)) { + $ret['message'] = t('Channel is blocked on this site.'); + return null; + } + + $h = @parse_url($url); + + if(! $h || !x($h, 'host') || !x($h, 'path')) { + return null; + } + if(substr($h['path'],-1,1) === '/') { + $h['path'] = substr($h['path'],0,-1); + } + if(substr($h['path'],0,1) === '/') { + $h['path'] = substr($h['path'],1); + } + $folders = explode('/', $h['path']); + if(!(array_shift($folders) === 'cloud')) { + return null; + } + $nick = array_shift($folders); + if(!$nick) { + return null; + } + return null; + } } diff --git a/include/text.php b/include/text.php index 096c8a5aa..a0f0ed7ae 100644 --- a/include/text.php +++ b/include/text.php @@ -2270,7 +2270,11 @@ function website_import_tools() { '$import_label' => t('Import website...'), '$import_placeholder' => t('Select folder to import'), '$file_upload_text' => t('Import from a zipped folder:'), - '$file_import_text' => t('Import from cloud files:') + '$file_import_text' => t('Import from cloud files:'), + '$file_remote_text' => t('Import from another channel'), + '$desc' => t('https://example.com/cloud/peter/sharedfolder'), + '$hint' => t('https://example.com/cloud/peter/sharedfolder'), + '$follow' => t('Import'), )); } diff --git a/view/tpl/website_import_tools.tpl b/view/tpl/website_import_tools.tpl index ca9cc8b33..d4360f634 100644 --- a/view/tpl/website_import_tools.tpl +++ b/view/tpl/website_import_tools.tpl @@ -5,13 +5,24 @@ {{$import_label}}