Výsledky – sezóna 2018

[insert_php]
function show_top_ten_racers($top_ten_racers, $description) {
echo ‚
‚.$description.‘

‚;

$top_ten_racer = array_slice($top_ten_racers[0], 0, 10, true);
$keys = array_keys($top_ten_racer);
$i = 1;
foreach ($keys as $key) {
echo ‚

‚;
$i++;
}
echo ‚

Poradie: Meno a priezvisko: Rok narodenia: Klub: Krajina: Počet bodov:
‚.$i.‘
‚.$top_ten_racers[1][$key][0].‘ ‚.$top_ten_racers[1][$key][1].‘
‚;
if($top_ten_racers[1][$key][2] != ‚0‘) {
echo $top_ten_racers[1][$key][2];
} else {
echo ‚- – – – -‚;
}
echo ‚
‚;
if($top_ten_racers[1][$key][3] != “) {
echo $top_ten_racers[1][$key][3];
} else {
echo ‚- – – – -‚;
}
echo ‚
‚;
if($top_ten_racers[1][$key][5] != “) {
echo $top_ten_racers[1][$key][5];
} else {
echo ‚- – – – -‚;
}
echo ‚
‚.$top_ten_racer[$key].‘

‚;

}

function sec2time($seconds) {
$hours = floor($seconds / (60 * 60));
$divisor_for_minutes = $seconds % (60 * 60);
$minutes = floor($divisor_for_minutes / 60);
$divisor_for_seconds = $divisor_for_minutes % 60;
$seconds = ceil($divisor_for_seconds);

if (strlen($hours) < 2) { $hours = '0'.$hours; } if (strlen($minutes) < 2) { $minutes = '0'.$minutes; } if (strlen($seconds) < 2) { $seconds = '0'.$seconds; } return $hours.':'.$minutes.':'.$seconds; } function display_time($time) { if ($time == '0') { return '- - - - -'; } else { return sec2time($time); } } function display_points($time, $best_time, $limit){ if ($time > 0) {
$points = round((($limit-$time)/($limit-$best_time))*1000);
return $points;
} else {
return 0;
}
}

function total_rank($time, $racer_id, $race) {
if ($time == ‚0‘) {
return ‚- – – – -‚;
} else {
$sql_rank = ‚SELECT racer_id FROM skyrunning_results_2018 WHERE ‚.$race.‘ != \’0\‘ ORDER BY ‚.$race.‘ ASC;‘;
$q_rank = mysql_query($sql_rank);
while ($id = mysql_fetch_row($q_rank)) {
$ids[] = $id[0];
}

$total_ranking = array_search($racer_id, $ids);
if($total_ranking !== false) {
$total_ranking = $total_ranking + 1;
} else {
$total_ranking = ‚—‚;
}
return ($total_ranking);
}
}

function get_best_time($race) {
$sql_times = ‚SELECT min(‚.$race.‘) as min FROM skyrunning_results_2018 WHERE ‚.$race.‘ != \’0\‘;‘;
$q_times = mysql_query($sql_times);
$time = mysql_fetch_row($q_times);
return $time[0];
}

function get_top_ten_points ($races, $gender, $best_times, $limits) {
foreach($races as $race) {
$sql_top_ten = ‚SELECT result.racer_id, result.‘.$race.‘, racer.first_name, racer.last_name, racer.year, racer.club, racer.gender, racer.country
FROM skyrunning_results_2018 as result
LEFT JOIN skyrunning_racer as racer ON racer.racer_id = result.racer_id
WHERE result.‘.$race.‘ != \’0\‘ AND racer.gender = \“.$gender.’\‘ ORDER BY ‚.$race.‘ ASC;‘;

$q_top_ten = mysql_query($sql_top_ten);
while($top_ten = mysql_fetch_row($q_top_ten)) {
$points = display_points($top_ten[1], $best_times[$race], $limits[$race]);
if($top_tens[$top_ten[0]]) {
$top_tens[$top_ten[0]] = ($top_tens[$top_ten[0]]+$points);
} else {
$top_tens[$top_ten[0]] = $points;
$top_tens_info[$top_ten[0]] = array($top_ten[2], $top_ten[3], $top_ten[4], $top_ten[5], $top_ten[6], $top_ten[7]);
}
}
}
arsort($top_tens);
return array($top_tens, $top_tens_info);
}
$mysql = mysql_connect(‚c119um.forpsi.com:3306‘, ‚f75974‘, ‚@nt1k2011@nt1k‘) or die (-1);
$mysql = mysql_select_db(‚f75974‘) or die(-1);

$kkk_best_time = get_best_time(‚kkk2018‘);
$poludnica_best_time = get_best_time(‚poludnica2018‘);
$selma2018_vertical_best_time = get_best_time(‚selma2018_vertical‘);
$polana_best_time = get_best_time(‚polana2018‘);
$selma2018_ultra_best_time = get_best_time(‚selma2018_ultra‘);
$klin2018_best_time = get_best_time(‚klin2018‘);
$chopok2018_long_best_time = get_best_time(‚chopok2018_long‘);
$chopok2018_short_best_time = get_best_time(‚chopok2018_short‘);

$races = array(‚kkk2018‘, ‚poludnica2018‘, ‚selma2018_vertical‘, ‚polana2018‘, ‚selma2018_ultra‘, klin2018, chopok2018_long, chopok2018_short);
$races_best_times = array(‚kkk2018‘ => $kkk_best_time, ‚poludnica2018‘ => $poludnica_best_time, ‚selma2018_vertical‘ => $selma2018_vertical_best_time, ‚polana2018‘ => $polana_best_time, ‚selma2018_ultra‘ => $selma2018_ultra_best_time, ‚klin2018‘ => $klin2018_best_time, ‚chopok2018_long‘ => $chopok2018_long_best_time, ‚chopok2018_short‘ => $chopok2018_short_best_time);
$races_limit = array(‚kkk2018‘ => ‚39600‘, ‚poludnica2018‘ => ‚21600‘, ‚selma2018_vertical‘ => ‚6960‘, ‚polana2018‘ => ‚18000‘, ‚selma2018_ultra‘ => ‚37800‘, ‚klin2018‘ => ‚14400‘, ‚chopok2018_long‘ => ‚30600‘, ‚chopok2018_short‘ => ‚18000‘);

$top_ten_racers_male = get_top_ten_points ($races, ‚M‘, $races_best_times, $races_limit);
$keys_male = array_keys($top_ten_racers_male[0]);

$top_ten_racers_female = get_top_ten_points ($races, ‚F‘, $races_best_times, $races_limit);
$keys_female = array_keys($top_ten_racers_female[0]);

echo ‚

‚;

$racer_id = trim($_GET[‚rid‘]);
$racer_id = intval($racer_id);
if($racer_id == NULL || !is_int($racer_id)) {
$racer_id = ‚0‘;

show_top_ten_racers($top_ten_racers_male, ‚Muži – Absolútne poradie‘);
show_top_ten_racers($top_ten_racers_female, ‚Ženy – Absolútne poradie‘);

echo ‚

Bodovací systém ligy SSkyA – legenda:

  • Každým pretekom v lige SSkyA je priradených 1000 bodov
  • Hodnotení sú všetci pretekári, ktorí dobehnú v limite pretekov
  • Víťaz pretekov dostáva 1000 bodov
  • Nulu dostávajú pretekári, ktorí nestihnú limit
  • Zvyšním pretekárom je priradená pomerná časť bodov podľa vzorca:
  • získané body = (časový limit – môj čas)/(časový limit – čas víťaza)*1000

‚;
} else {

$sql = ‚SELECT racer.first_name, racer.last_name, racer.year, racer.club, racer.gender, racer.country, results_2017.vsr2017, results_2017.kkk2017, results_2017.poludnica2017, results_2017.kh2017, results_2017.selma2017_vertical, results_2017.polana2017, results_2017.selma2017_ultra, results_2017.klin2017, results_2017.chopok2017_long, results_2017.chopok2017_short
FROM skyrunning_racer AS racer
LEFT JOIN skyrunning_results_2017 AS results_2017 ON racer.racer_id = results_2017.racer_id
WHERE racer.racer_id = \“.$racer_id.’\‘;‘;

$sql = ‚SELECT racer.first_name, racer.last_name, racer.year, racer.club, racer.gender, racer.country, results_2018.kkk2018, results_2018.kkk2018, results_2018.poludnica2018, results_2018.selma2018_vertical, results_2018.selma2018_vertical, results_2018.polana2018, results_2018.selma2018_ultra, results_2018.klin2018, results_2018.chopok2018_long, results_2018.chopok2018_short
FROM skyrunning_racer AS racer
LEFT JOIN skyrunning_results_2018 AS results_2018 ON racer.racer_id = results_2018.racer_id
WHERE racer.racer_id = \“.$racer_id.’\‘;‘;

$q = mysql_query($sql);
while($racer = mysql_fetch_row($q)) {
echo ‚‚.
$racer[0].‘ ‚.$racer[1].‘


Rok narodenia : ‚.$racer[2].‘
Kategória : ‚.$racer[4].‘
Klub : ‚.$racer[3].‘
Národnosť : ‚.$racer[5].‘
‚;

$kkk_points = display_points($racer[7], $kkk_best_time, $races_limit[kkk2018]);
$poludnica_points = display_points($racer[8], $poludnica_best_time, $races_limit[poludnica2018]);
$selma_vertical_points = display_points($racer[10], $selma2018_vertical_best_time, $races_limit[selma2018_vertical]);
$polana_points = display_points($racer[11], $polana_best_time, $races_limit[polana2018]);
$selma_ultra_points = display_points($racer[12], $selma2018_ultra_best_time, $races_limit[selma2018_ultra]);
$klin_points = display_points($racer[13], $klin2018_best_time, $races_limit[klin2018]);
if ($racer_id == ‚219‘) $klin_points = ‚1000‘;
$chopok_long_points = display_points($racer[14], $chopok2018_long_best_time, $races_limit[chopok2018_long]);
$chopok_short_points = display_points($racer[15], $chopok2018_short_best_time, $races_limit[chopok2018_short]);

$points_sum = $kkk_points + $poludnica_points + $selma_vertical_points + $polana_points + $selma_ultra_points + $klin_points + $chopok_long_points + $chopok_short_points;

if($racer[4] == ‚M‘) {
$ranking = array_search($racer_id, $keys_male);
} else {
$ranking = array_search($racer_id, $keys_female);
}

if($ranking !== false) {
$ranking = $ranking + 1;
} else {
$ranking = ‚—‚;
}

echo ‚
Rok 2018:

Názov podujatia: Čas (H:M:S): Abs. poradie: Počet bodov:
Krížna Krížom Krážom ULTRA
‚.display_time($racer[7]).‘
‚.total_rank($racer[7], $racer_id, kkk2018).‘
‚.$kkk_points.‘
Poludnica run
‚.display_time($racer[8]).‘
‚.total_rank($racer[8], $racer_id, poludnica2018).‘
‚.$poludnica_points.‘
Tatranská šelma Vertical
‚.display_time($racer[10]).‘
‚.total_rank($racer[10], $racer_id, selma2018_vertical).‘
‚.$selma_vertical_points.‘
Bear Foot Poľana SkyRace
‚.display_time($racer[11]).‘
‚.total_rank($racer[11], $racer_id, polana2018).‘
‚.$polana_points.‘
Tatranská šelma Ultra
‚.display_time($racer[12]).‘
‚.total_rank($racer[12], $racer_id, selma2018_ultra).‘
‚.$selma_ultra_points.‘
Vysokohorský beh cez Klin
‚.display_time($racer[13]).‘
‚.total_rank($racer[13], $racer_id, klin2018).‘
‚.$klin_points.‘
Sky Marathon Chopok
‚.display_time($racer[14]).‘
‚.total_rank($racer[14], $racer_id, chopok2018_long).‘
‚.$chopok_long_points.‘
Jasna Skyrace
‚.display_time($racer[15]).‘
‚.total_rank($racer[15], $racer_id, chopok2018_short).‘
‚.$chopok_short_points.‘
Umiestnenie v lige:
‚.$ranking.‘
Spolu bodov:
‚.$points_sum.‘

‚;

echo ‚‚;

echo ‚‚;

echo ‚‚;

echo ‚

Bodovací systém ligy SSkyA – legenda:

  • Každým pretekom v lige SSkyA je priradených 1000 bodov
  • Hodnotení sú všetci pretekári, ktorí dobehnú v limite pretekov
  • Víťaz pretekov dostáva 1000 bodov
  • Nulu dostávajú pretekári, ktorí nestihnú limit
  • Zvyšním pretekárom je priradená pomerná časť bodov podľa vzorca:
  • získané body = (časový limit – môj čas)/(časový limit – čas víťaza)*1000

‚;
}
}
[/insert_php]