]>
Commit | Line | Data |
---|---|---|
dace10b5 | 1 | #!/usr/bin/perl |
70df8302 MT |
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 | ############################################################################### | |
dace10b5 MT |
21 | |
22 | use strict; | |
23 | ||
8fba24ec | 24 | my $col; |
dace10b5 MT |
25 | my $lines = '1'; |
26 | my $lines2 = ''; | |
dace10b5 | 27 | |
df8c7810 | 28 | require '/var/ipfire/general-functions.pl'; |
d1a23835 | 29 | require "${General::swroot}/location-functions.pl"; |
dace10b5 MT |
30 | require "${General::swroot}/lang.pl"; |
31 | require "${General::swroot}/header.pl"; | |
32 | ||
cb204ea1 SS |
33 | require "${General::swroot}/location-functions.pl"; |
34 | ||
dace10b5 MT |
35 | &Header::showhttpheaders(); |
36 | ||
326a764d AH |
37 | &Header::openpage($Lang::tr{'countries'}, 1, ''); |
38 | &Header::openbigbox('100%', 'left'); | |
39 | ||
40 | &Header::openbox('100%', 'left', $Lang::tr{'country codes and flags'}); | |
8fba24ec SS |
41 | |
42 | print<<END; | |
43 | <table class='tbl'> | |
44 | <tr> | |
45 | <th style='width=5%'><b>$Lang::tr{'flag'}</b></th> | |
46 | <th style='width=5%'><b>$Lang::tr{'countrycode'}</b></th> | |
47 | <th style='width=40% text-align:left'><b>$Lang::tr{'country'}</b></th> | |
48 | <th> </th> | |
49 | <th style='width=5%'><b>$Lang::tr{'flag'}</b></th> | |
50 | <th style='width=5%;'><b>$Lang::tr{'countrycode'}</b></th> | |
51 | <th style='width=40% text-align:left;'><b>$Lang::tr{'country'}</b></th> | |
52 | </tr> | |
53 | END | |
54 | ||
cb204ea1 SS |
55 | # Init libloc database connection. |
56 | my $db_handle = &Location::Functions::init(); | |
57 | ||
8fba24ec | 58 | # Get a list of all supported country codes. |
cb204ea1 | 59 | my @countries = &Location::database_countries($db_handle); |
8fba24ec SS |
60 | |
61 | # Loop through whole country list. | |
62 | foreach my $country (@countries) { | |
dace10b5 | 63 | $lines++; |
4250f386 | 64 | |
8fba24ec | 65 | # Convert country code into upper case. |
00793c27 | 66 | $country = uc($country); |
3ea01fe0 SS |
67 | |
68 | # Get flag icon for of the country. | |
d1a23835 | 69 | my $flag_icon = &Location::Functions::get_flag_icon($country); |
8fba24ec SS |
70 | |
71 | # Get country name. | |
d1a23835 | 72 | my $name = &Location::Functions::get_full_country_name($country); |
3ea01fe0 | 73 | |
4250f386 | 74 | if ($lines % 2) { |
00793c27 MT |
75 | print "<td $col><a id='$country'><img src='$flag_icon' alt='$country' title='$country'/></a></td>"; |
76 | print "<td $col>$country</td>"; | |
8fba24ec SS |
77 | print "<td $col>$name</td></tr>\n"; |
78 | } else { | |
326a764d AH |
79 | $lines2++; |
80 | if($lines2 % 2) { | |
81 | $col="style='background-color:${Header::table2colour};'"; | |
82 | } else { | |
83 | $col="style='background-color:${Header::table1colour};'"; | |
84 | } | |
85 | print "<tr>"; | |
00793c27 MT |
86 | print "<td $col><a id='$country'><img src='$flag_icon' alt='$country' title='$country'/></a></td>"; |
87 | print "<td $col>$country</td>"; | |
8fba24ec | 88 | print "<td $col>$name</td>"; |
326a764d | 89 | print "<td $col> </td>"; |
8fba24ec SS |
90 | |
91 | # Finish column when the last element in the array has passed and we have an uneven amount of items. | |
92 | if ( $country eq $countries[-1] ) { | |
93 | print "<td $col> </td>\n"; | |
94 | print "<td $col> </td>\n"; | |
95 | print "<td $col> </td></tr>\n"; | |
96 | } | |
dace10b5 | 97 | } |
dace10b5 | 98 | } |
326a764d | 99 | print "</table>"; |
dace10b5 MT |
100 | &Header::closebox(); |
101 | ||
102 | &Header::closebigbox(); | |
103 | ||
8fba24ec | 104 | print "<div style='text-align:center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></div>\n"; |
dace10b5 MT |
105 | |
106 | &Header::closepage(); | |
107 | ||
108 |