4873: avoid error message when searching for duplicate gc or nc waypoints
This commit is contained in:
+5
-14
@@ -92,26 +92,17 @@
|
|||||||
if ((($target == 'oc') || ($target == 'nc') || ($target == 'gc')) && mb_ereg_match('(('.$opt['logic']['ocprefixes'].'|gc)([a-z0-9]){4,5}|n([a-f0-9]){5,5})$', mb_strtolower($searchfor)))
|
if ((($target == 'oc') || ($target == 'nc') || ($target == 'gc')) && mb_ereg_match('(('.$opt['logic']['ocprefixes'].'|gc)([a-z0-9]){4,5}|n([a-f0-9]){5,5})$', mb_strtolower($searchfor)))
|
||||||
{
|
{
|
||||||
// get cache_id from DB
|
// get cache_id from DB
|
||||||
$rs = sql("SELECT `cache_id` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&1') AND `wp_" . sql_escape($target) . "`='&2'", $login->userid, $searchfor);
|
// GC/NC waypoints can be duplicates -> return first match with least status number
|
||||||
$count = sql_num_rows($rs);
|
$rs = sql("SELECT `cache_id` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&1') AND `wp_" . sql_escape($target) . "`='&2' ORDER BY `caches`.`status`,`caches`.`cache_id` LIMIT 0,1", $login->userid, $searchfor);
|
||||||
if ($count == 1)
|
if (sql_num_rows($rs))
|
||||||
{
|
{
|
||||||
$record = sql_fetch_array($rs);
|
$record = sql_fetch_array($rs);
|
||||||
sql_free_result($rs);
|
|
||||||
$targeturl = 'viewcache.php?cacheid=' . $record['cache_id'];
|
$targeturl = 'viewcache.php?cacheid=' . $record['cache_id'];
|
||||||
unset($record);
|
unset($record);
|
||||||
}
|
}
|
||||||
else if ($count == 0)
|
else
|
||||||
{
|
|
||||||
sql_free_result($rs);
|
|
||||||
$tpl->error(ERROR_SEARCHPLUGIN_WAYPOINT_NOTFOUND, $searchfor);
|
$tpl->error(ERROR_SEARCHPLUGIN_WAYPOINT_NOTFOUND, $searchfor);
|
||||||
}
|
sql_free_result($rs);
|
||||||
else if ($count > 1)
|
|
||||||
{
|
|
||||||
sql_free_result($rs);
|
|
||||||
$tpl->error(ERROR_SEARCHPLUGIN_WAYPOINT_MANY, $searchfor);
|
|
||||||
}
|
|
||||||
unset($count);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user