Thread Virtuelle Hosts hinzufügen/löschen with a CGI: concerning Apache?s vhosts.conf file (13 answers)
Opened by pearl-man at 2005-12-21 09:45

pearl-man
 2005-12-21 16:13
#6410 #6410
User since
2005-07-25
65 Artikel
BenutzerIn
[default_avatar]
Das Modul Config::General ist eventl. ne Lösung, habs jedoch so gmacht:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sub del_vhost # ($_[0] = $domain)
{
open(VHOSTS, "<$vhosts_file") || &error("Kann die Datei $vhosts_file nicht lesen!", 1);
my $content = "";
while (<VHOSTS>){
$content.=$_;
}
close(VHOSTS);
my @vhosts = split(/\n\n/, $content);
open(OUT, ">$vhosts_file") || &error("Kann nicht in die Datei $vhosts_file schreiben!");
flock(OUT, LOCK_EX);
foreach my $vhost (@vhosts){
if (!($vhost =~ /ServerName\s*www.$domain/)){
print OUT $vhost."\n\n";
}
}
close(OUT);
&info("VHOST", "Entferne Virtuellen Host($_[0]).");
}

View full thread Virtuelle Hosts hinzufügen/löschen with a CGI: concerning Apache?s vhosts.conf file