Stash changes to merge from dev
This commit is contained in:
parent
ff2f599142
commit
e7b8531751
@ -261,18 +261,14 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($_POST) && array_key_exists('url',$_POST) && isset($_POST['remotesubmit'])) {
|
if (($_POST) && array_key_exists('path',$_POST) && isset($_POST['cloudsubmit'])) {
|
||||||
$ret = [];
|
$ret = [];
|
||||||
// Warning: Do not edit the following line. The first symbol is UTF-8 @
|
// Warning: Do not edit the following line. The first symbol is UTF-8 @
|
||||||
$url = str_replace('@','@',notags(trim($_REQUEST['url'])));
|
$path = str_replace('@','@',notags(trim($_REQUEST['path'])));
|
||||||
if(! allowed_url($url)) {
|
|
||||||
$ret['message'] = t('Channel is blocked on this site.');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$h = @parse_url($url);
|
$h = @parse_url($path);
|
||||||
|
|
||||||
if(! $h || !x($h, 'host') || !x($h, 'path')) {
|
if(! $h || !x($h, 'path')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(substr($h['path'],-1,1) === '/') {
|
if(substr($h['path'],-1,1) === '/') {
|
||||||
@ -282,13 +278,47 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
$h['path'] = substr($h['path'],1);
|
$h['path'] = substr($h['path'],1);
|
||||||
}
|
}
|
||||||
$folders = explode('/', $h['path']);
|
$folders = explode('/', $h['path']);
|
||||||
if(!(array_shift($folders) === 'cloud')) {
|
$f = array_shift($folders);
|
||||||
return null;
|
|
||||||
|
$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);
|
$clouddir = 'store/' . $nick . '/';
|
||||||
if(!$nick) {
|
$folder_path = $clouddir . implode('/', $folders);
|
||||||
return null;
|
|
||||||
|
|
||||||
|
// 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;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2271,10 +2271,9 @@ function website_import_tools() {
|
|||||||
'$import_placeholder' => t('Select folder to import'),
|
'$import_placeholder' => t('Select folder to import'),
|
||||||
'$file_upload_text' => t('Import from a zipped folder:'),
|
'$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('/path/to/folder'),
|
||||||
'$desc' => t('https://example.com/cloud/peter/sharedfolder'),
|
'$hint' => t('/path/to/folder'),
|
||||||
'$hint' => t('https://example.com/cloud/peter/sharedfolder'),
|
'$select' => t('Select folder'),
|
||||||
'$follow' => t('Import'),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,24 +5,17 @@
|
|||||||
<a href="#" onclick="openClose('import-form'); return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a>
|
<a href="#" onclick="openClose('import-form'); return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a>
|
||||||
</li>
|
</li>
|
||||||
<form id="import-form" enctype="multipart/form-data" method="post" action="" style="display: none;" class="sub-menu">
|
<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>
|
<p class="descriptive-text">{{$file_import_text}}</p>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<select id="import" name="target" class="form-control">
|
<div class="input-group">
|
||||||
<option value="">{{$import_placeholder}}</option>
|
<input class="widget-input" type="text" name="path" title="{{$hint}}" placeholder="{{$desc}}" />
|
||||||
</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-btn">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Or upload a zipped file containing the website -->
|
<!-- Or upload a zipped file containing the website -->
|
||||||
<p class="descriptive-text">{{$file_upload_text}}</p>
|
<p class="descriptive-text">{{$file_upload_text}}</p>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
Reference in New Issue
Block a user