/[smecontribs]/rpms/smeserver-xt_geoip/contribs9/smeserver-xt_geoip-1.0.1-stats_panel.patch
ViewVC logotype

Annotation of /rpms/smeserver-xt_geoip/contribs9/smeserver-xt_geoip-1.0.1-stats_panel.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Sun Apr 21 16:31:59 2019 UTC (5 years, 6 months ago) by michel
Branch: MAIN
CVS Tags: smeserver-xt_geoip-1_0_1-8_el6_sme
* Wed Apr 17 2019 Michel Begue <mab974@gmail.com> 1.0.1-8.sme
- add stats access in the panel [SME: 10745]
- add control of maximum number of countries [SME: 10749]

1 michel 1.1 diff -urN smeserver-xt_geoip-1.0.1.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/xt_geoip smeserver-xt_geoip-1.0.1/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/xt_geoip
2     --- smeserver-xt_geoip-1.0.1.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/xt_geoip 2019-04-10 18:04:05.000000000 +0400
3     +++ smeserver-xt_geoip-1.0.1/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/xt_geoip 2019-04-14 23:09:47.000000000 +0400
4     @@ -65,6 +65,11 @@
5     </entry>
6    
7     <entry>
8     + <base>ERR_COUNTRY_MAX: {$ctr}</base>
9     + <trans>Country code(s) maximum reached: {$ctr}</trans>
10     + </entry>
11     +
12     + <entry>
13     <base>LABEL_BADCOUNTRIES</base>
14     <trans>New country codes to be used :</trans>
15     </entry>
16     @@ -89,4 +94,39 @@
17     <trans>GeoIP table is updated every week, but you can ...</trans>
18     </entry>
19    
20     + <entry>
21     + <base>IPT_LIST</base>
22     + <trans>Geoip ban</trans>
23     + </entry>
24     +
25     + <entry>
26     + <base>SSH_LIST</base>
27     + <trans>Ssh errors</trans>
28     + </entry>
29     +
30     + <entry>
31     + <base>STATS_GENERATED</base>
32     + <trans>Statistics generated</trans>
33     + </entry>
34     +
35     + <entry>
36     + <base>END_OF_STATS</base>
37     + <trans>End of Statistics</trans>
38     + </entry>
39     +
40     + <entry>
41     + <base>INVALID_STATS_TYPE</base>
42     + <trans>Invalid type of statistics</trans>
43     + </entry>
44     +
45     + <entry>
46     + <base>STATS_DESCRIPTION</base>
47     + <trans><![CDATA[ <h3>Statistics for Xt_GeoIP</h3><ul>
48     + <li>For 3 periods : Day, Week and Month</li>
49     + <li>Banned Ips by country sorted by number</li>
50     + <li>Ssh errors by country sorted by number</li>
51     + </ul><p><i>XX means Country not found !</i></p> ]]>
52     + </trans>
53     + </entry>
54     +
55     </lexicon>
56     diff -urN smeserver-xt_geoip-1.0.1.old/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/xt_geoip smeserver-xt_geoip-1.0.1/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/xt_geoip
57     --- smeserver-xt_geoip-1.0.1.old/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/xt_geoip 2019-04-10 18:04:05.000000000 +0400
58     +++ smeserver-xt_geoip-1.0.1/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/xt_geoip 2019-04-14 23:39:03.000000000 +0400
59     @@ -60,6 +60,12 @@
60     </entry>
61    
62     <entry>
63     + <base>ERR_COUNTRY_MAX: {$ctr}</base>
64     + <trans>Code pays, maximum atteint: {$ctr}</trans>
65     + </entry>
66     +
67     +
68     + <entry>
69     <base>LABEL_BADCOUNTRIES</base>
70     <trans>Nouveaux codes pays à utiliser :</trans>
71     </entry>
72     @@ -89,5 +95,40 @@
73     <trans>Aucun changement... pas de mise à jour !
74     </trans>
75     </entry>
76     +
77     + <entry>
78     + <base>IPT_LIST</base>
79     + <trans>Geoip stop</trans>
80     + </entry>
81     +
82     + <entry>
83     + <base>SSH_LIST</base>
84     + <trans>Ssh erreurs</trans>
85     + </entry>
86     +
87     + <entry>
88     + <base>STATS_GENERATED</base>
89     + <trans>Statistiques générées</trans>
90     + </entry>
91     +
92     + <entry>
93     + <base>END_OF_STATS</base>
94     + <trans>Fin des Statistiques</trans>
95     + </entry>
96     +
97     + <entry>
98     + <base>INVALID_STATS_TYPE</base>
99     + <trans>Type de statistiques invalide</trans>
100     + </entry>
101     +
102     + <entry>
103     + <base>STATS_DESCRIPTION</base>
104     + <trans><![CDATA[ <h3>Statistiques pour Xtables GeoIP</h3><ul>
105     + <li>Pour 3 périodes : Jour, Semaine et Mois</li>
106     + <li>Ips bloqués par pays triés par score</li>
107     + <li>Erreurs Ssh par pays triées par score </li>
108     + </ul><p><i>XX signifie Pays non trouvé !</i></p> ]]>
109     + </trans>
110     + </entry>
111    
112     </lexicon>
113     diff -urN smeserver-xt_geoip-1.0.1.old/root/etc/e-smith/web/functions/xt_geoip smeserver-xt_geoip-1.0.1/root/etc/e-smith/web/functions/xt_geoip
114     --- smeserver-xt_geoip-1.0.1.old/root/etc/e-smith/web/functions/xt_geoip 2019-04-10 18:04:05.000000000 +0400
115     +++ smeserver-xt_geoip-1.0.1/root/etc/e-smith/web/functions/xt_geoip 2019-04-14 17:43:04.000000000 +0400
116     @@ -68,9 +68,10 @@
117     footer="/etc/e-smith/web/common/foot.tmpl">
118    
119     <page name="First"
120     - pre-event="print_status_message()">
121     + pre-event="print_status_message()">
122     + # post-event="wherenext('Second')" >
123     + # Ssh Ipt Second
124     <description>XT_GEOIP_STATUS_DESCRIPTION</description>
125     -
126     <field
127     type="literal"
128     id="geoip"
129     @@ -98,9 +99,15 @@
130     value="get_stat_geoip()">
131     <label> </label>
132     </field>
133     +
134     + <field type="literal" id="client_label" value="">
135     + <description>STATS_DESCRIPTION</description>
136     + </field>
137     +
138     + <subroutine src="print_custom_button('IPT_LIST', 'Stats', 'ipt')"/>
139     + <subroutine src="print_custom_button('SSH_LIST', 'Stats', 'ssh')"/>
140    
141     <subroutine src="print_button('NEXT')" />
142     -
143     </page>
144    
145     <page name="Second"
146     @@ -144,5 +151,14 @@
147     <subroutine src="print_button('SAVE')" />
148    
149     </page>
150     +
151     +
152     + <page name="Stats"
153     + pre-event="generateStats"
154     + post-event="wherenext('First')" >
155     + <subroutine src="print_button('NEXT')"/>
156     + </page>
157     +
158     +
159    
160     </form>
161    
162     diff -urN smeserver-xt_geoip-1.0.1.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm smeserver-xt_geoip-1.0.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm
163     --- smeserver-xt_geoip-1.0.1.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm 2019-04-10 18:04:05.000000000 +0400
164     +++ smeserver-xt_geoip-1.0.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm 2019-04-14 23:30:41.000000000 +0400
165     @@ -27,7 +27,7 @@
166     must_exist
167     );
168    
169     -our $VERSION = sprintf '%d.%03d', q$Revision: 0.01 $ =~ /: (\d+).(\d+)/;
170     +our $VERSION = sprintf '%d.%03d', q$Revision: 0.02 $ =~ /: (\d+).(\d+)/;
171    
172     our $db = esmith::ConfigDB->open || die "Couldn't open ConfigDB\n";
173    
174     @@ -81,7 +81,7 @@
175     my $self = esmith::FormMagick->new();
176     $self->{calling_package} = (caller)[0];
177     bless $self;
178     - #$self->debug(1);
179     +# $self->debug(1);
180     return $self;
181     }
182    
183     @@ -213,12 +213,65 @@
184     my $listerr = "";
185     my @mq_bcs = split /[,:]/, $q->param("masq_badcountries");
186     if (@mq_bcs) {
187     + my $ctr = @mq_bcs;
188     + return $self->localise('ERR_COUNTRY_MAX: {$ctr}', {ctr=> "$ctr"}) if ($ctr > 50);
189     +
190     foreach my $bcs (@mq_bcs) {
191     - my $file = "/usr/share/xt_geoip/LE/" . $bcs . ".iv4";
192     - if (! -f $file) { $listerr .= $bcs . ","; }
193     + my $file = "/usr/share/xt_geoip/LE/" . $bcs . ".iv4";
194     + if (! -f $file) { $listerr .= $bcs . ","; }
195     }
196     return $self->localise('ERR_COUNTRY_NOT_EXIST: {$listerr}', {listerr=> "$listerr"}) if $listerr;
197     }
198     return 'OK';
199     }
200     +
201     +#Subroutine to display buttons
202     +sub print_custom_button
203     +{
204     + my ($fm,$desc,$url,$type) = @_;
205     + my $q = $fm->{cgi};
206     + $url="xt_geoip?page=0&page_stack=&Next=Next&type=".$type."&wherenext=".$url;
207     + print " <tr>\n <td colspan='2'>\n";
208     + print $q->p($q->a({href => $url, -class => "button-like"},$fm->localise($desc)));
209     + print qq(</tr>\n);
210     + return undef;
211     +}
212     +
213     +#Subroutine to list statistics
214     +sub generateStats
215     +{
216     + my $self = shift;
217     + my $q = $self->{cgi};
218     +
219     + # Untaint $name before use in system()
220     + my $stats_type = $q->param ('type');
221     + $stats_type =~ /(.+)/; $stats_type = $1;
222     + if ($stats_type ne "ipt" && $stats_type ne "ssh")
223     + {
224     + print $q->p($q->b($self->localise('INVALID_STATS_TYPE').
225     + $stats_type));
226     + return '';
227     + } else {
228     + # my $now_string = $self->gen_locale_date_string();
229     + my $file = "/var/lib/xt_geoip/extA_" . $stats_type . "_country.lst";
230     + my $filetime = ( -e $file ) ? (stat($file))[9] : 0;
231     + my $date_string = strftime("%Y/%m/%d %H:%M", localtime( $filetime )) || '';
232     + print $q->h3($self->localise('STATS_GENERATED'), "[", $stats_type, "]", $date_string);
233     +
234     + open( XTGEOIPSTATS, $file );
235     + print "<pre>\n";
236     +
237     + while (<XTGEOIPSTATS>)
238     + {
239     + print;
240     + }
241     +
242     + close XTGEOIPSTATS;
243     + print "</pre>\n";
244     +
245     + print $q->h3($self->localise('END_OF_STATS'));
246     + return '';
247     + }
248     +}
249     +
250     1;

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed