Better plugin error management.
sub html_end {
my $listplugins=shift||0;
if (scalar keys %HTMLOutput) {
+
+ # Call to plugins' function AddHTMLBodyFooter
+ foreach my $pluginname (keys %{$PluginsLoaded{'AddHTMLBodyFooter'}}) {
+ my $function="AddHTMLBodyFooter_$pluginname()";
+ eval("$function");
+ }
+
if ($FrameName ne 'index' && $FrameName ne 'mainleft') {
print "$Center<br /><br />\n";
print "<span dir=\"ltr\" style=\"font: 11px verdana, arial, helvetica; color: #$color_text;\">";
my $ret; # To get init return
my $initfunction="\$ret=Init_$pluginname('$pluginparam')";
my $initret=eval("$initfunction");
+ if ($initret eq 'xxx') { $initret='Error: The PluginHooksFunctions variable defined in plugin file does not contain list of hooked functions'; }
if (! $initret || $initret =~ /^error/i) {
# Init function failed, we stop here
error("Plugin init for plugin '$pluginname' failed with return code: ".($initret?"$initret":"$@ (A module required by plugin might be missing)."));
if ($Debug) { debug(" No check on code or code is OK. Now we check other conditions.",5); }
# Check conditions
- my $conditionok=0;
+ $conditionok=0;
foreach my $condnum (0..@{$ExtraConditionType[$extranum]}-1) {
my $conditiontype=$ExtraConditionType[$extranum][$condnum];
my $conditiontypeval=$ExtraConditionTypeVal[$extranum][$condnum];
eval("$function");
}
- # MENU
+ # TOP BAN
#---------------------------------------------------------------------
if ($ShowMenu || $FrameName eq 'mainleft') {
- if ($Debug) { debug("ShowMenu",2); }
my $frame=($FrameName eq 'mainleft');
+ my $WIDTHMENU1=($FrameName eq 'mainleft'?$FRAMEWIDTH:150);
+
+ if ($Debug) { debug("ShowTopBan",2); }
print "$Center<a name=\"menu\"> </a>\n";
- my $WIDTHMENU1=($FrameName eq 'mainleft'?$FRAMEWIDTH:150);
if ($FrameName ne 'mainleft') {
my $NewLinkParams=${QueryString};
if ($FrameName ne 'mainleft') { print "</form>\n"; }
else { print "<br />\n"; }
print "\n";
+ }
+
+ # Call to plugins' function AddHTMLMenuHeader
+ foreach my $pluginname (keys %{$PluginsLoaded{'AddHTMLMenuHeader'}}) {
+ my $function="AddHTMLMenuHeader_$pluginname()";
+ eval("$function");
+ }
+
+ # MENU
+ #---------------------------------------------------------------------
+ if ($ShowMenu || $FrameName eq 'mainleft') {
+ my $frame=($FrameName eq 'mainleft');
+ my $WIDTHMENU1=($FrameName eq 'mainleft'?$FRAMEWIDTH:150);
+
+ if ($Debug) { debug("ShowMenu",2); }
# Print menu links
if (($HTMLOutput{'main'} && $FrameName ne 'mainright') || $FrameName eq 'mainleft') { # If main page asked
debug("firstdaytoshowtime=$firstdaytoshowtime, lastdaytoshowtime=$lastdaytoshowtime",1);
}
+ # Call to plugins' function AddHTMLContentHeader
+ foreach my $pluginname (keys %{$PluginsLoaded{'AddHTMLContentHeader'}}) {
+ my $function="AddHTMLContentHeader_$pluginname()";
+ eval("$function");
+ }
+
# Output particular part
# if ($HTMLOutput{'alldays'}) {
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: AddHTMLBodyHeader_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
-# Function called to Add HTML code at beginning of BODY section.
+# Function called to Add HTML code at beginning of BODY section (top of page).
# Parameters: None
#-----------------------------------------------------------------------------
sub AddHTMLBodyHeader_example {
# ----->
}
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: AddHTMLBodyFooter_pluginname
+# UNIQUE: NO (Several plugins using this function can be loaded)
+# Function called to Add HTML code at end of BODY section (bottom of page).
+# Parameters: None
+#-----------------------------------------------------------------------------
+sub AddHTMLBodyFooter_example {
+ # <-----
+ # PERL CODE HERE
+ # ----->
+}
+
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: AddHTMLMenuHeader_pluginname
+# UNIQUE: NO (Several plugins using this function can be loaded)
+# Function called to Add HTML code just before the menu section
+# Parameters: None
+#-----------------------------------------------------------------------------
+sub AddHTMLMenuHeader_example {
+ # <-----
+ # PERL CODE HERE
+ # ----->
+}
+
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: AddHTMLMenuFooter_pluginname
+# UNIQUE: NO (Several plugins using this function can be loaded)
+# Function called to Add HTML code just after the menu section
+# Parameters: None
+#-----------------------------------------------------------------------------
+sub AddHTMLMenuFooter_example {
+ # <-----
+ # PERL CODE HERE
+ # ----->
+}
+
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: AddHTMLContentHeader_pluginname
+# UNIQUE: NO (Several plugins using this function can be loaded)
+# Function called to Add HTML code just before the first report
+# Parameters: None
+#-----------------------------------------------------------------------------
+sub AddHTMLContentHeader_example {
+ # <-----
+ # PERL CODE HERE
+ # ----->
+}
+
#-----------------------------------------------------------------------------
# PLUGIN FUNCTION: ShowInfoHost_pluginname
# UNIQUE: NO (Several plugins using this function can be loaded)
# GetCountryCodeByName is called to translate a host name into a country name.
#-----------------------------------------------------------------------------
sub GetCountryCodeByName_geoip {
+ my $param="$_[0]";
# <-----
- my $res=$TmpDomainLookup{$_[0]}||'';
+ my $res=$TmpDomainLookup{$param}||'';
if (! $res) {
- $res=lc($gi->country_code_by_name($_[0]));
- $TmpDomainLookup{$_[0]}=$res;
- if ($Debug) { debug(" GetCountryCodeByName for $_[0]: [$res]",5); }
+ $res=lc($gi->country_code_by_name($param));
+ $TmpDomainLookup{$param}=$res;
+ if ($Debug) { debug(" GetCountryCodeByName for $param: [$res]",5); }
}
- elsif ($Debug) { debug(" GetCountryCodeByName for $_[0]: Already resolved to $res",5); }
- return $res;
+ elsif ($Debug) { debug(" GetCountryCodeByName for $param: Already resolved to $res",5); }
# ----->
+ return $res;
}
#-----------------------------------------------------------------------------
# GetCountryCodeByAddr is called to translate an ip into a country name.
#-----------------------------------------------------------------------------
sub GetCountryCodeByAddr_geoip {
+ my $param="$_[0]";
# <-----
- my $res=$TmpDomainLookup{$_[0]}||'';
+ my $res=$TmpDomainLookup{$param}||'';
if (! $res) {
- $res=lc($gi->country_code_by_addr($_[0]));
- $TmpDomainLookup{$_[0]}=$res;
- if ($Debug) { debug(" GetCountryCodeByAddr for $_[0]: $res",5); }
+ $res=lc($gi->country_code_by_addr($param));
+ $TmpDomainLookup{$param}=$res;
+ if ($Debug) { debug(" GetCountryCodeByAddr for $param: $res",5); }
}
- elsif ($Debug) { debug(" GetCountryCodeByAddr for $_[0]: Already resolved to $res",5); }
- return $res;
+ elsif ($Debug) { debug(" GetCountryCodeByAddr for $param: Already resolved to $res",5); }
# ----->
+ return $res;
}
# <-----
-push @INC, "${DIR}/plugins";
# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
+push @INC, "${DIR}/plugins";
if (!eval ('require "Geo/IPfree.pm";')) { return $@?"Error: $@":"Error: Need Perl module Geo::IPfree"; }
# ----->
use strict;no strict "refs";
# GetCountryCodeByName is called to translate a host name into a country name.
#-----------------------------------------------------------------------------
sub GetCountryCodeByName_geoipfree {
+ my $param="$_[0]";
# <-----
- my $res=$TmpDomainLookup{$_[0]}||'';
+ my $res=$TmpDomainLookup{$param}||'';
if (! $res) {
- ($res,undef)=$gi->LookUp($_[0]);
+ ($res,undef)=$gi->LookUp($param);
if ($res !~ /\w\w/) { $res='ip'; }
else { $res=lc($res); }
- $TmpDomainLookup{$_[0]}=$res;
- if ($Debug) { debug(" GetCountryCodeByName for $_[0]: $res",5); }
+ $TmpDomainLookup{$param}=$res;
+ if ($Debug) { debug(" GetCountryCodeByName for $param: $res",5); }
}
- elsif ($Debug) { debug(" GetCountryCodeByName for $_[0]: Already resolved to $res",5); }
- return $res;
+ elsif ($Debug) { debug(" GetCountryCodeByName for $param: Already resolved to $res",5); }
# ----->
+ return $res;
}
#-----------------------------------------------------------------------------
# GetCountryCodeByAddr is called to translate an ip into a country name.
#-----------------------------------------------------------------------------
sub GetCountryCodeByAddr_geoipfree {
+ my $param="$_[0]";
# <-----
- my $res=$TmpDomainLookup{$_[0]}||'';
+ my $res=$TmpDomainLookup{$param}||'';
if (! $res) {
- ($res,undef)=$gi->LookUp($_[0]);
+ ($res,undef)=$gi->LookUp($param);
if ($res !~ /\w\w/) { $res='ip'; }
else { $res=lc($res); }
- $TmpDomainLookup{$_[0]}=$res;
- if ($Debug) { debug(" GetCountryCodeByAddr for $_[0]: $res",5); }
+ $TmpDomainLookup{$param}=$res;
+ if ($Debug) { debug(" GetCountryCodeByAddr for $param: $res",5); }
}
- elsif ($Debug) { debug(" GetCountryCodeByAddr for $_[0]: Already resolved to $res",5); }
- return $res;
+ elsif ($Debug) { debug(" GetCountryCodeByAddr for $param: Already resolved to $res",5); }
# ----->
+ return $res;
}
1; # Do not remove this line