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:
		
						commit
						0aed496f80
					
				@ -50,37 +50,21 @@ DBPASS=""
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# database is updated every first tuesday of any month, so download it with that specific date and import it
 | 
					FILE="GeoLiteCity-latest.zip"
 | 
				
			||||||
TODAY_MONTH=$( date +%m )
 | 
					rm -f geoLiteCity_Blocks.csv
 | 
				
			||||||
TODAY_YEAR=$( date +%Y )
 | 
					rm -f geoLiteCity_Location.csv
 | 
				
			||||||
if [ $LINUX_OTHER == "1" ]
 | 
					rm -f geoLiteCity_Location.csv.temp
 | 
				
			||||||
 then CAL_COMMAND="cal -s" 
 | 
					rm -f $FILE
 | 
				
			||||||
 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
 | 
					 | 
				
			||||||
[ -f $FILE ] || wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/$FILE || exit 1
 | 
					[ -f $FILE ] || wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/$FILE || exit 1
 | 
				
			||||||
unzip -o $FILE || exit 1
 | 
					unzip -jo $FILE || exit 1
 | 
				
			||||||
mv $DIR/GeoLiteCity-Blocks.csv geoLiteCity_Blocks.csv
 | 
					mv GeoLiteCity-Blocks.csv geoLiteCity_Blocks.csv
 | 
				
			||||||
mv $DIR/GeoLiteCity-Location.csv geoLiteCity_Location.csv.temp
 | 
					mv GeoLiteCity-Location.csv geoLiteCity_Location.csv.temp
 | 
				
			||||||
iconv -f ISO-8859-1 -t UTF-8 geoLiteCity_Location.csv.temp > geoLiteCity_Location.csv
 | 
					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_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 
 | 
					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
 | 
					# Cleanup
 | 
				
			||||||
ls *.csv &>/dev/null && rm *.csv
 | 
					rm -f geoLiteCity_Blocks.csv
 | 
				
			||||||
ls *.csv.temp &>/dev/null && rm *.csv.temp
 | 
					rm -f geoLiteCity_Location.csv
 | 
				
			||||||
rm $FILE
 | 
					rm -f geoLiteCity_Location.csv.temp
 | 
				
			||||||
rmdir $DIR
 | 
					rm -f $FILE
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ function printMap($type = 'main')
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	if ($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">
 | 
							<script type="text/javascript">
 | 
				
			||||||
@ -150,7 +150,7 @@ function printMap($type = 'main')
 | 
				
			|||||||
					$servers_js = array();
 | 
										$servers_js = array();
 | 
				
			||||||
					foreach ($map_location['servers'] as $server)
 | 
										foreach ($map_location['servers'] as $server)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
 | 
											$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
 | 
				
			||||||
						$replace_pattern = array("");
 | 
											$replace_pattern = array("");
 | 
				
			||||||
						$server['name'] = preg_replace($search_pattern, $replace_pattern, $server['name']);
 | 
											$server['name'] = preg_replace($search_pattern, $replace_pattern, $server['name']);
 | 
				
			||||||
						$temp = "[" . $server['serverId'] . ',';
 | 
											$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']);
 | 
											$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("");
 | 
										$replace_pattern = array("");
 | 
				
			||||||
					$row['name'] = preg_replace($search_pattern, $replace_pattern, $row['name']);
 | 
										$row['name'] = preg_replace($search_pattern, $replace_pattern, $row['name']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -246,7 +246,7 @@ function printMap($type = 'main')
 | 
				
			|||||||
							'country' => $row['country']
 | 
												'country' => $row['country']
 | 
				
			||||||
						);
 | 
											);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
 | 
										$search_pattern = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;߲ł#+~_\-|<>\/@{}äöüÄÖÜ ]/");
 | 
				
			||||||
					$replace_pattern = array("");
 | 
										$replace_pattern = array("");
 | 
				
			||||||
					$row['name'] = preg_replace($search_pattern, $replace_pattern, $row['name']);
 | 
										$row['name'] = preg_replace($search_pattern, $replace_pattern, $row['name']);
 | 
				
			||||||
					
 | 
										
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user