One Hat Cyber Team
  • Dir : ~/usr/share/webmin/authentic-theme/
  • View File Name : authentic.pl
    "; } sub theme_ui_submit { my ($label, $name, $dis, $tags, $icon_class, $btn_class_extra, $text_key) = @_; my ($keys, $class, $icon) = get_button_style($label); if ($icon_class && !$icon) { $icon = ""; } my $ids; $ids = "_s_$main::ui_submit_tcalled" if ($main::ui_submit_tcalled++); my $nbsp; my $clabel; if ($label) { $nbsp = " "; if ($text_key && $text_key =~ /_compound_\w+/) { $clabel = filter_label_compound($label, $text_key); } } # Form attr has to be passed directly to input my $form_value = ""; if ($tags && $tags =~ /form=/) { if ($tags =~ s/(form='([^']*)')//) { $form_value = " $1"; } } return "\n" . "\n"; } sub theme_ui_reset { my ($label, $dis) = @_; my $rv; $rv .= '' . "\n"; return $rv; } sub theme_ui_button { my ($label, $name, $dis, $tags, $icon, $type, $btn_class_extra) = @_; my $rv; my $label_safe = &html_escape($label); my $nbsp; if ($label) { $nbsp = " "; } if ($icon) { $label_safe = "$nbsp$label_safe$nbsp"; } $type = "button" if (!$type); $rv .= "' . "\n"; return $rv; } sub theme_ui_date_input { my ($day, $month, $year, $dayname, $monthname, $yearname, $dis) = @_; my $rv; $rv .= ""; $rv .= &ui_textbox($dayname, $day, 3, $dis); $rv .= &ui_select($monthname, $month, [map {[$_, $text{"smonth_$_"}]} (1 .. 12)], 1, 0, 0, $dis); $rv .= &ui_textbox($yearname, $year, 5, $dis); $rv .= ""; return $rv; } sub theme_ui_pre_footer { my $rv; $rv .= '
    ' . "\n"; $rv .= '
    ' . "\n"; return $rv; } sub theme_ui_tabs_start { my ($tabs, $name, $sel, $border) = @_; my $rv; $rv .= '' . "\n"; $rv .= '
    ' . "\n"; $main::ui_tabs_selected = $sel; $rv .= &ui_hidden($name, $sel) . "\n"; return $rv; } sub theme_ui_tabs_end { my ($border) = @_; my $rv; $rv .= '
    ' . "\n"; return $rv; } sub theme_ui_tabs_start_tab { my ($name, $tab) = @_; my $rv; my $defclass = $tab eq $main::ui_tabs_selected ? 'active' : ''; $rv .= '
    ' . "\n"; return $rv; } sub theme_ui_tabs_end_tab { my $rv; $rv .= '
    ' . "\n"; return $rv; } sub theme_ui_hr { my $rv; $rv .= '
    ' . "\n"; return $rv; } sub theme_ui_alert_box { my ($msg, $class, $style, $new_line, $desc_to_title, $desc_icon) = @_; my ($rv, $type, $tmsg, $fa); if ($class eq "success") { $type = 'alert-success', $tmsg = ($theme_text{'theme_global_success'} . '!'), $fa = 'fa-check-circle'; } elsif ($class eq "info") { $type = 'alert-info', $tmsg = ($theme_text{'theme_global_info'} . '!'), $fa = 'fa-info-circle'; } elsif ($class eq "warn") { $type = 'alert-warning', $tmsg = ($theme_text{'theme_global_warning'} . '!'), $fa = 'fa2 fa2-warning fa-1_15x margined-left--2'; } elsif ($class eq "danger") { $type = 'alert-danger', $tmsg = ($theme_text{'theme_xhred_global_error'} . '!'), $fa = 'fa-bolt'; } elsif ($class eq "danger-fatal") { $type = 'alert-danger-fatal', $tmsg = ($theme_text{'theme_xhred_global_error_fatal'} . '!'), $fa = 'fa-exclamation-triangle'; } my $tmsg_space = " "; if (defined($desc_to_title)) { $tmsg = $desc_to_title || ''; $tmsg_space = '' if (!$tmsg); } if ($desc_icon) { $fa = $desc_icon; } $rv .= '
    ' . "\n"; $rv .= '' . $tmsg_space . '' . $tmsg . ''; $rv .= ($new_line ? '
    ' : ($tmsg_space ? ' ' : '')) . "\n"; $msg =~ s/button class="btn/button class="btn btn-tiny/gm; $msg =~ s/input class="ui_submit/input class="ui_submit btn btn-default btn-xs/gm; $rv .= $msg . "\n"; $rv .= '
    ' . "\n"; return $rv; } sub theme_ui_table_start { my ($heading, $tabletags, $cols, $tds, $rightheading) = @_; if (defined($main::ui_table_cols)) { push(@main::ui_table_cols_stack, $main::ui_table_cols); push(@main::ui_table_pos_stack, $main::ui_table_pos); push(@main::ui_table_default_tds_stack, $main::ui_table_default_tds); } my $colspan = 1; my $rv; $rv .= "
    " . "\n"; if (defined($heading) || defined($rightheading)) { $rv .= ""; if (defined($heading)) { $rv .= ""; } if (defined($rightheading)) { $rv .= ""; $colspan++; } $rv .= "\n"; } $rv .= "
    $heading$rightheading
    " . "\n"; $main::ui_table_cols = $cols || 4; $main::ui_table_pos = 0; $main::ui_table_default_tds = $tds; $rv .= "\n"; return $rv; } sub theme_ui_table_end { my $rv; if ($main::ui_table_cols == 4 && $main::ui_table_pos) { $rv .= &ui_table_row(" ", " "); } if (@main::ui_table_cols_stack) { $main::ui_table_cols = pop(@main::ui_table_cols_stack); $main::ui_table_pos = pop(@main::ui_table_pos_stack); $main::ui_table_default_tds = pop(@main::ui_table_default_tds_stack); } else { $main::ui_table_cols = undef; $main::ui_table_pos = undef; $main::ui_table_default_tds = undef; } $rv .= "
    \n"; return $rv; } sub theme_ui_table_row { my ($label, $value, $cols, $tds, $trs) = @_; $cols ||= 1; $tds ||= $main::ui_table_default_tds; my $rv; if ($main::ui_table_pos + $cols + 1 > $main::ui_table_cols && $main::ui_table_pos != 0) { $rv .= "\n"; $main::ui_table_pos = 0; } # Only allow data-* attributes as other, # like width, can have negative effects my ($tds1, $tds2); $tds1 = $tds->[0] if (ref($tds) && $tds->[0] =~ /^data-/); $tds2 = $tds->[1] if (ref($tds) && $tds->[1] =~ /^data-/); my $trtags_attrs = ref($trs) eq 'ARRAY' && $trs->[0] ? " $trs->[0]" : ""; $trtags_attrs .= " data-row-type='ui-table' data-cell-colspan='$cols'"; $trtags_attrs .= ' data-column-span="all" data-column-locked="1"' if ($cols == 2 && !length($label)); my $trtags_class = ref($trs) eq 'ARRAY' && $trs->[1] ? " class='$trs->[1]'" : ""; $rv .= "\n" if ($main::ui_table_pos % $main::ui_table_cols == 0); $rv .= "$label\n" if (defined($label)); $rv .= '' . $value . ''; $main::ui_table_pos += $cols + (defined($label) ? 1 : 0); if ($main::ui_table_pos % $main::ui_table_cols == 0) { $rv .= "\n"; $main::ui_table_pos = 0; } return $rv; } sub theme_ui_table_hr { my $rv; if ($main::ui_table_pos) { $rv .= "\n"; $main::ui_table_pos = 0; } $rv .= " " . "
    \n"; return $rv; } sub theme_ui_opt_textbox { my ($name, $value, $size, $opt1, $opt2, $dis, $extra, $max, $tags, $type) = @_; my $dis1 = &js_disable_inputs([$name, (defined($extra) ? @$extra : ())], []); my $dis2 = &js_disable_inputs([], [$name, (defined($extra) ? @$extra : ())]); my $rv; $type ||= 'text'; $size = &ui_max_text_width($size); $rv .= &ui_radio($name . "_def", $value eq '' ? 1 : 0, [[1, $opt1, "onClick='$dis1'"], [0, $opt2 || " ", "onClick='$dis2'"]], $dis) . "\n"; my $min_width = $size ? '' : ' min-width: 15%;'; $rv .= ""; # Optional (extra) elements must also be disabled (or enabled) on load if (defined($extra)) { $rv .= ""; } return $rv; } sub theme_ui_checked_columns_row { my ($cols, $tdtags, $checkname, $checkvalue, $checked, $disabled, $tags) = @_; my $rv; $rv .= "\n"; $rv .= "[0] : '') . ">
    " . &ui_checkbox($checkname, $checkvalue, undef, $checked, $tags, $disabled, ' thick') . "
    \n"; my $i; for ($i = 0; $i < @$cols; $i++) { $rv .= "[$i + 1] : '') . ">"; if ($cols->[$i] !~ /"; } $rv .= ($cols->[$i] !~ /\S/ ? "
    " : $cols->[$i]); if ($cols->[$i] !~ /\n"; } sub theme_ui_hidden_start { my ($title, $name, $status, $url) = @_; my $rv; if (!$main::ui_hidden_start_donejs++) { $rv .= &ui_hidden_javascript(); } my $divid = "hiddendiv_$name"; my $openerid = "hiddenopener_$name"; my $defclass = $status ? 'opener_shown' : 'opener_hidden'; $rv .= "\n"; $rv .= "$title
    \n"; $rv .= "
    \n"; return $rv; } sub theme_ui_hidden_table_start { my ($heading, $tabletags, $cols, $name, $status, $tds, $rightheading) = @_; my $rv; if (!$main::ui_hidden_start_donejs++) { $rv .= &ui_hidden_javascript(); } my $divid = "hiddendiv_$name"; my $openerid = "hiddenopener_$name"; my $defclass = $status ? 'opener_shown' : 'opener_hidden'; my $text = defined($tconfig{'cs_text'}) ? $tconfig{'cs_text'} : defined($gconfig{'cs_text'}) ? $gconfig{'cs_text'} : "f00"; $rv .= "\n"; my $colspan = 1; if (defined($heading) || defined($rightheading)) { $rv .= ""; } if (defined($rightheading)) { $rv .= ""; $colspan++; } $rv .= "\n"; } $rv .= "
    "; if (defined($heading)) { $rv .= " $heading$rightheading
    \n"; $main::ui_table_cols = $cols || 4; $main::ui_table_pos = 0; $main::ui_table_default_tds = $tds; $rv .= "\n"; return $rv; } sub ui_hidden_table_row_end { return "
    \n"; } sub theme_ui_buttons_start { return "
    \n\n\n HTML } sub theme_ui_buttons_end { return "\n\n\n
    \n"; } sub theme_ui_buttons_row { my ($script, $label, $desc, $hiddens, $after, $before) = @_; if (ref($hiddens)) { $hiddens = join("\n", map {&ui_hidden(@$_)} @$hiddens); } my $btn = ($before ? "$before " : "") . &ui_submit($label) . ($after ? " $after" : ""); return <<"HTML";
    $hiddens
    $btn $desc
    \n"; } sub theme_ui_radio_table { my ($name, $sel, $rows, $nobold) = @_; return "" if (!$rows || !@$rows); my $rv = "\n"; foreach my $r (@$rows) { $rv .= "\n"; $rv .= "[2]) ? "" : " colspan=2") . ">" . ($nobold ? "" : "") . &ui_oneradio($name, $r->[0], $r->[1], $r->[0] eq $sel, $r->[3]) . ($nobold ? "" : "") . "\n"; if (defined($r->[2])) { $rv .= "\n"; } $rv .= "\n"; } $rv .= "
    " . $r->[2] . "
    \n"; return $rv; } sub theme_ui_make_date { my ($date, $ts) = @_; return $date if ($main::webmin_script_type ne 'web' || $main::theme_prevent_make_date); return "$date"; } sub theme_make_date { return theme_make_date_local(@_); } sub theme_nice_size { return theme_nice_size_local(@_); } sub theme_get_webprefix { return theme_get_webprefix_local(@_) if (defined(&theme_get_webprefix_local)); } sub theme_redirect { my $request_uri = navigation_link_clean($ENV{'REQUEST_URI'}); if ($request_uri =~ /noredirect=1/) { head(); return; } my $origin = $ENV{'HTTP_ORIGIN'}; my $referer = navigation_link_clean($ENV{'HTTP_REFERER'}); my $prefix = $theme_webprefix; my $noredir = $gconfig{'webprefixnoredir'}; my $relredir = $gconfig{'relative_redir'}; my ($arg1, $arg2) = (navigation_link_clean($_[0]), navigation_link_clean($_[1])); # Bail out here if the proxy redirect is enforced my ($url_ready, $no_proxy_redirect) = theme_no_proxy_url($_[1]); if ($no_proxy_redirect && $url_ready) { print "Location: $url_ready\n\n"; return; } # Clean redirected links query string if requested if ($request_uri =~ /no-query=string/) { my $nocache = "no-cache=1"; $arg1 =~ s/\.cgi.*/.cgi/; $arg2 =~ s/\.cgi.*/.cgi/; if ($request_uri =~ /\Q$nocache\E/) { $arg1 .= "?" . $nocache; $arg2 .= "?" . $nocache; } } my ($link) = $arg1 || $arg2; my ($url) = $arg2; if (!$relredir) { ($url) = $arg2 =~ /\/\/\S+?(\/.*)/; } $url = "$prefix$url" if ($url && $noredir); theme_redirect_url_alterer(\$url); my ($remote_server_webprefix, $remote_server_linked) = &theme_get_webprefix_local('array'); if ($remote_server_webprefix) { ($link) = $arg2 =~ /:\d+(.*)/; $url = "$remote_server_webprefix$link" if ($url !~ /^$remote_server_webprefix/); } elsif ((string_starts_with($arg1, 'http') && ($arg1 !~ /$origin/ || $referer !~ /$arg1/))) { print "Location: $arg1\n\n"; return; } elsif (string_contains($arg1, '../')) { eval { $main::error_must_die = 1; set_theme_temp_data('redirected', $arg1) if ($arg1 !~ /switch\.cgi/); }; print "Location: $arg1\n\n"; return; } if (!theme_redirect_download($url)) { eval { $main::error_must_die = 1; set_theme_temp_data('redirected', $url) if (!theme_set_redirect_forbidden($url)); }; print "Location: $url\n\n"; } } sub theme_no_proxy_url { my ($url) = @_; if ($url && $url =~ /proxy-redirect=(\S+)/) { $url =~ s{/[^/]+/link\.cgi/\d+/}{/}g; $url =~ s{[?&]proxy-redirect=\d+(?:&|$)}{}; $url =~ s/[?&]$//; $url =~ s{^(?:[a-z][a-z0-9+.-]*:)?//[^/]*}{}i; return ($url, 1); } return ($url, 0); } sub theme_redirect_url_alterer { my ($u) = @_; my ($q) = $u =~ /\.cgi.*(\?)/; my $r = &getvar('navigation-reload'); if ($r) { if ($u !~ /\.cgi/) { if ($u !~ /\/$/) { $$u .= '/'; } $$u .= 'index.cgi'; } my $t = $q ? '&' : '?'; $$u .= "${t}refresh-navigation=1"; } } sub theme_set_redirect_forbidden { my ($url) = @_; if ($url && ($url =~ /\/tunnel\/link\.cgi\//)) { return 1; } return 0; } sub theme_header_redirect_download { my ($url, $delay, $message) = @_; PrintHeader(); print "\n"; print "\n"; print "\n"; print '', "\n"; print "\n"; my $script = '
    '; print "\n"; print $script . "\n"; if ($message) { print $message . "\n"; } print "\n"; print ''; } sub theme_redirect_download { if ($_[0] =~ /fetch.cgi/) { my $query = get_env('query_string'); my $show = $query =~ /show=1/ ? 1 : 0; my $delay = $_[0] =~ /unzip=1/ ? 1 : 0; my $zip = $_[0] =~ /.zip/ ? 1 : 0; my $message; if ($delay) { $message = $theme_text{'theme_xhred_download_is_being_prepared'}; } elsif (!$delay && !$show) { $message = $theme_text{'right_download_is_ready'}; } else { $message = $theme_text{'right_file_is_being_prepared'}; } theme_header_redirect_download($_[0], $delay, $message); return 1; } else { return 0; } } sub theme_js_redirect { my ($url, $window, $timeout) = @_; $window ||= "window"; $timeout ||= 100; if ($url =~ /^\//) { # If the URL is like /foo , add webprefix $url = &get_webprefix().$url; } return "\n"; } sub theme_post_save_domain { my ($d) = @_; print '\n"; } sub theme_post_save_domains { print '\n"; } sub theme_post_save_server { my ($s, $action) = @_; if ($action eq 'create' || $action eq 'delete' || !$done_theme_post_save_server++) { print '\n"; } } sub theme_select_domain { my ($s) = @_; print '\n"; } sub theme_select_server { my ($s) = @_; print '\n"; } sub theme_post_change_theme { # Clear module modifications lib_csf_control('unload'); # Remove error handler error_40x_handler(1); # Remove service worker print '\n"; } sub theme_post_change_modules { print '\n"; } sub theme_ui_text_color { my ($text, $type) = @_; $type = "warning" if ($type eq "warn"); return "$text\n"; } sub theme_error { my ($iref) = @_; my @err_msg = @{$iref->{'err'}}; my @err_stack = @{$iref->{'stack'}}; my $err_caller = $iref->{'err_caller'}; my $main_header = $main::done_webmin_header; my $main_capture = $miniserv::page_capture ? " captured" : ""; my $err_last_eval = $main::error_last_eval; $err_last_eval =~ s/\n$// if ($err_last_eval); &header($text{'error'}, "") if (!$main_header); my $error_what = ($main::whatfailed ? "$main::whatfailed : " : ""); my $error_message = join(", ", @err_msg); my $main_web = $main::webmin_script_type eq 'web'; my $err_caller_msg_esc = "e_escape(($err_last_eval ? "$err_last_eval : $err_caller" : $err_caller), '"'); if ($err_caller && $main_web) { if ($err_last_eval) { $err_caller = &ui_details({ 'title' => $text{'main_error_details'}, 'content' => $err_caller_msg_esc, 'class' =>'error'}, 1); } else { $err_caller = &ui_help(&html_strip($err_caller_msg_esc)) if ($err_caller); } } my $error = $error_what . $error_message . $err_caller; $error = &html_strip($error_what . $error_message . $err_caller) if (!$main_web); my $get_error_stack = sub { # Show call stack my $error_stack = ""; if ($gconfig{'error_stack'}) { $error_stack = "
    " if ($main_header); my $cls_err_caption = " class=\"err-head$main_capture\""; my $cls_err_td = $main_capture ? " class=\"@{[&trim($main_capture)]}\"" : ""; $error_stack .= "
    \n" if ($main_capture); $error_stack .= "$text{'error_stack'}\n"; $error_stack .= "$text{'error_file'} "; $error_stack .= "$text{'error_line'}"; $error_stack .= "$text{'error_sub'}\n"; foreach my $stack (@err_stack) { $error_stack .= "\n"; $error_stack .= "$stack->[1]\n"; $error_stack .= "$stack->[2]\n"; $error_stack .= "$stack->[3]\n"; $error_stack .= "\n"; } $error_stack .= "
    \n"; } return $error_stack; }; if (!$main_header) { print "
    \n"; print "

    $error

    \n"; print &$get_error_stack(); print "
    \n"; if ($ENV{'HTTP_REFERER'} && $main::completed_referers_check) { &footer("javascript:history.back()", $text{'error_previous'}); } } else { print ui_alert_box("$error@{[&$get_error_stack()]}", 'danger-fatal', undef, 1); } } sub theme_ui_page_refresh { return "page_refresh()"; } sub theme_fonts { return embed_css_fonts(1); } sub theme_css_inline { return get_css_inline(@_); } sub theme_forgot_url { my ($baseurl, $id, $username) = @_; my $url = "$baseurl/?forgot=".&urlize($id)."&username=".&urlize($username); $url .= "&return=".&urlize($in{'return'}) if ($in{'return'}); return $url; } sub theme_forgot_handler { my $page = shift; if (!$ENV{'HTTP_X_REQUESTED_WITH'} && !$main::session_id) { my $prefix = &get_webprefix()."/"; # If called from the framed theme if ($page && $page =~ /forgot_form/ && $in{'return'}) { my $return = &un_urlize($in{'return'}); &redirect($prefix."?return=".&urlize($return)); exit; } # Create expected format forgot link that is sent in email elsif ($gconfig{'forgot_pass'} && $page =~ /forgot\.cgi$/) { my ($id) = $ENV{'REQUEST_URI'} =~ /[?&]id=([0-9a-fA-F]{32})/; if ($id) { &redirect("$prefix?forgot=$id"); exit; } } &redirect($prefix); exit; } } sub theme_ui_brh { my $rv; $rv .= "
    " . "\n"; return $rv; } $main::cloudmin_no_create_links = 1; $main::cloudmin_no_edit_buttons = 1; $main::cloudmin_no_global_links = 1; $main::mailbox_no_addressbook_button = 1; $main::mailbox_no_folder_button = 1; $main::basic_virtualmin_menu = 1; $main::basic_virtualmin_domain = 1; $main::nocreate_virtualmin_menu = 1; $main::nosingledomain_virtualmin_mode = 1; 1;