]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
showrequestfromcountry.dat: Use language string, and fix links
authorAlf Høgemark <alf@i100.no>
Mon, 17 Feb 2014 19:05:00 +0000 (20:05 +0100)
committerAlf Høgemark <alf@i100.no>
Sat, 1 Mar 2014 13:59:18 +0000 (14:59 +0100)
Define language key for input field.
Fix links for older and newer links.
Indentation fixes.

The code is a copy from showrequestfromip.dat, ideally
we should have merged all three showrequestfrom*.dat files
into one file, but I do not do that now, because it would
really require a rewrite of most of the logic, and I understand
that one does not want to do such changes in 2.x.

html/cgi-bin/logs.cgi/showrequestfromcountry.dat
langs/de/cgi-bin/de.pl
langs/en/cgi-bin/en.pl

index 25a9f1578842cc9c4d83eb6e1b4f14865304b22e..c8421161882df63f30752273790e25592a133d73 100644 (file)
@@ -58,7 +58,7 @@ if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
        $start = $temp[0];
        $cgiparams{'MONTH'} = $temp[1];
        $cgiparams{'DAY'} = $temp[2];
-       $cgiparams{ip} = $temp[3];
+       $cgiparams{country} = $temp[3];
 }
 
 if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
@@ -156,8 +156,8 @@ my $gi = Geo::IP::PurePerl->new();
 
 if (!$skip)
 {
-        while (<FILE>)
-        {
+    while (<FILE>)
+    {
                if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
             if($_ =~  /SRC\=([\d\.]+)/){
                 my $srcaddr=$1;
@@ -252,7 +252,7 @@ print <<END
 <td width='5%'  align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day before'}' value='&lt;&lt;' /></td>
 <td width='5%'  align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day after'}' value='&gt;&gt;' /></td>
 <td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
-<tr><td width='15%'>$Lang::tr{'source ip'}</td><td><input type='text' name='ip' value='$cgiparams{ip}'size='15'></td></tr>
+<tr><td width='15%'>$Lang::tr{'source ip country'}</td><td><input type='text' name='country' value='$cgiparams{country}'size='15'></td></tr>
 </tr>
 </table>
 </form>
@@ -279,17 +279,17 @@ if ($start == 0) { $prev = -1; }
 if ($lines != 0) { &oldernewer(); }
 
 print <<END
-<TABLE WIDTH='100%'>
-<TR>
-<TD WIDTH='10%' ALIGN='CENTER' CLASS='boldbase'><B>$Lang::tr{'time'}</B></TD>
-<TD WIDTH='13%' ALIGN='CENTER' CLASS='boldbase'><B>$Lang::tr{'chain'}</B></TD>
-<TD WIDTH='5%' ALIGN='CENTER' CLASS='boldbase'><B>$Lang::tr{'iface'}</B></TD>
-<TD WIDTH='5%' ALIGN='CENTER' CLASS='boldbase'><B>$Lang::tr{'proto'}</B></TD>
-<TD WIDTH='16%' ALIGN='CENTER' CLASS='boldbase'><B>$Lang::tr{'source'}</B></TD>
-<TD WIDTH='10%' ALIGN='CENTER' CLASS='boldbase'><B>$Lang::tr{'src port'}</B></TD>
-<TD WIDTH='16%' ALIGN='CENTER' CLASS='boldbase'><B>$Lang::tr{'destination'}</B></TD>
-<TD WIDTH='16%' ALIGN='CENTER' CLASS='boldbase'><B>$Lang::tr{'dst port'}</B></TD>
-</TR>
+<table width='100%'>
+<tr>
+<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'time'}</b></td>
+<td width='13%' align='center' class='boldbase'><b>$Lang::tr{'chain'}</b></td>
+<td width='5%' align='center' class='boldbase'><b>$Lang::tr{'iface'}</b></td>
+<td width='5%' align='center' class='boldbase'><b>$Lang::tr{'proto'}</b></td>
+<td width='16%' align='center' class='boldbase'><b>$Lang::tr{'source'}</b></td>
+<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'src port'}</b></td>
+<td width='16%' align='center' class='boldbase'><b>$Lang::tr{'destination'}</b></td>
+<td width='16%' align='center' class='boldbase'><b>$Lang::tr{'dst port'}</b></td>
+</tr>
 END
 ;
 
@@ -305,57 +305,57 @@ foreach $_ (@slice)
     my $srcaddr=$1;
     my $ccode = $gi->country_code_by_name($srcaddr);
     if($ccode eq $country){
-       my $chain = '';
-       my $in = '-'; my $out = '-';
-       my $srcaddr = ''; my $dstaddr = '';
-       my $protostr = '';
-       my $srcport = ''; my $dstport = '';
-
-       $_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/;
-       my $timestamp = $1; my $chain = $2; my $packet = $3;
-       $timestamp =~ /(...) (..) (..:..:..)/;
-       my $month = $1; my $day = $2; my $time = $3;
-
-       if ($a =~ /IN\=(\w+)/) { $iface = $1; }
-       if ($a =~ /OUT\=(\w+)/) { $out = $1; }
-       if ($a =~ /SRC\=([\d\.]+)/) { $srcaddr = $1; }
-       if ($a =~ /DST\=([\d\.]+)/) { $dstaddr = $1; }
-       if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; }
-       my $protostrlc = lc($protostr);
-       if ($a =~  /SPT\=([\d\.]+)/){ $srcport = $1; }
-       if ($a =~  /DPT\=([\d\.]+)/){ $dstport = $1; }
-
-       if ($lines % 2) {
-               print "<tr bgcolor='${Header::table1colour}'>\n"; }
-       else {
-               print "<tr bgcolor='${Header::table2colour}'>\n"; }
-       print <<END
-       <TD ALIGN='CENTER'>$time</TD>
-       <TD ALIGN='CENTER'>$chain</TD>
-       <TD ALIGN='CENTER'>$iface</TD>
-       <TD ALIGN='CENTER'>$protostr</TD>
-       <td align='center'>
-       <table width='100%' cellpadding='0' cellspacing='0'><tr>
-       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
-       </tr></table>
-       </td>
-       <TD ALIGN='CENTER'>$srcport</TD>
-       <td align='center'>
-       <table width='100%' cellpadding='0' cellspacing='0'><tr>
-       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
-       </tr></table>
-       </td>
-       <TD ALIGN='CENTER'>$dstport</TD>
-</TR>
+         my $chain = '';
+      my $in = '-'; my $out = '-';
+      my $srcaddr = ''; my $dstaddr = '';
+      my $protostr = '';
+      my $srcport = ''; my $dstport = '';
+
+      $_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/;
+      my $timestamp = $1; my $chain = $2; my $packet = $3;
+      $timestamp =~ /(...) (..) (..:..:..)/;
+      my $month = $1; my $day = $2; my $time = $3;
+
+      if ($a =~ /IN\=(\w+)/) { $iface = $1; }
+      if ($a =~ /OUT\=(\w+)/) { $out = $1; }
+      if ($a =~ /SRC\=([\d\.]+)/) { $srcaddr = $1; }
+      if ($a =~ /DST\=([\d\.]+)/) { $dstaddr = $1; }
+      if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; }
+      my $protostrlc = lc($protostr);
+      if ($a =~  /SPT\=([\d\.]+)/){ $srcport = $1; }
+      if ($a =~  /DPT\=([\d\.]+)/){ $dstport = $1; }
+
+      if ($lines % 2) {
+        print "<tr bgcolor='${Header::table1colour}'>\n"; }
+      else {
+        print "<tr bgcolor='${Header::table2colour}'>\n"; }
+      print <<END
+      <td align='center'>$time</td>
+      <td align='center'>$chain</td>
+      <td align='center'>$iface</td>
+      <td align='center'>$protostr</td>
+      <td align='center'>
+      <table width='100%' cellpadding='0' cellspacing='0'><tr>
+      <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
+      </tr></table>
+      </td>
+      <td align='center'>$srcport</td>
+      <td align='center'>
+      <table width='100%' cellpadding='0' cellspacing='0'><tr>
+      <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
+      </tr></table>
+      </td>
+      <td align='center'>$dstport</td>
+      </tr>
 END
        ;
-       $lines++;
+      $lines++;
     }
   }
 }
 
 print <<END
-</TABLE>
+</table>
 END
 ;
 
@@ -369,29 +369,30 @@ END
 
 sub oldernewer
 {
-print <<END
-<table width='100%'>
-<tr>
+  print <<END
+  <table width='100%'>
+  <tr>
 END
 ;
 
-print "<td align='center' width='50%'>";
-if ($prev != -1) {
-       print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'older'}</a>"; }
-else {
-       print "$Lang::tr{'older'}"; }
-print "</td>\n";
+  print "<td align='center' width='50%'>";
+  if ($prev != -1) {
+    print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'older'}</a>"; }
+  else {
+    print "$Lang::tr{'older'}"; }
+  print "</td>\n";
 
-print "<td align='center' width='50%'>";
-if ($next != -1) {
-       print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'newer'}</a>"; }
-else {
-       print "$Lang::tr{'newer'}"; }
-print "</td>\n";
+  print "<td align='center' width='50%'>";
+  if ($next != -1) {
+    print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'newer'}</a>"; }
+  else {
+   print "$Lang::tr{'newer'}"; }
+  print "</td>\n";
 
 print <<END
-</tr>
-</table>
+  </tr>
+  </table>
 END
 ;
 }
+
index 700f41b3b1dd115463d08be683c32efb23c9d2a1..11e8370a7a2b1ef73a43e78c31f1ee0520ec94bf 100644 (file)
 'source ip' => 'Quell-IP-Adresse',
 'source ip and port' => 'Quell-IP:Port',
 'source ip bad' => 'Ungültige Quell-IP-Adresse.',
+'source ip country' => 'Quell-IP-Adresse Land',
 'source ip in use' => 'Benutzte Quell-IP:',
 'source ip or net' => 'Quellen-IP oder Netz',
 'source net' => 'Quell-Netz',
index 6a7835275c53df47a0d6070276c65366d46a8227..450842880d426866db660e14c4ad5d7562b5979c 100644 (file)
 'source ip' => 'Source IP',
 'source ip and port' => 'Source IP: Port',
 'source ip bad' => 'Not a valid IP address or a network address.',
+'source ip country' => 'Source IP Country',
 'source ip in use' => 'Source IP in use:',
 'source ip or net' => 'Source IP or Net',
 'source net' => 'Source Net',