diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-07-16 21:02:13 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-07-16 21:02:13 -0400 |
commit | e7b853175154688d60d83ca5935650d1128973c6 (patch) | |
tree | 61dbf6b129669a3ae4e3bf9f71540507a527c424 | |
parent | ff2f599142348162b6459a02aa014c7dbca84f76 (diff) | |
download | volse-hubzilla-e7b853175154688d60d83ca5935650d1128973c6.tar.gz volse-hubzilla-e7b853175154688d60d83ca5935650d1128973c6.tar.bz2 volse-hubzilla-e7b853175154688d60d83ca5935650d1128973c6.zip |
Stash changes to merge from dev
-rw-r--r-- | Zotlabs/Module/Webpages.php | 56 | ||||
-rw-r--r-- | include/text.php | 7 | ||||
-rw-r--r-- | view/tpl/website_import_tools.tpl | 19 |
3 files changed, 52 insertions, 30 deletions
diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index 16ecb5386..c78109cb7 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -261,18 +261,14 @@ class Webpages extends \Zotlabs\Web\Controller { return null; } - if (($_POST) && array_key_exists('url',$_POST) && isset($_POST['remotesubmit'])) { + if (($_POST) && array_key_exists('path',$_POST) && isset($_POST['cloudsubmit'])) { $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; - } + $path = str_replace('@','@',notags(trim($_REQUEST['path']))); - $h = @parse_url($url); + $h = @parse_url($path); - if(! $h || !x($h, 'host') || !x($h, 'path')) { + if(! $h || !x($h, 'path')) { return null; } if(substr($h['path'],-1,1) === '/') { @@ -282,13 +278,47 @@ class Webpages extends \Zotlabs\Web\Controller { $h['path'] = substr($h['path'],1); } $folders = explode('/', $h['path']); - if(!(array_shift($folders) === 'cloud')) { - return null; + $f = array_shift($folders); + + $channel = \App::get_channel(); + $nick = \App::$profile['channel_address']; + //check to see if the absolute path was provided (/cloud/channelname/path/to/folder) + if(($f === 'cloud') ) { + $g = array_shift($folders); + if( $g !== $nick) { + // if nick does not follow "cloud", then the top level folder must be called "cloud" + // and the given path must be relative to "/cloud/channelname/". + $folders = array_unshift($f,array_unshift($g, $folders)); + } } - $nick = array_shift($folders); - if(!$nick) { - return null; + $clouddir = 'store/' . $nick . '/'; + $folder_path = $clouddir . implode('/', $folders); + + +// if(!(is_dir($folder_path) && is_readable($folder_path))) { +// logger('path is not readable: ' . $folder_path); +// return null; +// } + $subdir = '/'; + $valid = true; + while($folders && $valid && is_dir($clouddir . $subdir) && is_readable($clouddir . $subdir)) { + logger('hashed path: ' . $clouddir . $subdir); + $valid = false; + $f = array_shift($folders); + $items = array_diff(scandir($clouddir . $subdir), array('.', '..')); // hashed names + foreach($items as $item) { + $filename = find_filename_by_hash($channel['channel_id'], $item); + if($filename === $f) { + $subdir .= $item . '/'; + $valid = true; + } + } } + if(!$valid) { + logger('path is not valid: ' . $folder_path); + } + + return null; } diff --git a/include/text.php b/include/text.php index a0f0ed7ae..3b285cfca 100644 --- a/include/text.php +++ b/include/text.php @@ -2271,10 +2271,9 @@ function website_import_tools() { '$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_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'), + '$desc' => t('/path/to/folder'), + '$hint' => t('/path/to/folder'), + '$select' => t('Select folder'), )); } diff --git a/view/tpl/website_import_tools.tpl b/view/tpl/website_import_tools.tpl index d4360f634..dc9ba6c08 100644 --- a/view/tpl/website_import_tools.tpl +++ b/view/tpl/website_import_tools.tpl @@ -5,24 +5,17 @@ <a href="#" onclick="openClose('import-form'); return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a> </li> <form id="import-form" enctype="multipart/form-data" method="post" action="" style="display: none;" class="sub-menu"> - <!-- + <p class="descriptive-text">{{$file_import_text}}</p> <div class="form-group"> - <select id="import" name="target" class="form-control"> - <option value="">{{$import_placeholder}}</option> - </select> - </div> - --> - <!-- Or download from another channel cloud files --> - <p class="descriptive-text">{{$file_remote_text}}</p> - <div class="form-group"> - <div class="input-group"> - <input class="widget-input" type="text" name="url" title="{{$hint}}" placeholder="{{$desc}}" /> + <div class="input-group"> + <input class="widget-input" type="text" name="path" title="{{$hint}}" placeholder="{{$desc}}" /> <div class="input-group-btn"> - <button class="btn btn-default btn-sm" type="submit" name="remotesubmit" value="{{$follow}}"><i class="fa fa-cloud-download generic-icons"></i></button> + <button class="btn btn-default btn-sm" type="submit" name="cloudsubmit" value="{{$select}}"><i class="fa fa-folder-open generic-icons"></i></button> </div> </div> - </div> + </div> + <!-- Or upload a zipped file containing the website --> <p class="descriptive-text">{{$file_upload_text}}</p> <div class="form-group"> |