]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/dial.cgi
Firewallhitgraphs gefixt.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / dial.cgi
CommitLineData
ac1cfefa
MT
1#!/usr/bin/perl
2#
3# SmoothWall CGIs
4#
5# This code is distributed under the terms of the GPL
6#
7# (c) The SmoothWall Team
8#
9# $Id: dial.cgi,v 1.4.2.3 2005/02/22 22:21:55 gespinasse Exp $
10#
11
12use strict;
13
14# enable only the following on debugging purpose
15#use warnings;
16#use CGI::Carp 'fatalsToBrowser';
17
986e08d9 18require '/var/ipfire/general-functions.pl';
ac1cfefa
MT
19require "${General::swroot}/lang.pl";
20require "${General::swroot}/header.pl";
21
22my %cgiparams=();
23
24$cgiparams{'ACTION'} = '';
25&Header::getcgihash(\%cgiparams);
26
10a04d70
MT
27if ($cgiparams{'ACTION'} eq $Lang::tr{'dial profile'})
28{
29 my $profile = $cgiparams{'PROFILE'};
30 my %tempcgiparams = ();
31 $tempcgiparams{'PROFILE'} = '';
32 &General::readhash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
33 \%tempcgiparams);
34
35 # make a link from the selected profile to the "default" one.
36 unlink("${General::swroot}/ppp/settings");
37 link("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
38 "${General::swroot}/ppp/settings");
9833e7d8 39 system ("/usr/bin/touch", "${General::swroot}/ppp/updatesettings");
10a04d70
MT
40
41 # read in the new params "early" so we can write secrets.
42 %cgiparams = ();
43 &General::readhash("${General::swroot}/ppp/settings", \%cgiparams);
44 $cgiparams{'PROFILE'} = $profile;
45 $cgiparams{'BACKUPPROFILE'} = $profile;
46 &General::writehash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
47 \%cgiparams);
48
49 # write secrets file.
50 open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
51 flock(FILE, 2);
52 my $username = $cgiparams{'USERNAME'};
53 my $password = $cgiparams{'PASSWORD'};
54 print FILE "'$username' * '$password'\n";
55 chmod 0600, "${General::swroot}/ppp/secrets";
56 close FILE;
57
58 &General::log("$Lang::tr{'profile made current'} $tempcgiparams{'PROFILENAME'}");
59 $cgiparams{'ACTION'} = "$Lang::tr{'dial'}";
60}
61
ac1cfefa 62if ($cgiparams{'ACTION'} eq $Lang::tr{'dial'}) {
d95bfe98 63 system('/usr/local/bin/redctrl','start') == 0
ac1cfefa
MT
64 or &General::log("Dial failed: $?"); }
65elsif ($cgiparams{'ACTION'} eq $Lang::tr{'hangup'}) {
d95bfe98 66 system('/usr/local/bin/redctrl','stop') == 0
ac1cfefa
MT
67 or &General::log("Hangup failed: $?"); }
68sleep 1;
69
70print "Status: 302 Moved\nLocation: /cgi-bin/index.cgi\n\n";