Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge

This commit is contained in:
redmatrix 2016-08-30 20:22:33 -07:00
commit 68f6baf938
2 changed files with 11 additions and 14 deletions

View file

@ -316,7 +316,6 @@ class Webpages extends \Zotlabs\Web\Controller {
$path = $website; $path = $website;
} }
$elements['pages'] = scan_webpage_elements($path, 'page', $cloud); $elements['pages'] = scan_webpage_elements($path, 'page', $cloud);
logger('$elements pages: ' . json_encode($elements['pages']));
$elements['layouts'] = scan_webpage_elements($path, 'layout', $cloud); $elements['layouts'] = scan_webpage_elements($path, 'layout', $cloud);
$elements['blocks'] = scan_webpage_elements($path, 'block', $cloud); $elements['blocks'] = scan_webpage_elements($path, 'block', $cloud);
$_SESSION['blocks'] = $elements['blocks']; $_SESSION['blocks'] = $elements['blocks'];
@ -426,7 +425,6 @@ class Webpages extends \Zotlabs\Web\Controller {
break; break;
case 'exportcloud': case 'exportcloud':
logger('exportcloud', LOGGER_DEBUG);
if(isset($_POST['exportcloudpath']) && $_POST['exportcloudpath'] !== '') { if(isset($_POST['exportcloudpath']) && $_POST['exportcloudpath'] !== '') {
$_SESSION['action'] = 'export_select_list'; $_SESSION['action'] = 'export_select_list';
$_SESSION['export'] = 'cloud'; $_SESSION['export'] = 'cloud';

View file

@ -1311,8 +1311,6 @@ function scan_webpage_elements($path, $type, $cloud = false) {
return false; return false;
} }
$content = file_get_contents($folder . '/' . $contentfilename); $content = file_get_contents($folder . '/' . $contentfilename);
logger('contentfile: ' . $folder . '/' . $contentfilename, LOGGER_DEBUG);
logger('content: ' . $content, LOGGER_DEBUG);
if (!$content) { if (!$content) {
if(is_readable($folder . '/' . $contentfilename)) { if(is_readable($folder . '/' . $contentfilename)) {
$content = ''; $content = '';
@ -1401,18 +1399,14 @@ function scan_webpage_elements($path, $type, $cloud = false) {
); );
$arr['mid'] = $arr['parent_mid'] = $iteminfo[0]['mid']; $arr['mid'] = $arr['parent_mid'] = $iteminfo[0]['mid'];
$arr['created'] = $iteminfo[0]['created']; $arr['created'] = $iteminfo[0]['created'];
$arr['edited'] = (($element['edited']) ? datetime_convert('UTC', 'UTC', $element['edited']) : datetime_convert());
} else { // otherwise, generate the creation times and unique id } else { // otherwise, generate the creation times and unique id
$arr['created'] = (($element['created']) ? datetime_convert('UTC', 'UTC', $element['created']) : datetime_convert()); $arr['created'] = datetime_convert('UTC', 'UTC');
$arr['edited'] = datetime_convert('UTC', 'UTC', '0000-00-00 00:00:00');
$arr['mid'] = $arr['parent_mid'] = item_message_id(); $arr['mid'] = $arr['parent_mid'] = item_message_id();
} }
// Update the edited time whether or not the element already exists
$arr['edited'] = datetime_convert('UTC', 'UTC');
// Import the actual element content // Import the actual element content
$arr['body'] = file_get_contents($element['path']); $arr['body'] = file_get_contents($element['path']);
if($arr['item_type'] === ITEM_TYPE_PDL) {
logger(' body: ' . $arr['body'], LOGGER_DEBUG);
logger(' path: ' . $element['path'], LOGGER_DEBUG);
}
// The element owner is the channel importing the elements // The element owner is the channel importing the elements
$arr['owner_xchan'] = get_observer_hash(); $arr['owner_xchan'] = get_observer_hash();
// The author is either the owner or whomever was specified // The author is either the owner or whomever was specified
@ -1425,7 +1419,7 @@ function scan_webpage_elements($path, $type, $cloud = false) {
'application/x-pdl', 'application/x-pdl',
'application/x-php' 'application/x-php'
]; ];
// Blocks and pages can have any mimetype, but layouts must be text/bbcode // Blocks and pages can have any of the valid mimetypes, but layouts must be text/bbcode
if((in_array($element['mimetype'], $mimetypes)) && ($type === 'page' || $type === 'block') ) { if((in_array($element['mimetype'], $mimetypes)) && ($type === 'page' || $type === 'block') ) {
$arr['mimetype'] = $element['mimetype']; $arr['mimetype'] = $element['mimetype'];
} else { } else {
@ -1434,7 +1428,7 @@ function scan_webpage_elements($path, $type, $cloud = false) {
// Verify ability to use html or php!!! // Verify ability to use html or php!!!
$execflag = false; $execflag = false;
if ($arr['mimetype'] === 'application/x-php') { if ($arr['mimetype'] === 'application/x-php' || $arr['mimetype'] === 'text/html') {
$z = q("select account_id, account_roles, channel_pageflags from account " $z = q("select account_id, account_roles, channel_pageflags from account "
. "left join channel on channel_account_id = account_id where channel_id = %d limit 1", . "left join channel on channel_account_id = account_id where channel_id = %d limit 1",
intval(local_channel()) intval(local_channel())
@ -1442,10 +1436,15 @@ function scan_webpage_elements($path, $type, $cloud = false) {
if ($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { if ($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) {
$execflag = true; $execflag = true;
} else {
logger('Unable to import element "' . $name .'" because AllowCode permission is denied.');
notice( t('Unable to import element "' . $name .'" because AllowCode permission is denied.') . EOL);
$element['import_success'] = 0;
return $element;
} }
} }
$z = q("select * from iconfig where v = '%s' and k = '%s' and cat = 'service' limit 1", $z = q("select * from iconfig where v = '%s' and k = '%s' and cat = 'system' limit 1",
dbesc($name), dbesc($name),
dbesc($namespace) dbesc($namespace)
); );