#!/usr/bin/perl
# sess_mgmt.cgi
# Manage Tarantella Services Sessions

 require './tarantella-lib.pl';
if ($access{'sessions'} ne 1 ) { &redirect("index.cgi"); } 
&ReadParse();
if ( !$in{ob} ) { &redirect("sess_filter.cgi"); }
$obj=$in{ob};

if ( "$obj" eq "user" ) {
        $str=$config{'tta_websessions_logout'}." \"".$in{objvalue}."\"\n";
}
if ( "$obj" eq "app" ) {
#        $str=$config{'tta_sessions'}." logout ".$in{objvalue};
        $str="";
}
if ( "$obj" eq "appserv" ) {
#        $str=$config{'tta_sessions'}." logout ".$in{objvalue};
        $str="";
}
if ( "$obj" eq "pe_id" ) {
        $task_to_do="END: ".$in{objvalue};
        $str=$config{'tta_emusessions_end'}." ".$in{id}."\n";
}

&foreign_require("proc", "proc-lib.pl");
#&header($text{'index_mgmt_ttasess'}, "", "ttasess");
print "Content-type: text/html; Charset=iso-8859-1 \n\n";
print "<html>\n";
print "<meta http-equiv= \"Content-Type \" content= \"text/html; Charset=iso-8859-1 \">\n";
print "<head>\n";
print "<title>Sesiones Tarantella</title>\n";
print "</head>\n";
print "<body bgcolor=#ffffff link=#0000ee vlink=#0000ee text=#000000   >\n";

# print "<hr><p>\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>$text{'titidx_ttasess'}</b></td> </tr>\n";
 print "<tr><td><b> $task_to_do $in{objname} ( $in{grpname} ) </td></tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
	print "<hr>\n";
 if ($str) {
        $| = 1;
        $temp = &tempname();
        open(TEMP, ">$temp");
        print TEMP "#!/bin/sh\n";
        print TEMP $env;
	print TEMP "export $export\n" if ($export);
	print TEMP "$str\n";
	close(TEMP);
	chmod(0777, $temp);
        print "<pre>\n"; 
	$got = &foreign_call("proc", "safe_process_exec",
	   		     "su root -c $temp", 0, 0,
                              STDOUT, undef, 0);   
#	unlink($temp);
        &additional_log('tta_cmd', undef, $str);
        if (!$got) { print "<i>$text{'run_noout'}</i>\n"; }
        print "</pre>\n" 
        &webmin_log("exec", "command", "root", "$str");
} else {
     print "<b>$text{'index_cmderr'}</b>\n"; 
   
}
 print "<tr>\n";
 print "<tr><tr></table></table><hr><p>\n";  
 print "<A href=\"javascript:self.close()\">".$text{'msg_close'}."</A>\n";
# &footer($config{'back_return'},$text{'index'});
 do "footer.pl";
 exit;



