Skip to content


awstats按日产生统计报表

修改wwwroot/cgi-bin/awstats.pl 

7851行增加日期下拉框

[code]
    print “<select class=\”aws_formfield\” name=\”day\”>\n”;
    foreach (1..31) {
     my $dayix=sprintf(“%02s”,$_);
     print “<option”.(“$DayRequired” eq “$dayix”?” selected=\”true\””:””).” value=\”$dayix\”>$dayix</option>\n”;
    }
    print “</select>\n”;
[/code]

7871行增加databasebreak参数

[code]
    if ($DatabaseBreak) { print “<input type=\”hidden\” name=\”DatabaseBreak\” value=\”$DatabaseBreak\” />\n”; }
[/code]

命令行统计增加:-databasebreak=day

查看报表时地址栏需增加:&databasebreak=day&day=DD

以下为查看页代码 
[code]

<script>  
 var   d   =   new   Date();  
 d.setTime(d.setDate(d.getDate()-1));  
 var day=d.getDate();  

 var srv = new Array();

 srv[0]=’www.c1gstudio.com’;
 srv[1]=’bbs.c1gstudio.com’;
 srv[2]=’blog.c1gstudio.com’;
 srv[3]=’admin.c1gstudio.com’;

 for (var i=0;i<srv.length ;i++ )
 {
 document.writeln(‘<p><a href=”http://admin.c1gstudio.com/cgi-bin/awstats.pl?config=’+srv[i]+’&databasebreak=day&day=’+day+'” target=”_blank”>http://admin.c1gstudio.com/cgi-bin/awstats.pl?config=’+srv[i]+'</a></p>’);
 }
 document.writeln(‘<hr>’);
[/code]

参考:
http://blogger.org.cn/blog/more.asp?name=chenjiejacky&id=20464
http://www.chedong.com/blog/archives/001293.html#more

Posted in linux 维护优化, 技术.

Tagged with , .


apache log中的 Apache (internal dummy connection)

 

#tail logs/access_log

::1 – – [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0” 200 843 “-” “Apache (internal dummy connection)”
::1 – – [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0” 200 843 “-” “Apache (internal dummy connection)”
::1 – – [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0” 200 843 “-” “Apache (internal dummy connection)”
::1 – – [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0” 200 843 “-” “Apache (internal dummy connection)”
::1 – – [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0” 200 843 “-” “Apache (internal dummy connection)”

修改httpd.conf

    SetEnvIf Remote_Addr “::1” dontlog
    CustomLog logs/access_log combined  env=!dontlog

Posted in Apache, 技术.

Tagged with , .


editplus小技巧:正则替换 html中的标签

举例有html内容如下
<table class=”data”>
<tr   class=”abc”>
<td class=”row1″>abc</td>
<td  width=”200″ class=”row2″>abc</td>
<td class=”row3″ style=”padding:5px” >abc</td>
</tr>
</table>

需将<td >中的内容清空.
用editplus打开,shift+H.
查找内容:<td[^>]*
替换内容:<td
勾上使用正则表达式
解释:查找以“<td”开始的字符,下一个或第N个字符不为”>”的行

也可以这样
查找内容:<td(.*)>(.*)</td>
替换内容:<td>\2</td>
解释:查找以“<td”开始,以</td>结束,中间以”>”分成两段,最出只输出第二段。

Posted in Tools, 其它.

Tagged with , .


nginx 目录自动加斜线”/”

 

默认配置当你访问http://abc.example.com/dir 时不会加”/”

常见做法

      if (-d $request_filename){
  rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
      }

更佳的替代方法

optimize_server_names off;#优化服务器名称:关
server_name_in_redirect off;#服务器名称重定向:关

http://wiki.codemongers.com/NginxHttpCoreModule#optimize_server_names

Posted in Nginx, 技术.

Tagged with , .


nginx 使用ip和密码保护你的目录

 

apache限制ip方法


documentroot “/opt/htdocs/www/”
servername admin.c1gstudio.com


    Options IncludesNoExec FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 222.222.222.222 111.111.111.111


使用ngx_http_access_module限制ip访问

官方示例
http://wiki.codemongers.com/NginxHttpAccessModule#allow

location / {
    deny    192.168.1.1;
    allow   192.168.1.0/24;
    allow   10.1.1.0/16;
    deny    all;
}

改成自已的

location / {
    allow   127.0.0.1;
    allow   222.222.222.222;#服务器ip
    allow   111.111.111.111;#自已电脑的ip
    deny    all;
}

             location ~ .*\.php?$
             {
                  #fastcgi_pass  unix:/tmp/php-cgi.sock;
                  fastcgi_pass  127.0.0.1:9000;
                  fastcgi_index index.php;
                  include fcgi.conf;     
             }

      location ~ ^/cgi-bin/.*\.pl$ {
    auth_basic “Restricted”;
    auth_basic_user_file htpasswd;
    gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
    include awstats.conf;
      }

             location ^~ /nginx {
                  stub_status on;
                  access_log   off;
    auth_basic “NginxStatus”;
    auth_basic_user_file htpasswd;
             }

             location ~ ^/memcached {
                  access_log   off;
    auth_basic “NginxStatus”;
    auth_basic_user_file htpasswd;
             }

结果:测试下来非定义的ip还是可以访问。

再修改下正则

location ^~ / {
    allow   127.0.0.1;
    allow   222.222.222.222;#服务器ip
    allow   111.111.111.111;#自已电脑的ip
    deny    all;
}

结果:非定义的是ip不可以访问了,但php变明文显示,perl是404。

 

你可以看看 nginx 的文档里面关于 location 的说明。它的匹配方式是 正则表达式 优先级比较高。
就是说,你的 PHP 解析用的是 正则表达式进行匹配,而你要限制的目录不是用正则表达式,所以,就算是要限制的目录,因为PHP还是能被匹配到,所以,还是解析PHP了。所以,如果想解决的话,可能需要把目录也写成正则匹配,而且要放在PHP的前面,否则就会先匹配PHP   

 

   satisfy_any on;

http://www.freebsdchina.org/forum/viewtopic.php?t=42141

使用多级目录将保护目录放在根中

location / {
    #allow   127.0.0.1;
    #allow   222.222.222.222;#服务器ip
    allow   111.111.111.111;#自已电脑的ip
    deny    all;

             location ~ .*\.php?$
             {
                  #fastcgi_pass  unix:/tmp/php-cgi.sock;
                  fastcgi_pass  127.0.0.1:9000;
                  fastcgi_index index.php;
                  include fcgi.conf;     
             }

      location ~ ^/cgi-bin/.*\.pl$ {
    auth_basic “Restricted”;
    auth_basic_user_file htpasswd;
    gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
    include awstats.conf;
      }

             location ^~ /nginx {
                  stub_status on;
                  access_log   off;
    auth_basic “NginxStatus”;
    auth_basic_user_file htpasswd;
             }

             location ~ ^/memcached {
                  access_log   off;
    auth_basic “NginxStatus”;
    auth_basic_user_file htpasswd;
             }
}

结果:有效

整个域名需禁止访问可以写在server中

server {

listion 80;
server_name admin.c1gstudio.com;
root /opt/htdocs/www;

allow   111.111.111.111;#自已电脑的ip
deny    all;
auth_basic “Nginx_Panel”;
auth_basic_user_file htpasswd;

location ~ .*\.php?$
{
….
}

 location ^~ /phpmyadmin {
  satisfy any;
       access_log   off;
       location ~ .*\.php?$
       {
     #fastcgi_pass  unix:/tmp/php-cgi.sock;
     fastcgi_pass  127.0.0.1:9000;
     fastcgi_index index.php;
     include fcgi.conf;     
       }
}
location ^~ /memcached {
  satisfy any;
       access_log   off;
       location ~ .*\.php?$
       {
     #fastcgi_pass  unix:/tmp/php-cgi.sock;
     fastcgi_pass  127.0.0.1:9000;
     fastcgi_index index.php;
     include fcgi.conf;     
       }
}

}

参考:http://marc.info/?l=nginx&m=120127282911304&w=2

Posted in Apache, Nginx, 安全, 技术.

Tagged with , , , , .


静态html用js取中文参数,无乱码

 <coolcode>

<script type=”text/javascript”>  
  String.prototype.getQueryString   =   function(name)  
  {  
      var   reg   =   new   RegExp(“(^|&|\\?)”+   name   +”=([^&]*)(&|$)”),   r;  
      if   (r=this.match(reg))   return   unescape(r[2]);   return   null;  
  };  
  </script>
     <script>
     var msg=window.location.href.getQueryString(“msg”);
     if (msg)
     {
     document.write(‘<li>· ’+msg+'</li>’);
     }
     </script>
</coolcode>

在ff下中文会乱码,参数传递过来时需先escape();

<coolcode>

function phpescape($str){
    preg_match_all(“/[\x80-\xff].|[\x01-\x7f]+/”,$str,$newstr);
    $ar = $newstr[0];
    foreach($ar as $k=>$v){
        if(ord($ar[$k])>=127){
            $tmpString=bin2hex(iconv(“GBK”,”ucs-2″,$v));
            if (!eregi(“WIN”,PHP_OS)){
                $tmpString = substr($tmpString,2,2).substr($tmpString,0,2);
            }
            $reString.=”%u”.$tmpString;
        } else {
            $reString.= rawurlencode($v);
        }
    }
    return $reString;
}

</coolcode>

 

参考:

PHP实现Javascript的escape(),unescape()的方法

Firefox自动对url中的中文进行编码导致乱码

Posted in JavaScript/DOM/XML.

Tagged with , , , , .


Google 企业应用套件

 

http://www.google.com/a/help/intl/zh-CN/admins/editions_spe.html

专业版为US$50.00美元/用户帐户/年。
免费版支持100个账号的7G邮箱,支持pop、smtp、imap,中文界面。
Google Talk Google 日历 Google 文件初始页移动访问Google Page Creator 等免费服务。

中文界面到了第二步填写信息的时候,总是会提示你选择的国家(中国)”Google 企业应用套件目前不支持该国家/地区的域名。”

这里有个问题: 最重要的是要通过美国的代理服务器访问;
1 申请的域名必须是.com域名的邮箱:如果有.cn com.cn域名需要申请,可以先申请一个.com域名的,然后设置另外的.cn .com.cn域名为相应的.com域名的别名即可;
2 申请的国家填写美国: 注册页面是有IP对应国家的校验的,所以要通过美国的代理服务器才能提交通过;
可以使用putty
 登录设置中配置tunnel,目标设置为Dynamic,添加一个端口7070,再按Add,一个动态转发端口就实现了;
然后用相应帐号ssh登录后:除了登录的终端窗口意外,本地的7070连服务器的22端口之间就有了一个SSH加密的转发通道了。

为了方便切换,可以使用FireFox的SwitchProxy tool插件,设置socks代理通过本地的127.0.0.1:7070 进行传输。
3 电话号码填写一个合法的美国电话号码:555 222-2222;

注册后:
1 会有域名拥有者校验:
在网站根域名的目录下,上传一个带有校验码的googlehostedservice.html文件;
2 域名MX记录修改等,基本上按照提示修改即可

ASPMX.L.GOOGLE.COM. 10
ALT1.ASPMX.L.GOOGLE.COM. 20
ALT2.ASPMX.L.GOOGLE.COM. 30
ASPMX2.GOOGLEMAIL.COM. 40
ASPMX3.GOOGLEMAIL.COM. 50
ASPMX4.GOOGLEMAIL.COM. 60
ASPMX5.GOOGLEMAIL.COM. 70

如果域名mx解析不够,可以只用ASPMX.L.GOOGLE.COM.

邮箱服务的入口:https://mail.google.com/a/c1gstudio.com/
初始页的入口:http://partnerpage.google.com/c1gstudio.com

客户端收发邮件

每个用户登录到自己的gmail请先设置一下自己的账户
  1. 登录到您的 Gmail 帐户。
  2. 点击任一 Gmail 页顶部的设置
  3. 点击橙色框邮件设置中的转发和 POP
  4. 选择针对所有邮件启用 POP 或者针对从现在起开始接收的邮件启用 POP
  5. 使用 POP 访问 Gmail 邮件后,选择您要对邮件采用的处理方式。
  6. 配置 POP 客户端* 然后点击保存更改

在客户端设置
POP服务器:pop.gmail.com 995
SMTP:smtp.gmail.com 25

用户名:你的企业邮箱邮件地址(包括@c1gstudio.com)
密码:你自己的企业邮箱密码

需要启动SSL(可参考gmail相关页面

 

参考:
 免费企业邮箱: Google企业邮箱的申

美国的代理服务器

Posted in 网站建设.

Tagged with , , .


log中的_vti_bin/owssvr.dll 和/MSOffice/cltreq.asp

404记录

/_vti_bin/owssvr.dll  
/MSOffice/cltreq.asp

此及IE工具栏上的”讨论”按钮产生(需ms office)

Posted in 其它, 分析报告.

Tagged with .


设置apache 日志不记录图片

<FilesMatch “\.(gif|jpg|jpeg|png|css|swf)”>
 SetEnv NoLOG 1
</FilesMatch>

CustomLog logs/www.c1gstudio.com-access_log common env=!NoLOG

对于找不到图片的还是会记录在log中的

Posted in Apache, linux 维护优化, 技术.

Tagged with , , .


linux awstats 安装

http://sourceforge.net/projects/awstats/
#wget http://nchc.dl.sourceforge.net/sourceforge/awstats/awstats-6.8.tar.gz
车东的内主要搜索引擎和蜘蛛定义
#wget http://www.chedong.com/tech/lib.tgz
下载GeoIP的应用库:C
http://www.maxmind.com/download/geoip/api/c/
#wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
下载GeoIP/GeoIPCityLite包:解包并部署到awstats目录下
#wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
#wget http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz

# tar zxvf GeoIP.tar.gz
#cd GeoIP-1.4.4
#./configure
#make && make install
#cd ..

#tar zxvf awstats-6.8.tar.gz
#mv awstats-6.8 /opt/awstats

#gunzip lib.tgz
#tar xvf lib.tar
覆盖原文件
#\cp -a lib/* /opt/awstats/wwwroot/cgi-bin/lib/

#gunzip GeoIP.dat.gz
#gunzip GeoLiteCity.dat.gz
#cp GeoIP.dat /opt/awstats/wwwroot/cgi-bin/plugins/
#cp GeoLiteCity.dat /opt/awstats/wwwroot/cgi-bin/plugins/

设置权限
#chown -R www:website /opt/awstats
#chmod 0755 //opt/awstats/wwwroot/cgi-bin/plugins/Geo*

perl -MCPAN -e ‘install “Geo::IP”‘ 或者使用纯Perl包  perl -MCPAN -e ‘install “Geo::IP::PurePerl”‘
#perl -MCPAN -e ‘install “Geo::IP”‘
一路回车到底

如果失败可以手动安装Geo::IP,并指定库的路径
#wget http://geolite.maxmind.com/download/geoip/api/perl/Geo-IP-1.38.tar.gz
#tar zxvf Geo-IP-1.38.tar.gz
#cd Geo-IP-1.38
#perl Makefile.PL LIBS=’-L/usr/local/lib’ INC=’-I/usr/local/include’
#make && make install

配置awstats
#cd /opt/awstats/tools/
#perl awstats_configure.pl
—–> Running OS detected: Linux, BSD or Unix
Warning: AWStats standard directory on Linux OS is ‘/usr/local/awstats’.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/opt/awstats
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ?

y

—–> Check for web server install
 
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path (‘none’ to skip web server setup):

指定httpd.conf的路径,我用nginx输入none

—–> Update model config file ‘/opt/awstats/wwwroot/cgi-bin/awstats.model.conf’
  File awstats.model.conf updated.
 
—–> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ?

我使用手工写的conf所以输入n

—–> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/opt/awstats/wwwroot/cgi-bin/awstats.pl -update -config=myvirtualserver
Or if you have several config files and prefer having only one command:
/opt/awstats/tools/awstats_updateall.pl now
Press ENTER to continue…

然后回车

将缺省awstats.model.conf 命名成common.conf
#cd ../wwwroot/cgi-bin/
#mv awstats.model.conf common.conf
修改其中的一些配置选项:
#vi common.conf
按”/”输入decodeutfkeys
去掉此行前的”#”
LoadPlugin=”decodeutfkeys”

查找geoip GEOIP_STANDARD和geoip_city_maxmind ,去掉注释并改成你的路径
LoadPlugin=”geoip GEOIP_STANDARD /opt/awstats/wwwroot/cgi-bin/plugins/GeoIP.dat”
LoadPlugin=”geoip_city_maxmind GEOIP_STANDARD /opt/awstats/wwwroot/cgi-bin/plugins/GeoLiteCity.dat

按照一下样例设置配置文件:
#vi /etc/awstats/awstats.www.c1gstudio.com.conf
Include “/opt/awstats/wwwroot/cgi-bin/common.conf”
LogFile=”gzip -d </opt/nginx/logs/www.c1gstudio.com.%YYYY-24%MM-24%DD-24.log.gz |”
SiteDomain=”www.c1gstudio.com”
HostAliases=”c1gstudio.com127.0.0.1 localhost”
DirData=”/var/lib/awstats”

创建数据目录
#mkdir /var/lib/awstats

成生报告
#perl /opt/awstats/wwwroot/cgi-bin/awstats.pl -config=www.c1gstudio.com -update

查看报告
http://www.c1gstudio.com/cgi-bin/awpstats.pl?config=www.c1gstudio.com

定时更新
10 5 * * * (cd /opt/awstats/wwwroot/cgi-bin/;./awstats.pl -update -config=www.c1gstudio.com)

参考资料
http://www.chedong.com/tech/awstats.html
http://blog.s135.com/read.php/199.htm
测试环境
as4 nginx0.6.32

Posted in 技术.