forked from webmin/authentic-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_save.cgi
executable file
·74 lines (61 loc) · 2.14 KB
/
config_save.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
#!/usr/local/bin/perl
#
# Authentic Theme (https://github.com/authentic-theme/authentic-theme)
# Copyright Jamie Cameron <[email protected]>
# Copyright Ilia Rostovtsev <[email protected]>
# Licensed under MIT (https://github.com/authentic-theme/authentic-theme/blob/master/LICENSE)
#
use strict;
use warnings;
our (%text, %in, $root_directory, $config_directory);
require("$ENV{'THEME_ROOT'}/authentic-lib.pl");
require("$root_directory/config-lib.pl");
my (%access,
%newconfig,
%oldconfig,
$module,
$module_dir,
$custom_config,
$config_post_save);
$module = $in{'module'};
&error_setup($text{'config_err'});
&foreign_available($module) || &error($text{'config_eaccess'});
%access = &get_module_acl(undef, $module);
$access{'noconfig'} && &error($text{'config_ecannot'});
mkdir("$config_directory/$module", 0700);
&lock_file("$config_directory/$module/config");
&read_file("$config_directory/$module/config", \%newconfig);
%oldconfig = %newconfig;
$module_dir = &module_root_directory($module);
if (-r "$module_dir/config_info.pl") {
# Module has a custom config editor
&foreign_require($module, "config_info.pl");
my $fn = "${module}::config_form";
if (defined(&$fn)) {
$custom_config++;
&foreign_call($module, "config_save", \%newconfig);
}
}
if (!$custom_config) {
# Use config.info to parse config inputs
&parse_config(\%newconfig, "$module_dir/config.info", $module, undef, $in{'section'});
}
&write_file("$config_directory/$module/config", \%newconfig);
&unlock_file("$config_directory/$module/config");
&save_module_preferences($module, \%newconfig);
# Call any post-config save function
if (&foreign_require($module) &&
&foreign_defined($module, 'config_post_save')) {
&foreign_call($module, "config_post_save", \%newconfig, \%oldconfig);
}
# Refresh installed modules
if (&foreign_check("webmin")) {
&foreign_require("webmin", "webmin-lib.pl");
&webmin::build_installed_modules(0, $module);
}
&webmin_log("_config_", undef, undef, \%in, $module);
if ($in{'save_next'}) {
&redirect("config.cgi?module=$module§ion=$in{'section_next'}");
} else {
&redirect("/$module/");
}