Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3098288
  • 博文数量: 797
  • 博客积分: 10134
  • 博客等级: 上将
  • 技术积分: 9335
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-22 22:57
个人简介

1

文章分类

全部博文(797)

文章存档

2022年(1)

2021年(2)

2017年(2)

2016年(1)

2015年(4)

2014年(1)

2013年(6)

2012年(6)

2011年(10)

2010年(26)

2009年(63)

2008年(61)

2007年(51)

2006年(563)

我的朋友

分类: LINUX

2006-07-26 10:32:35

服务器的日志合并统计
内容摘要:你完全不必耐心地看完下面的所有内容,因为结论无非以下2点:
1 用 cronolog 干净,安全地轮循apache“日”志
2 用 sort -m 合并排序多个日志

根据个人的使用经历:
1 先介绍apache日志的合并方法;
2 然后根据由此引出的问题说明日志轮循的必要性和解决方法,介绍如何通过cronolog对apache日志进行轮循;
中间有很多在设计日志合并过程中一些相关工具的使用技巧和一些尝试的失败经历……
我相信解决以上问题的路径不止这一条途径,以下方案肯定不是最简便或者说成本最低的,希望能和大家有更多的交流。


多服务器日志合并统计的必要性

越来越多大型的WEB服务使用DNS轮循来实现负载均衡:使用多个同样角色的服务器做前台的WEB服务,这大大方便了服务的分布规划和扩展性,但多个服务器的分布使得日志的分析统计也变得有些麻烦。如果使用webalizer等日志分析工具对每台机器分别做日志统计:
1 会对数据的汇总带来很多麻烦,比如:统计的总访问量需要将SERVER1 SERVER2...上指定月份的数字相加。
2 会大大影响统计结果中唯一访客数unique visits,唯一站点数unique sites的等指标的统计,因为这几个指标并非几台机器的代数相加。

统一日志统计所带来的好处是显而易见的,但如何把所有机器的统计合并到一个统计结果里呢?
首先也许会想:多个服务器能不能将日志记录到同一个远程文件里呢?我们不考虑使用远程文件系统记录日志的问题,因为带来的麻烦远比你获得的方便多的多……
因此,要统计的多个服务器的日志还是:分别记录=>并通过一定方式定期同步到后台=>合并=>后用日志分析工具来进行分析。

首先,要说明为什么要合并日志:因为webalizer没有将同一天的多个日志合并的功能
先后运行
webalizer log1
webalizer log2
webalizer log3
这样最后的结果是:只有log3的结果。

能不能将log1<因为一个日志的分析工具不是将日志一次全部读取后进行分析,而且流式的读取日志并按一定时间间隔,保存阶段性的统计结果。因此时间跨度过大(比如2条日志间隔超过5分钟),一些日志统计工具的算法就会将前面的结果“忘掉”。因此, log1<

多台服务日志合并问题:把多个日志中的记录按时间排序后合并成一个文件

典型的多个日志文件的时间字段是这样的:
log1 log2 log3
00:15:00 00:14:00 00:11:00
00:16:00 00:15:00 00:12:00
00:17:00 00:18:00 00:13:00
00:18:00 00:19:00 00:14:00
14:18:00 11:19:00 10:14:00
15:18:00 17:19:00 11:14:00
23:18:00 23:19:00 23:14:00

日志合并必须是按时间将多个日志的交叉合并。合并后的日志应该是:
00:15:00 来自log1
00:15:00 来自log2
00:16:00 来自log1
00:17:00 来自log3
00:18:00 来自log2
00:19:00 来自log1
....

如何合并多个日志文件?
下面以标准的clf格式日志(apache)为例:
apche的日志格式是这样的:
%h %l %u %t \"%r\" %>s %b
具体的例子:
111.222.111.222 - - [03/Apr/2002:10:30:17 +0800] "GET /index.html HTTP/1.1" 200 419

最简单的想法是将日志一一读出来,然后按日志中的时间字段排序
cat log1 log2 log3 |sort -k 4 -t " "
注释:
-t " ": 日志字段分割符号是空格
-k 4: 按第4个字段排序,也就是:[03/Apr/2002:10:30:17 +0800] 这个字段
-o log_all: 输出到log_all这个文件中

但这样的效率比较低,要知道。如果一个服务已经需要使用负载均衡,其服务的单机日志条数往往都超过了千万级,大小在几百M,这样要同时对多个几百M的日志进行排序,机器的负载可想而之……
其实有一个优化的途径,要知道:即使单个日志本身已经是一个“已经按照时间排好序“的文件了,而sort对于这种文件的排序合并提供了一个优化合并算法:使用 -m merge合并选项,
因此:合并这样格式的3个日志文件log1 log2 log3并输出到log_all中比较好方法是:
sort -m -t " " -k 4 -o log_all log1 log2 log3
注释:
-m: 使用 merge优化算法

注意:合并后的日志输出最好压缩以后再发给webalizer处理
有的系统能处理2G的文件,有的不能。有的程序能处理大于2G的文件,有的不能。尽量避免大于2G的文件,除非确认所有参与处理的程序和操作系统都能处理这样的文件。所以输出后的文件如果大于2G,最好将日志gzip后再发给webalizer处理:大于2G的文件分析过程中文件系统出错的可能性比较大,并且gzip后也能大大降低分析期间的I/O操作。

日志的按时间排序合并就是这样实现的。

日志的轮循机制

让我们关心一下数据源问题:webalizer其实是一个按月统计的工具,支持增量统计:因此对于大型的服务,我可以按天将apache的日志合并后送给 webalizer统计。WEB日志是如何按天(比如每天子夜00:00:00)截断呢?
如果你每天使用crontab:每天0点准时将日志备份成access_log_yesterday
mv /path/to/apache/log/access_log /path/to/apache/log/access_log_yesterday
的话:你还需要:马上运行一下:apache restart 否则:apache会因为的日志文件句柄丢失不知道将日志记录到哪里去了。这样归档每天子夜重启apache服务会受到影响。
比较简便不影响服务的方法是:先复制,后清空
cp /path/to/apache/log/access_log /path/to/apache/log/access_log_yesterday
echo >/path/to/apache/log/access_log

严肃的分析员会这样做发现一个问题:
但cp不可能严格保证严格的0点截断。加入复制过程用了6秒,截断的access_log_yesterday日志中会出现复制过程到00:00:06期间的日志。对于单个日志统计这些每天多出来几百行日志是没有问题的。但对于多个日志在跨月的1天会有一个合并的排序问题:
[31/Mar/2002:59:59:59 +0800]
[31/Mar/2002:23:59:59 +0800]
[01/Apr/2002:00:00:00 +0800]
[01/Apr/2002:00:00:00 +0800]

要知道[01/Apr/2002:00:00:00 这个字段是不可以进行“跨天排序”的。因为日期中使用了dd/mm/yyyy,月份还是英文名,如果按照字母排序,很有可能是这样的结果:排序导致了日志的错误
[01/Apr/2002:00:00:00 +0800]
[01/Apr/2002:00:00:00 +0800]
[01/Apr/2002:00:00:00 +0800]
[01/Apr/2002:00:00:00 +0800]
[01/Apr/2002:00:00:00 +0800]
[01/Apr/2002:00:00:00 +0800]
[01/Apr/2002:00:00:00 +0800]
[31/Mar/2002:59:59:59 +0800]
[31/Mar/2002:59:59:59 +0800]
[31/Mar/2002:23:59:59 +0800]
[31/Mar/2002:59:59:59 +0800]
[31/Mar/2002:23:59:59 +0800]

这些跨天过程中的非正常数据对于webalizer等分析工具来说简直就好像是吃了一个臭虫一样,运行的结果是:它可能会把前一个月所有的数据都丢失!因此这样的数据会有很多风险出现在处理上月最后一天的数据的过程中。

问题的解决有几个思路:
1 事后处理:
。所以一个事后的处理的方法是:用grep命令在每月第1天将日志跨月的日志去掉,比如:
grep -v "01/Apr" access_log_04_01 > access_log_new

修改SORT后的日志:所有跨天的数据去掉。也许对日志的事后处理是一个途径,虽然sort命令中有对日期排序的特殊选项 -M(注意是:大写M),可以让指定字段按照英文月份排序而非字母顺序,但对于apache日志来说,用SORT命令切分出月份字段很麻烦。(我尝试过用 "/"做分割符,并且使用“月份” “年:时间”这两个字段排序)。虽然用一些PERL的脚本肯定可以实现,但最终我还是放弃了。这不符合系统管理员的设计原则:通用性。并且你需要一直问自己:有没有更简单的方法呢?
还有就是将日志格式改成用TIMESTAMP(象SQUID的日志就没有这个问题,它的日志本身就是使用TIMESTAMP做时间时间戳的),但我无法保证所有的日志工具都能识别你在日期这个字段使用了特别的格式。

2 优化数据源:
最好的办法还是优化数据源。将数据源保证按天轮循,同一天的日志中的数据都在同一天内。这样以后你无论使用什么工具(商业的,免费的)来分析日志,都不会因为日志复杂的预处理机制受到影响。

首先可能会想到的是控制截取日志的时间:比如严格从0点开始截取日志,但在子夜前1分钟还是后一分钟开始截取是没有区别的,你仍然无法控制一个日志中有跨 2天记录的问题,而且你也无法预测日志归档过程使用的时间。
因此必须要好好考虑一下使用日志轮循工具的问题,这些日志轮循工具要符合:
1 不中断WEB服务:不能停apache=>移动日志=>重启apache
2 保证同一天日志能够按天轮循:每天一个日志00:00:00-23:59:59
3 不受apache重启的影响:如果apache每次重启都会生成一个新的日志是不符合要求的
4 安装配置简单

首先考虑了apache/bin目录下自带的一个轮循工具:rotatelogs 这个工具基本是用来按时间或按大小控制日志的,无法控制何时截断和如何按天归档。
然后考虑logrotate后台服务:logrotate是一个专门对各种系统日志(syslogd,mail)进行轮循的后台服务,比如SYSTEM LOG,但其配置比较复杂,放弃,实际上它也是对相应服务进程发出一个-HUP重启命令来实现日志的截断归档的。

在apache的FAQ中,推荐了经过近2年发展已经比较成熟的一个工具cronolog:安装很简单:configure=>make=> make install

他的一个配置的例子会让你了解它有多么适合日志按天轮循:对httpd.conf做一个很小的修改就能实现:
TransferLog "|/usr/sbin/cronolog /web/logs/%Y/%m/%d/access.log"
ErrorLog "|/usr/sbin/cronolog /web/logs/%Y/%m/%d/errors.log"

然后:日志将写入
/web/logs/2002/12/31/access.log
/web/logs/2002/12/31/errors.log
午夜过后:日志将写入
/web/logs/2003/01/01/access.log
/web/logs/2003/01/01/errors.log
而2003 2003/01 和 2003/01/01 如果不存在的话,将自动创建

所以,只要你不在0点调整系统时间之类的话,日志应该是完全按天存放的(00:00:00-23:59:59),后面日志分析中: [31/Mar/2002:15:44:59这个字段就和日期无关了,只和时间有关。

测试:考虑到系统硬盘容量,决定按星期轮循日志
apache配置中加入:
#%w weekday
TransferLog "|/usr/sbin/cronolog /path/to/apache/logs/%w/access_log"

重启apache后,除了原来的CustomLog /path/to/apche/logs/access_log继续增长外,系统log目录下新建立了 3/目录(测试是在周3),过了一会儿,我忽然发现2个日志的增长速度居然不一样!
分别tail了2个日志才发现:
我设置CustomLog使用的是combined格式,就是包含(扩展信息的),而TransferLog使用的是缺省日志格式,看了apache的手册才知道,TransferLog是用配置文件中离它自己最近的一个格式作为日志格式的。我的httpd.conf里写的是:
LogFormat ..... combined
LogFormat ... common
...
CustomLog ... combined
TransferLog ...

所以TrasferLog日志用的是缺省格式,手册里说要让TRANSFER日志使用指定的格式需要:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
TransferLog "|/usr/local/sbin/cronolog /path/to/apache/logs/%w/access_log"

重启,OK,日志格式一样了。
这样的设置结果其实是同时在logs目录下分别记录2个日志access_log和%w/access_log,能不能只记录%w/下的日志那?
查apache手册,更简单的方法:直接让CustomLog输出到cronolog归档日志,并且还能指定格式。
CustomLog "|/usr/local/sbin/cronolog /path/to/apache/logs/%w/access_log" combined

最后是一个日志同步的问题。

任务:每天凌晨找到前1天的日志,另存一个文件准备发送到服务器上。
比如我要保留前1周的日志:每天复制前1天的日志到指定目录,等待日志服务器来抓取:
/bin/cp -f /path/to/apache/logs/`date -v-1d +%w`/access_log /path/for/backup/logs/access_log_yesterday

在FREEBSD上使用以下命令
date -v-1d +%w
注释:
-v-1d: 前1天,而在GNU/Linux上这个选项应该是date -d yesterday
+%w: weekday,由于使用的都是标准时间函数库,所有工具中的WEEKDAY定义都是一样的 0-6 => 周日-周六

注意:
写到CRONTAB里的时候"%"前面需要加一个"\"转义:每天0点5分进行一次日志归档,
另外一个问题就是在cront中需要用:rm -f {} ; 而不是rm -f {}\;
5 0 * * * /bin/cp /path/to/logs/`date -v-1d +\%w`/access_log /path/to/for_sync/logs/access_yesterday
37 10 * * * /usr/bin/find /home/apache/logs/ -name access_log -mtime +1 -exec /bin/rm -f {} ;

首次开始cronolog日志统计是周3,一周以后日志又将轮循回3/access_log
但这次日志是追加到3/access_log还是重新创建一个文件呢?>>access_log or >access_log?
我测试的结果是日志将被追加:
[01/Apr/2002:23:59:59 +0800]
[01/Apr/2002:23:59:59 +0800]
[08/Apr/2002:00:00:00 +0800]
[08/Apr/2002:00:00:00 +0800]

肯定是不希望每次日志还带着上周的数据的并重复统计一次的(虽然对结果没影响),而且这样%w/下的日志不是也越来越多了吗?
解决方法1 把每天的cp改成mv
解决方法2 每天复制完成后:删除6天以前的access_log日志
find /path/to/apache/logs -name access_log -mtime +6 -exec rm -f {}\;
多保留几天的日志还是有必要的:万一日志分析服务器坏了一天呢?

以下是把apache安装在/home/apache下每天统计的一个脚本文件:
#!/bin/sh

#backup old log
/bin/cp -f /home/apache/logs/`date -d yesterday +%w`/access_log /home/apache/logs/access_log_yesterday

#remove old log
/usr/bin/find /home/apache/logs -name access_log -mtime +6 -exec rm -f {}\;

#analysis with webalizer
/usr/local/sbin/webalizer

总结:
1 用 cronolog 干净,安全地轮循日志
2 用 sort -m 排序合并多个日志


参考资料:

日志分析统计工具:

Apche的日志设置:

Apache的日志轮循:


Cronolog

Webalizer

Webalzer的Windows版

AWStats的使用简介

附1:Webalizer配置文件说明:重要的地方做了翻译并附有一些重要的配置修改

#
# Webalizer 样例配置文件
# Copyright 1997-2000 by Bradford L. Barrett (brad@mrunix.net)
# 翻译: 车东 (chedong@bigfoot.com)
#
# Distributed under the GNU General Public License.  See the
# files "Copyright" and "COPYING" provided with the webalizer
# distribution for additional information.
#
# 这是一个Webalizer (版本 2.01)的配置文件样例
# 所有以'#'开始的行都是被程序忽略的注释,此外空白行也会被跳过,其他行都是具体的配置选项。
# 并按照"ConfigOption  Value"的格式,ConfigOption是合法的配置选项关键词,而Value是相应选项对应的值
# 非法的键/值会被忽略并会有相应的警告提示。关键词和值之间至少需要一个空格或制表符tab分割
#
# 从0.98版本开始,Webalizer会找缺省在当前目录下找一个名为webalizer.conf缺省配置文件
# 如果没有找到,会使用/etc/webalizer.conf


# LogFile 定义了WEB服务的日志文件,如果这里没有定义,并且命令行参数也没有指定文件名,
# 则将STDIN(系统标准输入)作为输入数据源
# 如果日志文件扩展名为'.gz' (是一个gzip压缩文件),程序会一边读取一边进行解压缩。

LogFile        /home/apache/log/access_log_yesterday

# LogType 定义了日志的类型,Webalizer一般用于CLF和Combined格式的WEB服务日志格式
指定这个选项,你可以处理FTP日志(比如wu-ftp生成的xferlog,和Squid自己的日志
值可以是:'clf', 'ftp' 或'squid', 缺省是'clf'
# JNH : 新的'iis'是为IIS设计的,IIS4缺省使用标准日志格式,IIS5缺省使用W3C格式
# webalizer会自动根据日志的文件名进行识别:标准格式的日志文件名以I开头,W3C的是E
# 你可以在一个目录下同时存放2种日志,webalizer会全部读取并生成一份报告

LogType    iis

# OutputDir 报告的输出目录地址,必须是完整的全路径名,但相对路径也许也行,
# 如果没有指定,输出目录就是当前目录。

OutputDir      /home/apache/htdocs/usage/

# HistoryName 允许你设置webalizer生成的历史数据文件名
# 历史数据文件保存了12个月内的数据,这些数据会用来生成首页的HTML页面index.html
# 缺省文件名是:"webalizer.hist",缺省存放在指定的输出目录中, 也可以使用绝对路径指定到其他目录中。

#HistoryName    webalizer.hist

# Incremental 增量处理允许你处理被分隔成多个小文件的大日志,对于大型站点的按周,按天的日志轮循会非常有用
# 为了继续上次的处理,Webalizer在退出前会保存当时处理的数据并在下次运行是恢复当时的状态
在这个模式下,Webalizer会扫描并忽略重复的记录,请看README文件,里面有更详细的解说
值可以是:'yes'或'no'缺省为'no'.
# 'webalizer.current'这个文件用来保存当前数据,位置在OutputDir设置的输出目录中
# 启用这个选项前,请至少阅读一下README文件中的增量处理一节

Incremental    yes

# IncrementalName 允许你设置保存当前数据的文件名,和HistoryName选项一样,除非设置绝对路径,否则文件就在缺省输出目录中,
# 这个选项只有在启用了Incremental模式后才有意义

#IncrementalName    webalizer.current

# ReportTitle是标题文字,除非这个字符串是空的,否则主机名会空一格后显示在后面,
# 缺省是英文:"Usage Statistics for".

#ReportTitle    Usage Statistics for

# HostName 定义了报告对应的主机名,用在报告的标题和URL统计里,这样
# 即使在一个虚拟主机的统计中,点击URL统计的链接也可以转向相应的正确地址。
# 或者生成报告的服务器是在另外一台机器,clicking on URL's in the report to go to the proper location in
# the event you are running the report on a 'virtual' web server,
# or for a server different than the one the report resides on.
# 如果这里没有指定webalizer会尝试调用uname命令获得系统的主机名,如果失败缺省为"localhost"

HostName      

# HTMLExtension 允许你设置生成报告的文件扩展名,一般缺省是"html",但你也可以根据站点改成你需要的名字
(像配置PHP一样 embeded pages)?

#HTMLExtension  html

# PageType 你告诉Webalizer那种类型的URL是你定义的'页面访问'(Page View).  大部分人认为一个html或cgi请求文档是页面,
# 而嵌入在页面中的图片和声音不算,如果没有指定,如果是WEB日志统计,页面的扩展名就是'htm*'和'cgi',
# 如果是ftp日志,扩展名就是'txt' 对于Servlet这样没有扩展名的请求Webalizer也是算页面的。

PageType    htm*
PageType    cgi
PageType    asp
PageType    p*
#PageType    phtml
#PageType    php3
#PageType    pl

# UseHTTPS 如果分析的站点使用安全服务器,URL的链接将是以'https://'开头,而不是缺省的'http://'.
如果需要,把它设置成'yes'。缺省是'no'.  这个配置只影响'Top URL's'里的链接.

#UseHTTPS       no

# DNSCache 指定了用于反相DNS解析的DNS缓存文件,如果你希望对所有日志中所有的IP地址进行反相域名解析
# addresses found in the log file.  如果没有指定绝对路径(文件名不是以'/'开头),这个文件缺省就在输出目录下
更多详细说明请参考DNS.README
# JNH : 如果你使用ListServer选项,你必须指定DnsCache的全路径

#DNSCache    dns_cache.db

# DNSChildren 允许你设置用多少个"子"进程进行DNS解析和更新DNS缓存文件。
# 如果指定了数字,Webalizer会创建DNS缓存文件并且每次运行都会更新,DNS解析会在
日志分析之前根据指定的数值调起子进程进行。如果使用DNS解析,DNS缓存文件名也必须指定。
# DNS lookups.  If used, the DNS cache filename MUST be specified as
# well.  缺省值是0,等于禁用DNS缓存文件,子进程的个数可以是用1 到100之间,如果更大会影响系统运行。
比较合理的值是5到20之间,更多详细信息请参考DNS.README

#DNSChildren    0

# HTMLPre 定义了输出页面中最开头的HTML代码,缺省是以下的DOCTYPE声明
# 每行最长是80个字符,如果需要更多代码可以使用多条配置。

#HTMLPre

# HTMLHead 定义了插入到中间,紧接在行后的HTML代码<BR># 每行最长是80个字符,如果需要更多代码可以使用多条配置。<BR><BR>#HTMLHead <META NAME="author" CONTENT="The Webalizer"><BR><BR># HTMLBody 定义了第一行<BODY>标签的HTML代码,缺省如下:<BR># 每行最长是80个字符,如果需要更多代码可以使用多条配置。<BR><BR><BR>#HTMLBody <BODY BGCOLOR="#E8E8E8" TEXT="#000000" LINK="#0000FF" VLINK="#FF0000"><BR><BR># HTMLPost 定义了输出页面中紧跟在第个<HR>标签后面紧跟在标题<BR># 和"summary period"-"Generated on:"这几行后面的代码。<BR># As with HTMLHead, you can define as many of these as you want and<BR># they will be inserted in the output stream in order of apperance.<BR># 每行最长是80个字符,如果需要更多代码可以使用多条配置。<BR><BR>#HTMLPost     <BR CLEAR="all"><BR><BR># HTMLTail defines the HTML code to insert at the bottom of each<BR># HTML document, usually to include a link back to your home<BR># page or insert a small graphic.  It is inserted as a table<BR># data element (ie: <TD> your code here </TD>) and is right<BR># alligned with the page.  Max string size is 80 characters.<BR><BR>#HTMLTail <IMG SRC="msfree.png" ALT="100% Micro$oft free!"><BR><BR># HTMLEnd defines the HTML code to add at the very end of the<BR># generated files.  It defaults to what is shown below.  If<BR># used, you MUST specify the <script type="text/javascript" src="/js/jquery.qqFace.js"></script> </BODY> and </HTML> closing tags<BR># as the last lines.  Max string length is 80 characters.<BR><BR>#HTMLEnd </BODY></HTML><BR><BR># The Quiet option suppresses output messages... Useful when run<BR># as a cron job to prevent bogus e-mails.  Values can be either<BR># "yes" or "no".  Default is "no".  Note: this does not suppress<BR># warnings and errors (which are printed to stderr).<BR><BR>#Quiet        no<BR><BR># ReallyQuiet will supress all messages including errors and<BR># warnings.  Values can be 'yes' or 'no' with 'no' being the<BR># default.  If 'yes' is used here, it cannot be overriden from<BR># the command line, so use with caution.  A value of 'no' has<BR># no effect.<BR><BR>#ReallyQuiet    no<BR><BR># TimeMe allows you to force the display of timing information<BR># at the end of processing.  A value of 'yes' will force the<BR># timing information to be displayed.  A value of 'no' has no<BR># effect.<BR><BR>#TimeMe        no<BR><BR># GMTTime allows reports to show GMT (UTC) time instead of local<BR># time.  Default is to display the time the report was generated<BR># in the timezone of the local machine, such as EDT or PST.  This<BR># keyword allows you to have times displayed in UTC instead.  Use<BR># only if you really have a good reason, since it will probably<BR># screw up the reporting periods by however many hours your local<BR># time zone is off of GMT.<BR><BR>#GMTTime        no<BR><BR># Debug prints additional information for error messages.  This<BR># will cause webalizer to dump bad records/fields instead of just<BR># telling you it found a bad one.   As usual, the value can be<BR># either "yes" or "no".  The default is "no".  It shouldn't be<BR># needed unless you start getting a lot of Warning or Error<BR># messages and want to see why.  (Note: warning and error messages<BR># are printed to stderr, not stdout like normal messages).<BR><BR>#Debug        no<BR><BR># FoldSeqErr forces the Webalizer to ignore sequence errors.<BR># This is useful for Netscape and other web servers that cache<BR># the writing of log records and do not guarentee that they<BR># will be in chronological order.  The use of the FoldSeqErr<BR># option will cause out of sequence log records to be treated<BR># as if they had the same time stamp as the last valid record.<BR># Default is to ignore out of sequence log records.<BR><BR>#FoldSeqErr    no<BR><BR># VisitTimeout 用来定义一个访客回话的超时时间,缺省为30分钟。<BR># Visits是根据访客发出请求的时间和来自这个访客所在站点(IP)的最后访问时间决定的,<BR># 如果2者时间间隔超过VisitTimeout的值,这个请求就被认为是一个新的访客,访客数也被加1<BR># 值为超时的秒数(缺省为=1800秒=30分钟)<BR><BR>#VisitTimeout    1800<BR><BR># IgnoreHist shouldn't be used in a config file, but it is here<BR># just because it might be usefull in certain situations.  If the<BR># history file is ignored, the main "index.html" file will only<BR># report on the current log files contents.  Usefull only when you<BR># want to reproduce the reports from scratch.  USE WITH CAUTION!<BR># Valid values are "yes" or "no".  Default is "no".<BR><BR>#IgnoreHist    no<BR><BR># Country Graph allows the usage by country graph to be disabled.<BR># Values can be 'yes' or 'no', default is 'yes'.<BR><BR>#CountryGraph    yes<BR><BR># DailyGraph and DailyStats allows the daily statistics graph<BR># and statistics table to be disabled (not displayed).  Values<BR># may be "yes" or "no". Default is "yes".<BR><BR>#DailyGraph    yes<BR>#DailyStats    yes<BR><BR># HourlyGraph and HourlyStats allows the hourly statistics graph<BR># and statistics table to be disabled (not displayed).  Values<BR># may be "yes" or "no". Default is "yes".<BR><BR>#HourlyGraph    yes<BR>#HourlyStats    yes<BR><BR># GraphLegend allows the color coded legends to be turned on or off<BR># in the graphs.  The default is for them to be displayed.  This only<BR># toggles the color coded legends, the other legends are not changed.<BR># If you think they are hideous and ugly, say 'no' here :)<BR><BR>#GraphLegend    yes<BR><BR># GraphLines allows you to have index lines drawn behind the graphs.<BR># I personally am not crazy about them, but a lot of people requested<BR># them and they weren't a big deal to add.  The number represents the<BR># number of lines you want displayed.  Default is 2, you can disable<BR># the lines by using a value of zero ('0').  [max is 20]<BR># Note, due to rounding errors, some values don't work quite right.<BR># The lower the better, with 1,2,3,4,6 and 10 producing nice results.<BR><BR>#GraphLines    2<BR><BR># The "Top" options below define the number of entries for each table.<BR># Defaults are Sites=30, URL's=30, Referrers=30 and Agents=15, and<BR># Countries=30. TopKSites and TopKURLs (by KByte tables) both default<BR># to 10, as do the top entry/exit tables (TopEntry/TopExit).  The top<BR># search strings and usernames default to 20.  Tables may be disabled<BR># by using zero (0) for the value.<BR><BR>#TopSites        30<BR>#TopKSites       10<BR>#TopURLs         30<BR>#TopKURLs        10<BR>#TopReferrers    30<BR>#TopAgents       15<BR>#TopCountries    30<BR>#TopEntry        10<BR>#TopExit         10<BR>#TopSearch       20<BR>#TopUsers        20<BR><BR># All* 关键词允许显示所有的URL,独立站点(IP),引用链接(Referrers)<BR># 用户浏览器, 搜索关键词和用户名,如果启用,会生成另外一个HTML页面并有链接<BR># 加在相应栏目的下面,注意以下2点,这些统计必然比TOP统计要大的多,第2,这些对外都是可见的<BR># 值可以是yes或no,缺省都是no,对于一个公开发布的站点,这些按月生成的统计<BR># 会非常大。会需要很多磁盘空间,如果访问很多也会带来很多流量。<BR>  <BR>#AllSites    no<BR><SPAN style="COLOR: rgb(0,153,0)">AllURLs            yes</SPAN><BR>#AllReferrers    no<BR>#AllAgents    no<BR><SPAN style="COLOR: rgb(0,153,0)">AllSearchStr    yes</SPAN><BR>#AllUsers       no<BR><BR># The Webalizer normally strips the string 'index.' off the end of<BR># URL's in order to consolidate URL totals.  For example, the URL<BR># /somedir/index.html is turned into /somedir/ which is really the<BR># same URL.  This option allows you to specify additional strings<BR># to treat in the same way.  You don't need to specify 'index.' as<BR># it is always scanned for by The Webalizer, this option is just to<BR># specify _additional_ strings if needed.  If you don't need any,<BR># don't specify any as each string will be scanned for in EVERY<BR># log record... A bunch f them will degrade performance.  Also,<BR># the string is scanned for anywhere in the URL, so a string of<BR># 'home' would turn the URL /somedir/homepages/brad/home.html into<BR># just /somedir/ which is probably not what was intended.<BR><BR>#IndexAlias     home.htm<BR>#IndexAlias    homepage.htm<BR><BR># The Hide*, Group* and Ignore* and Include* keywords allow you to<BR># change the way Sites, URL's, Referrers, User Agents and Usernames<BR># are manipulated.  The Ignore* keywords will cause The Webalizer to<BR># completely ignore records as if they didn't exist (and thus not<BR># counted in the main site totals).  The Hide* keywords will prevent<BR># things from being displayed in the 'Top' tables, but will still be<BR># counted in the main totals.  The Group* keywords allow grouping<BR># similar objects as if they were one.  Grouped records are displayed<BR># in the 'Top' tables and can optionally be displayed in BOLD and/or<BR># shaded. Groups cannot be hidden, and are not counted in the main<BR># totals. The Group* options do not, by default, hide all the items<BR># that it matches.  If you want to hide the records that match (so just<BR># the grouping record is displayed), follow with an identical Hide*<BR># keyword with the same value.  (see example below)  In addition,<BR># Group* keywords may have an optional label which will be displayed<BR># instead of the keywords value.  The label should be seperated from<BR># the value by at least one 'white-space' character, such as a space<BR># or tab.<BR>#<BR># The value can have either a leading or trailing '*' wildcard<BR># character.  If no wildcard is found, a match can occur anywhere<BR># in the string. Given a string "", the values "your",<BR># "*mama.com" and "*" will all match.<BR># Your own site should be hidden<BR><BR>#HideSite    *mrunix.net<BR>#HideSite    localhost<BR><BR># Your own site gives most referrals<BR>#HideReferrer    mrunix.net/<BR><BR># This one hides non-referrers ("-" Direct requests)<BR>#HideReferrer    Direct Request<BR><BR># Usually you want to hide these<BR>HideURL        *.gif<BR>HideURL        *.GIF<BR>HideURL        *.jpg<BR>HideURL        *.JPG<BR>HideURL        *.png<BR>HideURL        *.PNG<BR>HideURL        *.ra<BR><SPAN style="COLOR: rgb(0,153,0)">HideURL         *.css</SPAN><BR><BR># Hiding agents is kind of futile<BR>#HideAgent    RealPlayer<BR><BR># You can also hide based on authenticated username<BR>#HideUser    root<BR>#HideUser    admin<BR><BR># Grouping options<BR>#GroupURL    /cgi-bin/*    CGI Scripts<BR>#GroupURL    /images/*    Images<BR>#GroupSite    *.aol.com<BR>#GroupSite    *.compuserve.com<BR>#GroupReferrer    yahoo.com/    Yahoo!<BR>#GroupReferrer    excite.com/     Excite<BR>#GroupReferrer    infoseek.com/   InfoSeek<BR>#GroupReferrer    webcrawler.com/ WebCrawler<BR><BR>#GroupUser      root            Admin users<BR>#GroupUser      admin           Admin users<BR>#GroupUser      wheel           Admin users<BR><BR># The following is a great way to get an overall total<BR># for browsers, and not display all the detail records.<BR># (You should use MangleAgent to refine further...)<BR><BR>#GroupAgent    MSIE        Micro$oft Internet Exploder<BR>#HideAgent    MSIE<BR>#GroupAgent    Mozilla        Netscape<BR>#HideAgent    Mozilla<BR>#GroupAgent    Lynx*        Lynx<BR>#HideAgent    Lynx*<BR><BR># HideAllSites allows forcing individual sites to be hidden in the<BR># report.  This is particularly useful when used in conjunction<BR># with the "GroupDomain" feature, but could be useful in other<BR># situations as well, such as when you only want to display grouped<BR># sites (with the GroupSite keywords...).  The value for this<BR># keyword can be either 'yes' or 'no', with 'no' the default,<BR># allowing individual sites to be displayed.<BR><BR>#HideAllSites    no<BR><BR># The GroupDomains keyword allows you to group individual hostnames<BR># into their respective domains.  The value specifies the level of<BR># grouping to perform, and can be thought of as 'the number of dots'<BR># that will be displayed.  For example, if a visiting host is named<BR># cust1.tnt.mia.uu.net, a domain grouping of 1 will result in just<BR># "uu.net" being displayed, while a 2 will result in "mia.uu.net".<BR># The default value of zero disable this feature.  Domains will only<BR># be grouped if they do not match any existing "GroupSite" records,<BR># which allows overriding this feature with your own if desired.<BR><BR>#GroupDomains    0<BR><BR># The GroupShading allows grouped rows to be shaded in the report.<BR># Useful if you have lots of groups and individual records that<BR># intermingle in the report, and you want to diferentiate the group<BR># records a little more.  Value can be 'yes' or 'no', with 'yes'<BR># being the default.<BR><BR>#GroupShading    yes<BR><BR># GroupHighlight allows the group record to be displayed in BOLD.<BR># Can be either 'yes' or 'no' with the default 'yes'.<BR><BR>#GroupHighlight    yes<BR><BR># The Ignore* keywords allow you to completely ignore log records based<BR># on hostname, URL, user agent, referrer or username.  I hessitated in<BR># adding these, since the Webalizer was designed to generate _accurate_<BR># statistics about a web servers performance.  By choosing to ignore<BR># records, the accuracy of reports become skewed, negating why I wrote<BR># this program in the first place.  However, due to popular demand, here<BR># they are.  Use the same as the Hide* keywords, where the value can have<BR># a leading or trailing wildcard '*'.  Use at your own risk ;)<BR><BR>#IgnoreSite    bad.site.net<BR>#IgnoreURL    /test*<BR>#IgnoreReferrer    file:/*<BR>#IgnoreAgent    RealPlayer<BR>#IgnoreUser     root<BR><BR># The Include* keywords allow you to force the inclusion of log records<BR># based on hostname, URL, user agent, referrer or username.  They take<BR># precidence over the Ignore* keywords.  Note: Using Ignore/Include<BR># combinations to selectivly process parts of a web site is _extremely<BR># inefficent_!!! Avoid doing so if possible (ie: grep the records to a<BR># seperate file if you really want that kind of report).<BR><BR># Example: Only show stats on Joe User's pages...<BR>#IgnoreURL    *<BR>#IncludeURL    ~joeuser*<BR><BR># Or based on an authenticated username<BR>#IgnoreUser     *<BR>#IncludeUser    someuser<BR><BR># The MangleAgents allows you to specify how much, if any, The Webalizer<BR># should mangle user agent names.  This allows several levels of detail<BR># to be produced when reporting user agent statistics.  There are six<BR># levels that can be specified, which define different levels of detail<BR># supression.  Level 5 shows only the browser name (MSIE or Mozilla)<BR># and the major version number.  Level 4 adds the minor version number<BR># (single decimal place).  Level 3 displays the minor version to two<BR># decimal places.  Level 2 will add any sub-level designation (such<BR># as Mozilla/3.01Gold or MSIE 3.0b).  Level 1 will attempt to also add<BR># the system type if it is specified.  The default Level 0 displays the<BR># full user agent field without modification and produces the greatest<BR># amount of detail.  User agent names that can't be mangled will be<BR># left unmodified.<BR><BR>#MangleAgents    0<BR><BR># 搜索引擎关键词允许你设置搜索引擎和URL中的查询格式,用于统计用户通过那些关键词<BR># 被用来找到你的站点。第1个关键词是从WEB日志中的referrer字段识别搜索引擎,第2个是<BR># URL中的关键词的参数名。<BR><BR>SearchEngine    yahoo.com    p=<BR>SearchEngine    altavista.com    q=<BR>SearchEngine    google.com    q=<BR>SearchEngine    eureka.com    q=<BR>SearchEngine    lycos.com    query=<BR>SearchEngine    hotbot.com    MT=<BR>SearchEngine    msn.com        MT=<BR>SearchEngine    infoseek.com    qt=<BR>SearchEngine    webcrawler    searchText=<BR>SearchEngine    excite        search=<BR>SearchEngine    netscape.com    search=<BR>SearchEngine    mamma.com    query=<BR>SearchEngine    alltheweb.com    query=<BR>SearchEngine    northernlight.com  qr=<BR><SPAN style="COLOR: rgb(0,153,0)">SearchEngine    baidu.com   word=</SPAN><BR style="COLOR: rgb(0,153,0)"><SPAN style="COLOR: rgb(0,153,0)">SearchEngine    sina.com.cn word=</SPAN><BR style="COLOR: rgb(0,153,0)"><SPAN style="COLOR: rgb(0,153,0)">SearchEngine    sohu.com    word=</SPAN><BR style="COLOR: rgb(0,153,0)"><SPAN style="COLOR: rgb(0,153,0)">SearchEngine    163.com q=</SPAN><BR><BR><BR><BR># Dump* 用来将统计导出成用制表符(TAB)分割的文本文件,从而方便导入到其他应用中做统计。<BR># 比如数据库和统计软件<BR><BR># DumpPath specifies the path to dump the files.  If not specified,<BR># it will default to the current output directory.  Do not use a<BR># trailing slash ('/').<BR><BR>#DumpPath    /var/lib/httpd/logs<BR><BR># The DumpHeader keyword specifies if a header record should be<BR># written to the file.  A header record is the first record of the<BR># file, and contains the labels for each field written.  Normally,<BR># files that are intended to be imported into a database system<BR># will not need a header record, while spreadsheets usually do.<BR># Value can be either 'yes' or 'no', with 'no' being the default.<BR><BR>#DumpHeader    no<BR><BR># DumpExtension allow you to specify the dump filename extension<BR># to use.  The default is "tab", but some programs are pickey about<BR># the filenames they use, so you may change it here (for example,<BR># some people may prefer to use "csv").<BR><BR>#DumpExtension    tab<BR><BR># 控制各个大类统计的导出。<BR># 值可以是'yes'或 'no'缺省为'no'.<BR><BR>#DumpSites    no<BR><SPAN style="COLOR: rgb(0,153,0)">DumpURLs    yes</SPAN><BR>DumpReferrers    yes<BR>#DumpAgents    no<BR>#DumpUsers    no<BR><SPAN style="COLOR: rgb(0,153,0)">DumpSearchStr   yes</SPAN><BR><BR># End of configuration file...  Have a nice day!<BR><BR># begin of JNH mofications<BR># new entry for Win32 release<BR><BR># NOUVELLE ENTREE pour les serveurs NT<BR><BR># nom de la page par defaut sur le serveur<BR># replace file "Index" for unix systems by other name <BR><BR># IndexPage default<BR><BR># 所有的日志存放目录<BR># 文件个数限制为一个目录下250,如果需要处理更多你需要移动文件并再次运行。<BR><BR># FolderLog       C:\JnhDev\WebAlizer32\Exemple de Logs\IIS4.0\Log Standard\<BR><SPAN style="COLOR: rgb(0,153,0)">FolderLog C:\WINNT\system32\LogFiles\W3SVC3\</SPAN><BR>ExtentionLog log<BR><BR># when you use mix type of log in same folder, webalizer sort file for order by<BR># name, but if begin of file file is mix sort didn't make work, then you can disable it<BR># default is no <BR><BR># DisableSort yes<BR><BR><BR># Name of file contain list of server to process like for each line :<BR># Name of Customer<SPACE>Folder of log<SPACE>Folder output<SPACE>Host Name1;Host Name 2<BR># sample (extract of production file, who have 255 lines)<BR># all of option in this file apply to all reports ...<BR># New in this file you can use coma (") for delimit field<BR># wA001 c:\WA001\LogIIS\ c:\wA001\stats wa001.LeRelaisInternet.com;www1.jeanlouisaubert.com<BR># wA002 c:\WA002\LogIIS\ c:\wA002\stats wa002.LeRelaisInternet.com;<BR># wA003 c:\WA003\LogIIS\ c:\wA003\stats Wa003.LeRelaisInternet.com;<BR><BR>#ServerList c:\jnhdev\webalizer\listeserv.txt<BR><BR># If you have dayly rotation on log name, you can change name after process a file<BR># to have less no productive work day<BR># to use this option you need to use "HistoryName" and "Incremental"<BR><BR><SPAN style="COLOR: rgb(0,153,0)">RenameLog yes</SPAN><BR style="COLOR: rgb(0,153,0)"><SPAN style="COLOR: rgb(0,153,0)">NewExtension sav</SPAN><BR><BR><BR># 2 New Options for optimize DNS resolution : is time to live in data base cache <BR># for good dns resolution (default is 30 days) and for bad resolution, like<BR># no reverse IP, in this case it's better to store errors in database file <BR># cause each day bad dns consume a lot of time (default 7 days)<BR><BR>#TtlDns         30<BR>#TtlDnsError    7<BR><BR># new option for convert each record date to Local time before process it ...<BR># Test only<BR># default = No<BR><BR>ConvertTime yes<BR><BR><BR># end of JNH .. HAve a nice day !!!<BR><BR></P> <P>注意:对IIS日志需要通过配置将发送字节数sc_size和referer2个字段启用。<BR></P></DIV></TD></TR></TBODY></TABLE></DIV> </div> <!-- <div class="Blog_con3_1">管理员在2009年8月13日编辑了该文章文章。</div> --> <div class="Blog_con2_1 Blog_con3_2"> <div> <!--<img src="/image/default/tu_8.png">--> <!-- JiaThis Button BEGIN --> <div class="bdsharebuttonbox"><A class=bds_more href="#" data-cmd="more"></A><A class=bds_qzone title=分享到QQ空间 href="#" data-cmd="qzone"></A><A class=bds_tsina title=分享到新浪微博 href="#" data-cmd="tsina"></A><A class=bds_tqq title=分享到腾讯微博 href="#" data-cmd="tqq"></A><A class=bds_renren title=分享到人人网 href="#" data-cmd="renren"></A><A class=bds_weixin title=分享到微信 href="#" data-cmd="weixin"></A></div> <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script> <!-- JiaThis Button END --> </div> 阅读(20784) | 评论(0) | 转发(0) | <div class="HT_line3"></div> </div> <div class="Blog_con3_3"> <div><span id='digg_num'>0</span><a href="javascript:void(0)" id='digg' bid='2842118' url='/blog/digg.html' ></a></div> <p>上一篇:<a href="/uid-16935607-id-2842117.html">Linux备份策略研究</a></p> <p>下一篇:<a href="/uid-16935607-id-2842119.html">Linux各项系统开机服务的功能是什么?</a></p> </div> </div> <!-- <div class="Blog_con3_4 Blog_con3_5"> <div class="Blog_tit2 Blog_tit7">热门推荐</div> <ul> <li><a href="" title="" target='blank' ></a></li> </ul> </div> --> </div> </div> <div class="Blog_right1_7" id='replyList'> <div class="Blog_tit3">给主人留下些什么吧!~~</div> <!--暂无内容--> <!-- 评论分页--> <div class="Blog_right1_6 Blog_right1_12"> </div> <!-- 评论分页--> <div class="Blog_right1_10" style="display:none"> <div class="Blog_tit3">评论热议</div> <!--未登录 --> <div class="Blog_right1_8"> <div class="nologin_con1"> 请登录后评论。 <p><a href="http://account.chinaunix.net/login" onclick="link(this)">登录</a> <a href="http://account.chinaunix.net/register?url=http%3a%2f%2fblog.chinaunix.net">注册</a></p> </div> </div> </div> <div style="text-align:center;margin-top:10px;"> <script type="text/javascript" smua="d=p&s=b&u=u3118759&w=960&h=90" src="//www.nkscdn.com/smu0/o.js"></script> </div> </div> </div> </div> <input type='hidden' id='report_url' value='/blog/ViewReport.html' /> <script type="text/javascript"> //测试字符串的长度 一个汉字算2个字节 function mb_strlen(str) { var len=str.length; var totalCount=0; for(var i=0;i<len;i++) { var c = str.charCodeAt(i); if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) { totalCount++; }else{ totalCount+=2; } } return totalCount; } /* var Util = {}; Util.calWbText = function (text, max){ if(max === undefined) max = 500; var cLen=0; var matcher = text.match(/[^\x00-\xff]/g), wlen = (matcher && matcher.length) || 0; //匹配url链接正则 http://*** var pattern = /http:\/\/([\w-]+\.)+[\w-]+(\/*[\w-\.\/\?%&=][^\s^\u4e00-\u9fa5]*)?/gi; //匹配的数据存入数组 var arrPt = new Array(); var i = 0; while((result = pattern.exec(text)) != null){ arrPt[i] = result[0]; i++; } //替换掉原文本中的链接 for(var j = 0;j<arrPt.length;j++){ text = text.replace(arrPt[j],""); } //减掉链接所占的长度 return Math.floor((max*2 - text.length - wlen)/2 - 12*i); }; */ var allowComment = '0'; //举报弹出层 function showJuBao(url, cid){ $.cover(false); asyncbox.open({ id : 'report_thickbox', url : url, title : '举报违规', width : 378, height : 240, scroll : 'no', data : { 'cid' : cid, 'idtype' : 2 , 'blogurl' : window.location.href }, callback : function(action){ if(action == 'close'){ $.cover(false); } } }); } $(function(){ //创建管理员删除的弹出层 $('#admin_article_del').click(function(){ $.cover(false); asyncbox.open({ id : 'class_thickbox', html : '<div class="HT_layer3_1"><ul><li class="HT_li1">操作原因:<select class="HT_sel7" id="del_type" name="del_type"><option value="广告文章">广告文章</option><option value="违规内容">违规内容</option><option value="标题不明">标题不明</option><option value="文不对题">文不对题</option></select></li><li class="HT_li1" ><input class="HT_btn4" id="admin_delete" type="button" /></li></ul></div>', title : '选择类型', width : 300, height : 150, scroll : 'no', callback : function(action){ if(action == 'close'){ $.cover(false); } } }); }); $('#admin_delete').live('click' , function(){ ///blog/logicdel/id/3480184/url/%252Fblog%252Findex.html.html var type = $('#del_type').val(); var url = '/blog/logicdel/id/2842118/url/%252Fuid%252F16935607.html.html'; window.location.href= url + '?type=' + type; }); //顶 js中暂未添加&过滤 $('#digg').live('click' , function(){ if(isOnLine == '' ) { //showErrorMsg('登录之后才能进行此操作' , '消息提示'); showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); return false; } var bid = $('#digg').attr('bid'); var url = $('#digg').attr('url'); var digg_str = $.cookie('digg_id'); if(digg_str != null) { var arr= new Array(); //定义一数组 arr = digg_str.split(","); //字符分割 for( i=0 ; i < arr.length ; i++ ) { if(bid == arr[i]) { showErrorMsg('已经赞过该文章', '消息提示'); return false; } } } $.ajax({ type:"POST", url:url, data: { 'bid' : bid }, dataType: 'json', success:function(msg){ if(msg.error == 0) { var num = parseInt($('#digg_num').html(),10); num += 1; $('#digg_num').html(num); $('#digg').die(); if(digg_str == null) { $.cookie('digg_id', bid, {expires: 30 , path: '/'}); } else { $.cookie('digg_id', digg_str + ',' + bid, {expires: 30 , path: '/'}); } showSucceedMsg('谢谢' , '消息提示'); } else if(msg.error == 1) { //showErrorMsg(msg.error_content , '消息提示'); showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); } else if(msg.error == 2) { showErrorMsg(msg.error_content , '消息提示'); } } }); }); //举报弹出层 /*$('.box_report').live('click' , function(){ if(isOnLine == '' ) { //showErrorMsg('登录之后才能进行此操作' , '消息提示'); showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); return false; } var url = $('#report_url').val(); var cid = $(this).attr('cid'); $.cover(false); asyncbox.open({ id : 'report_thickbox', url : url, title : '举报违规', width : 378, height : 240, scroll : 'no', data : { 'cid' : cid, 'idtype' : 2 }, callback : function(action){ if(action == 'close'){ $.cover(false); } } }); });*/ //评论相关代码 //点击回复显示评论框 $('.Blog_a10').live('click' , function(){ if(isOnLine == '' ) { //showErrorMsg('登录之后才能进行此操作' , '消息提示'); showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); return false; } if(allowComment == 1) { showErrorMsg('该博文不允许评论' , '消息提示'); return false; } var tid = $(this).attr('toid');//留言作者id var bid = $(this).attr('bid');//blogid var cid = $(this).attr('cid');//留言id var tname = $(this).attr('tname'); var tpl = '<div class="Blog_right1_9">'; tpl += '<div class="div2">'; tpl += '<textarea name="" cols="" rows="" class="Blog_ar1_1" id="rmsg">文明上网,理性发言...</textarea>'; tpl += '</div>'; tpl += '<div class="div3">'; tpl += '<div class="div3_2"><a href="javascript:void(0);" class="Blog_a11" id="quota_sbumit" url="/Comment/PostComment.html" tid="'+tid+'" bid="'+bid+'" cid="'+cid+'" tname="'+tname+'" ></a><a href="javascript:void(0)" id="qx_comment" class="Blog_a12"></a></div>'; tpl += '<div class="div3_1"><a href="javascript:void(0);" id="mface"><span></span>表情</a></div>'; tpl += '<div class="clear"></div>'; tpl += '</div>'; tpl += '</div>'; $('.z_move_comment').html(''); $(this).parents('.Blog_right1_8').find('.z_move_comment').html(tpl).show(); }); //引用的评论提交 $('#quota_sbumit').live('click' , function(){ if(isOnLine == '' ) { //showErrorMsg('登录之后才能进行此操作' , '消息提示'); showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); return false; } var bid = $(this).attr('bid'); var tid = $(this).attr('tid');//被引用人的id var qid = $(this).attr('cid');//引用的id var url = $(this).attr('url'); var text = $('#rmsg').val(); var tname = $(this).attr('tname'); if(text == '' || text=='文明上网,理性发言...') { showErrorMsg('评论内容不能为空!' , '消息提示'); return false; } else { if(mb_strlen(text) > 1000){ showErrorMsg('评论内容不能超过500个汉字' , '消息提示'); return false; } } $.ajax({ type: "post", url: url , data: {'bid': bid , 'to' : tid , 'qid' : qid , 'text': text , 'tname' : tname }, dataType: 'json', success: function(data){ if(data.code == 1){ var tpl = '<div class="Blog_right1_8">'; tpl+= '<div class="Blog_right_img1"><a href="' +data.info.url+ '" >' + data.info.header + '</a></div>'; tpl+= '<div class="Blog_right_font1">'; tpl+= '<p class="Blog_p5"><span><a href="' +data.info.url+ '" >' + data.info.username + '</a></span>' + data.info.dateline + '</p>'; tpl+= '<p class="Blog_p7"><a href="' + data.info.quota.url + '">' + data.info.quota.username + '</a>:'+ data.info.quota.content + '</p>'; tpl+= '<p class="Blog_p8">' + data.info.content + '</p><span class="span_text1"><a href="javascript:void(0);" class="Blog_a10" toid=' + data.info.fuid + ' bid=' + data.info.bid + ' cid=' + data.info.cid + ' tname = ' + data.info.username + ' >回复</a> |  <a class="comment_del_mark" style="cursor:pointer" url="' + data.info.delurl + '" >删除</a> |  <a href="javascript:showJuBao(\'/blog/ViewReport.html\','+data.info.cid+')" class="box_report" cid="' + data.info.cid + '" >举报</a></span></div>'; tpl+= '<div class="z_move_comment" style="display:none"></div>'; tpl+= '<div class="Blog_line1"></div></div>'; $('#replyList .Blog_right1_8:first').before(tpl); $('.z_move_comment').html('').hide(); } else if(data.code == -1){ //showErrorMsg(data.info , '消息提示'); showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); } }, error: function(){//请求出错处理 } }); }); //底部发表评论 $('#submitmsg').click(function(){ if(allowComment == 1) { showErrorMsg('该博文不允许评论' , '消息提示'); return false; } var bid = $(this).attr('bid'); var toid = $(this).attr('toid'); var text = $('#reply').val(); var url = $(this).attr('url'); if(text == '' || text=='文明上网,理性发言...') { showErrorMsg('评论内容不能为空!' , '消息提示'); return false; } else { if(mb_strlen(text) > 1000){ showErrorMsg('评论内容不能超过500个汉字' , '消息提示'); return false; } } $.ajax({ type: "post", url: url , data: {'bid': bid , 'to' : toid ,'text': text}, dataType: 'json', success: function(data){ if(data.code == 1) { var tpl = '<div class="Blog_right1_8">'; tpl += '<div class="Blog_right_img1"><a href="' +data.info.url+ '" >' + data.info.header + '</a></div>'; tpl += '<div class="Blog_right_font1">'; tpl += '<p class="Blog_p5"><span><a href="' +data.info.url+ '" >' + data.info.username + '</a></span>' + data.info.dateline + '</p>'; tpl += '<p class="Blog_p6">' + data.info.content + '</p>'; tpl += '<div class="div1"><a href="javascript:void(0);" class="Blog_a10" toid=' + data.info.fuid + ' bid=' + data.info.bid + ' cid=' + data.info.cid + '>回复</a> |  <a class="comment_del_mark" style="cursor:pointer" url="' + data.info.delurl + '">删除</a> |  <a href="javascript:showJuBao(\'/blog/ViewReport.html\','+data.info.cid+')" class="box_report" cid="' + data.info.cid + '">举报</a></div>'; tpl += '<div class="z_move_comment" style="display:none"></div>'; tpl += '</div><div class="Blog_line1"></div></div>'; $('.Blog_tit3:first').after(tpl); $('#reply').val('文明上网,理性发言...'); } else if(data.code == -1) { showErrorMsg(data.info , '消息提示'); } }, error: function(){//请求出错处理 } }); }); //底部评论重置 $('#reset_comment').click(function(){ $('#reply').val('文明上网,理性发言...'); }); //取消回复 $('#qx_comment').live('click' , function(){ $('.z_move_comment').html('').hide(); }); $('#rmsg, #reply').live({ focus:function(){ if($(this).val() == '文明上网,理性发言...'){ $(this).val(''); } }, blur:function(){ if($(this).val() == ''){ $(this).val('文明上网,理性发言...'); } } }); //删除留言确认 $('.comment_del_mark').live('click' , function(){ var url = $(this).attr('url'); asyncbox.confirm('删除留言','确认', function(action){ if(action == 'ok') { location.href = url; } }); }); //删除时间确认 $('.del_article_id').click(function(){ var delurl = $(this).attr('delurl'); asyncbox.confirm('删除文章','确认', function(action){ if(action == 'ok') { location.href = delurl; } }); }); /* //字数限制 $('#rmsg, #reply').live('keyup', function(){ var id = $(this).attr('id'); var left = Util.calWbText($(this).val(), 500); var eid = '#errmsg'; if(id == 'reply') eid = '#rerrmsg'; if (left >= 0) $(eid).html('您还可以输入<span>' + left + '</span>字'); else $(eid).html('<font color="red">您已超出<span>' + Math.abs(left) + '</span>字 </font>'); }); */ //加载表情 $('#face').qqFace({id : 'facebox1', assign : 'reply', path : '/image/qqface/'}); $('#mface').qqFace({id : 'facebox', assign : 'rmsg', path:'/image/qqface/'}); /* $('#class_one_id').change(function(){ alert(123213); var id = parseInt($(this).val() , 10); if(id == 0) return false; $('.hidden_son_class span').each(function( index , dom ){ if( dom.attr('cid') == id ) { } }); }); */ //转载文章 var turn_url = "/blog/viewClassPart.html"; $('#repost_bar').click(function(){ if(isOnLine == '' ) { //showErrorMsg('登录之后才能进行此操作' , '消息提示'); showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); return false; } var id = $(this).attr('bid'); asyncbox.open({ id : 'turn_class_thickbox', url : turn_url, title : '转载文章', width : 330, height : 131, scroll : 'no', data : { 'id' : id }, callback : function(action){ if(action == 'close'){ $.cover(false); } } }); }); /* //转发文章 $('#repost_bar').live('click' , function(){ if(isOnLine == '' ) { //showErrorMsg('登录之后才能进行此操作' , '消息提示'); showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); return false; } var bid = $(this).attr('bid'); var url = $(this).attr('url'); asyncbox.confirm('转载文章','确认', function(action){ if(action == 'ok'){ $.ajax({ type:"POST", url:url, data: { 'bid' : bid }, dataType: 'json', success:function(msg){ if(msg.error == 0){ showSucceedMsg('转发成功!', '消息提示'); }else if(msg.error == 1){ //location.href = '/index.php?r=site/login'; showErrorMsg('操作失败,您需要先登录!', '消息提示', 'http://account.chinaunix.net/login'); }else{ showErrorMsg(msg.error_content, '消息提示'); } } }); } }); }); */ }); </script> <!--该部分应该放在输出代码块的后面才起作用 --> <script type="text/javascript"> SyntaxHighlighter.autoloader( 'applescript /highlight/scripts/shBrushAppleScript.js', 'actionscript3 as3 /highlight/scripts/shBrushAS3.js', 'bash shell /highlight/scripts/shBrushBash.js', 'coldfusion cf /highlight/scripts/shBrushColdFusion.js', 'cpp c /highlight/scripts/shBrushCpp.js', 'c# c-sharp csharp /highlight/scripts/shBrushCSharp.js', 'css /highlight/scripts/shBrushCss.js', 'delphi pascal /highlight/scripts/shBrushDelphi.js', 'diff patch pas /highlight/scripts/shBrushDiff.js', 'erl erlang /highlight/scripts/shBrushErlang.js', 'groovy /highlight/scripts/shBrushGroovy.js', 'java /highlight/scripts/shBrushJava.js', 'jfx javafx /highlight/scripts/shBrushJavaFX.js', 'js jscript javascript /highlight/scripts/shBrushJScript.js', 'perl pl /highlight/scripts/shBrushPerl.js', 'php /highlight/scripts/shBrushPhp.js', 'text plain /highlight/scripts/shBrushPlain.js', 'py python /highlight/scripts/shBrushPython.js', 'ruby rails ror rb /highlight/scripts/shBrushRuby.js', 'scala /highlight/scripts/shBrushScala.js', 'sql /highlight/scripts/shBrushSql.js', 'vb vbnet /highlight/scripts/shBrushVb.js', 'xml xhtml xslt html /highlight/scripts/shBrushXml.js' ); SyntaxHighlighter.all(); function code_hide(id){ var code = document.getElementById(id).style.display; if(code == 'none'){ document.getElementById(id).style.display = 'block'; }else{ document.getElementById(id).style.display = 'none'; } } </script> <!--回顶部js2011.12.30--> <script language="javascript"> lastScrollY=0; function heartBeat(){ var diffY; if (document.documentElement && document.documentElement.scrollTop) diffY = document.documentElement.scrollTop; else if (document.body) diffY = document.body.scrollTop else {/*Netscape stuff*/} percent=.1*(diffY-lastScrollY); if(percent>0)percent=Math.ceil(percent); else percent=Math.floor(percent); document.getElementById("full").style.top=parseInt(document.getElementById("full").style.top)+percent+"px"; lastScrollY=lastScrollY+percent; if(lastScrollY<200) { document.getElementById("full").style.display="none"; } else { document.getElementById("full").style.display="block"; } } var gkuan=document.body.clientWidth; var ks=(gkuan-960)/2-30; suspendcode="<div id=\"full\" style='right:-30px;POSITION:absolute;TOP:500px;z-index:100;width:26px; height:86px;cursor:pointer;'><a href=\"javascript:void(0)\" onclick=\"window.scrollTo(0,0);\"><img src=\"\/image\/top.png\" /></a></div>" document.write(suspendcode); window.setInterval("heartBeat()",1); </script> <!-- footer --> <div class="Blog_footer" style='clear:both'> <div><a href="http://www.chinaunix.net/about/index.shtml" target="_blank" rel="nofollow">关于我们</a> | <a href="http://www.it168.com/bottomfile/it168.shtml" target="_blank" rel="nofollow">关于IT168</a> | <a href="http://www.chinaunix.net/about/connect.html" target="_blank" rel="nofollow">联系方式</a> | <a href="http://www.chinaunix.net/about/service.html" target="_blank" rel="nofollow">广告合作</a> | <a href="http://www.it168.com//bottomfile/flgw/fl.htm" target="_blank" rel="nofollow">法律声明</a> | <a href="http://account.chinaunix.net/register?url=http%3a%2f%2fblog.chinaunix.net" target="_blank" rel="nofollow">免费注册</a> <p>Copyright 2001-2010 ChinaUnix.net All Rights Reserved 北京皓辰网域网络信息技术有限公司. 版权所有 </p> <div>感谢所有关心和支持过ChinaUnix的朋友们 <p><a href="http://beian.miit.gov.cn/">16024965号-6 </a></p> </div> </div> </div> </div> <script language="javascript"> //全局错误提示弹出框 function showErrorMsg(content, title, url){ var url = url || ''; var title = title || '消息提示'; var html = ''; html += '<div class="HT_layer3_1 HT_layer3_2"><ul><li><p><span class="login_span1"></span>' + content + '</p></li>'; if(url == '' || url.length == 0){ html += '<li class="HT_li1"><input type="button" class="HT_btn2" onclick=\'close_windows("error_msg")\'></li>'; } else { html += '<li class="HT_li1"><input type="button" class="login_btn1" onclick="location.href=\'' + url + '\'"></li>'; } html += '</ul></div>'; $.cover(true); asyncbox.open({ id: 'error_msg', title : title, html : html, 'callback' : function(action){ if(action == 'close'){ $.cover(false); } } }); } //全局正确提示 function showSucceedMsg(content, title , url ){ var url = url || ''; var title = title || '消息提示'; var html = ''; html += '<div class="HT_layer3_1 HT_layer3_2"><ul><li><p><span class="login_span2"></span>' + content + '</p></li>'; if(url == '' || url.length == 0){ html += '<li class="HT_li1"><input type="button" class="HT_btn2" onclick=\'close_windows("error_msg")\'></li>'; } else { html += '<li class="HT_li1"><input type="button" class="HT_btn2" onclick="location.href=\'' + url + '\'"></li>'; } html += '</ul></div>'; $.cover(true); asyncbox.open({ id: 'error_msg', title : title, html : html, 'callback' : function(action){ if(action == 'close'){ $.cover(false); } } }); } //关闭指定id的窗口 function close_windows(id){ $.cover(false); $.close(id); } //公告 var tID; var tn; // 高度 var nStopTime = 5000; // 不同行间滚动时间隔的时间,值越小,移动越快 var nSpeed = 50; // 滚动时,向上移动一像素间隔的时间,值越小,移动越快 var isMove = true; var nHeight = 25; var nS = 0; var nNewsCount = 3; /** * n 用于表示是否为第一次运行 **/ function moveT(n) { clearTimeout(tID) var noticev2 = document.getElementById("noticev2") nS = nSpeed; // 只在第一次调用时运行,初始化环境(有没有参数) if (n) { // 设置行高 noticev2.style.lineHeight = nHeight + "px"; // 初始化显示位置 tn = 0; // 刚进入时在第一行停止时间 nS = nStopTime; } // 判断鼠标是否指向层 if (isMove) { // 向上移动一像素 tn--; // 如果移动到最下面一行了,则移到顶行 if (Math.abs(tn) == nNewsCount * nHeight) { tn = 0; } // 设置位置 noticev2.style.marginTop = tn + "px"; // 完整显示一行时,停止一段时间 if (tn % nHeight == 0) { nS = nStopTime; } } tID = setTimeout("moveT()", nS); } moveT(1); // 此处可以传入任何参数 </script> <script type="text/javascript"> // var _gaq = _gaq || []; // _gaq.push(['_setAccount', 'UA-20237423-2']); // _gaq.push(['_setDomainName', '.chinaunix.net']); // _gaq.push(['_trackPageview']); // // (function() { // var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; // ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; // var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); // })(); </script> <script type="text/javascript"> var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://"); document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F0ee5e8cdc4d43389b3d1bfd76e83216b' type='text/javascript'%3E%3C/script%3E")); function link(t){ var href= $(t).attr('href'); href+="?url="+encodeURIComponent(location.href); $(t).attr('href',href); //setCookie("returnOutUrl", location.href, 60, "/"); } </script> </body> </html>