Skip to content

Commit

Permalink
Merge pull request #151 from leojonathanoh/feature/bf2sclone-add-envi…
Browse files Browse the repository at this point in the history
…ronment-variables-to-customize-rankings

Feature (bf2sclone): Add environment variables to customize rankings
  • Loading branch information
leojonathanoh authored Jan 28, 2024
2 parents f1f8eb1 + 09ecdd4 commit 6269050
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 39 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ services:
- RANKING_REFRESH_TIME=0
# - RANKING_HIDE_BOTS=false
# - RANKING_HIDE_HIDDEN_PLAYERS=false
# - RANKING_HIDE_PIDS_START=1
# - RANKING_HIDE_PIDS_END=999999999
# - LEADERBOARD_COUNT=25
ports:
- 8082:80
Expand Down
4 changes: 4 additions & 0 deletions src/bf2sclone/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function defineVar($name, $default) {
// Whether to hide hidden players from rankings
defineVar('RANKING_HIDE_HIDDEN_PLAYERS', false);

// Whether to hide a range of PIDs from rankings
defineVar('RANKING_HIDE_PIDS_START', 1);
defineVar('RANKING_HIDE_PIDS_END', 999999999);

// Number of players to show on the leaderboard frontpage
defineVar('LEADERBOARD_COUNT', 25);
?>
6 changes: 6 additions & 0 deletions src/bf2sclone/queries/getEnemiesByPID.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT attacker, count FROM kills INNER JOIN player ON kills.attacker = player.id WHERE victim = $PID $WHERE ORDER BY count DESC LIMIT 11;";
?>
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getLeaderBoardEntry.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = 'SELECT id,name,kills,rank,score,(score/(time/60)) as spm, (kills/deaths) as kdr, time, country FROM player WHERE (';
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getNameFromPID.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT name FROM player WHERE id = $PID $WHERE;";
Expand Down
12 changes: 9 additions & 3 deletions src/bf2sclone/queries/getPIDList.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}

if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,score,(score/(time/60)) as spm, (kills/deaths) as kdr, time, country FROM player WHERE (name LIKE '$SEARCHVALUE' OR name LIKE ' $SEARCHVALUE' OR id = '$SEARCHVALUE') $WHERE ORDER BY score DESC LIMIT 30;";
?>
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getPlayerData.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT * FROM player WHERE id = $PID $WHERE;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getPlayerDataByName.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT * FROM player WHERE name like '$NICK' $WHERE;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankFromPID.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT rank FROM player WHERE id = $PID $WHERE;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopCMD.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,cmdscore/cmdtime as cmd ,country FROM player WHERE 1=1 $WHERE ORDER BY cmd DESC LIMIT 5;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopCaptures.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

#WHERE captures>0
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopCmdScore.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,cmdscore,country FROM player WHERE 1=1 $WHERE ORDER BY cmdscore DESC LIMIT 5;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopFlagwork.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,captureassists+captures+neutralizes+defends as flagwork,country FROM player WHERE 1=1 $WHERE ORDER BY flagwork DESC LIMIT 5;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopKDR.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

#NOTE: minimum 1 death
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopKills.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,kills,country FROM player WHERE 1=1 $WHERE ORDER BY kills DESC LIMIT 5;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopRndScore.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

#NOTE: minimum 1 death
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopSPM.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,score/(time/60) as spm,country FROM player WHERE 1=1 $WHERE ORDER BY spm DESC LIMIT 5;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopSani.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,heals+revives as sani ,country FROM player WHERE 1=1 $WHERE ORDER BY sani DESC LIMIT 5;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopScore.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,score,country FROM player WHERE 1=1 $WHERE ORDER BY score DESC LIMIT 5;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopTeamwork.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id,name,rank,teamscore-(teamdamage+teamkills+teamvehicledamage) as teamwork,country FROM player WHERE teamscore>(teamdamage+teamkills+teamvehicledamage) $WHERE ORDER BY teamwork DESC LIMIT 5;";
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getRankingTopWLR.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

#NOTE: minimum 1 death
Expand Down
10 changes: 8 additions & 2 deletions src/bf2sclone/queries/getTopPlayers.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?php
$WHERE = '';
if (RANKING_HIDE_BOTS) {
$WHERE .= ' AND isbot = 0';
$WHERE .= ' AND player.isbot = 0';
}
if (RANKING_HIDE_HIDDEN_PLAYERS) {
$WHERE .= ' AND hidden = 0';
$WHERE .= ' AND player.hidden = 0';
}
if (RANKING_HIDE_PIDS_START) {
$WHERE .= ' AND player.id >= ' . RANKING_HIDE_PIDS_START;
}
if (RANKING_HIDE_PIDS_END) {
$WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END;
}

$query = "SELECT id, rank, country, name, score, time, (score/(time/60)) as spm, (kills/deaths) as kdr FROM player WHERE 1=1 $WHERE ORDER BY score DESC LIMIT ". LEADERBOARD_COUNT .";";
Expand Down
Loading

0 comments on commit 6269050

Please sign in to comment.