Участник
Пользователь
- Сообщения
- 366
- Реакции
- 5
- Предупреждения
- 5
- Помог
- 1 раз(а)
Как отсортировать рейтинговый список?
умение - показывать последовательно
P- H+ H H- M+ M M- L+ L L-
Код:
ther<?php
function url_get_contents ($Url) {
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$Url = html_entity_decode($Url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
?>
<html>
<head>
<meta charset="utf-8" />
<style type="text/css">
body {
background:#232323;
color:#cfcbc2;
font-family:sans-serif;
}
table {
font-size:12px;
width:100%;
}
th {
background:#2f3030;
color:#93ba10;
text-align:left;
}
tr {
background:#262626;
}
.q {
border:1px solid #4a4945;
}
.b {
background:#2a2a2a;
}
#q {
border:1px solid #4a4945;
}
#b {
background:#2a2a2a;
}
.iN {
color:#FF0000;
}
.iY {
color:#008000;
}
#Lm {
text-indent: 16px;
background-image: url(skill/Lm.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px;
}
#L {
text-indent: 16px;
background-image: url(skill/L.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px;
}
#Lp {
text-indent: 16px;
background-image: url(skill/Lp.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px;
}
#Mm {
text-indent: 16px;
background-image: url(skill/Mm.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px;
}
#M {
text-indent: 16px;
background-image: url(skill/M.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
#Mp {
text-indent: 16px;
background-image: url(skill/Mp.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
#Hm {
text-indent: 16px;
background-image: url(skill/Hm.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
#H {
text-indent: 16px;
background-image: url(skill/H.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
#Hp {
text-indent: 16px;
background-image: url(skill/Hp.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
#Pm {
text-indent: 16px;
background-image: url(skill/Pm.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
#P {
text-indent: 16px;
background-image: url(skill/P.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
#Pp {
text-indent: 16px;
background-image: url(skill/Pp.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
#G {
text-indent: 16px;
background-image: url(skill/G.png);
background-repeat: no-repeat;
color: #000000;
padding: 1px;
font-size: 11px
}
</style>
</head>
<body>
<?php
$link = mysqli_connect("localhost", "-", "-", "-);
if ($link == false){
die("Ошибка: Невозможно подключиться к MySQL " . mysqli_connect_error());
}
print("<h2>Статистика матча</h2>\n");
print("<table width=100%% border=0 align=center cellpadding=0 cellspacing=1>\n");
print("<tr>\n");
print("<th>Игpoк\n");
print("<th>Убитo\n");
print("<th>Cмepтeй\n");
print("<th>Плантов\n");
print("<th>Взрывов\n");
print("<th>Дефузов\n");
print("<th>Skill\n");
print("<th>\n");
print("<th>Результат\n");
print("</tr>\n");
$srv_address = filter_input(INPUT_GET, 'srv_address', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if(!$srv_address) $srv_address = '80.241.246.26:27023';
if(!$srv_address) $srv_address = '80.241.246.26:27017';
if(!$srv_address) $srv_address = '80.241.246.26:27020';
if(!$srv_address) $srv_address = '80.241.246.26:27336';
$sql = "SELECT * FROM `gather_stats` WHERE `srv_address` = '{$srv_address}'";
$row = mysqli_query($link, $sql);
$pos = 1;
while(($result = mysqli_fetch_array($row)))
{
$name = htmlspecialchars($result[ 'name' ]);
$curr_skill = $result[ 'skill_last' ];
$skill_diff = $curr_skill - $result[ 'skill_start' ];
$authid = $result['authid'];
$smt = mysqli_query($link, "SELECT `skill`,`steamid` FROM `csstats` WHERE `steamid` = '{$authid}'");
if(mysqli_num_rows($smt)) $list = mysqli_fetch_array($smt);
printf("<tr id=%s>\n", (($pos % 2) == 1) ? "b" : "q");
printf("<td>%s\n", $name );
printf("<td>%d\n", $result[ 'frags' ]);
printf("<td>%d\n", $result[ 'deaths' ]);
printf("<td>%d\n", $result[ 'plants' ]);
printf("<td>%d\n", $result[ 'explosions' ]);
printf("<td>%d\n", $result[ 'defusions' ]);
printf("<td><span style='background:url(http://fastcup.luxserv.ge//template/img/skill/%s.png); background-repeat: no-repeat;'> <span style='margin-left: 16px;margin-right: 0px;color:#303027'> ". number_format($list['skill'], 0, '.', '') ."</span></span>\n", get_letter($curr_skill, 1));
printf("<td><div id=\"%s\">%.0f</div>\n", get_letter($curr_skill, 0), $curr_skill);
printf("<td>%s%.2f\n", ($skill_diff > 0.0) ? "+" : "", $skill_diff);
print("</tr>\n");
$pos++;
}
print("</table>\n");
$result->close();
$conn->close();
function get_letter($curr_skill, $type = 0)
{
$values = array(
array('skill' => 0.0, 'letter' => 'Lm'),
array('skill' => 70.0, 'letter' => 'L'),
array('skill' => 80.0, 'letter' => 'Lp'),
array('skill' => 90.0, 'letter' => 'Mm'),
array('skill' => 100.0, 'letter' => 'M'),
array('skill' => 110.0, 'letter' => 'Mp'),
array('skill' => 120.0, 'letter' => 'Hm'),
array('skill' => 130.0, 'letter' => 'H'),
array('skill' => 140.0, 'letter' => 'Hp'),
array('skill' => 150.0, 'letter' => 'Pm'),
array('skill' => 160.0, 'letter' => 'P'),
array('skill' => 170.0, 'letter' => 'Pp'),
array('skill' => 180.0, 'letter' => 'G'),
);
$count = count($values);
for($counter = 0; $counter < $count; $counter++) {
if($curr_skill <= $values[$counter]['skill'])
{
break;
}
}
if($type == 0) return sprintf("%s", $values[ min($counter, $count - 1) ]['letter']);else
return $values[$counter]['letter'];
}
?>
</body>
</html>