#!/usr/bin/perl
# tta_delprofcache.cgi
# Delete Cache Profile from Tarantella Services

 require './tarantella-lib.pl';
&foreign_require("proc", "proc-lib.pl");
&ReadParse();

 $profilename=$in{profilename};
 &header($text{'index_delprofcache'}, "", "");
 print "<hr><p>\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>$text{'titidx_delprofcache'} $profcache </b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
 print "<center> \n";

if ($profilename) {
              print "<tr><td><pre>\n";
                      print "<tr></tr><tr></tr>\n";
                      @lista_profcache=&list_profcache();
                      &lock_file($config{'profcache_list'});
	              open(FILEPROFCACHE, ">$config{'profcache_list'}");
                      foreach $list_profcache (@lista_profcache) {
                         if ( $list_profcache->{'alias'} ne $profilename) {
                             $lin_profcache=$list_profcache->{'alias'}."::".$list_profcache->{'name'};
                             $lin_profcache=$lin_profcache."::".$list_profcache->{'hostusername'};
                             $lin_profcache=$lin_profcache."::".$list_profcache->{'hostname'};
                             $lin_profcache=$lin_profcache."::".$list_profcache->{'usergrphosts'};
                             $lin_profcache=$lin_profcache."::".$list_profcache->{'username'};
                             $lin_profcache=$lin_profcache."::".$list_profcache->{'userou'};
                             print FILEPROFCACHE "$lin_profcache\n";
                         }
                      }
                      close (FILEPROFCACHE);
                      $str=$text{'user_delete'}.$profilename;
                      &additional_log('delprofcache.cgi', undef, $str);
                      &webmin_log($config{'profcache_list'}, undef, "delete");
                      &unlock_file($config{'profcache_list'});
                      print "</pre><tr><p><b>$text{'user_delete'}... Tarantella </b></tr>\n";
              print "</tr></td></pre>\n";
}
 print "<tr><tr></table></table><hr><p>\n";
 &footer($config{'back_return'},$text{'index'});
 print "<p><p><p>\n";
 do "footer.pl";
 exit;
