diff options
author | Thomas Willingham <beardyunixer@beardyunixer.com> | 2014-12-20 13:37:46 +0000 |
---|---|---|
committer | Thomas Willingham <beardyunixer@beardyunixer.com> | 2014-12-20 13:37:46 +0000 |
commit | b0da38c09aa12f186e9413cf34b3eeff92d96b47 (patch) | |
tree | 545564851e25e69172070c6d7b83360fedf3937c /mod/import.php | |
parent | 49a4ca9182195c99ace39d1a897c4578bd932d76 (diff) | |
parent | 6d8214f96bfc8b981fae7c0ffe0cba68206dd86b (diff) | |
download | volse-hubzilla-b0da38c09aa12f186e9413cf34b3eeff92d96b47.tar.gz volse-hubzilla-b0da38c09aa12f186e9413cf34b3eeff92d96b47.tar.bz2 volse-hubzilla-b0da38c09aa12f186e9413cf34b3eeff92d96b47.zip |
Merge branch 'master' of https://github.com/friendica/red
Diffstat (limited to 'mod/import.php')
-rw-r--r-- | mod/import.php | 30 |
1 files changed, 27 insertions, 3 deletions
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']); |