From: eldy <> Date: Sat, 13 Dec 2003 01:26:38 +0000 (+0000) Subject: Added graphapplet plugin. X-Git-Tag: AWSTATS_6_0_BETA~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2be5730e07f06128200167abe82b1eb38759088c;p=thirdparty%2FAWStats.git Added graphapplet plugin. --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index a3c061c6..ce28c928 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -1757,12 +1757,13 @@ sub Read_Plugins { foreach my $key (keys %NoLoadPlugin) { if ($NoLoadPlugin{$key} < 0) { push @PluginsToLoad, $key; } } if ($Debug) { debug("Call to Read_Plugins with list: ".join(',',@PluginsToLoad)); } foreach my $plugininfo (@PluginsToLoad) { - if ($NoLoadPlugin{$plugininfo} && $NoLoadPlugin{$plugininfo} > 0) { - if ($Debug) { debug(" Plugin load for '$plugininfo' has been disabled from command line"); } - next; - } my @loadplugin=split(/\s+/,$plugininfo,2); my $pluginfile=$loadplugin[0]; $pluginfile =~ s/\.pm$//i; + # Check if we plugin is not disabled + if ($NoLoadPlugin{$pluginfile} && $NoLoadPlugin{$pluginfile} > 0) { + if ($Debug) { debug(" Plugin load for '$pluginfile' has been disabled from parameters"); } + next; + } my $pluginparam=$loadplugin[1]||''; $pluginfile =~ /([^\/\\]*)$/; my $pluginname=$1; @@ -5027,7 +5028,7 @@ $tomorrowtime=int($tomorrowyear.$tomorrowmonth.$tomorrowday.$tomorrowhour.$tomor # Allowed option my @AllowedCLIArgs=('migrate','config', 'logfile','output','runascli','update', -'staticlinks','staticlinksext','noloadplugin','forceloadplugin', +'staticlinks','staticlinksext','noloadplugin','loadplugin', 'hostfilter','urlfilter','refererpagesfilter', 'lang','month','year','framename','debug', 'showsteps','showdropped','showcorrupted','showunknownorigin', @@ -5129,8 +5130,8 @@ if ($QueryString =~ /(^|&)staticlinksext=([^&]+)/i) { $StaticExt="$2"; } if ($QueryString =~ /(^|&)framename=([^&]+)/i) { $FrameName="$2"; } if ($QueryString =~ /(^|&)debug=(\d+)/i) { $Debug=$2; } if ($QueryString =~ /(^|&)updatefor=(\d+)/i) { $UpdateFor=$2; } -if ($QueryString =~ /(^|&)noloadplugin=([^&]+)/i) { foreach (split(/,/,$2)) { $NoLoadPlugin{"$_"}=1; } } -if ($QueryString =~ /(^|&)forceloadplugin=([^&]+)/i) { foreach (split(/,/,$2)) { $NoLoadPlugin{"$_"}=-1; } } +if ($QueryString =~ /(^|&)noloadplugin=([^&]+)/i) { foreach (split(/,/,$2)) { $NoLoadPlugin{"$_"}=1; } } +if ($QueryString =~ /(^|&)loadplugin=([^&]+)/i) { foreach (split(/,/,$2)) { $NoLoadPlugin{"$_"}=-1; } } if ($QueryString =~ /(^|&)limitflush=(\d+)/i) { $LIMITFLUSH=$2; } # Get/Define output if ($QueryString =~ /(^|&)output(=[^&]*|)(.*)&output(=[^&]*|)(&|$)/i) { error("Only 1 output option is allowed","","",1); } @@ -5169,6 +5170,7 @@ else { $DayRequired=''; } # Print AWStats and Perl version if ($Debug) { + if ($ENV{'GATEWAY_INTERFACE'}) { print "\n"; } # To end the HTTP header and see all debug debug(ucfirst($PROG)." - $VERSION - Perl $^X $]",1); debug("QUERY_STRING=$QueryString",2); debug("HTMLOutput=".join(',',keys %HTMLOutput),1); diff --git a/wwwroot/cgi-bin/plugins/graphapplet.pm b/wwwroot/cgi-bin/plugins/graphapplet.pm index cbf1eb1d..b40ad3fb 100644 --- a/wwwroot/cgi-bin/plugins/graphapplet.pm +++ b/wwwroot/cgi-bin/plugins/graphapplet.pm @@ -26,6 +26,12 @@ my $PluginNeedAWStatsVersion="6.0"; my $PluginHooksFunctions="ShowGraph"; # -----> +# <----- +# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE. +use vars qw/ +$DirClasses +/; +# -----> #----------------------------------------------------------------------------- @@ -37,6 +43,7 @@ sub Init_graphapplet { # <----- # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS + $DirClasses=$InitParams; # -----> return ($checkversion?$checkversion:"$PluginHooksFunctions"); @@ -78,7 +85,7 @@ sub ShowGraph_graphapplet() { else { error("Unknown type parameter in ShowGraph_graphapplet function"); } # print "\n"; - print "\n"; + print "\n"; print < @@ -86,6 +93,7 @@ print < + EOF print "\n"; print "\n"; diff --git a/wwwroot/classes/awgraphapplet.jar b/wwwroot/classes/awgraphapplet.jar index f0219363..38fb8cea 100644 Binary files a/wwwroot/classes/awgraphapplet.jar and b/wwwroot/classes/awgraphapplet.jar differ diff --git a/wwwroot/classes/src/AWGraphApplet.java b/wwwroot/classes/src/AWGraphApplet.java index 58a0e5e9..42781c24 100644 --- a/wwwroot/classes/src/AWGraphApplet.java +++ b/wwwroot/classes/src/AWGraphApplet.java @@ -14,6 +14,7 @@ public class AWGraphApplet extends Applet public AWGraphApplet() { special = "Not yet defined"; + textVertSpacing = 0; b_fontsize = 11; blockSpacing = 5; valSpacing = 0; @@ -21,6 +22,7 @@ public class AWGraphApplet extends Applet maxLabelWidth = 0; background_color = Color.white; border_color = Color.white; + special_color = Color.gray; backgraph_colorl = Color.decode("#F6F6F6"); backgraph_colorm = Color.decode("#EDEDED"); backgraph_colorh = Color.decode("#E0E0E0"); @@ -64,12 +66,15 @@ public class AWGraphApplet extends Applet if (s != null) { background_color = Color.decode("#"+s); } s = getParameter("border_color"); if (s != null) { border_color = Color.decode("#"+s); } + s = getParameter("special_color"); + if (s != null) { special_color = Color.decode("#"+s); } Log("bblocks "+nbblocks); Log("nbvalues "+nbvalues); Log("barsize "+barsize); - font = new Font("Verdana", 0, b_fontsize); + font = new Font("Verdana,Arial,Helvetica", 0, b_fontsize); + fontb = new Font("Verdana,Arial,Helvetica", Font.BOLD, b_fontsize); fontmetrics = getFontMetrics(font); blabels = new String[nbblocks]; @@ -235,9 +240,9 @@ public class AWGraphApplet extends Applet { // background and border bfr.setColor(background_color); - bfr.fillRect(0, 0, getSize().width - 1, getSize().height - 1); + bfr.fillRect(0, 0, getSize().width, getSize().height); bfr.setColor(border_color); - bfr.drawRect(0, 0, getSize().width - 1, getSize().height - 1); + bfr.drawRect(0, 0, getSize().width, getSize().height); // draw the bars and their titles if(orientation == HORIZONTAL) { paintHorizontal(bfr); } @@ -288,16 +293,14 @@ public class AWGraphApplet extends Applet private synchronized void paintVertical(Graphics g) { - Font font1 = new java.awt.Font("Verdana", 0, b_fontsize); - FontMetrics fontmetrics = getFontMetrics(font1); g.setColor(Color.black); - g.setFont(font1); + g.setFont(font); int shift=10; int allbarwidth=(((nbvalues*(valWidth+valSpacing))+blockSpacing)*nbblocks); int allbarheight=barsize; int axepointx=(getSize().width-allbarwidth)/2 - 2*shift; - int axepointy = getSize().height - (2*fontmetrics.getHeight()) - fontmetrics.getDescent(); + int axepointy = getSize().height - (2*fontmetrics.getHeight()) - textVertSpacing; int cx=axepointx; int cy=axepointy; @@ -338,25 +341,32 @@ public class AWGraphApplet extends Applet // Draw the block label // Log("Write block j="+j+" with cx="+cx); - cy = getSize().height - fontmetrics.getHeight() - fontmetrics.getDescent(); + cy = getSize().height - fontmetrics.getHeight() - textVertSpacing; g.setColor(Color.black); // Check if bold or highlight - int bold=0; int highlight=0; - if (blabels[j].indexOf(":")>0) { bold=1; blabels[j]=remove(blabels[j],":"); } - if (blabels[j].indexOf("!")>0) { highlight=1; blabels[j]=remove(blabels[j],"!"); } - - String as[] = split(blabels[j], "\247", 0); + int bold=0; int highlight=0; String label=blabels[j]; + if (blabels[j].indexOf(":")>0) { bold=1; label=remove(blabels[j],":"); } + if (blabels[j].indexOf("!")>0) { highlight=1; label=remove(blabels[j],"!"); } + + if (bold==1) { g.setFont(fontb); } + String as[] = split(label, "\247", 0); + if (highlight==1) { + g.setColor(special_color); + g.fillRect(cx-Math.max(-1+blockSpacing>>1,0),cy-fontmetrics.getHeight(),(nbvalues*(valWidth+valSpacing))+Math.max(blockSpacing-2,0)+1,((fontmetrics.getHeight()+textVertSpacing)*as.length)+2); + g.setColor(Color.black); + } for (int i=0; i>1; + int cxoffset=((nbvalues*(valWidth+valSpacing))-fontmetrics.stringWidth(as[i]))>>1; if (cxoffset<0) { cxoffset=0; } - g.drawString(as[i], cx+cxoffset, cy); - cy+=fontmetrics.getHeight()-2; + g.drawString(as[i], cx+cxoffset, cy); + cy+=fontmetrics.getHeight()+textVertSpacing; } + if (bold==1) { g.setFont(font); } // Loop on each value for (int i = 0; i < nbvalues; i++) { - cy = getSize().height - fontmetrics.getHeight() - fontmetrics.getDescent() - 4; + cy = getSize().height - fontmetrics.getHeight() - textVertSpacing - 4; cy -= fontmetrics.getHeight() - 4; // draw the shadow and bar @@ -378,7 +388,7 @@ public class AWGraphApplet extends Applet public synchronized String[][] getParameterInfo() { String[][] as = { - {"version", "string", "AWGraphApplet 1.0"}, + {"version", "string", "AWGraphApplet "+VERSION}, {"copyright", "string", "GPL"}, {"title", "string", title} }; @@ -391,11 +401,12 @@ public class AWGraphApplet extends Applet private static final int STRIPED = 1; private static final int DEBUG = 3; private static final int SHIFTBAR = 3; - private static final String VERSION = "1.0"; + private static final String VERSION = "1.1"; private String title; private String special; private Font font; + private Font fontb; private FontMetrics fontmetrics; private int orientation; private int barsize; @@ -404,6 +415,7 @@ public class AWGraphApplet extends Applet private String blabels[]; private int b_fontsize; private int blockSpacing; + private int textVertSpacing; private int nbvalues; private Color colors[]; @@ -418,6 +430,7 @@ public class AWGraphApplet extends Applet private int maxLabelWidth; private Color background_color; private Color border_color; + private Color special_color; private Color backgraph_colorl; private Color backgraph_colorm; private Color backgraph_colorh;