Merged in pricetx/hlstatsx-community-edition (pull request #2)

GeoLiteCity has a new URL. Updated the script to reflect this change
This commit is contained in:
Christopher Lynch 2015-07-07 20:29:53 -04:00
commit 0aed496f80
2 changed files with 16 additions and 32 deletions

View File

@ -50,37 +50,21 @@ DBPASS=""
#
# database is updated every first tuesday of any month, so download it with that specific date and import it
TODAY_MONTH=$( date +%m )
TODAY_YEAR=$( date +%Y )
if [ $LINUX_OTHER == "1" ]
then CAL_COMMAND="cal -s"
else CAL_COMMAND="cal"
fi
FIRST_TUESDAY_MONTH=$( $CAL_COMMAND $TODAY_MONTH $TODAY_YEAR |
awk '
NR == 1 { next }
NR == 2 { next }
NF <= 4 { next }
NF == 5 { print $1 ; exit }
NF == 6 { print $2 ; exit }
NF == 7 { print $3 ; exit }
' )
DATE=""$TODAY_YEAR""$TODAY_MONTH"0"$FIRST_TUESDAY_MONTH""
DIR="GeoLiteCity_$DATE"
FILE="GeoLiteCity_$DATE.zip"
ls *.csv &>/dev/null && rm *.csv
FILE="GeoLiteCity-latest.zip"
rm -f geoLiteCity_Blocks.csv
rm -f geoLiteCity_Location.csv
rm -f geoLiteCity_Location.csv.temp
rm -f $FILE
[ -f $FILE ] || wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/$FILE || exit 1
unzip -o $FILE || exit 1
mv $DIR/GeoLiteCity-Blocks.csv geoLiteCity_Blocks.csv
mv $DIR/GeoLiteCity-Location.csv geoLiteCity_Location.csv.temp
unzip -jo $FILE || exit 1
mv GeoLiteCity-Blocks.csv geoLiteCity_Blocks.csv
mv GeoLiteCity-Location.csv geoLiteCity_Location.csv.temp
iconv -f ISO-8859-1 -t UTF-8 geoLiteCity_Location.csv.temp > geoLiteCity_Location.csv
mysqlimport -C -d --fields-terminated-by=, --fields-enclosed-by=\" --ignore-lines=2 --default-character-set=utf8 -L -i -h $DBHOST -u $DBUSER --password=$DBPASS $DBNAME geoLiteCity_Blocks.csv
mysqlimport -C -d --fields-terminated-by=, --fields-enclosed-by=\" --ignore-lines=2 --default-character-set=utf8 -L -i -h $DBHOST -u $DBUSER --password=$DBPASS $DBNAME geoLiteCity_Location.csv
# Cleanup
ls *.csv &>/dev/null && rm *.csv
ls *.csv.temp &>/dev/null && rm *.csv.temp
rm $FILE
rmdir $DIR
rm -f geoLiteCity_Blocks.csv
rm -f geoLiteCity_Location.csv
rm -f geoLiteCity_Location.csv.temp
rm -f $FILE

View File

@ -42,7 +42,7 @@ function printMap($type = 'main')
if ($type == 'main')
{
echo ('<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>');
echo ('<script src="//maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>');
}
?>
<script type="text/javascript">
@ -150,7 +150,7 @@ function printMap($type = 'main')
$servers_js = array();
foreach ($map_location['servers'] as $server)
{
$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
$replace_pattern = array("");
$server['name'] = preg_replace($search_pattern, $replace_pattern, $server['name']);
$temp = "[" . $server['serverId'] . ',';
@ -183,7 +183,7 @@ function printMap($type = 'main')
{
$players[$row['cli_lat'] . ',' . $row['cli_lng']] = array('cli_lat' => $row['cli_lat'], 'cli_lng' => $row['cli_lng'], 'cli_city' => $row['cli_city'], 'cli_country' => $row['cli_country']);
}
$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
$replace_pattern = array("");
$row['name'] = preg_replace($search_pattern, $replace_pattern, $row['name']);
@ -246,7 +246,7 @@ function printMap($type = 'main')
'country' => $row['country']
);
}
$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
$replace_pattern = array("");
$row['name'] = preg_replace($search_pattern, $replace_pattern, $row['name']);