<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ls /proc &#187; webalizer</title>
	<atom:link href="http://www.lsproc.com/blog/tag/webalizer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lsproc.com/blog</link>
	<description>lsproc.com</description>
	<lastBuildDate>Fri, 21 May 2010 14:29:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>解决webalizer 汉化后图表中乱码的问题</title>
		<link>http://www.lsproc.com/blog/webalizer_graphs_bad_encode/</link>
		<comments>http://www.lsproc.com/blog/webalizer_graphs_bad_encode/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 09:47:03 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[webalizer]]></category>
		<category><![CDATA[乱码]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/%e8%a7%a3%e5%86%b3webalizer_%e6%b1%89%e5%8c%96%e5%90%8e%e5%9b%be%e8%a1%a8%e4%b8%ad%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/webalizer_graphs_bad_encode/ 代码如下(webalizer_patch.pl): #!/usr/bin/perl ###################################################### # webalizer_patch.pl # 原作：http://mail.tses.tcc.edu.tw/nuke/sections.php?op=viewarticle&#38;artid=139 # 修改：陶然 &#60;taoran@taoran.net&#62; # 功能: 解决HTML汉化后图表中乱码的问题 # 方法：图表中乱码改用英文显示就正常了 # 需要修改: graphs.c output.c webalizer_lang.h lang.h # # tar zxf webalizer-2.01-10-src.tgz # cd webalizer-2.01-10 # ./configure --with-language=simplified_chinese # perl /path/of/webalizer_patch.pl ./ # make # make install # #################################################### $file_graph = &#34;$ARGV[0]/graphs.c&#34;; if(!(-e $file_graph)) { print &#34;error open [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/webalizer_graphs_bad_encode/">http://www.lsproc.com/blog/webalizer_graphs_bad_encode/</a></p>
<p>代码如下(webalizer_patch.pl):</p>
<pre class="brush: perl">
#!/usr/bin/perl
######################################################
# webalizer_patch.pl
# 原作：http://mail.tses.tcc.edu.tw/nuke/sections.php?op=viewarticle&amp;artid=139
# 修改：陶然 &lt;taoran@taoran.net&gt;
# 功能: 解决HTML汉化后图表中乱码的问题
# 方法：图表中乱码改用英文显示就正常了
#       需要修改: graphs.c output.c webalizer_lang.h lang.h
#
# tar zxf webalizer-2.01-10-src.tgz
# cd webalizer-2.01-10
# ./configure --with-language=simplified_chinese
# perl /path/of/webalizer_patch.pl ./
# make
# make install
#
####################################################
$file_graph	= &quot;$ARGV[0]/graphs.c&quot;;
if(!(-e $file_graph))   {
	print &quot;error open  $file_graph
&quot;;
	print &quot;Usage:
  perl $0  DIR
&quot;;
#DIR是源文件目录，比如 ./
	exit;
}

#把图表中的月份和注释改成英文
@old_var	= (&quot;msg_h_hits&quot;,
		&quot;msg_h_pages&quot;,
		&quot;msg_h_visits&quot;,
		&quot;msg_h_files&quot;,
		&quot;msg_h_sites&quot;,
		&quot;msg_h_xfer&quot;,
		&quot;s_month&quot;);

@new_var	= (&quot;msg_gh_hits&quot;,
		&quot;msg_gh_pages&quot;,
		&quot;msg_gh_visits&quot;,
		&quot;msg_gh_files&quot;,
		&quot;msg_gh_sites&quot;,
		&quot;msg_gh_xfer&quot;,
		&quot;s_gmonth&quot;);

open(IN,&quot;&lt;$file_graph&quot;);
@lines	= &lt;IN&gt;;
$size	= @lines;
close(IN);

`mv $file_graph $file_graph.bak`;
open(OUT,&quot;&gt;$file_graph&quot;);
for($i=0;$i&lt;$size;$i++)   {
	for($k=0;$k&lt;@old_var;$k++)   {
		if($lines[$i] =~ s/$old_var[$k]/$new_var[$k]/g)   {
			print &quot;$i	$old_var[$k] -&gt; $new_var[$k]
&quot;;
			print OUT &quot;/* --- Modified --- */
&quot;;
		}
	}
	print OUT $lines[$i];
}
close(OUT);

#把图表中的标题改成英文显示
$file_output	= &quot;$ARGV[0]/output.c&quot;;
open(IN,&quot;&lt;$file_output&quot;);
@lines	= &lt;IN&gt;;
$size	= @lines;
close(IN);
`mv $file_output $file_output.bak`;
open(OUT,&quot;&gt;$file_output&quot;);
for($i=0;$i&lt;$size;$i++)   {
	if($lines[$i] =~ s/msg_hmth_du,l_month/&quot;Daily Usage for&quot;,s_gmonth/xg) {
		print &quot;$i	patched
&quot;;
		print OUT &quot;/* --- Modified --- */
&quot;;
	} elsif($lines[$i] =~ s/msg_hmth_hu,l_month/&quot;Hourly Usage for&quot;,s_gmonth/xg) {
		print &quot;$i	patched
&quot;;
		print OUT &quot;/* --- Modified --- */
&quot;;
	} elsif($lines[$i] =~ s/msg_ctry_use,l_month/&quot;Usage by Country for&quot;,s_gmonth/xg) {
		print &quot;$i	patched
&quot;;
		print OUT &quot;/* --- Modified --- */
&quot;;
	} elsif($lines[$i] =~ s/msg_main_us/&quot;Usage summary for&quot;/xg) {
		print &quot;$i	patched
&quot;;
		print OUT &quot;/* --- Modified --- */
&quot;;
	}
	print  OUT $lines[$i];
}
close(OUT);

#加入新的函数给前面显示的程序用 

print &quot;
patch	$ARGV[0]/webalizer_lang.h
&quot;;

$file_lang	= &quot;$ARGV[0]/webalizer_lang.h&quot;;
open(OUT,&quot;&gt;&gt;$file_lang&quot;);
print OUT qq~
/* --- start Add  ---*/
char *msg_gh_hits  = &quot;Hits&quot;;
char *msg_gh_pages = &quot;Pages&quot;;
char *msg_gh_visits= &quot;Visits&quot;;
char *msg_gh_files = &quot;Files&quot;;
char *msg_gh_sites = &quot;Sites&quot;;
char *msg_gh_xfer  = &quot;KBytes&quot;;

char *s_gmonth[12]={ &quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;,
                    &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;,
                    &quot;Jul&quot;, &quot;Aug&quot;, &quot;Sep&quot;,
                    &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot;};

/* -------------End------------- */
~;

#补充声明这些新加的函数
print &quot;
patch	$ARGV[0]/lang.h
&quot;;

$file_lang	= &quot;$ARGV[0]/lang.h&quot;;
open(OUT,&quot;&gt;&gt;$file_lang&quot;);
print OUT qq~
/* --- start Add  ---*/
extern char *msg_gh_hits  ;
extern char *msg_gh_pages ;
extern char *msg_gh_visits;
extern char *msg_gh_files ;
extern char *msg_gh_sites ;
extern char *msg_gh_xfer  ;
extern char *s_gmonth[12];
/* -------------End------------- */
~;

print &quot;Done ^_^
&quot;;

####################################################
</pre>
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2010-01-15 -- <a href="http://www.lsproc.com/blog/bash_if_parameters/" title="bash if条件判断参数">bash if条件判断参数</a> (0)</li><li>2010-01-11 -- <a href="http://www.lsproc.com/blog/cacti_graph_with_chinese/" title="cacti 图片中文乱码问题">cacti 图片中文乱码问题</a> (2)</li><li>2010-01-09 -- <a href="http://www.lsproc.com/blog/linux_timeline/" title="linux timeline">linux timeline</a> (2)</li><li>2008-12-16 -- <a href="http://www.lsproc.com/blog/linux_webserver_cmd/" title="Webserver 维护常用命令">Webserver 维护常用命令</a> (9)</li><li>2008-11-10 -- <a href="http://www.lsproc.com/blog/useful_linux_command/" title="一些 linux 命令">一些 linux 命令</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/webalizer_graphs_bad_encode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
