3 This file must be included by all Webmin CGI scripts, either directly or via
4 another module-specific .pl file. For example :
9 ui_print_header(undef, 'My Module', '');
11 This file in turn includes web-lib-funcs.pl, which is where the majority of
12 the Webmin API functions are defined.
16 # Configuration and spool directories
17 if (!defined($ENV{'WEBMIN_CONFIG'})) {
18 die "WEBMIN_CONFIG not set";
20 $config_directory = $ENV{'WEBMIN_CONFIG'};
21 if (!defined($ENV{'WEBMIN_VAR'})) {
22 open(VARPATH, "$config_directory/var-path");
23 chop($var_directory = <VARPATH>);
27 $var_directory = $ENV{'WEBMIN_VAR'};
30 if ($ENV{'SESSION_ID'}) {
31 # Hide this variable from called programs, but keep it for internal use
32 $main::session_id = $ENV{'SESSION_ID'};
33 delete($ENV{'SESSION_ID'});
35 if ($ENV{'REMOTE_PASS'}) {
36 # Hide the password too
37 $main::remote_pass = $ENV{'REMOTE_PASS'};
38 delete($ENV{'REMOTE_PASS'});
41 if ($> == 0 && $< != 0 && !$ENV{'FOREIGN_MODULE_NAME'}) {
42 # Looks like we are running setuid, but the real UID hasn't been set.
43 # Do so now, so that executed programs don't get confused
48 # On Windows, always do IO in binary mode
52 $remote_error_handler = "error";
53 @INC = &unique(@INC, ".");
54 %month_to_number_map = ( 'jan' => 0, 'feb' => 1, 'mar' => 2, 'apr' => 3,
55 'may' => 4, 'jun' => 5, 'jul' => 6, 'aug' => 7,
56 'sep' => 8, 'oct' => 9, 'nov' =>10, 'dec' =>11 );
57 %number_to_month_map = reverse(%month_to_number_map);
58 $main::initial_process_id ||= $$;
59 $main::http_cache_directory = $ENV{'WEBMIN_VAR'}."/cache";
60 $main::default_debug_log_size = 10*1024*1024;
61 $main::default_debug_log_file = $ENV{'WEBMIN_VAR'}."/webmin.debug";
63 $webmin_feedback_address = "feedback\@webmin.com";
64 $default_charset = "iso-8859-1";
66 =head2 unique(string, ...)
68 Returns the unique elements of some array, passed as its parameters.
73 local(%found, @rv, $e);
75 if (!$found{$e}++) { push(@rv, $e); }
80 if (!$done_web_lib_funcs) {
81 local $script = -r '../web-lib-funcs.pl' ? '../web-lib-funcs.pl'