InterWave Forums: Top 10 php gets banned/inactive players - InterWave Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Top 10 php gets banned/inactive players

#1 User is offline   propaganda 

  • Member
  • PipPip
  • Group: Members
  • Posts: 28
  • Joined: 31-August 09

Posted 07 March 2010 - 05:15 PM

I took Stachis Top 10 code and edited it a bit to work on our e107 site. The issue I have is even though banned or people flagged as incative don't show in the stats page they show on my top 10 on the main page. What can I do to prevent this? Here is the code.

<?php
/*
Script written by stachi
Contact: stachi@gfbg-clan.de
Version: 1.3
   
No Copyright feel free to use and edit.
*/
  define('IN_HLSTATS', true);
 
  require('config.php');
  require(INCLUDE_PATH . "/class_db.php");
  require(INCLUDE_PATH . "/functions.php");
 
  $db_classname = 'DB_' . DB_TYPE;
  if ( class_exists($db_classname) ) {
    $db = new $db_classname(DB_ADDR, DB_USER, DB_PASS, DB_NAME, DB_PCONNECT);
  }else{
    error('Database class does not exist.  Please check your config.php file for DB_TYPE');
  }
 
  $game = 'tf'; 
  if ((isset($_GET['game'])) && (is_string($_GET['game'])))
    $game = valid_request($_GET['game'], 0);

  if ((isset($_GET['server_id'])) && (is_numeric($_GET['server_id'])))
    $server_id = valid_request($_GET['server_id'], 1);


   $player_data_query = $db->query("
      SELECT
      lastName,
      skill,
      kills,
      deaths,
      playerId,
      flag
      FROM
      hlstats_Players
    WHERE
      game='$game'
    ORDER BY
      skill desc
    LIMIT
      0,10");
     
?>

<!-- Theme css -->
<link rel='stylesheet' href='styletop10.css' type='text/css' media='all' />

<table align="center" width="240px" overflow="hidden">
<?php
          $rank="0";
          while($row = $db->fetch_array($player_data_query)) 

          {
              $flagge = $row['flag'];
              if (empty($flagge))
              $flagge="0";
              $flagge = strtolower($flagge);
              $row['flagge'] = '<img border="0" alt="'.$flagge.'" src="hlstatsimg/flags/'.$flagge.'.gif" />';
              $iduser = $row['playerId'];
              $row['nick'] = '<a target="_blank" href="hlstats.php?mode=playerinfo&amp;player='.$iduser.'">'.$row['flagge'].$row['lastName'].'</a>';
              $rank=$rank+1;
              echo "<tr><td>".$rank.".</td><td>".$row['nick']."</td></tr>";
          }
?>
       
</table>

0

#2 User is offline   Nick (psychonic) 

  • HLstatsX:CE Developer
  • PipPipPipPip
  • Group: HLstatsX:CE Developers
  • Posts: 678
  • Joined: 13-August 09
  • SteamID:psychonic

Posted 07 March 2010 - 06:45 PM

Adapted from pages/players.php:

$player_data_query = $db->query("
				SELECT
					hlstats_Players.lastName,
					hlstats_Players.skill,
					hlstats_Players.kills,
					hlstats_Players.deaths,
					hlstats_Players.playerId,
					hlstats_Players.flag
				FROM
					hlstats_Players
				WHERE
					hlstats_Players.game = '$game'
					AND hlstats_Players.hideranking = 0
					AND hlstats_Players.kills >= 1
				ORDER BY
					skill,
					kpd,
					hlstats_Players.lastName ASC
				LIMIT 0, 10
			");

0

#3 User is offline   propaganda 

  • Member
  • PipPip
  • Group: Members
  • Posts: 28
  • Joined: 31-August 09

Posted 07 March 2010 - 07:39 PM

Yeah thanks Nick works only had to change
ORDER BY "skill" to "skill desc" amd removed the kpd and hlstats_Players.lastName ASC

$player_data_query = $db->query("
                                SELECT
                                        hlstats_Players.lastName,
                                        hlstats_Players.skill,
                                        hlstats_Players.kills,
                                        hlstats_Players.deaths,
                                        hlstats_Players.playerId,
                                        hlstats_Players.flag
                                FROM
                                        hlstats_Players
                                WHERE
                                        hlstats_Players.game = '$game'
                                        AND hlstats_Players.hideranking = 0
                                        AND hlstats_Players.kills >= 1
                                ORDER BY
                                        skill desc
                                LIMIT 0, 10");
     
?>

0

#4 User is offline   Nick (psychonic) 

  • HLstatsX:CE Developer
  • PipPipPipPip
  • Group: HLstatsX:CE Developers
  • Posts: 678
  • Joined: 13-August 09
  • SteamID:psychonic

Posted 08 March 2010 - 02:29 PM

View Postpropaganda, on 07 March 2010 - 01:39 PM, said:

Yeah thanks Nick works only had to change
ORDER BY "skill" to "skill desc" amd removed the kpd and hlstats_Players.lastName ASC

$player_data_query = $db->query("
                                SELECT
                                        hlstats_Players.lastName,
                                        hlstats_Players.skill,
                                        hlstats_Players.kills,
                                        hlstats_Players.deaths,
                                        hlstats_Players.playerId,
                                        hlstats_Players.flag
                                FROM
                                        hlstats_Players
                                WHERE
                                        hlstats_Players.game = '$game'
                                        AND hlstats_Players.hideranking = 0
                                        AND hlstats_Players.kills >= 1
                                ORDER BY
                                        skill desc
                                LIMIT 0, 10");
     
?>


The kpd is added to resolve ties (more than one person having the same number of skill points.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users