From 574f074dc01d59043e0e1cb24215ad0b435ab44f Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 14 Jun 2012 18:42:06 -0700 Subject: [PATCH] make it harder to create duplicate globaldir entries --- include/items.php | 1 + mod/submit.php | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/items.php b/include/items.php index 3d7f0b9a..22509f24 100755 --- a/include/items.php +++ b/include/items.php @@ -241,3 +241,4 @@ function post_remote($a,$arr) { return $current_post; } + diff --git a/mod/submit.php b/mod/submit.php index 854c6aff..d1ceb46f 100755 --- a/mod/submit.php +++ b/mod/submit.php @@ -31,14 +31,15 @@ function submit_content(&$a) { $parms = scrape_dfrn($url); - if((! count($parms)) || (validate_dfrn($parms))) + if((! count($parms)) || (validate_dfrn($parms))) { exit; + } if((x($parms,'hide')) || (! (x($parms,'fn')) && (x($parms,'photo')))) { if($profile_exists) { nuke_record($url); } - return; + exit; } $photo = $parms['photo']; @@ -103,11 +104,23 @@ function submit_content(&$a) { ); logger('Insert returns: ' . $r); - $r = q("SELECT `id` FROM `profile` WHERE `homepage` = '%s' LIMIT 1", - dbesc($url) + $r = q("SELECT `id` FROM `profile` WHERE ( `homepage` = '%s' or `nurl` = '%s' ) order by id asc", + dbesc($url), + dbesc($nurl) ); + if(count($r)) - $profile_id = $r[0]['id']; + $profile_id = $r[count($r) - 1]['id']; + + if(count($r) > 1) + q("DELETE FROM `photo` WHERE `profile-id` = %d LIMIT 1", + intval($r[0]['id']) + ); + q("DELETE FROM `profile` WHERE `id` = %d LIMIT 1", + intval($r[0]['id']) + ); + + } if($parms['tags']) {