From ab2d11b37ee2a568fcbe04a155131a3545ccab80 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 18 Dec 2014 19:48:23 -0800 Subject: mod/import: try ten times to create a unique webbie if the chosen one is in use. --- mod/import.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/import.php b/mod/import.php index 6cb3767a6..c9a4edb67 100644 --- a/mod/import.php +++ b/mod/import.php @@ -101,9 +101,33 @@ function import_post(&$a) { // We should probably also verify the hash if($r) { - logger('mod_import: duplicate channel. ', print_r($channel,true)); - notice( t('Cannot create a duplicate channel identifier on this system. Import failed.') . EOL); - return; + if($r[0]['channel_guid'] === $channel['channel_guid'] || $r[0]['channel_hash'] === $channel['channel_hash']) { + logger('mod_import: duplicate channel. ', print_r($channel,true)); + notice( t('Cannot create a duplicate channel identifier on this system. Import failed.') . EOL); + return; + } + else { + // try at most ten times to generate a unique address. + $x = 0; + $found_unique = false; + do { + $tmp = $channel['channel_address'] . mt_rand(1000,9999); + $r = q("select * from channel where channel_address = '%s' limit 1", + dbesc($tmp) + ); + if(! $r) { + $channel['channel_address'] = $tmp; + $found_unique = true; + break; + } + $x ++; + } while ($x < 10); + if(! $found_unique) { + logger('mod_import: duplicate channel. randomisation failed.', print_r($channel,true)); + notice( t('Unable to create a unique channel address. Import failed.') . EOL); + return; + } + } } unset($channel['channel_id']); -- cgit v1.2.3 From 9c445e98175b55e369f06220a46cf36893960cdc Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 19 Dec 2014 00:28:36 -0800 Subject: incorrect check for sys ownership --- mod/display.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/display.php b/mod/display.php index 55f7c1306..7d7f4ca13 100644 --- a/mod/display.php +++ b/mod/display.php @@ -157,6 +157,7 @@ function display_content(&$a, $update = 0, $load = false) { require_once('include/identity.php'); $sys = get_sys_channel(); + $sysid = $sys['channel_id']; if(local_user()) { $r = q("SELECT * from item @@ -178,8 +179,8 @@ function display_content(&$a, $update = 0, $load = false) { // in case somebody turned off public access to sys channel content using permissions // make that content unsearchable by ensuring the owner_xchan can't match - if(! perm_is_allowed($sys['channel_id'],$observer_hash,'view_stream')) - $sys['xchan_hash'] .= 'disabled'; + if(! perm_is_allowed($sysid,$observer_hash,'view_stream')) + $sysid = 0; $r = q("SELECT * from item @@ -188,11 +189,11 @@ function display_content(&$a, $update = 0, $load = false) { AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) and owner_xchan in ( " . stream_perms_xchans(($observer_hash) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) - OR owner_xchan = '%s') + OR uid = %d ) $sql_extra ) limit 1", dbesc($target_item['parent_mid']), - dbesc($sys['xchan_hash']) + intval($sysid) ); } -- cgit v1.2.3 From 6d8214f96bfc8b981fae7c0ffe0cba68206dd86b Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 19 Dec 2014 01:48:47 -0800 Subject: provide link to help for channel permission roles when creating a channel --- mod/new_channel.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mod') diff --git a/mod/new_channel.php b/mod/new_channel.php index 8329f0ec3..185fc7c28 100644 --- a/mod/new_channel.php +++ b/mod/new_channel.php @@ -116,6 +116,8 @@ function new_channel_content(&$a) { '$label_import' => t('Or import an existing channel from another location'), '$name' => $name, '$label_role' => t('Channel Type'), + '$questionmark' => t('?'), + '$what_is_role' => t('What is this?'), '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'), '$role_select' => role_selector(($privacy_role) ? $privacy_role : 'social'), '$nickname' => $nickname, -- cgit v1.2.3