250915a722379b8a00cba4e6b15efc1ad92ad5cb
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / country.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 use strict;
23
24 use Locale::Country;
25
26 my $flagdir = '/home/httpd/html/images/flags';
27 my $lines = '1';
28 my $lines2 = '';
29 my @flaglist=();
30 my @flaglistfiles=();
31 my $flag = '';
32
33 require '/var/ipfire/general-functions.pl';
34 require "${General::swroot}/lang.pl";
35 require "${General::swroot}/header.pl";
36
37 &Header::showhttpheaders();
38
39 &Header::openpage('Country Codes', 1, '');
40 &Header::openbigbox('100%', 'LEFT');
41
42 &Header::openbox('100%', 'LEFT', 'Flags & Country Codes:');
43 print "<TABLE WIDTH='100%'>";
44 print "<tr><td width='5%'><b>Flag</b></td>";
45 print "<td width='5%'><b>Code</b></td>";
46 print "<td width='40%'><b>Country</b></td>";
47 print "<td><b>&nbsp;</b></td>";
48 print "<td width='5%'><b>Flag</b></td>";
49 print "<td width='5%'><b>Code</b></td>";
50 print "<td width='40%'><b>Country</b></td></tr>";
51
52 @flaglist = <$flagdir/*>;
53
54 undef @flaglistfiles;
55
56 foreach (@flaglist)
57 {
58 if (!-d) { push(@flaglistfiles,substr($_,rindex($_,"/")+1)); }
59 }
60
61 foreach $flag (@flaglistfiles)
62 {
63 $lines++;
64
65 my $flagcode = uc(substr($flag, 0, 2));
66 my $fcode = lc($flagcode);
67 my $country = Locale::Country::code2country($fcode);
68 if($fcode eq 'eu') { $country = 'Europe'; }
69 if($fcode eq 'tp') { $country = 'East Timor'; }
70 if($fcode eq 'yu') { $country = 'Yugoslavia'; }
71 if ($lines % 2) {
72 print "<td><a name='$fcode'/><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$flagcode'</td>";
73 print "<td>$flagcode</td>";
74 print "<td>$country</td></tr>\n";
75 }
76 else {
77 $lines2++;
78 if($lines2 % 2) {
79 print "<tr bgcolor='${Header::table1colour}'>";
80 } else {
81 print "<tr bgcolor='${Header::table2colour}'>";
82 }
83 print "<td><a name='$fcode'/><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$flagcode'</td>";
84 print "<td>$flagcode</td>";
85 print "<td>$country</td>";
86 #print "<td><img src='/blob.gif' alt='*' /></td>";
87 print "<td>&nbsp;</td>";
88 }
89 }
90
91
92 print "</TABLE>";
93 &Header::closebox();
94
95 &Header::closebigbox();
96
97 print <<END
98 <div align='center'>
99 <table width='80%'>
100 <tr>
101 <td align='center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></td>
102 </tr>
103 </table>
104 </div>
105 END
106 ;
107
108 &Header::closepage();
109
110