]>
Commit | Line | Data |
---|---|---|
cd1a2927 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: dialer,v 1.3.2.2 2005/01/26 12:23:26 riddles Exp $ | |
10 | # | |
11 | ||
12 | use strict; | |
13 | require 'CONFIG_ROOT/general-functions.pl'; | |
14 | ||
15 | my %pppsettings; | |
16 | my %modemsettings; | |
17 | ||
18 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
19 | &General::readhash("${General::swroot}/modem/settings", \%modemsettings); | |
20 | ||
21 | if ($modemsettings{'INIT'} eq '') { | |
22 | $modemsettings{'INIT'} = 'AT'; } | |
23 | if ($modemsettings{'HANGUP'} eq '') { | |
24 | $modemsettings{'HANGUP'} = 'AT'; } | |
25 | if ($modemsettings{'SPEAKER_ON'} eq '') { | |
26 | $modemsettings{'SPEAKER_ON'} = 'AT'; } | |
27 | if ($modemsettings{'SPEAKER_OFF'} eq '') { | |
28 | $modemsettings{'SPEAKER_OFF'} = 'AT'; } | |
29 | if ($modemsettings{'TONE_DIAL'} eq '') { | |
30 | $modemsettings{'TONE_DIAL'} = 'ATD'; } | |
31 | if ($modemsettings{'PULSE_DIAL'} eq '') { | |
32 | $modemsettings{'PULSE_DIAL'} = 'ATD'; } | |
33 | ||
34 | my $telephone = $pppsettings{'TELEPHONE'}; | |
35 | my $username = $pppsettings{'USERNAME'}; | |
36 | my $password = $pppsettings{'PASSWORD'}; | |
37 | ||
38 | my ($loginscript, $speaker, $dial, $btfudge); | |
39 | ||
40 | if ($pppsettings{'AUTH'} eq 'standard-login-script') { | |
41 | $loginscript = 'standardloginscript'; } | |
42 | elsif ($pppsettings{'AUTH'} eq 'demon-login-script') { | |
43 | $loginscript = 'demonloginscript'; } | |
44 | else { | |
45 | $loginscript = $pppsettings{'LOGINSCRIPT'}; } | |
46 | if ($pppsettings{'SPEAKER'} eq 'on') { | |
47 | $speaker = $modemsettings{'SPEAKER_ON'}; } | |
48 | else { | |
49 | $speaker = $modemsettings{'SPEAKER_OFF'}; } | |
50 | if ($pppsettings{'DIALMODE'} eq 'T') { | |
51 | $dial = $modemsettings{'TONE_DIAL'} } | |
52 | else { | |
53 | $dial = $modemsettings{'PULSE_DIAL'} } | |
54 | if ($pppsettings{'SENDCR'} eq 'off') { | |
55 | $btfudge = '\\c'; } | |
56 | else { | |
57 | $btfudge = ''; } | |
58 | ||
59 | unlink('/var/log/connect.log'); | |
60 | ||
61 | my $com = "/usr/sbin/chat -v -r /var/log/connect.log \ | |
62 | TIMEOUT 3 \ | |
63 | REPORT CONNECT \ | |
64 | ABORT '\\nBUSY\\r' \ | |
65 | ABORT '\\nNO ANSWER\\r' \ | |
66 | ABORT '\\nRINGING\\r\\n\\r\\nRINGING\\r' \ | |
67 | ABORT '\\nNO CARRIER\\r' \ | |
68 | '' '$modemsettings{'INIT'}' \ | |
69 | OK '$modemsettings{'HANGUP'}' \ | |
70 | OK '$speaker' \ | |
71 | TIMEOUT '$modemsettings{'TIMEOUT'}' \ | |
72 | OK '${dial}${telephone}' \ | |
73 | CONNECT '${btfudge}' "; | |
74 | ||
75 | if ($loginscript) | |
76 | { | |
77 | if (open(FILE, "/etc/ppp/${loginscript}")) | |
78 | { | |
79 | while (<FILE>) { | |
80 | $com = "$com $_ "; } | |
81 | close FILE; | |
82 | } | |
83 | $com =~ s/USERNAME/$username/; | |
84 | $com =~ s/PASSWORD/$password/; | |
85 | } | |
86 | ||
87 | $com =~ s/\n//g; | |
88 | ||
89 | exec $com; |