From 09ecdd435699350e9bf482ca96028413431c5667 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Sun, 28 Jan 2024 09:32:56 +0000 Subject: [PATCH] Feature (bf2sclone): Add environment variables to customize rankings --- docker-compose.yml | 2 ++ src/bf2sclone/config.inc.php | 4 ++++ src/bf2sclone/queries/getEnemiesByPID.php | 6 ++++++ src/bf2sclone/queries/getLeaderBoardEntry.php | 10 ++++++++-- src/bf2sclone/queries/getNameFromPID.php | 10 ++++++++-- src/bf2sclone/queries/getPIDList.php | 12 +++++++++--- src/bf2sclone/queries/getPlayerData.php | 10 ++++++++-- src/bf2sclone/queries/getPlayerDataByName.php | 10 ++++++++-- src/bf2sclone/queries/getRankFromPID.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopCMD.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopCaptures.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopCmdScore.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopFlagwork.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopKDR.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopKills.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopRndScore.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopSPM.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopSani.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopScore.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopTeamwork.php | 10 ++++++++-- src/bf2sclone/queries/getRankingTopWLR.php | 10 ++++++++-- src/bf2sclone/queries/getTopPlayers.php | 10 ++++++++-- src/bf2sclone/queries/getVictimsByPID.php | 6 ++++++ 23 files changed, 171 insertions(+), 39 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7a3f12b8..7f348cbf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/src/bf2sclone/config.inc.php b/src/bf2sclone/config.inc.php index 9267dda9..615e7625 100644 --- a/src/bf2sclone/config.inc.php +++ b/src/bf2sclone/config.inc.php @@ -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); ?> diff --git a/src/bf2sclone/queries/getEnemiesByPID.php b/src/bf2sclone/queries/getEnemiesByPID.php index 385b6d77..fd2a4cc3 100644 --- a/src/bf2sclone/queries/getEnemiesByPID.php +++ b/src/bf2sclone/queries/getEnemiesByPID.php @@ -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;"; ?> diff --git a/src/bf2sclone/queries/getLeaderBoardEntry.php b/src/bf2sclone/queries/getLeaderBoardEntry.php index d6ab78fb..473c55e2 100644 --- a/src/bf2sclone/queries/getLeaderBoardEntry.php +++ b/src/bf2sclone/queries/getLeaderBoardEntry.php @@ -1,10 +1,16 @@ = ' . 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 ('; diff --git a/src/bf2sclone/queries/getNameFromPID.php b/src/bf2sclone/queries/getNameFromPID.php index 8864b66a..921c9141 100644 --- a/src/bf2sclone/queries/getNameFromPID.php +++ b/src/bf2sclone/queries/getNameFromPID.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getPIDList.php b/src/bf2sclone/queries/getPIDList.php index 38851002..d1d6ad45 100644 --- a/src/bf2sclone/queries/getPIDList.php +++ b/src/bf2sclone/queries/getPIDList.php @@ -1,11 +1,17 @@ = ' . 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;"; ?> diff --git a/src/bf2sclone/queries/getPlayerData.php b/src/bf2sclone/queries/getPlayerData.php index f051ca86..5f913f57 100644 --- a/src/bf2sclone/queries/getPlayerData.php +++ b/src/bf2sclone/queries/getPlayerData.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getPlayerDataByName.php b/src/bf2sclone/queries/getPlayerDataByName.php index 6a1fff2c..0ad7168f 100644 --- a/src/bf2sclone/queries/getPlayerDataByName.php +++ b/src/bf2sclone/queries/getPlayerDataByName.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankFromPID.php b/src/bf2sclone/queries/getRankFromPID.php index a357b884..198f1353 100644 --- a/src/bf2sclone/queries/getRankFromPID.php +++ b/src/bf2sclone/queries/getRankFromPID.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopCMD.php b/src/bf2sclone/queries/getRankingTopCMD.php index 55512d14..9b71c857 100644 --- a/src/bf2sclone/queries/getRankingTopCMD.php +++ b/src/bf2sclone/queries/getRankingTopCMD.php @@ -2,10 +2,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopCaptures.php b/src/bf2sclone/queries/getRankingTopCaptures.php index 797e4796..b7101173 100644 --- a/src/bf2sclone/queries/getRankingTopCaptures.php +++ b/src/bf2sclone/queries/getRankingTopCaptures.php @@ -1,10 +1,16 @@ = ' . RANKING_HIDE_PIDS_START; + } + if (RANKING_HIDE_PIDS_END) { + $WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END; } #WHERE captures>0 diff --git a/src/bf2sclone/queries/getRankingTopCmdScore.php b/src/bf2sclone/queries/getRankingTopCmdScore.php index dd909299..7b5c1a65 100644 --- a/src/bf2sclone/queries/getRankingTopCmdScore.php +++ b/src/bf2sclone/queries/getRankingTopCmdScore.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopFlagwork.php b/src/bf2sclone/queries/getRankingTopFlagwork.php index 5f8ff33a..2d71b3b3 100644 --- a/src/bf2sclone/queries/getRankingTopFlagwork.php +++ b/src/bf2sclone/queries/getRankingTopFlagwork.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopKDR.php b/src/bf2sclone/queries/getRankingTopKDR.php index 70e34616..c0c5247e 100644 --- a/src/bf2sclone/queries/getRankingTopKDR.php +++ b/src/bf2sclone/queries/getRankingTopKDR.php @@ -1,10 +1,16 @@ = ' . RANKING_HIDE_PIDS_START; + } + if (RANKING_HIDE_PIDS_END) { + $WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END; } #NOTE: minimum 1 death diff --git a/src/bf2sclone/queries/getRankingTopKills.php b/src/bf2sclone/queries/getRankingTopKills.php index 3b0ee1ff..4b319de5 100644 --- a/src/bf2sclone/queries/getRankingTopKills.php +++ b/src/bf2sclone/queries/getRankingTopKills.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopRndScore.php b/src/bf2sclone/queries/getRankingTopRndScore.php index 8f933454..e1127fcb 100644 --- a/src/bf2sclone/queries/getRankingTopRndScore.php +++ b/src/bf2sclone/queries/getRankingTopRndScore.php @@ -1,10 +1,16 @@ = ' . RANKING_HIDE_PIDS_START; + } + if (RANKING_HIDE_PIDS_END) { + $WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END; } #NOTE: minimum 1 death diff --git a/src/bf2sclone/queries/getRankingTopSPM.php b/src/bf2sclone/queries/getRankingTopSPM.php index 4ef51713..8abe4ed8 100644 --- a/src/bf2sclone/queries/getRankingTopSPM.php +++ b/src/bf2sclone/queries/getRankingTopSPM.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopSani.php b/src/bf2sclone/queries/getRankingTopSani.php index 760b42c2..253a1513 100644 --- a/src/bf2sclone/queries/getRankingTopSani.php +++ b/src/bf2sclone/queries/getRankingTopSani.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopScore.php b/src/bf2sclone/queries/getRankingTopScore.php index 3a3d4126..36f1538d 100644 --- a/src/bf2sclone/queries/getRankingTopScore.php +++ b/src/bf2sclone/queries/getRankingTopScore.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopTeamwork.php b/src/bf2sclone/queries/getRankingTopTeamwork.php index 6a6a77f2..45f957fc 100644 --- a/src/bf2sclone/queries/getRankingTopTeamwork.php +++ b/src/bf2sclone/queries/getRankingTopTeamwork.php @@ -1,10 +1,16 @@ = ' . 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;"; diff --git a/src/bf2sclone/queries/getRankingTopWLR.php b/src/bf2sclone/queries/getRankingTopWLR.php index 8312888c..0f87b63b 100644 --- a/src/bf2sclone/queries/getRankingTopWLR.php +++ b/src/bf2sclone/queries/getRankingTopWLR.php @@ -1,10 +1,16 @@ = ' . RANKING_HIDE_PIDS_START; + } + if (RANKING_HIDE_PIDS_END) { + $WHERE .= ' AND player.id <= ' . RANKING_HIDE_PIDS_END; } #NOTE: minimum 1 death diff --git a/src/bf2sclone/queries/getTopPlayers.php b/src/bf2sclone/queries/getTopPlayers.php index e7981d92..3b5f84f8 100644 --- a/src/bf2sclone/queries/getTopPlayers.php +++ b/src/bf2sclone/queries/getTopPlayers.php @@ -1,10 +1,16 @@ = ' . 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 .";"; diff --git a/src/bf2sclone/queries/getVictimsByPID.php b/src/bf2sclone/queries/getVictimsByPID.php index 1cc70cfd..45c04ab6 100644 --- a/src/bf2sclone/queries/getVictimsByPID.php +++ b/src/bf2sclone/queries/getVictimsByPID.php @@ -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 victim, count FROM kills INNER JOIN player ON kills.victim = player.id WHERE attacker = $PID $WHERE ORDER BY count DESC LIMIT 11;"; ?>