#!/usr/bin/perl use strict; no strict 'vars'; ## ## Settings ## # $opt_configfile - Absolute path and filename of configuration file. $opt_configfile = "./perl.conf"; # $opt_libdir - Directory to look in for local required files # (our *.plib, *.pm files). $opt_libdir = "./"; ## ## ################################################################################ ## No need to edit below this line ## use Getopt::Long; use Time::Local; use IO::Socket; use IO::Select; use DBI; use Digest::MD5; require "$opt_libdir/ConfigReaderSimple.pm"; do "$opt_libdir/perl.plib"; $|=1; Getopt::Long::Configure ("bundling"); $last_trend_timestamp = 0; ## ## MAIN ## # Options $opt_help = 0; $opt_version = 0; $db_host = "localhost"; $db_user = ""; $db_pass = ""; $db_name = ""; $db_lowpriority = 1; $s_ip = ""; $s_port = "27500"; $g_mailto = ""; $g_mailpath = "/bin/mail"; $g_mode = "Normal"; $g_deletedays = 5; $g_minactivity = 28; $g_requiremap = 0; $g_debug = 1; $g_nodebug = 0; $g_rcon = 1; $g_rcon_ignoreself = 0; $g_rcon_record = 1; $g_stdin = 0; $g_server_ip = ""; $g_server_port = 27015; $g_timestamp = 0; $g_dns_resolveip = 1; $g_dns_timeout = 5; $g_skill_maxchange = 100; $g_skill_minchange = 2; $g_player_minkills = 50; $g_bot_ids = "BOT:0"; $g_onlyconfig_servers = 1; $g_track_stats_trend = 0; %g_lan_noplayerinfo = (); %g_preconnect = (); $g_global_banning = 0; $g_masterserver_address = ""; $g_masterserver_port = ""; $g_statsserver_address = ""; $g_statsserver_port = ""; $g_log_chat = 0; $g_log_chat_admins = 0; $g_global_chat = 0; # Usage message $usage = <new($opt_configfile); $conf->parse(); %directives = ( "DBHost", "db_host", "DBUsername", "db_user", "DBPassword", "db_pass", "DBName", "db_name", "DBUsername2", "db_user2", "DBPassword2", "db_pass2", "DBName2", "db_name2", "DBLowPriority", "db_lowpriority", "BindIP", "s_ip", "Port", "s_port", "MailTo", "g_mailto", "MailPath", "g_mailpath", "Mode", "g_mode", "DeleteDays", "g_deletedays", "MinActivity", "g_minactivity", "DebugLevel", "g_debug", "UseTimestamp", "g_timestamp", "DNSResolveIP", "g_dns_resolveip", "DNSTimeout", "g_dns_timeout", "RconIgnoreSelf", "g_rcon_ignoreself", "Rcon", "g_rcon", "RconRecord", "g_rcon_record", "MinPlayers", "g_minplayers", "SkillMaxChange", "g_skill_maxchange", "SkillMinChange", "g_skill_minchange", "PlayerMinKills", "g_player_minkills", "AllowOnlyConfigServers", "g_onlyconfig_servers", "TrackStatsTrend", "g_track_stats_trend", "GlobalBanning", "g_global_banning", "LogChat", "g_log_chat", "LogChatAdmins", "g_log_chat_admins", "GlobalChat", "g_global_chat" ); &doConf($conf, %directives); #, #"Servers", "g_config_servers" # Connect to the database $db_conn = DBI->connect( "DBI:mysql:$db_name:$db_host", $db_user, $db_pass ) or die ("\nCan't connect to MySQL database '$db_name' on '$db_host'\n" . "Server error: $DBI::errstr\n"); &printEvent("MYSQL", "Connecting to MySQL database '$db_name' on '$db_host' as user '$db_user' ... connected ok", 1); $db_conn2 = DBI->connect( "DBI:mysql:$db_name2:$db_host", $db_user2, $db_pass2 ) or die ("\nCan't connect to Global MySQL database '$db_name2' on '$db_host2'\n" . "Server error: $DBI::errstr\n"); &printEvent("MYSQL", "Connecting to Global MySQL database '$db_name2' on '$db_host' as user '$db_user2' ... connected ok", 1); my $query = " SELECT * FROM hlstats_Servers "; my $result = &doQuery($query); my $hash_ref; # mit jedem Durchlauf gibt es eine neue Variable $hash_ref mit eigener Speicheradresse while ( my $hash_ref = $db_conn->fetchrow_hashref( $result ) ) { # $hash_ref nicht dereferenzieren, weil wir einen AoH aufbauen; perldoc perldsc $g_config_servers[ $hash_ref->{'serverId'} ] = $hash_ref; print $hash_ref; }