349 lines
17 KiB
Perl
Executable File
349 lines
17 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
# tta_sess.cgi
|
|
# Display Services with Tarantella Sessions
|
|
# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo --- license GNU GPL
|
|
# stta: (@#) 1.31051043346- [2004_01_29_102036]
|
|
|
|
require './stta-lib.pl';
|
|
if ($access{'sessions'} ne 1 ) { &redirect("index.cgi"); }
|
|
&ReadParse();
|
|
$sort_on=$in{sort_on};
|
|
$is_reload=true;
|
|
if ( !$sort_on ) { &redirect("sess_filter.cgi"); }
|
|
$reload = ($in{reload}) ? $in{reload} : "0";
|
|
if ( $reload eq "1" ) { $is_reload= true }
|
|
elsif ( $reload eq "0" ) { $is_reload= false };
|
|
&foreign_require("proc", "proc-lib.pl");
|
|
|
|
#$debug=2;
|
|
if ( $in{debug} ) { $debug= $in{debug} };
|
|
if ( $debug gt 0 ) {
|
|
$DebugFile="/tmp/log";
|
|
open(DebugLog, ">$DebugFile");
|
|
}
|
|
|
|
&headerstta($text{'index_ttasess'}, "", "ttasess",undef,1,0,"$text{'headpage_right'}"."$text{'head_logout'}",undef,undef,"$text{head_below}" );
|
|
print "<SCRIPT SRC=\"global.js\">\n";
|
|
print "</SCRIPT>\n";
|
|
print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
|
|
print "<!--\n";
|
|
print "/* Strings for locales */\n";
|
|
print "var msg0=\"".$text{'msg_0'},"\";\n";
|
|
print "var msg1=\"".$text{'msg_1'},"\";\n";
|
|
print "var msg2=\"".$text{'msg_2'},"\";\n";
|
|
print "var msg3=\"".$text{'msg_3'},"\";\n";
|
|
print "var msg4=\"".$text{'msg_4'},"\";\n";
|
|
print "var msg5=\"".$text{'msg_5'},"\";\n";
|
|
print "var msg6=\"".$text{'msg_6'},"\";\n";
|
|
print "var msg7=\"".$text{'msg_7'},"\";\n";
|
|
|
|
print "/******************************************************************\n";
|
|
print " showValue(formObj)\n";
|
|
print " Show Password value from form.\n";
|
|
print "*******************************************************************/\n";
|
|
print "function showValue() {\n";
|
|
print " alert(document.tta_$postform.dn.value);\n";
|
|
print "}\n";
|
|
print "/******************************************************************\n";
|
|
print " set_username(icn,iou,idn)\n";
|
|
print "*******************************************************************/\n";
|
|
print "function set_username(icn,iou,idn) {\n";
|
|
print " document.tta_$postform.elements[0].value=icn;\n";
|
|
print " document.tta_$postform.elements[1].value=iou;\n";
|
|
print " document.tta_$postform.elements[2].value=idn;\n";
|
|
print " return;\n";
|
|
print "}\n";
|
|
print "/*******************************************************************\n";
|
|
print " open_peID(nlin,ob_type,peID,i_name,i_grp,i_value,id_value) \n";
|
|
print "*******************************************************************/\n";
|
|
print "function open_peID(nlin,ob_type,peID,i_name,i_grp,i_value,id_value) {\n";
|
|
print " strquote='\\'';\n";
|
|
print " eval(\"w_name='w_'+peID\");\n";
|
|
print " str=\"w_name=window.open('', 'emulsess_'+peID,'toolbar=no,menubar=no,scrollbars=yes,width=800,height=300,resizable=yes')\";\n";
|
|
print " eval (str) \n";
|
|
print " eval (\"w_name.document.writeln('<body bgcolor=#ffffff link=#0000ee vlink=#0000ee text=#000000>');\")\n";
|
|
print " eval (\"w_name.document.writeln('<table width=100% border>');\")\n";
|
|
print " str='<form METHOD=POST name=\"sess_mgmt\" ACTION=\"sess_mgmt.cgi?ob='\n";
|
|
print " str2='\" onSubmit=\"\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+ob_type+str2);\")\n";
|
|
print " if ( ob_type == 'user' ) { \n";
|
|
print " eval (\"w_name.document.writeln('<tr $tb> <td $tb><font color=\\\"$revtext\\\"><b> $text{'tit_ttasess'} '+peID+' --- $text{l_ses_user} </b></td></tr>');\")\n";
|
|
print " eval (\"w_name.document.writeln('<tr $cb><td $cb><table width=100% border>');\")\n";
|
|
print " eval (\"w_name.document.write('<tr><td>Name </td><td>'+i_name+'</td></tr></b>')\")\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"objname\" VALUE=\"';\n";
|
|
print " str2='\">';";
|
|
print " eval (\"w_name.document.writeln(str+i_name+str2);\");\n";
|
|
print " eval (\"w_name.document.writeln('<tr><td>Group </td><td>'+i_grp+'</td></tr></b>')\")\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"grpname\" VALUE=\"';\n";
|
|
print " str2='\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+i_grp+str2);\");\n";
|
|
print " }\n";
|
|
print " if ( ob_type == 'app' ) { \n";
|
|
print " eval (\"w_name.document.writeln('<tr $tb> <td $tb><font color=\\\"$revtext\\\"><b> $text{'tit_ttasess'} '+peID+' --- $text{l_ses_app} </h> </td></tr>');\")\n";
|
|
print " eval (\"w_name.document.writeln('<tr $cb><td $cb><table width=100% border>');\")\n";
|
|
print " eval (\"w_name.document.writeln('<tr><td><b>Name </td><td>'+i_name+'</td></tr></b>')\")\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"objname\" VALUE=\"';\n";
|
|
print " str2='\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+i_name+str2);\");\n";
|
|
print " eval (\"w_name.document.writeln('<tr><td><b>Group </td><td>'+i_grp+'</td></tr></b>')\")\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"grpname\" VALUE=\"';\n";
|
|
print " str2='\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+i_grp+str2);\");\n";
|
|
print " }\n";
|
|
print " if ( ob_type == 'appserv' ) { \n";
|
|
print " eval (\"w_name.document.writeln('<tr $tb> <td $tb><font color=\\\"$revtext\\\"><b> $text{'tit_ttasess'} '+peID+' --- $text{l_ses_appsrv} </b> </td></tr>');\")\n";
|
|
print " eval (\"w_name.document.writeln('<tr $cb><td $cb><table width=100% border>');\")\n";
|
|
print " eval (\"w_name.document.writeln('<tr><td><b>Name </td><td>'+i_name+'</td></tr></b>')\")\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"objname\" VALUE=\"';\n";
|
|
print " str2='\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+i_name+str2);\");\n";
|
|
print " eval (\"w_name.document.writeln('<tr><td><b>Group </td><td>'+i_grp+'</td></tr></b>')\")\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"grpname\" VALUE=\"';\n";
|
|
print " str2='\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+i_grp+str2);\");\n";
|
|
print " }\n";
|
|
print " if ( ob_type == 'pe_id' ) { \n";
|
|
print " eval (\"w_name.document.writeln('<tr $tb> <td $tb><font color=\\\"$revtext\\\"><b> $text{'tit_ttasess'} '+peID+' --- $text{l_ses_peid} </b> </td></tr>');\")\n";
|
|
print " eval (\"w_name.document.writeln('<tr $cb><td $cb><table width=100% border>');\")\n";
|
|
print " i_value=peID;\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"objvalue\" VALUE=\"'\n";
|
|
print " str2='\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+i_value+str2);\")\n";
|
|
print " }\n";
|
|
print " eval (\"w_name.document.writeln('<td><b> $text{'tit_ttasess'} </b> </td>');\")\n";
|
|
print " str='<td valign=top><input TYPE=\"button\" NAME=\"?\" VALUE=\"?\" onClick=\"javascript:alert(';\n";
|
|
print " str2=')\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+strquote+i_value+strquote+str2);\");\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"objvalue\" VALUE=\"'\n";
|
|
print " str2='\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+i_value+str2);\")\n";
|
|
print " str='<input TYPE=\"hidden\" NAME=\"id\" VALUE=\"'\n";
|
|
print " str2='\">';\n";
|
|
print " eval (\"w_name.document.writeln(str+id_value+str2);\")\n";
|
|
print " str='<input TYPE=\"submit\" NAME=\"",$text{'f_sendreq'},"\" VALUE=\"",$text{'f_sendreq'},"\">';\n";
|
|
print " eval (\"w_name.document.writeln(str);\");\n";
|
|
print " str='<input TYPE=\"button\" NAME=\"",$text{'msg_close'},"\" VALUE=\"",$text{'msg_close'},"\" onClick=\"javascript:self.close()\"></td></tr>';\n";
|
|
print " eval (\"w_name.document.writeln(str);\");\n";
|
|
|
|
print " eval (\"w_name.document.writeln('</table></form></td></tr></table>');\");\n";
|
|
# print " str=StringClip(true,'$ahora');\n";
|
|
# print " eval (\"w_name.document.writeln(str);\");\n";
|
|
print " eval (\"w_name.document.close();\");\n";
|
|
print "}\n";
|
|
print "/******************************************************************\n";
|
|
print " Check_fields(obj)\n";
|
|
print "*******************************************************************/\n";
|
|
print "function Check_fields(obj) {\n";
|
|
print " if ( emptyField(obj.username) == true ) {\n";
|
|
print " alert(obj.username.name+\":\"+msg1+\"->\"+obj.username.value+\"<-\");\n";
|
|
print " obj.username.focus();\n";
|
|
print " return false;\n";
|
|
print " } \n";
|
|
print " if ( get_value(\"select\",obj.userou) == \"none\" ) {\n";
|
|
print " alert(obj.userou.name+\":\"+msg1);\n";
|
|
print " obj.userou.focus();\n";
|
|
print " return false;\n";
|
|
print " } \n";
|
|
print " return true;\n";
|
|
print "}\n";
|
|
print "//-->\n";
|
|
print "</SCRIPT>\n";
|
|
|
|
print "<table width=100% border>\n";
|
|
|
|
$ahora=&set_now();
|
|
print "<tr $tb> <td><font color='$revtext'><b>$text{'titidx_ttasess'} $ahora</b></td> </tr>\n";
|
|
|
|
# call to ttasess_tables()
|
|
#
|
|
# To load TTA session Tables
|
|
# if "has_cronsess" and "tta_sessout_file" it will try to use stored info
|
|
# $is_reload force to reload in case of true
|
|
# $counter_time & $counter_date are checked to match upon defined $config{sessout_timeout}# $config{'tta_sessout_file'} & $config{'countsessout_file'} are read, clean or write
|
|
# %h_countsess for counters and @tta_sess order ($sort_on) from @all_ttasess are set
|
|
# There are many Globals in this module ...
|
|
# CGI calling this function should pay attention to:
|
|
# $is_reload (true|false) as default
|
|
# $sort_op ( "pe_id"; "application"; "user"; "startTime"; "resume"; "status";
|
|
# "applicationServer"; "client"; "serverUser"; "user"; )
|
|
# should use;
|
|
# $counter_time, $ttasess_time %h_countsess @tta_sess order on $sort_on @all_ttasess
|
|
|
|
$status_ret=&ttasess_tables();
|
|
if ( $status_ret eq -2 ) {
|
|
# if ( $is_reload ne true && "$counter_time" ne "$ttasess_time" )
|
|
$status_ret=&ttasess_tables();
|
|
if ( $status_ret ne 0 ) {
|
|
$err_msg=$text{sessdiff_err};
|
|
&footHere();
|
|
exit;
|
|
}
|
|
}
|
|
if ( $status_ret eq -1 || $#all_ttasess < 0) {
|
|
$err_msg=$text{nosess_err};
|
|
&footHere();
|
|
exit;
|
|
}
|
|
print "<tr><td><B>-- $text{'l_orderby'} ";
|
|
if ($sort_on eq "pe_id") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_peid} . "\n";
|
|
}
|
|
if ($sort_on eq "application") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_app} . "\n";
|
|
}
|
|
if ($sort_on eq "user") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_user} . "\n";
|
|
}
|
|
if ($sort_on eq "startTime") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_starttime} . "\n";
|
|
}
|
|
if ($sort_on eq "resume") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_resume} . "\n";
|
|
}
|
|
if ($sort_on eq "status") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_status} . "\n";
|
|
}
|
|
if ($sort_on eq "applicationServer") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_appsrv} . "\n";
|
|
}
|
|
if ($sort_on eq "client") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_client} . "\n";
|
|
}
|
|
if ($sort_on eq "serverUser") {
|
|
@ttasess = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_ttasess;
|
|
print $text{l_ses_serveruser} . "\n";
|
|
}
|
|
print "</td></tr>\n";
|
|
if ( $config{has_cronsess} eq "true" && $is_reload ne true ) {
|
|
print "<TR><TD><B>$text{l_ses_count} $text{'user_update'} $counter_time </B></TD><TR>\n";
|
|
}
|
|
print "<tr><td><table width=100%>\n";
|
|
print "</b><TR $tb>\n";
|
|
print "<TD><center><B>".$text{l_ses_peid} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_user} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_client} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_app} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_starttime} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_resume} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_status} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_appsrv} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_serveruser} . "</B></center></TD>\n";
|
|
$lnum=0;
|
|
|
|
foreach $ttasess (@ttasess) {
|
|
$NameUser=$ttasess->{'nameUser'};
|
|
$OuName=$ttasess->{'nameOu'};
|
|
$NameApp=$ttasess->{'nameApp'};
|
|
$NameAppGrp=$ttasess->{'nameAppGrp'};
|
|
$NameHost=$ttasess->{'nameHost'};
|
|
$NameHostGrp=$ttasess->{'nameHostGrp'};
|
|
$NameHostGrp=$ttasess->{'nameHostGrp'};
|
|
|
|
$pe_ID=$ttasess->{'pe_id'};
|
|
print "<TR $cb>\n";
|
|
# print "<TD>" . $ttasess->{'id'}."</TD>\n";
|
|
print "<TD><A class=\"menu1\" href=\"javascript:".
|
|
"open_peID($lnum,'pe_id','$pe_ID','','','".$ttasess->{'id'}.
|
|
"','".$ttasess->{'id'}."')\">";
|
|
print "$pe_ID</A></TD>\n";
|
|
print "<TD><A class=\"menu1\" href=\"javascript:".
|
|
"open_peID($lnum,'user','$pe_ID','$NameUser','$OuName','".
|
|
$ttasess->{'user'}."','".$ttasess->{'id'}."')\">";
|
|
print "$NameUser ($OuName) $userType</A></TD>\n";
|
|
print "<TD>" . $ttasess->{'client'}."</TD>\n";
|
|
print "<TD><A class=\"menu1\" href=\"javascript: ".
|
|
"open_peID($lnum,'app','$pe_ID','$NameApp','$NameAppGrp','".
|
|
$ttasess->{'application'}."','".$ttasess->{'id'}."')\">";
|
|
print "$NameApp";
|
|
if ( $NameAppGrp.length ne 0 ) { print " ($NameAppGrp)"; }
|
|
print "</A></TD>\n";
|
|
print "<TD>" . $ttasess->{'startTime'}."</TD>\n";
|
|
print "<TD>" . $ttasess->{'resume'}."</TD>\n";
|
|
print "<TD>" . $ttasess->{'status'}."</TD>\n";
|
|
print "<TD><A class=\"menu1\" href=\"javascript: ".
|
|
"open_peID($lnum,'appserv','$pe_ID','$NameHost','$NameHostGrp','".
|
|
$ttasess->{'applicationServer'}."','".$ttasess->{'id'}."')\">";
|
|
print "$NameHost";
|
|
if ( $NameHostGrp.length ne 0 ) { print " ($NameHostGrp)"; }
|
|
print "</A></TD>\n";
|
|
print "<TD>" . $ttasess->{'serverUser'}."</TD>\n";
|
|
print "<\TR>\n";
|
|
$lnum++;
|
|
}
|
|
if ( $debug gt 0 ) { close (DebugLog); }
|
|
|
|
print "<p></table>\n";
|
|
if (%h_countsess) {
|
|
print "<TR><TD><B>".$text{l_ses_count} . "</B></TD><TR>\n";
|
|
print "</td></tr>\n";
|
|
print "<tr><td><table width=50%>\n";
|
|
print "</b><TR $tb>\n";
|
|
print "<TD><center><B>".$text{l_ses_object} . "</B></center></TD>\n";
|
|
print "<TD><center><B>".$text{l_ses_num} . "</B></center></TD>\n";
|
|
if ( $debug eq 2 ) {
|
|
print "<TD><center><B> obj </B></center></TD>\n";
|
|
print "<TD><center><B> objalias </B></center></TD>\n";
|
|
print "<TD><center><B> alias </B></center></TD>\n";
|
|
print "<TD><center><B> maxsess </B></center></TD>\n";
|
|
print "<TD><center><B> objgrpalias </B></center></TD>\n";
|
|
print "<TD><center><B> grpalias </B></center></TD>\n";
|
|
print "<TD><center><B> name </B></center></TD>\n";
|
|
}
|
|
foreach $lin (keys (%h_countsess)) {
|
|
if ($lin ne "TOTAL" && $lin ne "" ) {
|
|
$objdescrip=$h_countsess{$lin}->{'descrip'};
|
|
print "<TR $cb>\n";
|
|
print "<TD><A class=\"menu1\" href=\"javascript: alert('".$h_countsess{$lin}->{'name'};
|
|
if ( $objdescrip ne $h_countsess{$lin}->{'alias'} ) { print " (".$objdescrip.")"; }
|
|
print "')\">";
|
|
$objdescrip=~s/ou=//g;
|
|
$objdescrip=~s/cn=//g;
|
|
print $objdescrip;
|
|
print "</A></TD>\n";
|
|
print "<TD>" . $h_countsess{$lin}->{'numsess'}."</TD>\n";
|
|
if ( $debug eq 2 ) {
|
|
print "<TD>" . $h_countsess{$lin}->{'obj'}."</TD>\n";
|
|
print "<TD>" . $h_countsess{$lin}->{'objalias'}."</TD>\n";
|
|
print "<TD>" . $h_countsess{$lin}->{'alias'}."</TD>\n";
|
|
print "<TD>" . $h_countsess{$lin}->{'maxsess'}."</TD>\n";
|
|
print "<TD>" . $h_countsess{$lin}->{'objgrpalias'}."</TD>\n";
|
|
print "<TD>" . $h_countsess{$lin}->{'grpalias'}."</TD>\n";
|
|
print "<TD>" . $h_countsess{$lin}->{'name'}."</TD>\n";
|
|
}
|
|
print "<\TR>\n";
|
|
}
|
|
}
|
|
print "<TR $cb>\n";
|
|
print "<TD>".$h_countsess{"TOTAL"}->{'descrip'}."</A></TD>\n";
|
|
print "<TD>" . $h_countsess{"TOTAL"}->{'numsess'}."</TD>\n";
|
|
print "<\TR>\n";
|
|
print "<p></table>\n";
|
|
print "<p></table>\n";
|
|
print "<tr>\n";
|
|
print "<tr>\n";
|
|
}
|
|
if ( $config{has_cronsess} eq "true" && $config{'countsessout_file'} ne "" ) {
|
|
if ( $is_reload eq true ) {
|
|
print "<tr><p><b> $text{'msg_count_update'} $ahora </b></tr>\n";
|
|
} else {
|
|
print "<tr><p><b> $text{'msg_count_update'} $counter_time </b></tr>\n";
|
|
}
|
|
}
|
|
print "<tr>\n";
|
|
print "</table></table><p>\n";
|
|
&footer($config{'back_return'},$text{'index'});
|
|
print "<p><p><p>\n";
|
|
do "footer.pl";
|
|
exit;
|
|
|
|
|
|
|