Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some code cleanup #171

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions server/server
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if ($file = fopen("/home/timezoned/posixinfo", "r")) {
while(!feof($file)) {
$line = fgets($file);
preg_match("/^(.*?) (.*?)$/", $line, $matches);
if ($matches[1] != "" && $matches[2] != "") {
if (count($matches) >= 2 && $matches[1] != "" && $matches[2] != "") {
array_push($tz, array("olsen" => trim($matches[1]), "posix" => trim($matches[2])));
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ while(1)

$parts = explode("#", $packet, 2);
$query = $parts[0];
$version = $parts[1];
// $version = $parts[1];
$process = strtoupper(str_replace(" ", "_", $query));

$logstart = date("D, d M Y H:i:s") . "Z -- $remote_ip:$remote_port --";
Expand Down Expand Up @@ -164,3 +164,5 @@ while(1)
}

socket_close($sock);

?>
25 changes: 19 additions & 6 deletions server/update
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
#!/bin/sh

rm -rf ~timezoned/download
mkdir ~timezoned/download
cd ~timezoned

rm -rf ~timezoned/zoneinfo
mkdir ~timezoned/zoneinfo
# Clear work environment
if [ -e "download" ]; then rm -rf download; fi
mkdir download

if [ -e "zoneinfo" ]; then rm -rf zoneinfo; fi
mkdir zoneinfo

# Download TZ data
cd ~timezoned/download

wget ftp://ftp.iana.org/tz/tzdata-latest.tar.gz
tar zxvf tzdata-latest.tar.gz
rm tzdata-latest.tar.gz
for i in `ls`; do zic -d ~timezoned/zoneinfo $i;done

rm ~timezoned/posixinfo
# Process TZ data

for f in `grep -l "# tzdb data" *`; do zic -d ~timezoned/zoneinfo $f; done
zic -d ~timezoned/zoneinfo backward

# POSIX info
cd ~timezoned/zoneinfo

if [ -e "posixinfo" ]; then
rm posixinfo
touch posixinfo
fi

for i in `find *|grep /`
do
if [ -f $i ]; then
Expand Down