mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
New version message
This commit is contained in:
@@ -37,6 +37,23 @@ elsif ($err) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if new version is out, if we haven't checked in the last 6 hours
|
||||
if (time() - $config{'last_check'} > 6*60*60) {
|
||||
my $sz = &check_server_download_size();
|
||||
$config{'last_check'} = time();
|
||||
&save_module_config();
|
||||
my $jar = $config{'minecraft_jar'} ||
|
||||
$config{'minecraft_dir'}."/"."minecraft_server.jar";
|
||||
my @st = stat($jar);
|
||||
if (@st && $sz && $st[7] != $sz) {
|
||||
print "<center>\n";
|
||||
print &ui_form_start("download.cgi");
|
||||
print "<b>$text{'index_upgradedesc'}</b>\n";
|
||||
print &ui_form_end([ [ undef, $text{'index_upgrade'} ] ]);
|
||||
print "</center>\n";
|
||||
}
|
||||
}
|
||||
|
||||
my @links = ( "edit_conf.cgi", "edit_users.cgi",
|
||||
"view_logs.cgi", "list_conns.cgi",
|
||||
"list_worlds.cgi", "edit_cmds.cgi",
|
||||
|
||||
@@ -17,6 +17,8 @@ index_atbootdesc=Change this option to control whether the Minecraft server is s
|
||||
index_return=module index
|
||||
index_download=Download Server
|
||||
index_downloaddesc=Click this button to download and install the latest version of the Minecraft server JAR file.
|
||||
index_upgradedesc=A new Minecraft server version is now available for download.
|
||||
index_upgrade=Upgrade Now
|
||||
|
||||
check_edir=The base directory $1 does not exist
|
||||
check_ejar=The server JAR file $1 does not exist
|
||||
|
||||
@@ -570,4 +570,39 @@ eval("\$str = \"$str\"");
|
||||
return $str;
|
||||
}
|
||||
|
||||
# check_server_download_size()
|
||||
# Returns the size in bytes of the minecraft server that is available
|
||||
# for download
|
||||
sub check_server_download_size
|
||||
{
|
||||
my ($host, $port, $page, $ssl) = &parse_http_url($server_jar_url);
|
||||
|
||||
# Make HTTP connection
|
||||
my @headers;
|
||||
push(@headers, [ "Host", $host ]);
|
||||
push(@headers, [ "User-agent", "Webmin" ]);
|
||||
push(@headers, [ "Accept-language", "en" ]);
|
||||
alarm(5);
|
||||
my $h = &make_http_connection($host, $port, $ssl, "HEAD", $page, \@headers);
|
||||
alarm(0);
|
||||
return undef if (!ref($h));
|
||||
|
||||
# Read headers
|
||||
my $line;
|
||||
($line = &read_http_connection($_[0])) =~ tr/\r\n//d;
|
||||
if ($line !~ /^HTTP\/1\..\s+(200)(\s+|$)/) {
|
||||
return undef;
|
||||
}
|
||||
my %header;
|
||||
while(1) {
|
||||
$line = &read_http_connection($_[0]);
|
||||
$line =~ tr/\r\n//d;
|
||||
$line =~ /^(\S+):\s+(.*)$/ || last;
|
||||
$header{lc($1)} = $2;
|
||||
}
|
||||
|
||||
&close_http_connection($h);
|
||||
return $header{'content-length'};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user