]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/dial.cgi
5 # This code is distributed under the terms of the GPL
7 # (c) The SmoothWall Team
9 # $Id: dial.cgi,v 1.4.2.3 2005/02/22 22:21:55 gespinasse Exp $
14 # enable only the following on debugging purpose
16 #use CGI::Carp 'fatalsToBrowser';
18 require '/var/ipfire/general-functions.pl';
19 require "${General::swroot}/lang.pl";
20 require "${General::swroot}/header.pl";
24 $cgiparams{'ACTION'} = '';
25 &Header
::getcgihash
(\
%cgiparams);
27 if ($cgiparams{'ACTION'} eq $Lang::tr
{'dial profile'})
29 my $profile = $cgiparams{'PROFILE'};
30 my %tempcgiparams = ();
31 $tempcgiparams{'PROFILE'} = '';
32 &General
::readhash
("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
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");
39 system ("/bin/touch", "${General::swroot}/ppp/updatesettings");
41 # read in the new params "early" so we can write secrets.
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'}",
50 open(FILE
, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
52 my $username = $cgiparams{'USERNAME'};
53 my $password = $cgiparams{'PASSWORD'};
54 print FILE
"'$username' * '$password'\n";
55 chmod 0600, "${General::swroot}/ppp/secrets";
58 &General
::log("$Lang::tr{'profile made current'} $tempcgiparams{'PROFILENAME'}");
59 $cgiparams{'ACTION'} = "$Lang::tr{'dial'}";
62 if ($cgiparams{'ACTION'} eq $Lang::tr
{'dial'}) {
63 system('/etc/rc.d/rc.red','start') == 0
64 or &General
::log("Dial failed: $?"); }
65 elsif ($cgiparams{'ACTION'} eq $Lang::tr
{'hangup'}) {
66 system('/etc/rc.d/rc.red','stop') == 0
67 or &General
::log("Hangup failed: $?"); }
70 print "Status: 302 Moved\nLocation: /cgi-bin/index.cgi\n\n";