Výsledky – sezóna 2017

[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_2017 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_2017 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_2017 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);

$vsr_best_time = get_best_time(‚vsr2017‘);
$kkk_best_time = get_best_time(‚kkk2017‘);
$poludnica_best_time = get_best_time(‚poludnica2017‘);
$kh_best_time = get_best_time(‚kh2017‘);
$selma2017_vertical_best_time = get_best_time(‚selma2017_vertical‘);
$polana_best_time = get_best_time(‚polana2017‘);
$selma2017_ultra_best_time = get_best_time(‚selma2017_ultra‘);
$klin2017_best_time = get_best_time(‚klin2017‘);
$chopok2017_long_best_time = get_best_time(‚chopok2017_long‘);
$chopok2017_short_best_time = get_best_time(‚chopok2017_short‘);

$races = array(‚vsr2017′,’kkk2017‘, ‚poludnica2017′,’kh2017′,’selma2017_vertical‘, ‚polana2017‘, ‚selma2017_ultra‘, klin2017, chopok2017_long, chopok2017_short);
$races_best_times = array( ‚vsr2017‘ => $vsr_best_time, ‚kkk2017‘ => $kkk_best_time, ‚poludnica2017‘ => $poludnica_best_time, ‚kh2017‘ => $kh_best_time , ‚selma2017_vertical‘ => $selma2017_vertical_best_time, ‚polana2017‘ => $polana_best_time, ‚selma2017_ultra‘ => $selma2017_ultra_best_time, ‚klin2017‘ => $klin2017_best_time, ‚chopok2017_long‘ => $chopok2017_long_best_time, ‚chopok2017_short‘ => $chopok2017_short_best_time);
$races_limit = array(‚vsr2017‘ => ‚21600‘, ‚kkk2017‘ => ‚39600‘, ‚poludnica2017‘ => ‚21600‘, ‚kh2017‘ => ‚7200‘, ‚selma2017_vertical‘ => ‚7080‘, ‚polana2017‘ => ‚18000‘, ‚selma2017_ultra‘ => ‚39600‘, ‚klin2017‘ => ‚14400‘, ‚chopok2017_long‘ => ‚30600‘, ‚chopok2017_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.’\‘;‘;

$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].‘
‚;

$vsr_points = display_points($racer[6], $vsr_best_time, $races_limit[vsr2017]);
$kkk_points = display_points($racer[7], $kkk_best_time, $races_limit[kkk2017]);
$poludnica_points = display_points($racer[8], $poludnica_best_time, $races_limit[poludnica2017]);
$kh_points = display_points($racer[9], $kh_best_time, $races_limit[kh2017]);
$selma_vertical_points = display_points($racer[10], $selma2017_vertical_best_time, $races_limit[selma2017_vertical]);
$polana_points = display_points($racer[11], $polana_best_time, $races_limit[polana2017]);
$selma_ultra_points = display_points($racer[12], $selma2017_ultra_best_time, $races_limit[selma2017_ultra]);
$klin_points = display_points($racer[13], $klin2017_best_time, $races_limit[klin2017]);
$chopok_long_points = display_points($racer[14], $chopok2017_long_best_time, $races_limit[chopok2017_long]);
$chopok_short_points = display_points($racer[15], $chopok2017_short_best_time, $races_limit[chopok2017_short]);

$points_sum = $vsr_points + $kkk_points + $poludnica_points + $kh_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 2017:

Názov podujatia: Čas (H:M:S): Abs. poradie: Počet bodov:
Vitalcity SkyRace 2017
‚.display_time($racer[6]).‘
‚.total_rank($racer[6], $racer_id, vsr2017).‘
‚.$vsr_points.‘
Krížna Krížom Krážom ULTRA
‚.display_time($racer[7]).‘
‚.total_rank($racer[7], $racer_id, kkk2017).‘
‚.$kkk_points.‘
Poludnica run
‚.display_time($racer[8]).‘
‚.total_rank($racer[8], $racer_id, poludnica2017).‘
‚.$poludnica_points.‘
Kráľová hoľa VK
‚.display_time($racer[9]).‘
‚.total_rank($racer[9], $racer_id, kh2017).‘
‚.$kh_points.‘
Tatranská šelma Vertical
‚.display_time($racer[10]).‘
‚.total_rank($racer[10], $racer_id, selma2017_vertical).‘
‚.$selma_vertical_points.‘
Bear Foot Poľana SkyRace
‚.display_time($racer[11]).‘
‚.total_rank($racer[11], $racer_id, polana2017).‘
‚.$polana_points.‘
Tatranská šelma Ultra
‚.display_time($racer[12]).‘
‚.total_rank($racer[12], $racer_id, selma2017_ultra).‘
‚.$selma_ultra_points.‘
Vysokohorský beh cez Klin
‚.display_time($racer[13]).‘
‚.total_rank($racer[13], $racer_id, klin2017).‘
‚.$klin_points.‘
Sky Marathon Chopok
‚.display_time($racer[14]).‘
‚.total_rank($racer[14], $racer_id, chopok2017_long).‘
‚.$chopok_long_points.‘
Jasna Skyrace
‚.display_time($racer[15]).‘
‚.total_rank($racer[15], $racer_id, chopok2017_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]