diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Daemon/Cron.php | 10 | ||||
-rw-r--r-- | Zotlabs/Module/Impel.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Like.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Menu.php | 6 | ||||
-rw-r--r-- | Zotlabs/Module/Ping.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Settings.php | 76 | ||||
-rw-r--r-- | Zotlabs/Module/Webpages.php | 185 | ||||
-rw-r--r-- | Zotlabs/Storage/Directory.php | 1 |
8 files changed, 269 insertions, 17 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index c6e82b13a..c66b62f55 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -64,12 +64,16 @@ class Cron { // delete expired access tokens - q("delete from atoken where atoken_expires != '%s' && atoken_expires < %s", + $r = q("select atoken_id from atoken where atoken_expires != '%s' && atoken_expires < %s", dbesc(NULL_DATE), db_utcnow() ); - - + if($r) { + require_once('include/security.php'); + foreach($r as $rr) { + atoken_delete($rr['atoken_id']); + } + } // Ensure that every channel pings a directory server once a month. This way we can discover // channels and sites that quietly vanished and prevent the directory from accumulating stale diff --git a/Zotlabs/Module/Impel.php b/Zotlabs/Module/Impel.php index 735c311d0..197d9f859 100644 --- a/Zotlabs/Module/Impel.php +++ b/Zotlabs/Module/Impel.php @@ -88,7 +88,11 @@ class Impel extends \Zotlabs\Web\Controller { foreach($j['items'] as $it) { $mitem = array(); + $mitem['mitem_link'] = str_replace('[channelurl]',z_root() . '/channel/' . $channel['channel_address'],$it['link']); + $mitem['mitem_link'] = str_replace('[pageurl]',z_root() . '/page/' . $channel['channel_address'],$it['link']); + $mitem['mitem_link'] = str_replace('[cloudurl]',z_root() . '/cloud/' . $channel['channel_address'],$it['link']); $mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']); + $mitem['mitem_desc'] = escape_tags($it['desc']); $mitem['mitem_order'] = intval($it['order']); if(is_array($it['flags'])) { diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 170349509..dd0bc99d4 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -495,6 +495,8 @@ class Like extends \Zotlabs\Web\Controller { $arr['deny_gid'] = $deny_gid; $arr['item_private'] = $private; + call_hooks('post_local',$arr); + $post = item_store($arr); $post_id = $post['item_id']; diff --git a/Zotlabs/Module/Menu.php b/Zotlabs/Module/Menu.php index e98053f8c..1dec65c1f 100644 --- a/Zotlabs/Module/Menu.php +++ b/Zotlabs/Module/Menu.php @@ -65,7 +65,7 @@ class Menu extends \Zotlabs\Web\Controller { - function get() { + function get() { $uid = local_channel(); @@ -81,7 +81,7 @@ class Menu extends \Zotlabs\Web\Controller { if(argc() == 1) { - + $channel = (($sys) ? $sys : \App::get_channel()); // list menus $x = menu_list($uid); @@ -89,7 +89,7 @@ class Menu extends \Zotlabs\Web\Controller { for($y = 0; $y < count($x); $y ++) { $m = menu_fetch($x[$y]['menu_name'],$uid,get_observer_hash()); if($m) - $x[$y]['element'] = '[element]' . base64url_encode(json_encode(menu_element($m))) . '[/element]'; + $x[$y]['element'] = '[element]' . base64url_encode(json_encode(menu_element($channel,$m))) . '[/element]'; $x[$y]['bookmark'] = (($x[$y]['menu_flags'] & MENU_BOOKMARK) ? true : false); } } diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 5cbf45daa..e01c3b49a 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -173,7 +173,7 @@ class Ping extends \Zotlabs\Web\Controller { ); break; case 'all_events': - $r = q("update event set `dimissed` = 1 where `dismissed` = 0 and uid = %d AND dtstart < '%s' AND dtstart > '%s' ", + $r = q("update event set `dismissed` = 1 where `dismissed` = 0 and uid = %d AND dtstart < '%s' AND dtstart > '%s' ", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php index af3a25c60..57a0aa535 100644 --- a/Zotlabs/Module/Settings.php +++ b/Zotlabs/Module/Settings.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; /** @file */ require_once('include/zot.php'); - +require_once('include/security.php'); class Settings extends \Zotlabs\Web\Controller { @@ -145,7 +145,7 @@ class Settings extends \Zotlabs\Web\Controller { return; } if($atoken_id) { - $r = q("update atoken set atoken_name = '%s', atoken_token = '%s' atoken_expires = '%s' + $r = q("update atoken set atoken_name = '%s', atoken_token = '%s', atoken_expires = '%s' where atoken_id = %d and atoken_uid = %d", dbesc($name), dbesc($token), @@ -164,7 +164,23 @@ class Settings extends \Zotlabs\Web\Controller { dbesc($expires) ); } + + $atoken_xchan = substr($channel['channel_hash'],0,16) . '.' . $name; + + $all_perms = \Zotlabs\Access\Permissions::Perms(); + + if($all_perms) { + foreach($all_perms as $perm => $desc) { + if(array_key_exists('perms_' . $perm, $_POST)) { + set_abconfig($channel['channel_id'],$atoken_xchan,'my_perms',$perm,intval($_POST['perms_' . $perm])); + } + else { + set_abconfig($channel['channel_id'],$atoken_xchan,'my_perms',$perm,0); + } + } + } + info( t('Token saved.') . EOL); return; } @@ -270,7 +286,7 @@ class Settings extends \Zotlabs\Web\Controller { $email = ((x($_POST,'email')) ? trim(notags($_POST['email'])) : ''); $account = \App::get_account(); if($email != $account['account_email']) { - if(! valid_email($email)) + if(! valid_email($email)) $errs[] = t('Not valid email.'); $adm = trim(get_config('system','admin_email')); if(($adm) && (strcasecmp($email,$adm) == 0)) { @@ -378,7 +394,7 @@ class Settings extends \Zotlabs\Web\Controller { intval(local_channel()) ); } - else { + else { $role_permissions = \Zotlabs\Access\PermissionRoles::role_perms($_POST['permissions_role']); if(! $role_permissions) { notice('Permissions category could not be found.'); @@ -765,6 +781,8 @@ class Settings extends \Zotlabs\Web\Controller { if((argc() > 1) && (argv(1) === 'tokens')) { $atoken = null; + $atoken_xchan = ''; + if(argc() > 2) { $id = argv(2); @@ -773,23 +791,56 @@ class Settings extends \Zotlabs\Web\Controller { intval(local_channel()) ); - if($atoken) + if($atoken) { $atoken = $atoken[0]; + $atoken_xchan = substr($channel['channel_hash'],0,16) . '.' . $atoken['atoken_name']; + } if($atoken && argc() > 3 && argv(3) === 'drop') { - $r = q("delete from atoken where atoken_id = %d", - intval($id) - ); + atoken_delete($id); + $atoken = null; + $atoken_xchan = ''; } } + $t = q("select * from atoken where atoken_uid = %d", intval(local_channel()) ); - $desc = t('Use this form to create temporary access identifiers to share things with non-members. These identities may be used in Access Control Lists and visitors may login using these credentials to access the private content.'); + $desc = t('Use this form to create temporary access identifiers to share things with non-members. These identities may be used in Access Control Lists and visitors may login using these credentials to access private content.'); $desc2 = t('You may also provide <em>dropbox</em> style access links to friends and associates by adding the Login Password to any specific site URL as shown. Examples:'); + $global_perms = \Zotlabs\Access\Permissions::Perms(); + + $existing = get_all_perms(local_channel(),(($atoken_xchan) ? $atoken_xchan : '')); + + if($atoken_xchan) { + $theirs = q("select * from abconfig where chan = %d and xchan = '%s' and cat = 'their_perms'", + intval(local_channel()), + dbesc($atoken_xchan) + ); + $their_perms = array(); + if($theirs) { + foreach($theirs as $t) { + $their_perms[$t['k']] = $t['v']; + } + } + } + foreach($global_perms as $k => $v) { + $thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k); +//fixme + + $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$k); + + if($existing[$k]) + $thisperm = "1"; + + $perms[] = array('perms_' . $k, $v, ((array_key_exists($k,$their_perms)) ? intval($their_perms[$k]) : ''),$thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited); + } + + + $tpl = get_markup_template("settings_tokens.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_tokens"), @@ -803,6 +854,13 @@ class Settings extends \Zotlabs\Web\Controller { '$name' => array('name', t('Login Name') . ' <span class="required">*</span>', (($atoken) ? $atoken['atoken_name'] : ''),''), '$token'=> array('token', t('Login Password') . ' <span class="required">*</span>',(($atoken) ? $atoken['atoken_token'] : autoname(8)), ''), '$expires'=> array('expires', t('Expires (yyyy-mm-dd)'), (($atoken['atoken_expires'] && $atoken['atoken_expires'] != NULL_DATE) ? datetime_convert('UTC',date_default_timezone_get(),$atoken['atoken_expires']) : ''), ''), + '$them' => t('Their Settings'), + '$me' => t('My Settings'), + '$perms' => $perms, + '$inherited' => t('inherited'), + '$notself' => '1', + '$permlbl' => t('Individual Permissions'), + '$permnote' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can <strong>not</strong> change those settings here.'), '$submit' => t('Submit') )); return $o; diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index cc0a01cce..d3199f223 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -45,7 +45,29 @@ class Webpages extends \Zotlabs\Web\Controller { $observer = \App::get_observer(); $channel = \App::get_channel(); - + + switch ($_SESSION['action']) { + case 'import': + $_SESSION['action'] = null; + $o .= replace_macros(get_markup_template('webpage_import.tpl'), array( + '$title' => t('Import Webpage Elements'), + '$importbtn' => t('Import selected'), + '$action' => 'import', + '$pages' => $_SESSION['pages'], + '$layouts' => $_SESSION['layouts'], + '$blocks' => $_SESSION['blocks'], + )); + return $o; + + case 'importselected': + $_SESSION['action'] = null; + break; + default : + $_SESSION['action'] = null; + break; + } + + if(\App::$is_sys && is_site_admin()) { $sys = get_sys_channel(); if($sys && intval($sys['channel_id'])) { @@ -209,4 +231,165 @@ class Webpages extends \Zotlabs\Web\Controller { return $o; } + function post() { + + $action = $_REQUEST['action']; + if( $action ){ + switch ($action) { + case 'scan': + + // the state of this variable tracks whether website files have been scanned (null, true, false) + $cloud = null; + + // Website files are to be imported from an uploaded zip file + 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; + $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed'); + foreach ($accepted_types as $mime_type) { + if ($mime_type == $type) { + $okay = true; + break; + } + } + if(!$okay) { + notice( t('Invalid file type.') . EOL); + return; + } + $zip = new \ZipArchive(); + if ($zip->open($source) === true) { + $tmp_folder_name = random_string(5); + $website = dirname($source) . '/' . $tmp_folder_name; + $zip->extractTo($website); // change this to the correct site path + $zip->close(); + @unlink($source); // delete the compressed file now that the content has been extracted + $cloud = false; + } else { + notice( t('Error opening zip file') . EOL); + return null; + } + } + + // Website files are to be imported from the channel cloud files + if (($_POST) && array_key_exists('path',$_POST) && isset($_POST['cloudsubmit'])) { + + $channel = \App::get_channel(); + $dirpath = get_dirpath_by_cloudpath($channel, $_POST['path']); + if(!$dirpath) { + notice( t('Invalid folder path.') . EOL); + return null; + } + $cloud = true; + + } + + // If the website files were uploaded or specified in the cloud files, then $cloud + // should be either true or false + if ($cloud !== null) { + require_once('include/import.php'); + $elements = []; + if($cloud) { + $path = $_POST['path']; + } else { + $path = $website; + } + $elements['pages'] = scan_webpage_elements($path, 'page', $cloud); + $elements['layouts'] = scan_webpage_elements($path, 'layout', $cloud); + $elements['blocks'] = scan_webpage_elements($path, 'block', $cloud); + $_SESSION['blocks'] = $elements['blocks']; + $_SESSION['layouts'] = $elements['layouts']; + $_SESSION['pages'] = $elements['pages']; + if(!(empty($elements['pages']) && empty($elements['blocks']) && empty($elements['layouts']))) { + //info( t('Webpages elements detected.') . EOL); + $_SESSION['action'] = 'import'; + } else { + notice( t('No webpage elements detected.') . EOL); + $_SESSION['action'] = null; + } + + } + + // If the website elements were imported from a zip file, delete the temporary decompressed files + if ($cloud === false && $website && $elements) { + rrmdir($website); // Delete the temporary decompressed files + } + + break; + + case 'importselected': + require_once('include/import.php'); + $channel = \App::get_channel(); + + // Import layout first so that pages that reference new layouts will find + // the mid of layout items in the database + + // Obtain the user-selected layouts to import and import them + $checkedlayouts = $_POST['layout']; + $layouts = []; + if (!empty($checkedlayouts)) { + foreach ($checkedlayouts as $name) { + foreach ($_SESSION['layouts'] as &$layout) { + if ($layout['name'] === $name) { + $layout['import'] = 1; + $layoutstoimport[] = $layout; + } + } + } + foreach ($layoutstoimport as $elementtoimport) { + $layouts[] = import_webpage_element($elementtoimport, $channel, 'layout'); + } + } + $_SESSION['import_layouts'] = $layouts; + + // Obtain the user-selected blocks to import and import them + $checkedblocks = $_POST['block']; + $blocks = []; + if (!empty($checkedblocks)) { + foreach ($checkedblocks as $name) { + foreach ($_SESSION['blocks'] as &$block) { + if ($block['name'] === $name) { + $block['import'] = 1; + $blockstoimport[] = $block; + } + } + } + foreach ($blockstoimport as $elementtoimport) { + $blocks[] = import_webpage_element($elementtoimport, $channel, 'block'); + } + } + $_SESSION['import_blocks'] = $blocks; + + // Obtain the user-selected pages to import and import them + $checkedpages = $_POST['page']; + $pages = []; + if (!empty($checkedpages)) { + foreach ($checkedpages as $pagelink) { + foreach ($_SESSION['pages'] as &$page) { + if ($page['pagelink'] === $pagelink) { + $page['import'] = 1; + $pagestoimport[] = $page; + } + } + } + foreach ($pagestoimport as $elementtoimport) { + $pages[] = import_webpage_element($elementtoimport, $channel, 'page'); + } + } + $_SESSION['import_pages'] = $pages; + if(!(empty($_SESSION['import_pages']) && empty($_SESSION['import_blocks']) && empty($_SESSION['import_layouts']))) { + info( t('Import complete.') . EOL); + } + break; + + default : + break; + } + } + + + + + } + } diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index 0860f99a1..15e06e28f 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -371,6 +371,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { ); if ($r) { + require_once('include/attach.php'); $result = attach_mkdir($r[0], $this->auth->observer, array('filename' => $name, 'folder' => $this->folder_hash)); if($result['success']) { |