$thisextra = "";
 $lang = XDb::xEscape($lang);
 $rsAttributes = XDb::xSql("SELECT `cache_attrib`.`id`, `caches_attributes`.`attrib_id`, `cache_attrib`.`text_long`\n                            FROM `caches_attributes`, `cache_attrib`\n                            WHERE `caches_attributes`.`cache_id`= ? AND `caches_attributes`.`attrib_id` = `cache_attrib`.`id`\n                                AND `cache_attrib`.`language` = '{$lang}'\n                            ORDER BY `caches_attributes`.`attrib_id`", $r['cacheid']);
 if ($r['votes'] > 3 || $r['topratings'] > 0 || XDb::xNumRows($rsAttributes) > 0) {
     $thisextra .= "\n-- " . tr('search_gpxgc_03') . ": --\n";
     if (XDb::xNumRows($rsAttributes) > 0) {
         $attributes = '' . tr('search_gpxgc_04') . ': ';
         while ($rAttribute = XDb::xFetchArray($rsAttributes)) {
             // if ($rAttribute['id'] == 55) $wigo = true; todo ustawic typ kesza na wigo
             $attributes .= cleanup_text(xmlentities($rAttribute['text_long']));
             $attributes .= " | ";
         }
         $thisextra .= $attributes;
     }
     if ($r['votes'] > 3) {
         $score = cleanup_text(score2rating($r['score']));
         $thisextra .= "\n" . tr('search_gpxgc_05') . ": " . $score . "\n";
     }
     if ($r['topratings'] > 0) {
         $thisextra .= "" . tr('search_gpxgc_06') . ": " . $r['topratings'] . "\n";
     }
     // NPA - nature protection areas
     // Parki Narodowe , Krajobrazowe
     $rsArea = XDb::xSql("SELECT `parkipl`.`id` AS `npaId`, `parkipl`.`name` AS `npaname`,`parkipl`.`link` AS `npalink`,`parkipl`.`logo` AS `npalogo`\n                    FROM `cache_npa_areas`\n                        INNER JOIN `parkipl` ON `cache_npa_areas`.`parki_id`=`parkipl`.`id`\n                    WHERE `cache_npa_areas`.`cache_id`= ? AND `cache_npa_areas`.`parki_id`!='0'", $r['cacheid']);
     if (XDb::xNumRows($rsArea) != 0) {
         $thisextra .= "" . tr('search_gpxgc_07') . ": ";
         while ($npa = XDb::xFetchArray($rsArea)) {
             $thisextra .= $npa['npaname'] . "  ";
         }
     }
     // Natura 2000
             $scorecolor = "#F06464";
         } else {
             if ($scorenum == 2) {
                 $scorecolor = "#DD7700";
             } else {
                 if ($scorenum == 3) {
                     $scorecolor = "#77CC00";
                 } else {
                     if ($scorenum == 4) {
                         $scorecolor = "#00DD00";
                     }
                 }
             }
         }
     }
     tpl_set_var('score', score2rating($score));
     tpl_set_var('scorecolor', $scorecolor);
 }
 // begin visit-counter
 // delete cache_visits older 1 day 60*60*24 = 86400
 sql("DELETE FROM `cache_visits` WHERE `cache_id`=&1 AND `user_id_ip` != '0' AND NOW()-`last_visited` > 86400", $cache_id);
 // first insert record for visit counter if not in db
 $chkuserid = isset($usr['userid']) ? $usr['userid'] : $_SERVER["REMOTE_ADDR"];
 // note the visit of this user
 sql("INSERT INTO `cache_visits` (`cache_id`, `user_id_ip`, `count`, `last_visited`) VALUES (&1, '&2', 1, NOW())\n                    ON DUPLICATE KEY UPDATE `count`=`count`+1", $cache_id, $chkuserid);
 if ($chkuserid != $owner_id) {
     // if the previous statement does an INSERT, it was the first visit for this user
     if (mysql_affected_rows($dblink) == 1) {
         // increment the counter for this cache
         sql("INSERT INTO `cache_visits` (`cache_id`, `user_id_ip`, `count`, `last_visited`) VALUES (&1, '0', 1, NOW())\n                            ON DUPLICATE KEY UPDATE `count`=`count`+1, `last_visited`=NOW()", $cache_id);
     }