-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.cgi
92 lines (79 loc) · 3.08 KB
/
index.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/perl
# File manager written in perl
require './filemin-lib.pl';
$usermin = &get_product_name() eq 'usermin';
if(!$usermin) {
&foreign_require("webmin", "webmin-lib.pl");
}
my $vc = eval #102 fix
{
require version;
version->import();
1;
};
#use version;
$webprefix = $gconfig{'webprefix'};
&ui_print_unbuffered_header(undef, "Filemin", "", undef, 1 , 0, 0);
print "<h3>$text{'will_open'} <a target='_blank' href='$webprefix/filemin/filemin.cgi'>$text{'new_tab'}</a><br></h3>";
print "<script>window.open('$webprefix/filemin/filemin.cgi','_blank');</script>";
print "<script src='$webprefix/filemin/unauthenticated/js/markdown.min.js'></script>";
# Check for updates
if($remote_user eq 'root' & $vc & !$usermin) {
# Check if updater is installed
my $updater = &foreign_installed('filemin-updater');
if(!$updater) {
print "Installing updater<br>";
$irv = &webmin::install_webmin_module("$module_root_directory/unauthenticated/filemin-updater.tar.gz");
if (!ref($irv)) {
print "Installation failed $irv<br>";
}
else {
print "Updater Installed <b>$irv->[0]->[0]</b> <b>$irv->[2]->[0]</b><br>";
}
} else {
my %updater_info = &get_module_info('filemin-updater');
$installed = version->parse($updater_info{'version'});
$latest = version->parse('1.0.3');
if ($installed < $latest) {
print "Updating updater<br>";
$irv = &webmin::install_webmin_module("$module_root_directory/unauthenticated/filemin-updater.tar.gz");
if (!ref($irv)) {
print "Update failed $irv<br>";
}
else {
print "Updater updated <b>$irv->[0]->[0]</b> <b>$irv->[2]->[0]</b><br>";
}
}
}
print $text{'checking_for_update'};
my $url = 'https://github.com/Real-Gecko/filemin/raw/master/module.info';
my $tempfile = transname();
my %remote_module_info = ();
my %module_info = ();
my ($host, $port, $page, $ssl) = &parse_http_url($url);
&http_download($host, $port, $page, $tempfile, undef, undef, $ssl)
&read_file($tempfile, \%remote_module_info);
%module_info = &get_module_info('filemin');
my $remote = version->parse($remote_module_info{'version'});
my $local = version->parse($module_info{'version'});
my $flavour = $module_info{'flavour'};
&save_module_config({'flavour' => $flavour}, 'filemin-updater');
if($local < $remote) {
print "<h4>$text{'newer_version_available'}<br><a href='update.cgi?version=$remote'>$text{'click_to_update'}</a></h4>";
} else {
print $text{'module_up_to_date'};
};
}
# Display changelog
if($remote_user eq 'root' & $vc) {
my $changelog = &read_file_contents('CHANGELOG.md');
print '<hr><article id="changelog">';
print $changelog;
print '</article>';
print "<script>\
var changelog = document.getElementById('changelog');
var content = changelog.innerHTML;
changelog.innerHTML = markdown.toHTML(content);
</script>";
}
&ui_print_footer("/", $text{'index'});