par Sorg » 02 Mars 2002 15:46
Je voulais modifier le fichier vpnconfig.dat pour pouvoir utiliser des dns dynamiques a la place d'IPs
<BR>Je pensais que pour mettre une ligne en commentaire il fallait un dièse (#) mais apres modif j'ai une erreur 500 quand j'affiche la page.
<BR>Voila le début de mon fichier:
<BR>Voyez vous un problème?
<BR>
<BR>
<BR>#!/usr/bin/perl
<BR>#
<BR># SmoothWall CGIs
<BR>#
<BR># This code is distributed under the terms of the GPL
<BR>#
<BR># (c) The SmoothWall Team
<BR>#
<BR># $Id: vpnconfig.dat,v 1.3.2.1 2002/01/20 11:43:42 eanna Exp $
<BR>#
<BR>
<BR>require '/var/ipcop/header.pl';
<BR>use File::Copy;
<BR>
<BR>my %cgiparams;
<BR>my $filename = "${swroot}/vpn/config";
<BR>
<BR>$cgiparams{'ENABLED'} = 'off';
<BR># wantfile required for import, sadly it can only be enabled globally...
<BR>&getcgihash(%cgiparams, {'wantfile' => 1, 'filevar' => 'FH'});
<BR>
<BR>my $errormessage = '';
<BR>
<BR>if ($cgiparams{'ACTION'} eq $tr{'add'})
<BR>{
<BR># unless ($cgiparams{'NAME'} =~ /^[a-zA-Z]+$/) {
<BR> $errormessage = $tr{'name must only contain characters'}; }
<BR># unless (&validip($cgiparams{'LEFT'})) {
<BR> $errormessage = $tr{'left ip is invalid'}; }
<BR># unless (&validip($cgiparams{'LEFTNEXTHOP'})) {
<BR> $errormessage = $tr{'left next hop ip is invalid'}; }
<BR># unless (&validipandmask($cgiparams{'LEFT_SUBNET'})) {
<BR> $errormessage = $tr{'left subnet is invalid'}; }
<BR># unless (&validip($cgiparams{'RIGHT'})) {
<BR> $errormessage = $tr{'right ip is invalid'}; }
<BR># unless (&validip($cgiparams{'RIGHTNEXTHOP'})) {
<BR> $errormessage = $tr{'right next hop ip is invalid'}; }
<BR># unless (&validipandmask($cgiparams{'RIGHT_SUBNET'})) {
<BR> $errormessage = $tr{'right subnet is invalid'}; }
<BR>
<BR> open(FILE, $filename) or die 'Unable to open config file.';
<BR> my @current = <FILE>;
<BR> close(FILE);
<BR> unless ($errormessage)
<BR> {
<BR> open(FILE,">>$filename") or die 'Unable to open config file.';
<BR> flock FILE, 2;
<BR> print FILE
<BR>
<BR>