|
| 1 | +#!/usr/bin/perl |
| 2 | + |
| 3 | +use WebminCore; |
| 4 | +&init_config(); |
| 5 | +&foreign_require("webmin", "webmin-lib.pl"); |
| 6 | + |
| 7 | +my $vc = eval #102 fix |
| 8 | +{ |
| 9 | + require version; |
| 10 | + version->import(); |
| 11 | + 1; |
| 12 | +}; |
| 13 | + |
| 14 | +$webprefix = $gconfig{'webprefix'}; |
| 15 | + |
| 16 | +&ui_print_unbuffered_header(undef, "Filemin Updater", "", undef, 1 , 0, 0); |
| 17 | + |
| 18 | +# Check for updates |
| 19 | +if($remote_user eq 'root' & $vc) { |
| 20 | + print $text{'checking_for_update'}; |
| 21 | + my $url = 'https://github.com/Real-Gecko/filemin/raw/master/module.info'; |
| 22 | + my $tempfile = transname(); |
| 23 | + my %remote_module_info = (); |
| 24 | + my %module_info = (); |
| 25 | + my ($host, $port, $page, $ssl) = &parse_http_url($url); |
| 26 | + &http_download($host, $port, $page, $tempfile, undef, undef, $ssl) |
| 27 | + &read_file($tempfile, \%remote_module_info); |
| 28 | + %module_info = &get_module_info('filemin'); |
| 29 | + my $remote = version->parse($remote_module_info{'version'}); |
| 30 | + my $local = version->parse($module_info{'version'}); |
| 31 | + if($local < $remote) { |
| 32 | + my $os = $gconfig{'os_type'}; |
| 33 | + if(index($os, 'linux') != -1) { |
| 34 | + $os = 'linux'; |
| 35 | + } elsif (index($os, 'freebsd') != -1){ |
| 36 | + $os = 'freebsd'; |
| 37 | + } else { |
| 38 | + &error('WHAT???'); |
| 39 | + } |
| 40 | + my $url = "https://github.com/Real-Gecko/filemin/raw/master/distrib/filemin-$remote.$os.wbm.gz"; |
| 41 | + my $tempfile = transname(); |
| 42 | + my ($host, $port, $page, $ssl) = &parse_http_url($url); |
| 43 | + &http_download($host, $port, $page, $tempfile, undef, \&progress_callback, $ssl); |
| 44 | + $irv = &webmin::install_webmin_module($tempfile); |
| 45 | + if (!ref($irv)) { |
| 46 | + print &text('update_failed', $irv),"<p>\n"; |
| 47 | + } |
| 48 | + else { |
| 49 | + print &text('module_updated', "<b>$irv->[0]->[0]</b>", "<b>$irv->[2]->[0]</b>"),"\n"; |
| 50 | + print "<a href='$webprefix/filemin/index.cgi'>Filemin</a>"; |
| 51 | + } |
| 52 | + } else { |
| 53 | + print $text{'module_up_to_date'}; |
| 54 | + }; |
| 55 | +} |
| 56 | + |
| 57 | +&ui_print_footer("/", $text{'index'}); |
0 commit comments