gather_stats

Сообщения
368
Реакции
5
Предупреждения
5
Помог
1 раз(а)


Как отсортировать рейтинговый список?
умение - показывать последовательно
P- H+ H H- M+ M M- L+ L L-

1732289214787.png





Код:
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>
 
Сообщения
3,593
Реакции
1,576
Помог
141 раз(а)
Запрос mysql надо переписать
 
Сообщения
264
Реакции
132
Помог
13 раз(а)
Ну как-то так :

Код:
-$sql = "SELECT * FROM `gather_stats` WHERE `srv_address` = '{$srv_address}'";
+$sql = "SELECT * FROM `gather_stats` WHERE `srv_address` = '{$srv_address}' ORDER BY skill_last DESC";
 
Сообщения
368
Реакции
5
Предупреждения
5
Помог
1 раз(а)
Возможно ли, чтобы эти ранги появились по одной ссылке?
https://fastcup.luxserv.ge/info.php?srv_address=80.241.246.26:27017
https://fastcup.luxserv.ge/info.php?srv_address=80.241.246.26:27336
https://fastcup.luxserv.ge/info.php?srv_address=80.241.246.26:27020
https://fastcup.luxserv.ge/info.php?srv_address=80.241.246.26:27023

https://fastcup.luxserv.ge/info.php -
Оба должны быть подключены.
Отдельные ссылки и все по одной ссылк
 
Сообщения
147
Реакции
29
if you want to show stats on site/info.php, without option of adding "?srv_address=XXX" then you need changes in:
Код:
//add somewhere:
$default_addresses = [ '80.241.246.26:27023', '80.241.246.26:27017', '80.241.246.26:27020', '80.241.246.26:27336' ];
foreach ($default_addresses as &$address) { $address = mysqli_real_escape_string($link, $address); }
//change your query to:
$sql = "SELECT * FROM `gather_stats` WHERE `srv_address` IN ('" . implode("','", $default_addresses) . "')";
//you should remove all your code related to:
//'$srv_address', because the link is:  https://fastcup.luxserv.ge/info.php
that should be it...otherwise if u want more flexibility with URL, more changes in code are needed
 
Сообщения
368
Реакции
5
Предупреждения
5
Помог
1 раз(а)
if you want to show stats on site/info.php, without option of adding "?srv_address=XXX" then you need changes in:
Код:
//add somewhere:
$default_addresses = [ '80.241.246.26:27023', '80.241.246.26:27017', '80.241.246.26:27020', '80.241.246.26:27336' ];
foreach ($default_addresses as &$address) { $address = mysqli_real_escape_string($link, $address); }
//change your query to:
$sql = "SELECT * FROM `gather_stats` WHERE `srv_address` IN ('" . implode("','", $default_addresses) . "')";
//you should remove all your code related to:
//'$srv_address', because the link is:  https://fastcup.luxserv.ge/info.php
that should be it...otherwise if u want more flexibility with URL, more changes in code are needed
Можете ли вы написать мне полный код?
Код:
<?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", "x", "x", "x");
 
      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);
    
    $sql = "SELECT * FROM `gather_stats` WHERE `srv_address` = '{$srv_address}' ORDER BY skill_last DESC";
    $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>
 
Сообщения
368
Реакции
5
Предупреждения
5
Помог
1 раз(а)
if you want to show stats on site/info.php, without option of adding "?srv_address=XXX" then you need changes in:
Код:
//add somewhere:
$default_addresses = [ '80.241.246.26:27023', '80.241.246.26:27017', '80.241.246.26:27020', '80.241.246.26:27336' ];
foreach ($default_addresses as &$address) { $address = mysqli_real_escape_string($link, $address); }
//change your query to:
$sql = "SELECT * FROM `gather_stats` WHERE `srv_address` IN ('" . implode("','", $default_addresses) . "')";
//you should remove all your code related to:
//'$srv_address', because the link is:  https://fastcup.luxserv.ge/info.php
that should be it...otherwise if u want more flexibility with URL, more changes in code are needed
IP-адреса писать не нужно. Это уже видно.
Все хорошо и работает.

Мне было интересно, как объединить ранги всех игроков, чтобы показать их в одной ссылке.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу