# html-lib.pl # STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo --- license GNU GPL # stta: (@#) 1.31051043346- [2004_01_29_102036] # Common functions # header(title, image, [help], [config], [nomodule], [nowebmin], [rightside], # [header], [body]) # Output a page header with some title and image. The header may also # include a link to help, and a link to the config page. # The header will also have a link to to webmin index, and a link to the # module menu if there is no config link use Net::LDAP::Util qw(ldap_error_name ldap_error_text); sub headerstta { local $text_str; local $html_str; local %minfo=&load_minfo("$root_directory/$module_name/"); &set_interface_colors(); # just to be sure !!! $text_str=" "; $html_str=""; if ( $config{check_services} eq "true" ) { &checkSTTA_services("all","status",\$text_str); } if ($current_theme eq "mscstyle3" && $_[6] =~ //$text{index_title}/ge; } if ( ! -r "$root_directory/$module_name/help/$_[2].html" ) { &header($_[0],$_[1],'',$_[3],$_[4],$_[5],$_[6],$_[7],$_[8]); } else { &header($_[0],$_[1],$_[2],$_[3],$_[4],$_[5],$_[6],$_[7],$_[8]); } print &out_css(); print ""; if ( $config{motd} ne "" && -r $config{motd} ) { print "\n"; } print ""; if ( $config{stta_srvtitle} ne "" ) { print "\n"; } print "
"; print ""; print "
"; print "  "; if ( $config{motd_style} eq "marquee" ) { print ""; } open(MOTDPAGE,$config{motd}); while() { if ( $config{motd_style} ne "marquee" ) { s/\r|\n/
/g; } if (/\S/ && !/^[#\+\-]/) { s/\$(\S+){(\S+)}/text_subs($2,\%{$1})/ge; print $_; } } close MOTDPAGE; if ( $config{motd_style} eq "marquee" ) { print "
"; } print "
"; &out_tabserv_chk(); print ""; print "\n"; print "
$config{stta_srvtitle}
"; print "\n"; } # JavaScript with in depth menu sub js_sttamenu { local %minfo=%{$_[0]}; local $text_str; @line=split(/\//, $config{'tta_daemon'}, -1); $daemonTTA=$line[$#line]; @line=split(/\//, $config{'ldap_daemon'}, -1); $daemonLDAP=$line[$#line]; @line=split(/\//, $config{'ldapache_daemon'}, -1); $daemonLDAPCACHE=$line[$#line]; print " w_stta.document.writeln('');\n"; print " w_stta.document.writeln('');\n"; foreach $item (@ttahosts) { print " w_stta.document.writeln('');\n"; } } print " w_stta.document.writeln('');\n"; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"$text{ttaps_list_title}\");\n"; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"$text{ldapps_list_title}\");\n"; print " w_stta.document.writeln('
  • ');\n"; if ( $config{'is_ldapcache'} eq "true" ) { print " w_stta.document.writeln(\"$text{ldapcacheps_list_title}\");\n"; print " w_stta.document.writeln('
  • ');\n"; } print " w_stta.document.writeln(\"", &html_objlink("config","STTA $text{'config_title'}",\%config,$text{'config_title'},"docwrite"),"\");\n"; if ( $config{check_services} eq "true" ) { print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"", &html_objlink("ttaprops",$text{'index_ttaproperties'},\%ttaprops,$text{index_globaltta},"docwrite"),"\");\n"; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"", &html_objlink("ttaparams tta",$text{ttastatus_title},\%{$sttaparams{tta}},$text{ttastatus_title},"docwrite"),"\");\n"; print" w_stta.document.writeln('
  • ');\n"; print "w_stta.document.writeln(\"", &html_objlink("ttaparams ldap",$text{index_ldap},\%{$sttaparams{ldap}},$text{index_ldap},"docwrite"),"\");\n"; $lnum=0; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"", &html_objlink("host",$item->{name},\%{$ttahosts[$lnum]},$item->{name},"docwrite"),"\");\n"; $lnum++; print" w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"", &html_objlink("module stta",$text{index_module},\%minfo,$text{index_module},"docwrite"),"\");\n"; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"", &html_objlink("access stta",$text{index_acl},\%access,$text{index_acl},"docwrite"),"\");\n"; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"$text{index_alivehosts}\");\n"; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"$text{ldapps_title}\");\n"; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"$text{ldapcacheps_title}\");\n"; print " w_stta.document.writeln('
  • ');\n"; print " w_stta.document.writeln(\"$text{ttaps_title}\");\n"; print " w_stta.document.writeln('

  • ');\n"; } # config_icons(context, program) # Displays up to 17 icons, one for each type of configuration directive, for # some context (global, virtual, directory or htaccess) sub config_icons { local($m, $func, $e, %etype, $i, $c); foreach $m (sort { $a cmp $b } (keys %httpd_modules)) { $func = $m."_directives"; foreach $e (&$func($httpd_modules{$m})) { if ($e->{$_[0]}) { $etype{$e->{'type'}}++; } } } print "\n"; for($i=0; $text{"type_$i"}; $i++) { if ($etype{$i} && $access_types{$i}) { if ($c%5 == 0) { print "\n"; } print "\n"; if ($c%5 == 4) { print "\n"; } $c++; } } for($i=2; $i<@_; $i++) { next if ( !$_[$i]->{'link'} || $_[$i]->{'link'} eq "" ); if ($c%5 == 0) { print "\n"; } print "\n"; if ($c%5 == 4) { print "\n"; } $c++; } print "
    \n"; &generate_icon("images/type_icon_$i.gif", $text{"type_$i"}, $_[1]."type=$i"); print "
    \n"; &generate_icon($_[$i]->{'icon'}, $_[$i]->{'name'}, $_[$i]->{'link'}); print "

    \n"; } sub footHere { if ( $err_msg ) { print "


    \n"; print "\n"; print "
    $err_msg
    \n"; } print "

    \n"; &footer($config{'back_return'},$text{'index'}); print "

    \n"; do "footer.pl"; } # restart_button() # Returns HTML for a link to put in the top-right corner of every page sub restart_button { my $fullOps=0; local $rv=""; if ( $access{stop} ne 1 ) { return } if ( $config{interface} eq "index" ) { $fullOps=1 } if ( $in{cat} eq "admin" || $in{cat} eq "supervision" ) { $fullOps=1 } if ( $fullOps eq 1 || $in{cat} eq "tta" ) { $rv .="$text{'tta_restart'}|\n"; } if ( $fullOps eq 1 || $in{cat} eq "ldap" ) { $rv .= "$text{'ldap_restart'}\n"; } if ( $config{'is_ldapcache'} eq "true" ) { if ( $fullOps eq 1 || $in{cat} eq "ldapcache" ) { $rv .= "|$text{'ldapcache_restart'}\n"; } } return $rv; } # show_error([message]) # Display an error message and exit. The variable $whatfailed must be set # to the name of the operation that failed. sub show_error { print "


    \n"; print "

    ",($whatfailed ? "$whatfailed : " : ""),@_,"

    \n"; print "
    \n"; } sub SrvError { if ( $cginame ne "stta_warn.cgi" ) { &redirect("stta_warn.cgi?msg=$err_msg"); } } # footCacheHere() # Display a message, close tables and put page foot ... # almost ready to exit with good look & feel sub footCacheHere { print "\n"; print "\n"; if ( !$err_msg ) { $err_msg=$text{'ldapcache_disable'}; } print "\n"; print "
    |
    $err_msg

    \n"; &footer($config{'back_return'},$text{'index'}); print "

    \n"; do "footer.pl"; } # htmlCacheapp(msgObj,formObj) # Display all htmls labels to get input for "ttacacheapp" object sub htmlCacheapp { if ( $msgObj eq $text{'default_obj'} ) { print "".&hlink('','cacheobj'); print " $msgObj$text{msg_fieldsreq}\n"; } else { print "$msgObj$text{msg_fieldsreq}\n"; } print " ",&hlink("$text{'f_3tierlogin'}","f3tierlogin"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tierpassword'}","f3tierpassword"),"\n"; print " \n"; print " "; print " ",&hlink("$text{'f_3tiertitle'}","f3tiertitle")," \n"; print " \n"; print " ",&hlink("$text{'f_3tierdomain'}","f3tierdomain"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tierstringcmd'}","f3tierstringcmd"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tierappkey1'}","f3tierappkey1"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tierappkey2'}","f3tierappkey2"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tierappkey3'}","f3tierappkey3"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tierappkey4'}","f3tierappkey4"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tierappkey5'}","f3tierappkey5"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tierappkey6'}","f3tierappkey6"),"\n"; print " \n"; print " ",&hlink("$text{'f_3tiermaxsess'}","f3tiermaxsess")," \n"; if ( $tta3tier_maxsess eq "" ) { $tta3tier_maxsess=$config{default_maxsess}; } print " \n"; if ( $config{'check_ticket'} eq "false" && $tta3tier_ticketstatus eq "" ) { $tta3tier_ticketstatus="no"; } print " ",&hlink("$text{'f_ticketstatus'}","fticketstatus")," \n"; print " ",&hlink("$text{'f_endticket'}","fendticket")," \n"; print " \n"; print " ",&hlink("$text{'f_ticketcounter'}","fticketcounter")," \n"; print " \n"; print " ",&hlink("$text{'f_doifendticket'}","fdoifendticket")," \n"; print " \n"; print "\n"; } #script_cache_chek() #Print javascript lines to check "ttacacheapp" object input fields # sub script_cache_chek { print " if ( emptyField(obj.tta3tier_login) == false ) {\n"; print " if ( emptyField(obj.tta3tier_password) == true ) {\n"; print " alert(obj.tta3tier_password.name+\":\"+msg1+\"->\"+obj.tta3tier_password.value+\"<-\");\n"; print " obj.tta3tier_password.focus();\n"; print " return false;\n"; print " }\n"; print " if ( emptyField(obj.tta3tier_title) == true ) {\n"; print " alert(obj.tta3tier_title.name+\":\"+msg1+\"->\"+obj.tta3tier_title.value+\"<-\");\n"; print " obj.tta3tier_title.focus();\n"; print " return false;\n"; print " }\n"; print " nro=parseInt(obj.tta3tier_maxsess.value);\n"; print " if ( nro+1 > 0) { \n"; print " obj.tta3tier_maxsess.value=nro;\n"; print " } else {;\n"; print " alert(obj.tta3tier_maxsess.name+\":\"+msg1+\"->\"+obj.tta3tier_maxsess.value+\"<-\");\n"; print " obj.tta3tier_maxsess.focus();\n"; print " return false;\n"; print " };\n"; print " if ( get_value(\"select\",obj.tta3tier_ticketstatus) == \"none\" ) {\n"; print " alert(obj.tta3tier_ticketstatus.name+\":\"+msg1+\"->\"+obj.tta3tier_ticketstatus.value+\"<-\");\n"; print " obj.tta3tier_ticketstatus.focus();\n"; print " return false;\n"; print " } \n"; print " if ( get_value(\"select\",obj.tta3tier_ticketstatus) != \"no\" ) {\n"; print " if ( emptyField(obj.tta3tier_endticket) == true ) {\n"; print " alert(obj.tta3tier_endticket.name+\":\"+msg1+\"->\"+obj.tta3tier_endticket.value+\"<-\");\n"; print " obj.tta3tier_endticket.focus();\n"; print " return false;\n"; print " }\n"; print " nro=parseInt(obj.tta3tier_ticketcounter.value);\n"; print " if ( nro+1 > 0) { \n"; print " obj.tta3tier_ticketcounter.value=nro;\n"; print " } else {;\n"; print " alert(obj.tta3tier_ticketcounter.name+\":\"+msg1+\"->\"+obj.tta3tier_ticketcounter.value+\"<-\");\n"; print " obj.tta3tier_ticketcounter.focus();\n"; print " return false;\n"; print " };\n"; print " } \n"; print " }\n"; } # htmlCacheShowPassw(msgObj,formObj) # Display all htmls labels to get input for "ttacacheapp" object sub htmlCacheaShowPassw { print "/******************************************************************\n"; print " showPasswd(formObj)\n"; print " Show Password value from form.\n"; print "*******************************************************************/\n"; print "function showPasswd(formObj) {\n"; print " alert(\"Password:\"+formObj.tta3tier_password.value+\"\");\n"; print "}\n"; } # htmlCheckAlias # Out javascript to control aliases, it is need to get @_ with hash object list sub htmlCheckAlias { local (%h_obj); print "/******************************************************************\n"; print " checkAlias_$_[0](Obj)\n"; print " checkAlias from the array and return false is already exist\n"; print "*******************************************************************/\n"; print "function checkAlias_$_[0](Obj) {\n"; print " var isalready = false; \n"; print " var listAlias = new Array();\n"; if ( "$_[0]" eq "hostaddress" ) { %h_obj=&list_hosts(); } else { %h_obj=eval("\&list_$_[0]()"); } $nItem=0; foreach $item (keys (%h_obj)) { if ( "$_[0]" eq "hostaddress" ) { if ( $ipaddress eq "" && $h_obj{$item}->{'ipname'} ne $ipaddress ) { print " listAlias[".$nItem++."] = \"".$h_obj{$item}->{'ipname'}."\";\n"; } } else { print " listAlias[".$nItem++."] = \"".$h_obj{$item}->{'alias'}."\";\n"; } } print " \n"; print " for (var i=0; i < listAlias.length; i++) {\n"; print " if ( Obj.value == listAlias[i] ) { \n"; print " isalready = true; \n"; print " break;\n"; print " }\n"; print " }\n"; print " if ( isalready == true ) { \n"; print " alert(Obj.name+\":\"+msg1+\"->\"+Obj.value+\"<-\");\n"; print " Obj.focus();\n"; print " }\n"; print " return isalready;\n"; print "}\n"; } # htmlWinLdapUsers(msgObj,formObj) # Open Window to show Users sub htmlWinLdapUsers { print "\n"; } sub outicons_table # This is to output code for the "Tabs" interface menu { local $per=20; local $cols=5; local ($i) = 0; foreach $lnk (@olinks) { print "\n"; print "
    ", "\"\"", "
    \n"; print "$otitles[$i]\n"; $i++; if ($pos++ % $cols == $cols - 1) { print "\n"; } } while($pos++ % $cols) { print "\n"; } print "\n"; } sub outconfig_icons { local $per=20; local $cols=5; local($i); local ($n) = 0; for($i=2; $i<@_; $i++) { next if ( !$_[$i]->{'link'} || $_[$i]->{'link'} eq "" ); print "\n"; print "
    {'link'}>", "{'icon'} alt=\"\" border=0>", "
    \n"; print "{'link'} class='menu1'>$_[$i]->{'name'}\n"; $n++; if ($pos++ % $cols == $cols - 1) { print "\n"; } } while($pos++ % $cols) { print "\n"; } print "\n"; } # html_objlink($type,$object,%{$p},$anchor,$_[4]); # $_[4] = return | print | docwrite | report sub html_objlink { local $text_str=""; local $html_str="STTA: $_[3]"; local $item; return undef if (!%{$_[2]}); $no_out=0; $text_str=""; if ($_[3] eq $text{index_acl} ) { local %h_lst=%{$_[2]}; foreach $item (keys (%h_lst)) { $text_str.=eval("\$text{'acl_$item'}")."==="; if ( $h_lst{$item} eq 1 ) { $text_str.=$text{yes}; } elsif ( $h_lst{$item} eq 0 ) { $text_str.=$text{no}; } else { $text_str.=$h_lst{$item}; } $text_str.="===($item)\n"; } } elsif ( $_[3] eq $text{config_title} ) { local %h_lst=%{$_[2]}; local @configList,@configInfo; &read_file("$root_directory/stta/config.info.$current_lang", \%textcfg); foreach $item (keys (%textcfg)) { push (@configList,{'name' => $item, 'text' => $textcfg{$item}} ); } @configInfo = sort {$a->{text} cmp $b->{text}} @configList; foreach $tcfg (@configInfo) { $item=$tcfg->{name}; @line=(); if ( $textcfg{$item} ne "" ) { @line=split(/,/, $textcfg{$item}, -1); $text_str.=$line[0]."===".$h_lst{$item}."===($item)\n"; } } } else { &show_hash(\%{$_[2]},"","=","",\$text_str); } $text_str=~s/\n/<\/td><\/tr>/g; $text_str=~s/===/<\/td>/g; $html_str.=""; $html_str.="
    $_[0]: $_[1]
    "; $html_str.="
    "; $html_str.="
    $text_str
    "; if ( $_[4] eq "print" ) { print "$_[3]"; } elsif ( $_[4] eq "report" ) { print "$html_str"; } elsif ( $_[4] eq "docwrite" ) { return "$_[3]"; } else { return "$_[3]"; } } sub html_errshow { local $where_err = $_[0]; print "


    \n"; if ( "$where_err" eq "ldap-rep" ) { print "($dn):
    ".$text{'replica_err'} ."-->".$line_conn."
    \n"; print " ".$text{'replica_msg'} ."
    \n"; } elsif ( "$where_err" eq "tta" ) { print "$text{f_error}: $text{'msgerr_tta'}
    \n"; } elsif ( "$where_err" eq "cmd" ) { print "$text{f_error}: $text{'msgerr_cmd'}
    \n"; } elsif ( "$where_err" eq "sync" ) { print "$text{f_error}: ".&text('msgerr_sync',$_[1])."
    \n"; } if ( $err_msg ) { print "$err_msg
    \n"; } if ( $err gt 0 ) { print "$text{f_error} ($err):".eval("\$text{'msgerr_$err'}")."
    \n"; } if ( $debug gt 0 ) { print &text('viewlog_action',$stta_sid); } print "
    \n"; if ( $config{'iferror_objects'} eq "stop" ) { $err_msg=$text{'error_found'}; &footHere; exit; } } sub out_htmlfile { local $to_out= "0"; unless ( open(INDEXPAGE,$_[0]) ) { return -1} @ary = ; close INDEXPAGE; foreach $line (@ary) { if ( $line =~/^<\/BODY/ || $line =~/^<\/body/ ) { $to_out="0" } if ( $to_out eq "1" ) { if ( $_[1] ) { ${$_[1]}.=$line; } else { # chomp ($line); print "$line\n"; } } if ( $line =~/^{'args'} =~ /\Q$matchPS\E/i } @procs; # Ignore this process and any children # @dis = grep { $_->{'pid'} != $$ && $_->{'ppid'} != $$ } @dis; # display matches if (@dis) { if ( $out_html eq 1 ) { print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; } foreach $d (@dis) { $p = $d->{'pid'}; push(@pidlist, $p); if ( $out_html eq 1 ) { if ($edit_ps eq 1 ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; } } if ( $out_html eq 1 ) { print "
    $text{'pid'}$text{'owner'}$text{'cpu'}$text{'command'}
    ", "$p $d->{ppid}
    $p - $d->{ppid}$d->{user}$d->{cpu}",&html_escape(foreign_call("proc", "cut_string",$d->{args})); #cut_string($d->{args})), "

    \n"; } } if ( $_[3] ) { $| =1; select(STDOUT);} return @pidlist; } sub show_tta_serv_table { if ( $ReportOut ) { select(REPORTOUT)} &load_ttaprops(); &scanSTTA_services("all"); $text_str=""; &checkSTTA_services("all","status",\$text_str); &printSTTA_config(\$text_str,"="); $text_str=~s/STTA:/

  • /g; $text_str=~s/\n/<\/b><\/td><\/tr>/g; $text_str=~s/==//g; $html_str.=""; $html_str.="\n"; } sub show_procServ { my ($serv) = $_[0] || return undef; my ($outhtml) = $_[1] || 1; my ($edit_ps) = $_[2] || 1; if ( $ReportOut ) { select(REPORTOUT)} $title_list=$serv."ps_list_title"; $title_idx=$serv."ps_title"; print "\n"; $daemon=$serv."_daemon"; @line=split(/\//, $config{$daemon}, -1); $daemonStr=$line[$#line]; return &get_processes_list($daemonStr,$outhtml,$edit_ps); } sub check_ps_serv { if ( $ReportOut ) { select(REPORTOUT)} print "
    ".$text{srvSTATUS}."
    "; $html_str.="
      $text_str
    "; $html_str.="
    "; print $html_str; print "
    $text{$title_idx}
    "; print "\n"; @ttaps=&show_procServ("tta"); print "
    "; print "\n"; @ldapps=&show_procServ("ldap",1,1,\$_[0]); if ( $config{'is_ldapcache'} ne "true" ) { return } print "
    "; print "\n"; @ldapcacheps=&show_procServ("ldapcache"); } sub check_ttabase { if ( $ReportOut ) { select(REPORTOUT)} if ( $debug eq 0 ) { $debug=1 }; print "
    \n"; print "\n"; # loading object attributes ... $ens_obj=$config{tta_base}; $op="attributes"; $type_cmd="attributes"; $status_cmd=&run_tta_cmd($type_cmd,$ens_obj); if ( !$status_cmd ) { print ""; &html_errshow("tta"); } else { # Assigning and collecting values to be used in the form ... %h_ttaobj=&load_ttaobj(); } if ( $debug lt 2 ) { unlink($temp_f); } print "\n"; print &parse_webminlog(); print "
    Tarantella: $text{chk_srv_title} - $config{tta_base} -
    ".$text{'tta_noobject'}."
    ".&text('viewlog_action',$stta_sid)."
    \n"; } sub parse_webminlog { local ($user, $script, $action, $type, $object, $p) = @_; local $text_str; local $html_str; $debug=4; # Just uncoment here and bypass $config{debug} local %h_obj; local @line, $line_str, $LDAP_msgerr; if ( $cginame eq "view.cgi" ) { # This is need to fix parse log for STTA and avoid webmin master changes # In STTA action, type and object are always among quotes .... open(LOG, $webmin_logfile); while() { @line=split(/ /, $_, -1); if ( $line[0] eq $stta_sid ) { $line_str=$_; last; } } close(LOG); if ( $line_str ne "" ) { @line=split(/ "/, $line_str, -1); if ( $line[1] ne "" ) { ${action} = $line[1]; } if ( $line[2] ne "" ) { ${type} = $line[2]; } if ( $line[3] ne "" ) { ${object} = $line[3]; @line=split(/"/, ${object}, -1); ${object} = $line[0]; } ${action}=~s/"//g; ${type}=~s/"//g; } if ( ${object} =~ /\|\|/ ) { local @obj= split(/\|\|/, ${object}, -1); foreach $item (@obj) { local @objdata= split(/=>/, $item, -1); if ( ${action} =~ /^tta/ && $objdata[0] eq "cmd" ) { $objdata[1] =~ s/\\\\//g; $objdata[1] =~ s/\\/
    /g; $objdata[1] =~ s//\\
    /g; $objdata[1] =~ s/'/"/g; } if (defined($h_obj{$objdata[0]}) ) { $h_obj{$objdata[0]} .= ", ".$objdata[1]; } else { $h_obj{$objdata[0]} = $objdata[1]; } } if ( $obj[0] gt 0 ) { if ( ${action} =~ /^tta/ ) { $h_obj{$obj[0]}="
    $text{f_error}:$text{'msgerr_tta'}
    "; } else { $LDAP_msgerr.=&ldap_error_text($obj[0]); $LDAP_msgerr=~s/\n/
    /g; $h_obj{$obj[0]}="
    $LDAP_msgerr
    "; } } elsif ($obj[0] eq 0 ) {$h_obj{$obj[0]}="
    $text{'msgerr_0'}
    "} }; $text_str=&text("log_stta", "$texto
    "); if ($debug gt 1 && %{$p} ) { $html_str=${action}; if ( ! %h_obj ) { $html_str=" ${type} ${object}"; } $html_str=&html_objlink(${type},$html_str,\%{$p},${action}); $html_str=~s/\0/, /g; #webminlog-lib.pl in &parse_logline # will add "\0" in a multivalue field # it will crash javascript:window.document.writeln() } else { $html_str=" ${action}"; $html_str.=" ${type}"; if ( ! %h_obj ) { $html_str.=" ${object}"; } } if ( %h_obj ) { &show_hash(\%h_obj,"","=","",\$text_str); $text_str=~s/'//g; $text_str=~s/\n/<\/tr>
    /g; $text_str=~s/===/:<\/td>/g; $html_str.=""; $html_str.="
    $text_str
    "; } } if ( $cginame eq "search.cgi" ) { $html_str=${script}.":".${action}." ".${type}; } return "$html_str"; } sub make_STTA_Report { if ( $ReportOut ) { select(REPORTOUT)} $cginame="view.cgi"; $indexTopHtml="
    \n"; $nowis=&set_now($now); print "

    \n"; print "


    \n"; print "\n"; print "
    $text{'sttareport_title'} $nowis
    \n"; # From here all checking staff ..... # print "
    \n"; $config{iferror_services}="warn"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $lnum=0; foreach $item (@ttahosts) { print "\n"; $lnum++; } print "
    • $text{srvSTATUS}
    • ",&hlink("?","srvSTATUS")," - $d 
    • $text{ttaps_title}
    • ",&hlink("?","procServTTA")," - $d 
    • $text{ldapps_title}
    • ",&hlink("?","procServLDAP")," - $d 
    • $text{ldapcache_title}
    • ",&hlink("?","procServLDAPCACHE")," - $d 
    • Tarantella: $text{chk_srv_title}
    • ",&hlink("?","checkTTA")," - $d 
    • Ldap: $text{chk_srv_title}
    • ",&hlink("?","checkldap")," - $d 
    • Ldap Cache: $text{chk_srv_title}
    • ",&hlink("?","checkLDAPCACHE")," - $d 
    • $text{config_title}
    • ",&hlink("?","sttaconfig")," - $d 
    • $text{index_acl}
    • ",&hlink("?","acl")," - $d 
    • $text{index_ttaproperties}
    • ",&hlink("?","ttaproperties")," - $d 
    • {name}."\">".$item->{name}."
    • ",&hlink("?",$item->{name})," - $d 
      \n"; print "$indexTopHtml"; print "
      \n"; print "
      \n"; &show_tta_serv_table(); print "$indexTopHtml"; &check_ps_serv(); print "$indexTopHtml"; print "
      \n"; &check_ttabase(); if ( $debug eq 0 ) { $debug=2 } print "$indexTopHtml"; print "
      \n"; if ( $ldap_ok eq true ) { print "\n"; print "\n"; } } else { print "\n";} print &parse_webminlog(); print "$indexTopHtml"; print "\n"; print " \n"; } sub out_tta_app_js { local (@appdef) =@_; foreach $data (@appdef) { next if ( $data->{att} eq "name" ); next if ( $data->{att} eq "description" ); if ( $data->{need} eq 1 ) { if ( $data->{opstype} eq "select" ) { print " if ( get_value(\"select\",obj.".$data->{att}.") == \"none\" ) {\n"; print " alert(obj.".$data->{att}.".name+\":\"+msg1+\"->\"+obj.".$data->{att}.".value+\"<-\");\n"; print " obj.".$data->{att}.".focus();\n"; print " return false;\n"; print " } \n"; } else { print " if ( emptyField(obj.".$data->{att}.") == true || obj.".$data->{att}.".value == '$data->{ops}' ) {\n"; print " alert(obj.".$data->{att}.".name+\":\"+msg1+\"->\"+obj.".$data->{att}.".value+\"<-\");\n"; print " obj.".$data->{att}.".focus();\n"; print " return false;\n"; print " }\n"; } } } } sub out_tta_appform { local (@appdef) =@_; local $f_name=""; &load_more_text('tta_apps'); # print ""; foreach $data (@appdef) { next if ( $data->{att} eq "name" ); next if ( $data->{att} eq "description" ); $f_name=$text{'f_tta_'.$data->{att}}; print "\n"; # print "\n"; if ( $data->{opstype} eq "select" ) { print " \n"; } else { $fvalue=$data->{value}; if ( $data->{att} eq "appserv" ) { print " \n"; } else { if ( $data->{att} eq "width" && $fvalue eq "" ) { $fvalue=$config{tta_appwidth} } if ( $data->{att} eq "height" && $fvalue eq "" ) { $fvalue=$config{tta_appheigth} } if ( $data->{att} eq "ntdomain" && $fvalue eq "" ) { $fvalue=$config{companyntdomain} } if ( $fvalue eq "" ) { $fvalue = $data->{ops} }; print "\n"; } } $f_name=$data->{line}; $f_name=~ s/"/'/g; $f_name=~ s/\$text{(\S+)}/tta_textOut($1)/ge; print "\n"; } } sub tta_textOut { if ( $_[0] eq "f_fdefault" ) { return "".$text{$_[0]}."" } return "".$text{$_[0]}.""; } # output select html options code between labels # out_htmlselobj [hash-objects] [sort_attr_name] [default_attr_name-in-hash] [default_attr_value-in-hash] sub out_htmlselobj { local %h_obj=%{$_[0]}; local $obj_sort_attr=$_[1]; local $obj_default_attr=$_[2]; local $obj_default_value=$_[3]; local @listobjs=(); local @list_objs=(); local $nItems=0; foreach $item (keys (%h_obj)) { push (@listobjs, $h_obj{$item}); } @list_objs = sort {$a->{$obj_sort_attr} cmp $b->{$obj_sort_attr}} @listobjs; foreach $item (@list_objs) { print "
      \n"; $ldap_server=$in{ldapserver} || "1"; print "
      \n"; if ( "$ldap_server" eq "1" ) { print $config{ldap_type}.":".$config{ldap_server}.":".$config {ldap_port}; } elsif ( "$ldap_server" eq "2" ) { print $config{ldap2_type}.":".$config{ldap2_server}.":".$config {ldap2_port}; } print "
      LDAP: $text{chk_srv_title} - $config{ldap_base} -
      \n"; &connect(); $dn=$config{ldap_base}; $cur_entry=&sel_ldap_obj($dn,"o=*"); if ( !defined($cur_entry) || $cur_entry->dn ne $dn) { &html_errshow("ldap") } else { &ldap_logerr("browse $dn"); print "
      ".&text('viewlog_action',$stta_sid)."
      LDAP: - $config{ldap_base} - ????
      \n"; if ( $ldapcache_ok eq true ) { print "\n"; print "\n"; } } else { print "\n"}; print &parse_webminlog(); print "
      \n"; $ldapcache_server=$in{ldapcacheserver} || "1"; print "
      \n"; if ( "$ldapcache_server" eq "1" ) { print $config{ldapcache_type}.":".$config{ldapcache_server}.":".$config {ldapcache_port}; } elsif ( "$ldapcache_server" eq "2" ) { print $config{ldapcache2_type}.":".$config{ldapcache2_server}.":".$config {ldapcache2_port}; } print "
      LDAP Cache: $text{chk_srv_title} - $config{ldapcache_base} -
      \n"; &connect_cache(); $dnCache=$config{ldapcache_base}; $cur_entry=&sel_cache_obj($dnCache,"o=*"); if ( !defined($cur_entry) || $cur_entry->dn ne $dnCache) { &html_errshow("ldapcache") } else { &ldapcache_logerr("browse $dnCache"); print "
      ".&text('viewlog_action',$stta_sid)."
      LDAP Cache: $text{chk_srv_title} - $config{ldapcache_base} - ????
      "; print "
      \n"; print "$indexTopHtml"; print "
      \n"; &html_objlink("ttaprops",$text{'index_ttaproperties'},\%ttaprops,$text{index_globaltta},"report"),"\");\n"; $lnum=0; foreach $item (@ttahosts) { print "$indexTopHtml"; print "{name}."\">\n"; &html_objlink("host",$item->{name},\%{$ttahosts[lnum]},$item->{name},"report"),"\");\n"; $lnum++; } print "$indexTopHtml"; print "
      \n"; &html_objlink("access stta",$text{index_acl},\%access,$text{index_acl},"report"),"\");\n"; print "$indexTopHtml"; if ( $ReportOut ) { $| =1; select(STDOUT);} } sub sel_tta_app { local $file_path=&get_tta_app_path(); local %h_tta_apps=&load_tta_apptypes(); print "
      ",&hlink("$text{'f_ttaapptype'}","fttaapptype"),"
      $#appdef
      "; if ( $data->{need} eq 1 ) { print "*"; }; if ( $f_name eq "" ) { $f_name=$data->{att} } print "$f_name"; if ( $data->{need} eq 1 ) { print ""; }; print "{att}."_need\" VALUE=\"$data->{need}\">\n"; print "\n"; print "\n"; print "{att}\" VALUE=\"$fvalue\" cols=\"22\" size=\"42\" ALIGN=left>"; print "$f_name"; # eval ("print \"$f_name\""); print "
      ');"; foreach $itematt (keys (%h_obj)) { next if ( $itematt eq "targets" || $itematt eq "numtargets" ); $html_str .= "w_objs.document.writeln('');"; } $html_str .= "w_objs.document.writeln('
      $obj_type$_[2]
      $itematt".$h_obj{$itematt}."
      '); return false"; return $html_str; } # output OM html icons & labels # out_htmlOMobj [objtype] [hash-objects] [sort_attr_name] [default_attr_name-in-hash] [default_attr_value-in-hash] [href ] sub out_htmlOMobj { local $objtype=$_[0]; local $grpobjtype=$_[0]; local %h_obj=%{$_[1]}; local $obj_sort_attr=$_[2]; local $obj_default_attr=$_[3]; local $obj_default_value=$_[4]; local $obj_href=$_[5]; local @listobjs=(); local @list_objs=(); local @list_targets=(); local $nItems=0; local $nTabs=0; local $lastgrp=""; local $linegrp=""; local @line=(); local @ensline=(); local $lineUrl=""; local %h_target=(); local $has_grp="false"; local $iconType=""; local $targetalias=""; foreach $item (keys (%h_obj)) { $h_obj{$item}->{'targets'}=(); $h_obj{$item}->{'numtargets'}=-1; } if ( $objtype eq "ous" ) { $has_grp="false" } if ( $objtype eq "domains" ) { $has_grp="false" } if ( $objtype eq "links" ) { $has_grp="false" } if ( $objtype eq "hosts" ) { %h_target=%h_obj; foreach $item (keys (%h_target)) { push (@listobjs, $h_target{$item}); } @list_targets = sort {$a->{$obj_sort_attr} cmp $b->{$obj_sort_attr}} @listobjs; %h_obj=&list_grphosts(); $has_grp="true"; $grpobjtype="grphosts"; } if ( $objtype eq "grphosts" ) { %h_target=&list_hosts(); foreach $item (keys (%h_target)) { push (@listobjs, $h_target{$item}); } @list_targets = sort {$a->{$obj_sort_attr} cmp $b->{$obj_sort_attr}} @listobjs; $has_grp="true"; } if ( $objtype eq "grpapps" ) { %h_target=&list_apps(); foreach $item (keys (%h_target)) { push (@listobjs, $h_target{$item}); } @list_targets = sort {$a->{$obj_sort_attr} cmp $b->{$obj_sort_attr}} @listobjs; $has_grp="true"; } if ( $objtype eq "apps" ) { %h_target=%h_obj; foreach $item (keys (%h_target)) { push (@listobjs, $h_target{$item}); } @list_targets = sort {$a->{$obj_sort_attr} cmp $b->{$obj_sort_attr}} @listobjs; %h_obj=&list_grpapps(); $has_grp="true"; $grpobjtype="grpapps"; } if ( $objtype eq "sysusers" ) { %h_target=%h_obj; foreach $item (keys (%h_target)) { push (@listobjs, $h_target{$item}); } @list_targets = sort {$a->{$obj_sort_attr} cmp $b->{$obj_sort_attr}} @listobjs; %h_obj=&list_ous(); $has_grp="true"; $grpobjtype="ous"; } @listobjs=(); foreach $item (keys (%h_obj)) { push (@listobjs, $h_obj{$item}); } @list_objs = sort {$a->{$obj_sort_attr} cmp $b->{$obj_sort_attr}} @listobjs; print "\n"; $nItems=0; foreach $item (@list_objs) { @ensline=split(/\//, $item->{ens}, -1); $nTabs=$#ensline+1; $linegrp=$item->{$obj_sort_attr}; @a_target=$item->{'targets'}; if ( $item->{$obj_sort_attr} =~ /\// ) { @line=split(/\//, $item->{$obj_sort_attr}, -1); $linegrp=~ s/$line[$#line]$//; } else { $linegrp=$item->{$obj_sort_attr}; } # print ""; if ( $obj_default_value =~ /$item->{$obj_default_attr}/ ) { print ""; } else { print $item->{'descrip'}." "; } print "\n"; $nItems++; next if ( $has_grp ne "true" ); foreach $item_target (@list_targets) { next if ( $item->{'alias'} ne $item_target->{'grpalias'} ); $targetalias=$item_target->{'alias'}; if ( $obj_default_value =~ /$item_target->{$obj_default_attr}/) { print ""; } else { if ( $obj_href =~ /^onClick=/ ) { $lineUrl=$obj_href; $lineUrl=~ s/VALUE/$item_target->{$obj_default_attr}/g; print "{$obj_default_attr}; } print ">"; if ( $obj_default_value =~ /$item_target->{$obj_default_attr}/) { print ""; } print $item_target->{'descrip'}; if ( $obj_default_value =~ /$item_target->{$obj_default_attr}/ ) { print ""; } print " "; print ""; } print "\n"; } } print "
      --$linegrp -- $lastgrp -- $nTabs -- $has_grp-->
      "; } else { print "
      "; } for ( $i = 0 ; $i < $nTabs ; $i++ ) { if ( $i gt 0 ) { print "spacetab"; } print "vertline"; } if ( $nTabs gt 0 ) { print "spacetab"; print "tvertline"; } if ( $has_grp eq "true" ) { print " minus "; } else { print " plus "; } if ( $item->{$obj_sort_attr} eq "" && $obj_sort_attr eq "ens" ) { # print ""; print "{name})."\" >"; print " ou "; } else { # print "{$obj_sort_attr}."');\" >"; print "{name})."\" >"; print " ou "; } print "\n"; if ( $has_grp ne "true" || $objtype =~ /^grp/ ) { if ( $obj_href =~ /^onClick=/ ) { $lineUrl=$obj_href; $lineUrl=~ s/VALUE/$item->{$obj_default_attr}/g; print "{$obj_default_attr}; } print ">"; if ( $obj_default_value =~ /$item->{$obj_default_attr}/ ) { print ""; } print $item->{'descrip'}; if ( $obj_default_value =~ /$item->{$obj_default_attr}/ ) { print ""; } print " "; if ( $obj_default_value =~ /$item->{$obj_default_attr}/ ) { print ""; } print $item->{'name'}; if ( $obj_default_value =~ /$item->{$obj_default_attr}/ ) { print ""; } print "".$item->{'name'}."
      "; } else { print "
      "; } for ( $i = 0 ; $i < $nTabs+1 ; $i++ ) { if ( $i gt 0 ) { print "spacetab"; } print "vertline"; } if ( $objtype =~ /host/ ) { $iconType="host"; } else { $iconType=$item_target->{'apptype'}; } print "spacetab"; print "tvertline"; print "horizline"; #print "{'ens'}."');\" >"; print "{name})."\" >"; print "icon"; print "\n"; if ( $objtype =~ /^grp/ ) { print $item_target->{'descrip'}." ".$item_target->{'name'}.""; if ( $obj_default_value =~ /$item_target->{$obj_default_attr}/) { print ""; } print $item_target->{'name'}; if ( $obj_default_value =~ /$item_target->{$obj_default_attr}/ ) { print ""; } print "
      "; } # Output status warning services sub out_tabserv_chk { if ( $tta_ok ne true ) { print "TTA \n"; } if ( $ldap_ok ne true && $config{has_ldapusers} eq "true" ) { print "LDAP \n"; } if ( $ldapcache_ok ne true && $config{is_ldapcache} eq "true" ) { print "LDAPCACHE \n"; } } sub out_css { my $str=""; $str .=""; # return " "; $str .= ""; } 1; # Return true