Raised This Month: $51 Target: $400
 12% 

adding Nav-Button "Last 24h connected"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sil_El_mot
Member
Join Date: Jan 2015
Old 08-12-2015 , 08:47   adding Nav-Button "Last 24h connected"
Reply With Quote #1

Hey there.
i thought i better (so it wont get lost) add the changes i made in order to add a button called "last"
which shows the players that connected in the last 24h to your server ordered by last connection time!
This button is optional in the admin-settings like the "chat" or "bans"-button is.
Example on http://sils-server.ask53.de/hlstats....=insurgency_mm
so, lets start:

the MYSQL-Part:

go to hlstats_Options and add
Code:
Keyname: nav_lastcon
value: 1
opttype: 2
in hlstats_OptionChoices add
Code:
Keyname:nav_lastcon
value: 1
text: Show
isDefault: 1
Code:
Keyname:nav_lastcon
value: 0
text: Hide
isDefault: 0
Now the html-part:

in pages/admintasks/options.php add after line 212
PHP Code:
$optiongroups[0]->options[] = new Option('nav_cheaters''Show Banned Players nav-link''select'); 
the following line:
PHP Code:
$optiongroups[0]->options[] = new Option('nav_lastcon''Show Last connected Players''select'); 
now you have the settings set for your admin-panel.

in hlstats.php add in line 186 after 'bans',
HTML Code:
'last',
in /pages/header.php add on line 333
after:
HTML Code:
            <li><a href="<?php echo $g_options['scripturl'] . "?mode=bans&amp;game=$game"; ?>" class="fHeading"><img src="<?php echo $iconpath; ?>/nav-bans.png" alt="Banned" /></a> <a href="<?php echo $g_options['scripturl'] . "?mode=bans&amp;game=$game"; ?>" class="fHeading">Bans</a></li>
PHP Code:
<?php
    

    if (
$g_options['nav_lastcon'] == 1) {
?>
            <li><a href="<?php echo $g_options['scripturl'] . "?mode=last&amp;game=$game"?>" class="fHeading"><img src="<?php echo $iconpath?>/nav-last.png" alt="Last" /></a> <a href="<?php echo $g_options['scripturl'] . "?mode=last&amp;game=$game"?>" class="fHeading">Last</a></li>
so that it now looks like this:

PHP Code:
    $result = $db->query("SELECT game from hlstats_Roles WHERE game='$game' AND hidden = '0'");
    $numitems = $db->num_rows($result);
    if ($numitems > 0) {
?>
            <li><a href="<?php echo $g_options['scripturl'] . "?mode=roles&amp;game=$game"?>" class="fHeading"><img src="<?php echo $iconpath?>/nav-roles.png" alt="Roles" /></a> <a href="<?php echo $g_options['scripturl'] . "?mode=roles&amp;game=$game"?>" class="fHeading">Roles</a></li>
<?php
    
}
    if (
$g_options['nav_cheaters'] == 1) {
?>
            <li><a href="<?php echo $g_options['scripturl'] . "?mode=bans&amp;game=$game"?>" class="fHeading"><img src="<?php echo $iconpath?>/nav-bans.png" alt="Banned" /></a> <a href="<?php echo $g_options['scripturl'] . "?mode=bans&amp;game=$game"?>" class="fHeading">Bans</a></li>
<?php
    

    if (
$g_options['nav_lastcon'] == 1) {
?>
            <li><a href="<?php echo $g_options['scripturl'] . "?mode=last&amp;game=$game"?>" class="fHeading"><img src="<?php echo $iconpath?>/nav-last.png" alt="Last" /></a> <a href="<?php echo $g_options['scripturl'] . "?mode=last&amp;game=$game"?>" class="fHeading">Last</a></li>
<?php
    

?>
    </ul>
... so now the option is integrated in the header. all we need now is an icon and the "last.php"

in /pages/ create a ne file called "last.php" and copy n paste this code into it:
(or download it here (with icon): http://www.file-upload.net/download-10836129/nav_last.rar.html)

PHP Code:
<?php

    
if ( !defined('IN_HLSTATS') )
    {
        die(
'Do not access this file directly.');
    }
// Player Rankings
    
$db->query
    
("
        SELECT
            hlstats_Games.name
        FROM
            hlstats_Games
        WHERE
            hlstats_Games.code = '
$game'
    "
);
    if (
$db->num_rows() < 1error("No such game '$game'.");
        
$time time() - (24 60 60);
    list(
$gamename) = $db->fetch_row();
    
$db->free_result();
    if (isset(
$_GET['minkills']))
    {
        
$minkills valid_request(intval($_GET['minkills']),1);
    }
    else
    {
        
$minkills 1;
    }
    
pageHeader
    
(
        array (
$gamename'Last 24h Connected'),
        array (
$gamename=>"%s?game=$game"'Last 24h Connected'=>'')
    );
    
$table = new Table
    
(
        array(
            new 
TableColumn
            
(
                
'lastName',
                
'Player',
                
'width=26&flag=1&link=' urlencode('mode=playerinfo&amp;player=%k')
            ),
            new 
TableColumn
            
(
                
'con_date',
                
'Last Connect',
                
'width=15&align=right'
            
),
            new 
TableColumn
            
(
                
'skill',
                
'Points',
                
'width=6&align=right'
            
),
            new 
TableColumn
            
(
                
'activity',
                
'Activity',
                
'width=10&sort=no&type=bargraph'
            
),
            new 
TableColumn
            
(
                
'kills',
                
'Kills',
                
'width=5&align=right'
            
),
            new 
TableColumn
            
(
                
'deaths',
                
'Deaths',
                
'width=5&align=right'
            
),
            new 
TableColumn
            
(
                
'headshots',
                
'Headshots',
                
'width=7&align=right'
            
),
            new 
TableColumn
            
(
                
'kpd',
                
'K:D',
                
'width=10&align=right'
            
),
            new 
TableColumn
            
(
                
'hpk',
                
'HS:K',
                
'width=5&align=right'
            
),
            new 
TableColumn
            
(
                
'acc',
                
'Accuracy',
                
'width=6&align=right&append=' urlencode('%')
            )
        ),
        
'playerId',
        
'last_event',
        
'skill',
        
true
    
);
    
$day_interval 28;
    
$resultCount $db->query
    
("
        SELECT
            COUNT(*)
        FROM
            hlstats_Players
        WHERE
            hlstats_Players.game = '
$game'
            AND hlstats_Players.hideranking = 0
            AND hlstats_Players.kills >= 
$minkills
            AND hlstats_Players.last_event >= 
$time
    "
);
    list(
$numitems) = $db->fetch_row($resultCount);

    
$result $db->query
    
("
        SELECT
            hlstats_Players.playerId,
            FROM_UNIXTIME(last_event,'%Y.%m.%d %T') as con_date,
            hlstats_Players.flag,
                        unhex(replace(hex(hlstats_Players.lastName), 'E280AE', '')) as lastName,
            hlstats_Players.skill,
            hlstats_Players.kills,
            hlstats_Players.deaths,
            IFNULL(ROUND(hlstats_Players.kills / IF(hlstats_Players.deaths = 0, 1, hlstats_Players.deaths), 2), '-') AS kpd,
            hlstats_Players.headshots,
            IFNULL(ROUND(hlstats_Players.headshots / hlstats_Players.kills, 2), '-') AS hpk,
            IFNULL(ROUND((hlstats_Players.hits / hlstats_Players.shots * 100), 0), 0) AS acc,
            activity
        FROM
            hlstats_Players
        WHERE
            hlstats_Players.game = '
$game'
            AND hlstats_Players.hideranking = 0
            AND hlstats_Players.kills >= 
$minkills
            AND hlstats_Players.last_event >= 
$time
        ORDER BY
            
$table->sort $table->sortorder,
            
$table->sort2 $table->sortorder,
            hlstats_Players.lastName ASC
        LIMIT
            
$table->startitem,
            
$table->numperpage
    "
);
?>

<div class="block">
    <?php printSectionTitle('Last 24h Connected'); ?>
        <div class="subblock">
            <div style="float:left;">
                <form method="get" action="<?php echo $g_options['scripturl']; ?>">
                    <input type="hidden" name="mode" value="search" />
                    <input type="hidden" name="game" value="<?php echo $game?>" />
                    <input type="hidden" name="st" value="player" />
                    <strong>•</strong> Find a player:
                    <input type="text" name="q" size="20" maxlength="64" class="textbox" />
                    <input type="submit" value="Search" class="smallsubmit" />
                </form>
            </div>
        </div><br /><br />
        <div style="clear:both;padding-top:4px;"></div>
        <?php $table->draw($result$numitems95); ?><br /><br />
        <div class="subblock">
            <div style="float:left;">
                <form method="get" action="<?php echo $g_options['scripturl']; ?>">
                    <?php
                        
foreach ($_GET as $k=>$v)
                        {
                            
$v valid_request($v0); 
                            if (
$k != "minkills")
                            {
                                echo 
"<input type=\"hidden\" name=\"" htmlspecialchars($k) . "\" value=\"" htmlspecialchars($v) . "\" />\n";
                            }
                        }
                    
?>
                    <strong>•</strong> Show only players with
                    <input type="text" name="minkills" size="4" maxlength="2" value="<?php echo $minkills?>" class="textbox" /> or more kills from a total <strong><?php echo number_format($numitems); ?></strong> players
                    <input type="submit" value="Apply" class="smallsubmit" />
                </form>
            </div>
            <div style="float:right;">
                Go to: <a href="<?php echo $g_options["scripturl"] . "?game=$game"?>"><?php echo $gamename?></a>
            </div>
    </div>
</div>
last but not least you need an icon.
you can create one on your own or take this:
it belongs in following folder: /hlstatsimg/icons/sourcebans/

so.. hope everything works. .. if not write!
sil_El_mot is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode