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

Contents 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.5 - (show annotations) (download)
Sun Apr 21 18:41:58 2019 UTC (5 years, 7 months ago) by michel
Branch: MAIN
CVS Tags: smeserver-xt_geoip-1_0_1-18_el6_sme, smeserver-xt_geoip-1_0_1-20_el6_sme, smeserver-xt_geoip-1_0_1-14_el6_sme, smeserver-xt_geoip-1_0_1-17_el6_sme, smeserver-xt_geoip-1_0_1-24_el6_sme, smeserver-xt_geoip-1_0_1-23_el6_sme, smeserver-xt_geoip-1_0_1-26_el6_sme, smeserver-xt_geoip-1_0_1-25_el6_sme, smeserver-xt_geoip-1_0_1-11_el6_sme, smeserver-xt_geoip-1_0_1-12_el6_sme, smeserver-xt_geoip-1_0_1-16_el6_sme, smeserver-xt_geoip-1_0_1-15_el6_sme, smeserver-xt_geoip-1_0_1-22_el6_sme, smeserver-xt_geoip-1_0_1-21_el6_sme, smeserver-xt_geoip-1_0_1-13_el6_sme, smeserver-xt_geoip-1_0_1-10_el6_sme, smeserver-xt_geoip-1_0_1-9_el6_sme, smeserver-xt_geoip-1_0_1-19_el6_sme, HEAD
Changes since 1.4: +0 -0 lines
* 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 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-21 21:19:38.819847189 +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-21 21:19:38.819847189 +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-21 21:19:38.819847189 +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 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
162 --- 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
163 +++ smeserver-xt_geoip-1.0.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm 2019-04-21 21:22:29.486625737 +0400
164 @@ -81,7 +81,7 @@
165 my $self = esmith::FormMagick->new();
166 $self->{calling_package} = (caller)[0];
167 bless $self;
168 - #$self->debug(1);
169 +# $self->debug(1);
170 return $self;
171 }
172
173 @@ -213,12 +213,65 @@
174 my $listerr = "";
175 my @mq_bcs = split /[,:]/, $q->param("masq_badcountries");
176 if (@mq_bcs) {
177 + my $ctr = @mq_bcs;
178 + return $self->localise('ERR_COUNTRY_MAX: {$ctr}', {ctr=> "$ctr"}) if ($ctr > 50);
179 +
180 foreach my $bcs (@mq_bcs) {
181 - my $file = "/usr/share/xt_geoip/LE/" . $bcs . ".iv4";
182 - if (! -f $file) { $listerr .= $bcs . ","; }
183 + my $file = "/usr/share/xt_geoip/LE/" . $bcs . ".iv4";
184 + if (! -f $file) { $listerr .= $bcs . ","; }
185 }
186 return $self->localise('ERR_COUNTRY_NOT_EXIST: {$listerr}', {listerr=> "$listerr"}) if $listerr;
187 }
188 return 'OK';
189 }
190 +
191 +#Subroutine to display buttons
192 +sub print_custom_button
193 +{
194 + my ($fm,$desc,$url,$type) = @_;
195 + my $q = $fm->{cgi};
196 + $url="xt_geoip?page=0&page_stack=&Next=Next&type=".$type."&wherenext=".$url;
197 + print " <tr>\n <td colspan='2'>\n";
198 + print $q->p($q->a({href => $url, -class => "button-like"},$fm->localise($desc)));
199 + print qq(</tr>\n);
200 + return undef;
201 +}
202 +
203 +#Subroutine to list statistics
204 +sub generateStats
205 +{
206 + my $self = shift;
207 + my $q = $self->{cgi};
208 +
209 + # Untaint $name before use in system()
210 + my $stats_type = $q->param ('type');
211 + $stats_type =~ /(.+)/; $stats_type = $1;
212 + if ($stats_type ne "ipt" && $stats_type ne "ssh")
213 + {
214 + print $q->p($q->b($self->localise('INVALID_STATS_TYPE').
215 + $stats_type));
216 + return '';
217 + } else {
218 + # my $now_string = $self->gen_locale_date_string();
219 + my $file = "/var/lib/xt_geoip/extA_" . $stats_type . "_country.lst";
220 + my $filetime = ( -e $file ) ? (stat($file))[9] : 0;
221 + my $date_string = strftime("%Y/%m/%d %H:%M", localtime( $filetime )) || '';
222 + print $q->h3($self->localise('STATS_GENERATED'), "[", $stats_type, "]", $date_string);
223 +
224 + open( XTGEOIPSTATS, $file );
225 + print "<pre>\n";
226 +
227 + while (<XTGEOIPSTATS>)
228 + {
229 + print;
230 + }
231 +
232 + close XTGEOIPSTATS;
233 + print "</pre>\n";
234 +
235 + print $q->h3($self->localise('END_OF_STATS'));
236 + return '';
237 + }
238 +}
239 +
240 1;

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