Reupload after bitbucket wipe

This commit is contained in:
Chris Lynch
2013-12-25 18:43:29 -05:00
commit 965453909e
5942 changed files with 99045 additions and 0 deletions

55
scripts/ImportBans/README Normal file
View File

@ -0,0 +1,55 @@
HLStatsX:CE Import Ban Options
----------------------
Description:
HLStatsX:CE has two different scripts to use to import bans from your banning system:
1) ImportBans
ImportBans.pl is a perl script and is the original importing script.
It only imports bans and does not unban a player if they're unbanned from your ban system.
This script supports SourceBans, AMXBans, BeetleMod, and GlobalBan.
You must have perl installed to use this script.
2) hlstatsxbans
Hlstatsxbans is written by Peace-Maker and is written in PHP.
This script will ban AND UNBAN players as they are banned from your banning system.
Forum URL: http://forums.interwavestudios.com/topic/167-import-mysql-bans-to-hlxce-bancheater-page/
This script suports SourceBans, AMXBans, BeetleMod, and GlobalBan.
You must have PHP installed to use this script.
Configuration:
Select which ban system you want to use, either ImportBans or HLStatsXBans. You must then edit the corresponding file.
*run_importbans
** Open run_importbans in a text editor
** Configure "BANSYSTEM" for which script you would like to use.
*ImportBans
** Open ImportBans.pl in a text editor.
** Fill in the HLX DB INFO section (should be same as that found in hlstats.conf in the Perl directory)
** Fill in at least one of the other databases (Sourcebans, AMXBans, BeetlesMod) that you want to import from.
NOTE: You can use any of these databases simultaneously -- fill in the ones you want
to pull from and those databases will be queried.
*HLStatsXBans
** Open HLStatsXBans.cfg in a text editor.
** Fill in the database info for HLX.
** Fill in at least one of the other databases that you want to import from.
Running:
You should run the script manually one time to make sure everything is working.
To run ImportBans, run:
./importbans.pl
To run HLStatsXBans, run:
php hlstatsxbans.php
If everything works, you can either schedule the exact same command you just executed to run at a configured interval or time,
or use the run_importbans wrapper to get logging (great for console use).
To use run_importbans, make sure you have edited the file for which script you want to use, and then simply execute:
./run_importbans.
Note: you will not get any output from this script. Everything is written into your logs/ directory.

View File

@ -0,0 +1,105 @@
<?php
/***************
** Deactivate HLstatsX ranking for banned players
** and reactivate them if unbanned
** Supports SourceBans, AMXBans, Beetlesmod, Globalban, MySQL Banning*
** by Jannik 'Peace-Maker' Hartung
** http://www.sourcebans.net/, http://www.wcfan.de/
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
**
** Version 1.3: Added MySQL Banning support
** Version 1.2: Added more error handling
** Version 1.1: Fixed banned players not marked as banned, if a previous ban was unbanned
** Version 1.0: Initial Release
** YOU MUST ADJUST THIS FILE TO MEET YOUR NEEDS!
** Please fill in AT LEAST one bans database AND
** the HLStatsX Database section! Don't forget the names
** of the HLStatsX Databases near the end of this file!
**************/
//** SOURCEBANS MYSQL INFO ----------------------------
// http://www.sourcebans.net/
define('SB_HOST', 'localhost'); // MySQL host
define('SB_PORT', 3306); // MySQL port (Default 3306)
define('SB_USER', ''); // MySQL user
define('SB_PASS', ''); // MySQL password
define('SB_NAME', ''); // MySQL database name
define('SB_PREFIX', 'sb'); // MySQL table prefix
//** END SOURCEBANS MYSQL INFO ------------------------
//** AMXBANS MYSQL INFO -------------------------------
// http://www.amxbans.net/
define('AMX_HOST', 'localhost'); // MySQL host
define('AMX_PORT', 3306); // MySQL port (Default 3306)
define('AMX_USER', ''); // MySQL user
define('AMX_PASS', ''); // MySQL password
define('AMX_NAME', ''); // MySQL database name
define('AMX_PREFIX', 'amx'); // MySQL table prefix
//** END AMXBANS MYSQL INFO ---------------------------
//** BEETLESMOD MYSQL INFO ----------------------------
// http://www.beetlesmod.com/
define('BM_HOST', 'localhost'); // MySQL host
define('BM_PORT', 3306); // MySQL port (Default 3306)
define('BM_USER', ''); // MySQL user
define('BM_PASS', ''); // MySQL password
define('BM_NAME', ''); // MySQL database name
define('BM_PREFIX', 'bm'); // MySQL table prefix
//** END BEETLESMOD MYSQL INFO ------------------------
//** GLOBALBAN MYSQL INFO -----------------------------
// http://addons.eventscripts.com/addons/view/GlobalBan
// http://forums.eventscripts.com/viewtopic.php?t=14384
define('GB_HOST', 'localhost'); // MySQL host
define('GB_PORT', 3306); // MySQL port (Default 3306)
define('GB_USER', ''); // MySQL user
define('GB_PASS', ''); // MySQL password
define('GB_NAME', 'global_ban'); // MySQL database name
define('GB_PREFIX', 'gban'); // MySQL table prefix
//** END GLOBALBAN MYSQL INFO -------------------------
//** MySQL Banning - MYSQL INFO -----------------------
// http://forums.alliedmods.net/showthread.php?t=65822
define('MB_HOST', 'localhost'); // MySQL host
define('MB_PORT', 3306); // MySQL port (Default 3306)
define('MB_USER', ''); // MySQL user
define('MB_PASS', ''); // MySQL password
define('MB_NAME', ''); // MySQL database name
define('MB_PREFIX', 'mysql'); // MySQL table prefix
//** END MySQL Banning - MYSQL INFO -------------------
//** HLSTATSX MYSQL INFO ------------------------------
// http://www.hlxcommunity.com/
define('HLX_HOST', 'localhost'); // MySQL host
define('HLX_PORT', 3306); // MySQL port (Default 3306)
define('HLX_USER', ''); // MySQL user
define('HLX_PASS', ''); // MySQL password
define('HLX_PREFIX', 'hlstats'); // MySQL table prefix
/*************************************************
/* We're using different databases for each of our server to isolate each ranking
/* Type the HLstatsX database name here like
/* $hlxdbs[] = "databasename";
/* It's fine to just type one database.
**************************************************/
$hlxdbs = array();
$hlxdbs[] = "hlstatsx";
//** END HLSTATSX MYSQL INFO --------------------------
?>

View File

@ -0,0 +1,362 @@
<?php
/***************
** Deactivate HLstatsX ranking for banned players
** and reactivate them if unbanned
** Supports SourceBans, AMXBans, Beetlesmod, Globalban, MySQL Banning*
** by Jannik 'Peace-Maker' Hartung
** http://www.sourcebans.net/, http://www.wcfan.de/
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
**
** Version 1.3: Added MySQL Banning support
** Version 1.2: Added more error handling
** Version 1.1: Fixed banned players not marked as banned, if a previous ban was unbanned
** Version 1.0: Initial Release
***************/
/*****************************
/***MAKE YOUR CONFIGURATION***
/********SETTINGS IN**********
/******hlstatsxban.cfg********
/***** DON'T EDIT BELOW ******
/*****************************/
require("hlstatsxban.cfg");
if (!extension_loaded('mysqli')) {
die("This script requires the MySQLi extension to be enabled. Consult your administrator, or edit your php.ini file, to enable this extension.");
}
$usesb = (SB_HOST == ""||SB_PORT == ""||SB_USER == ""||SB_PASS == ""||SB_NAME == ""||SB_PREFIX == ""?false:true);
$useamx = (AMX_HOST == ""||AMX_PORT == ""||AMX_USER == ""||AMX_PASS == ""||AMX_NAME == ""||AMX_PREFIX == ""?false:true);
$usebm = (BM_HOST == ""||BM_PORT == ""||BM_USER == ""||BM_PASS == ""||BM_NAME == ""||BM_PREFIX == ""?false:true);
$usegb = (GB_HOST == ""||GB_PORT == ""||GB_USER == ""||GB_PASS == ""||GB_NAME == ""||GB_PREFIX == ""?false:true);
$usemb = (MB_HOST == ""||MB_PORT == ""||MB_USER == ""||MB_PASS == ""||MB_NAME == ""||MB_PREFIX == ""?false:true);
$hlxready = (HLX_HOST == ""||HLX_PORT == ""||HLX_USER == ""||HLX_PASS == ""||empty($hlxdbs)||HLX_PREFIX == ""?false:true);
if (!$hlxready || (!$usesb && !$useamx && !$usebm && !$usegb && !$usemb))
die('[-] Please type your database information for HLstatsX and at least for one other ban database.');
$bannedplayers = array();
$unbannedplayers = array();
//------------------------------
// SourceBans Part
//------------------------------
if ($usesb)
{
// Connect to the SourceBans database.
$con = new mysqli(SB_HOST, SB_USER, SB_PASS, SB_NAME, SB_PORT);
if (mysqli_connect_error()) die('[-] Can\'t connect to SourceBans Database (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
print("[+] Successfully connected to SourceBans database. Retrieving bans now.\n");
// Get permanent banned players
$bcnt = 0;
if ($bans = $con->query("SELECT `authid` FROM `".SB_PREFIX."_bans` WHERE `RemoveType` IS NULL AND `length` = 0")) {
while ($banned = $bans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($banned["authid"], $bannedplayers)) {
$bannedplayers[] = $banned["authid"];
++$bcnt;
}
}
}
else {
die('[-] Error retrieving banned players: ' . $con->error);
}
// Read unbanned players
$ubcnt = 0;
if ($unbans = $con->query("SELECT `authid` FROM `".SB_PREFIX."_bans` WHERE `RemoveType` IS NOT NULL AND `RemovedOn` IS NOT NULL")) {
while ($unbanned = $unbans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($unbanned["authid"], $bannedplayers) && !in_array($unbanned["authid"], $unbannedplayers)) {
$unbannedplayers[] = $unbanned["authid"];
++$ubcnt;
}
}
}
else {
die('[-] Error retrieving unbanned players: ' . $con->error);
}
$con->close();
print("[+] Retrieved ".$bcnt." banned and ".$ubcnt." unbanned players from SourceBans.\n");
}
//------------------------------
// AMXBans Part
//------------------------------
if ($useamx)
{
// Connect to the AMXBans database.
$con = new mysqli(AMX_HOST, AMX_USER, AMX_PASS, AMX_NAME, AMX_PORT);
if (mysqli_connect_error()) die('[-] Can\'t connect to AMXBans Database (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
print("[+] Successfully connected to AMXBans database. Retrieving bans now.\n");
// Get permanent banned players
$bcnt = 0;
if ($bans = $con->query("SELECT `player_id` FROM `".AMX_PREFIX."_bans` WHERE `ban_length` = 0")) {
while ($banned = $bans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($banned["player_id"], $bannedplayers))
{
$bannedplayers[] = $banned["player_id"];
++$bcnt;
}
}
} else {
die('[-] Error retrieving banned players: ' . $con->error);
}
// Read unbanned players
$ubcnt = 0;
// Handles (apparently) pre-6.0 version DB or lower
if ($unbans = $con->query("SELECT `player_id` FROM `".AMX_PREFIX."_banhistory` WHERE `ban_length` = 0")) {
while ($unbanned = $unbans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($unbanned["player_id"], $bannedplayers) && !in_array($unbanned["player_id"], $unbannedplayers))
{
$unbannedplayers[] = $unbanned["player_id"];
++$ubcnt;
}
}
}
// Handles (apparently) 6.0 version DB or higher
else if ($unbans = $con->query("SELECT `player_id` FROM `".AMX_PREFIX."_bans` WHERE `expired` = 1")) {
while ($unbanned = $unbans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($unbanned["player_id"], $bannedplayers) && !in_array($unbanned["player_id"], $unbannedplayers))
{
$unbannedplayers[] = $unbanned["player_id"];
++$ubcnt;
}
}
} else {
die('[-] Error retrieving unbanned players: ' . $con->error);
}
$con->close();
print("[+] Retrieved ".$bcnt." banned and ".$ubcnt." unbanned players from AMXBans.\n");
}
//------------------------------
// Beetlesmod Part
//------------------------------
if ($usebm)
{
// Connect to the Beetlesmod database.
$con = new mysqli(BM_HOST, BM_USER, BM_PASS, BM_NAME, BM_PORT);
if (mysqli_connect_error()) die('[-] Can\'t connect to Beetlesmod Database (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
print("[+] Successfully connected to Beetlesmod database. Retrieving bans now.\n");
// Get permanent banned players
$bcnt = 0;
if ($bans = $con->query("SELECT `steamid` FROM `".BM_PREFIX."_bans` WHERE `Until` IS NULL")) {
while ($banned = $bans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($banned["steamid"], $bannedplayers))
{
$bannedplayers[] = $banned["steamid"];
++$bcnt;
}
}
} else {
die('[-] Error retrieving banned players: ' . $con->error);
}
// Read unbanned players
$ubcnt = 0;
if ($unbans = $con->query("SELECT `steamid` FROM `".BM_PREFIX."_bans` WHERE `Until` IS NULL AND `Remove` = 0")) {
while ($unbanned = $unbans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($unbanned["steamid"], $bannedplayers) && !in_array($unbanned["steamid"], $unbannedplayers))
{
$unbannedplayers[] = $unbanned["steamid"];
++$ubcnt;
}
}
} else {
die('[-] Error retrieving unbanned players: ' . $con->error);
}
$con->close();
print("[+] Retrieved ".$bcnt." banned and ".$ubcnt." unbanned players from Beetlesmod.\n");
}
//------------------------------
// Globalban Part
//------------------------------
if ($usegb)
{
// Connect to the Globalban database.
$con = new mysqli(GB_HOST, GB_USER, GB_PASS, GB_NAME, GB_PORT);
if (mysqli_connect_error()) die('[-] Can\'t connect to Globalban Database (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
print("[+] Successfully connected to Globalban database. Retrieving bans now.\n");
// Get permanent banned players
$bcnt = 0;
if ($bans = $con->query("SELECT `steam_id` FROM `".GB_PREFIX."_ban` WHERE `active` = 1 AND `pending` = 0 AND `length` = 0")) {
while ($banned = $bans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($banned["steam_id"], $bannedplayers))
{
$bannedplayers[] = $banned["steam_id"];
++$bcnt;
}
}
} else {
die('[-] Error retrieving banned players: ' . $con->error);
}
// Read unbanned players
$ubcnt = 0;
if ($unbans = $con->query("SELECT `steam_id` FROM `".GB_PREFIX."_ban` WHERE `active` = 0 AND `pending` = 0 AND `length` = 0")) {
while ($unbanned = $unbans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($unbanned["steam_id"], $bannedplayers) && !in_array($unbanned["steam_id"], $unbannedplayers))
{
$unbannedplayers[] = $unbanned["steam_id"];
++$ubcnt;
}
}
} else {
die('[-] Error retrieving unbanned players: ' . $con->error);
}
$con->close();
print("[+] Retrieved ".$bcnt." banned and ".$ubcnt." unbanned players from Globalban.\n");
}
//------------------------------
// MySQL Banning Part
//------------------------------
if ($usemb)
{
// Connect to the MySQL Banning database.
$con = new mysqli(MB_HOST, MB_USER, MB_PASS, MB_NAME, MB_PORT);
if (mysqli_connect_error()) die('[-] Can\'t connect to MySQL Banning Database (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
print("[+] Successfully connected to MySQL Banning database. Retrieving bans now.\n");
// Get permanent banned players
$bcnt = 0;
if ($bans = $con->query("SELECT `steam_id` FROM `".MB_PREFIX."_bans` WHERE `ban_length` = 0")) {
while ($banned = $bans->fetch_array(MYSQL_ASSOC)) {
if(!in_array($banned["steam_id"], $bannedplayers))
{
$bannedplayers[] = $banned["steam_id"];
++$bcnt;
}
}
} else {
die('[-] Error retrieving banned players: ' . $con->error);
}
/****** SM MySQL Banning doesn't provide a ban history AFAIK ******/
// Read unbanned players
// $ubcnt = 0;
// if ($unbans = $con->query("SELECT `steam_id` FROM `".MB_PREFIX."_bans` WHERE `ban_length` = 0")) {
// while ($unbanned = $unbans->fetch_array(MYSQL_ASSOC)) {
// if(!in_array($unbanned["steam_id"], $bannedplayers) && !in_array($unbanned["steam_id"], $unbannedplayers))
// {
// $unbannedplayers[] = $unbanned["steam_id"];
// ++$ubcnt;
// }
// }
// } else {
// die('[-] Error retrieving unbanned players: ' . $con->error);
//}
$con->close();
//print("[+] Retrieved ".$bcnt." banned and ".$ubcnt." unbanned players from MySQL Banning.\n");
print("[+] Retrieved ".$bcnt." banned players from MySQL Banning.\n");
}
//------------------------------
// HLstatsX Part
//------------------------------
if(empty($bannedplayers) && empty($unbannedplayers))
die('[-] Nothing to change. Exiting.');
$bannedsteamids="''";
$unbannedsteamids="''";
if(!empty($bannedplayers))
{
$bannedsteamids = "'";
foreach ($bannedplayers as $steamid)
{
$steamid = preg_replace('/^STEAM_[0-9]+?\:/i','',$steamid);
$bannedsteamids .= $steamid."','";
}
$bannedsteamids .= preg_replace('/\,\'$/','',$steamid);
$bannedsteamids .= "'";
}
if(!empty($unbannedplayers))
{
$unbannedsteamids = "'";
foreach ($unbannedplayers as $steamid)
{
$steamid = preg_replace('/^STEAM_[0-9]+?\:/i','',$steamid);
$unbannedsteamids .= $steamid."','";
}
$unbannedsteamids .= preg_replace('/\,\'$/','',$steamid);
$unbannedsteamids .= "'";
}
// Connection to DB
$hlxcon = new mysqli(HLX_HOST, HLX_USER, HLX_PASS, '', HLX_PORT);
if (mysqli_connect_error()) die('[-] Can\'t connect to HLstatsX Database (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
print("[+] Successfully connected to HLstatsX database server. Updating players...\n");
// Loop through all hlstatsx databases
foreach ($hlxdbs as $hlxdb)
{
$unbancnt = $bancnt = 0;
$hlxcon->select_db($hlxdb);
// Hide all banned players
if ($hlxban = $hlxcon->query("UPDATE `".HLX_PREFIX."_Players` SET `hideranking` = 2 WHERE `hideranking` < 2 AND `playerId` IN (SELECT `playerId` FROM `".HLX_PREFIX."_PlayerUniqueIds` WHERE `uniqueId` IN (".$bannedsteamids."));")) {
$bancnt = ($hlxcon->affected_rows?$hlxcon->affected_rows:0);
}
else {
die('[-] Error hiding banned players: ' . $hlxcon->error);
}
// Show all unbanned players
if ($hlxunban = $hlxcon->query("UPDATE `".HLX_PREFIX."_Players` SET `hideranking` = 0 WHERE `hideranking` = 2 AND `playerId` IN (SELECT `playerId` FROM `".HLX_PREFIX."_PlayerUniqueIds` WHERE `uniqueId` IN (".$unbannedsteamids."));")) {
$unbancnt = ($hlxcon->affected_rows?$hlxcon->affected_rows:0);
if ($bancnt>0||$unbancnt>0) {
print("[+] ".$hlxdb.": ".$bancnt." players were marked as banned, ".$unbancnt." players were reenabled again.\n");
}
else {
print("[-] ".$hlxdb.": No player changed.\n");
}
}
else {
die('[-] Error showing unbanned players: ' . $hlxcon->error);
}
}
$hlxcon->close();
?>

View File

@ -0,0 +1,194 @@
#!/usr/bin/perl
# HLstatsX Community Edition - Real-time player and clan rankings and statistics
# Copyleft (L) 2008-20XX Nicholas Hastings (nshastings@gmail.com)
# http://www.hlxcommunity.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# For support and installation notes visit http://www.hlxcommunity.com
####
# Script to mark banned users in HLstatsX Community Edition from a Sourcebans, AMXBans, Beetlesmod, or ES GlobalBan database (or multiple at once!)
# Last Revised: 2009-07-22 13:35 GMT
# BeetlesMod and GlobalBan support added by Bo Tribun (R3M)
#######################################################################################
# You must fill info out for the HLX DB and at least one of the Bans databases
#######################################################################################
# Sourcebans DB Info
$sb_dbhost = "localhost";
$sb_dbport = 3306;
$sb_dbuser = "";
$sb_dbpass = "";
$sb_dbname = "";
$sb_prefix = "sb_"; # be sure to include the underscore (_)
# AMXBans DB Info
$amxb_dbhost = "localhost";
$amxb_dbport = 3306;
$amxb_dbuser = "";
$amxb_dbpass = "";
$amxb_dbname = "";
# BeetlesMod DB Info
$bm_dbhost = "localhost";
$bm_dbport = 3306;
$bm_dbuser = "";
$bm_dbpass = "";
$bm_dbname = "";
# ES GlobalBan DB Info
$gb_dbhost = "localhost";
$gb_dbport = 3306;
$gb_dbuser = "";
$gb_dbpass = "";
$gb_dbname = "";
# HLX DB Info
$hlx_dbhost = "localhost";
$hlx_dbport = 3306;
$hlx_dbuser = "";
$hlx_dbpass = "";
$hlx_dbname = "";
##
##
################################################################################
## No need to edit below this line
##
use DBI;
$havesbinfo = ($sb_dbhost eq "" || $sb_dbuser eq "" || $sb_dbpass eq "" || $sb_dbname eq "")?0:1;
$haveamxbinfo = ($amxb_dbhost eq "" || $amxb_dbuser eq "" || $amxb_dbpass eq "" || $amxb_dbname eq "")?0:1;
$havebminfo = ($bm_dbhost eq "" || $bm_dbuser eq "" || $bm_dbpass eq "" || $bm_dbname eq "")?0:1;
$havegbinfo = ($gb_dbhost eq "" || $gb_dbuser eq "" || $gb_dbpass eq "" || $gb_dbname eq "")?0:1;
$havehlxinfo = ($hlx_dbhost eq "" || $hlx_dbuser eq "" || $hlx_dbpass eq "" || $hlx_dbname eq "")?0:1;
die("DB login info incomplete. Exiting\n") if ($havehlxinfo == 0 || ($havesbinfo == 0 && $haveamxbinfo == 0 && $havebminfo == 0 && $havegbinfo == 0));
@steamids = ();
if ($havesbinfo) {
print "Connecting to Sourcebans database...\n";
my $sb_dbconn = DBI->connect(
"DBI:mysql:database=$sb_dbname;host=$sb_dbhost;port=$sb_dbport",
$sb_dbuser, $sb_dbpass) or die ("\nCan't connect to Sourcebans database '$sb_dbname' on '$sb_dbhost'\n" .
"Server error: $DBI::errstr\n");
print "Successfully connected to Sourcebans database. Retrieving banned Steam IDs now...\n";
my $result = &doQuery($sb_dbconn, "SELECT `authid` FROM ".$sb_prefix."bans WHERE `length` = 0 AND `RemovedBy` IS NULL");
while ( my($steamid) = $result->fetchrow_array) {
push(@steamids, $steamid);
}
my $rows = $result->rows;
if ($rows) {
print $rows." banned users retrieved from Sourcebans.\n";
}
$sb_dbconn->disconnect;
}
if ($haveamxbinfo) {
print "Connecting to AMXBans database...\n";
my $amxb_dbconn = DBI->connect(
"DBI:mysql:database=$amxb_dbname;host=$amxb_dbhost;port=$amxb_dbport",
$amxb_dbuser, $amxb_dbpass) or die ("\nCan't connect to AMXBans database '$amxb_dbname' on '$amxb_dbhost'\n" .
"Server error: $DBI::errstr\n");
print "Successfully connected to AMXBans database. Retrieving banned Steam IDs now...\n";
my $result = &doQuery($amxb_dbconn, "SELECT `player_id` FROM amx_bans WHERE `ban_length` = 0");
while ( my($steamid) = $result->fetchrow_array) {
push(@steamids, $steamid);
}
my $rows = $result->rows;
if ($rows) {
print $rows." banned users retrieved from AMXBans.\n";
}
$amxb_dbconn->disconnect;
}
if ($havebminfo) {
print "Connecting to BeetlesMod database...\n";
my $bm_dbconn = DBI->connect(
"DBI:mysql:database=$bm_dbname;host=$bm_dbhost;port=$bm_dbport",
$bm_dbuser, $bm_dbpass) or die ("\nCan't connect to BeetlesMod database '$bm_dbname' on '$bm_dbhost'\n" .
"Server error: $DBI::errstr\n");
print "Successfully connected to BeetlesMod database. Retrieving banned Steam IDs now...\n";
my $result = &doQuery($bm_dbconn, "SELECT `steamid` FROM `bm_bans` WHERE `Until` IS NULL");
while ( my($steamid) = $result->fetchrow_array) {
push(@steamids, $steamid);
}
my $rows = $result->rows;
if ($rows) {
print $rows." banned users retrieved from BeetlesMod.\n";
}
$bm_dbconn->disconnect;
}
if ($havegbinfo) {
print "Connecting to ES GlobalBan database...\n";
my $gb_dbconn = DBI->connect(
"DBI:mysql:database=$gb_dbname;host=$gb_dbhost;port=$gb_dbport",
$gb_dbuser, $gb_dbpass) or die ("\nCan't connect to ES GlobalBan database '$gb_dbname' on '$gb_dbhost'\n" .
"Server error: $DBI::errstr\n");
print "Successfully connected to ES GlobalBan database. Retrieving banned Steam IDs now...\n";
my $result = &doQuery($gb_dbconn, "SELECT `steam_id` FROM `gban_ban` WHERE `active` = 1 AND `pending` = 0 AND `length` = 0");
while ( my($steamid) = $result->fetchrow_array) {
push(@steamids, $steamid);
}
my $rows = $result->rows;
if ($rows) {
print $rows." banned users retrieved from ES GlobalBan.\n";
}
$gb_dbconn->disconnect;
}
if (@steamids) {
$steamidstring = "'";
foreach $steamid (@steamids)
{
$steamid =~ s/^STEAM_[0-9]+?\://i;
$steamidstring .= $steamid."','";
}
$steamidstring =~ s/\,\'$//;
print "Connecting to HLX:CE database...\n";
$hlx_dbconn = DBI->connect(
"DBI:mysql:database=$hlx_dbname;host=$hlx_dbhost;port=$hlx_dbport",
$hlx_dbuser, $hlx_dbpass) or die ("\nCan't connect to HLX:CE database '$hlx_dbname' on '$hlx_dbhost'\n" .
"Server error: $DBI::errstr\n");
print "Updating HLX:CE banned players...\n";
$result = &doQuery($hlx_dbconn, "UPDATE `hlstats_Players` SET `hideranking` = 2 WHERE `playerId` IN (SELECT `playerId` FROM hlstats_PlayerUniqueIds WHERE `uniqueId` IN ($steamidstring)) AND `hideranking` < 2");
print $result->rows." users newly marked as banned.\n";
$hlx_dbconn->disconnect;
} else {
die("No banned users found in database(s). Exiting\n");
}
sub doQuery
{
my ($dbconn, $query, $callref) = @_;
my $result = $dbconn->prepare($query) or die("Unable to prepare query:\n$query\n$DBI::errstr\n$callref");
$result->execute or die("Unable to execute query:\n$query\n$DBI::errstr\n$callref");
return $result;
}

View File

@ -0,0 +1,79 @@
#!/bin/bash
# HLstatsX Community Edition - Real-time player and clan rankings and statistics
# Copyleft (L) 2008-20XX Nicholas Hastings (nshastings@gmail.com)
# http://www.hlxcommunity.com
#
# HLstatsX Community Edition is a continuation of
# ELstatsNEO - Real-time player and clan rankings and statistics
# Copyleft (L) 2008-20XX Malte Bayer (steam@neo-soft.org)
# http://ovrsized.neo-soft.org/
#
# ELstatsNEO is an very improved & enhanced - so called Ultra-Humongus Edition of HLstatsX
# HLstatsX - Real-time player and clan rankings and statistics for Half-Life 2
# http://www.hlstatsx.com/
# Copyright (C) 2005-2007 Tobias Oetzel (Tobi@hlstatsx.com)
#
# HLstatsX is an enhanced version of HLstats made by Simon Garner
# HLstats - Real-time player and clan rankings and statistics for Half-Life
# http://sourceforge.net/projects/hlstats/
# Copyright (C) 2001 Simon Garner
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# For support and installation notes visit http://www.hlxcommunity.com
# HLStatsX:CE now has two import ban utilities:
# 1) ImportBans.pl is the original importing script written in perl.
#
# 2) hlstatsxbans.php is written by Peace-Maker and is written in PHP.
#
# More information on these scripts can be found in README.
# Please select your banning system below using the number that corresponds to the ban system above.
BANSYSTEM=1
### Nothing needs to be modified below here ###
# verify that you have a logs directory
if [ ! -d logs ];then
mkdir logs
fi
if [ ! -w logs ];then
echo "you need write access to the logs folder"
exit 1
fi
# print info to the log file and run importbans.pl
echo Importing Bans -- `date +%c` >> logs/log`date +_%Y%m%d`
case $BANSYSTEM in
1)
echo Using importbans.pl >> logs/log`date +_%Y%m%d` 2>&1
./importbans.pl >> logs/log`date +_%Y%m%d` 2>&1
;;
2)
echo Using hlstatsxbans.php >> logs/log`date +_%Y%m%d` 2>&1
/usr/bin/php `pwd`/hlstatsxban.php >> logs/log`date +_%Y%m%d` 2>&1
;;
*)
echo Warning: BANSYSTEM is not correctly configured. Please check your configuration.
;;
esac
echo >> logs/log`date +_%Y%m%d`
exit 0