/[cvs]/janosch/isdnlog-scripts/isdnlog
ViewVC logotype

Contents of /janosch/isdnlog-scripts/isdnlog

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Wed Oct 20 18:33:19 2010 UTC (13 years, 6 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
initial commit (original from 2005-07-25)

1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 # Zeitvariablen initialisieren
7 my $CTIME_String = localtime(time);
8
9 my $status_datei = '/opt/own/isdnlog/scripts/isdn-web-caller.log';
10 my $cfg_AusgabeZiel = '/srv/www/htdocs/isdn.htm';
11 #$vars_datei = ' /etc/ppp/varsdatei.log';
12
13 my $text="Anruf erfolgte am: ";
14
15 #$action = $ARGV[5];
16
17 #if ($action eq "ip-down.local") {
18 #$text="Abwahl erfolgte am: ";
19 #}
20
21
22 # Config Datei Lesen
23 open(DATEI, "<$status_datei") || die "Datei nicht gefunden";
24 my @Zeilen = <DATEI>;
25 close(DATEI);
26
27 # Config Datei Lesen
28 #open(DATEI, "</etc/ppp/ppp-status.cfg") || die "Datei nicht gefunden";
29 #my @Zeilen = <DATEI>;
30 #close(DATEI);
31
32
33
34 # -------------------------------------------
35 # Aktionen ausfuehren
36 # -------------------------------------------
37 # Auf Uebergabeparameter pruefen: Falls keine vorhanden, dann Anruf nicht verarbeiten!
38 append_call() if (scalar @ARGV);
39 generate_html();
40
41
42
43 # -------------------------------------------
44 # 1. Anruf-Info an Datendatei anhaengen
45 # -------------------------------------------
46
47 sub append_call {
48
49 my $localport = $ARGV[1];
50 chomp $localport;
51 $localport =~ s/^\+49/0/;
52 $localport = "SomeCompany" if ($localport =~ "089123456");
53 $localport = "SomePerson" if ($localport =~ "0891234567");
54 $localport = "Fax" if ($localport =~ "08912345678");
55
56
57 my $ZeilenCounter = "0";
58
59 #Zeilenausgabe
60 foreach(@Zeilen) {
61 #print "$_\n";
62 $ZeilenCounter++;
63 #print "$ZeilenCounter\n";
64 }
65 #print "$#Zeilen\n";
66
67
68
69 $Zeilen[$ZeilenCounter] = $CTIME_String;
70 $Zeilen[$ZeilenCounter] = $text . $Zeilen[$ZeilenCounter] . " mit der Rufnummer: " . $ARGV[0] . " von " . $ARGV[2] . " fuer " . $localport . "\n";
71 #$Zeilen[$ZeilenCounter] .= join(";", @ARGV) . "\n";
72
73 open(DATEI, ">$status_datei") || die "Datei nicht gefunden";
74 print DATEI @Zeilen;
75 close(DATEI);
76
77 # open(DATEI, ">/tmp/ppp-argv.tmp") || die "Datei nicht gefunden";
78 # print DATEI @ARGV;
79 # close(DATEI);
80
81 }
82
83
84 # -------------------------------------------
85 # 2. HTML-Datei generieren
86 # -------------------------------------------
87
88 sub generate_html {
89
90 my @dateparts = split(" ", $CTIME_String);
91 my $day = join(" ", @dateparts[0..2]);
92 my $trenner_flag = 0;
93 my $trenner = '<hr color="red" style="margin-top:2px;margin-bottom:2px;" />';
94 #print "day: '$day'", "\n";
95
96 open (FH, '>' . $cfg_AusgabeZiel);
97
98 print FH <<EOT;
99 <html><head><title>ISDN-Status</title></head><body>
100 EOT
101 foreach (reverse @Zeilen) {
102 my $daybreak_flag = ($_ !~ /$day/);
103 # if (not $trenner_flag and not $daybreak_flag) {
104 if (!$trenner_flag && $daybreak_flag) {
105 print FH $trenner;
106 $trenner_flag = 1;
107 }
108 print FH "$_ <br>";
109 }
110 print FH
111 "</body></html>";
112 close (FH);
113
114 chmod(0644,$cfg_AusgabeZiel);
115
116 }

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed