下载
wget ftp://ftp.mrunix.net/pub/webalizer/webalizer-2.23-05-src.tar.bz2
tar jxvf webalizer-2.23-05-src.tar.bz2
修改增加中文支持(主要是调用ttf字体的gd函数来生成图片)
由于diff文件比较长,这里只帖出关键的部分。
graphs.c
+
/* common public declarations */
@@ -98,6 +101,27 @@
/*****************************************************************/
/* */
+/* Chinese font support by è??é???? ??ˉ */
+/* */
+/*****************************************************************/
+
+/**
+ * font_path is extern var defined in webalizer.h and set in webalizer.c
+ */
+void my_gdImageString(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color)
+{
+ gdImageStringFT(im, 0 , color, font_path, 9 , 0.0, x, y+9, s); //font size is 9
+}
+
+void my_gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color)
+{
+ gdImageStringFT(im, 0 , color, font_path, 9 , -PI/2, x, y-9 , s);
+}
然后把所有的gdImageStringUp替换为my_gdImageStringUp
gdImageString替换为my_gdImageString
再把my_my_替换为my_
再将lang/webalizer_lang.simplified_chinese重新保存为utf-8编码的文件。
为了增加一个“return top":
diff -Nur webalizer-2.23-05-orig/output.c webalizer-2.23-05/output.c
--- webalizer-2.23-05-orig/output.c 2011-01-03 12:52:05.000000000 +0800
+++ webalizer-2.23-05/output.c 2012-09-02 14:17:37.000000000 +0800
@@ -223,7 +223,7 @@
fprintf(out_fp,"%s\n",lptr->string);
lptr=lptr->next;
}
- fprintf(out_fp,"\n
\n
\n
\n");
+ fprintf(out_fp,"\n
\n
\n
\n");
}
sample.conf
+FontPath /usr/share/fonts/truetype/arphic/uming.ttc
#HTMLHead
#HTMLHead
+HTMLHead
+HTMLEnd
+HTMLEnd ↑Top
+HTMLEnd
HTMLEnd