messages日志文件中IP获取小程序

日志内容: …… authentication failure; logname= uid=0 euid=0 tty=NODEVssh ruser= rhost=61.146.178.13 authentication failure; logname= uid=0 euid=0 tty=NODEVssh ruser= rhost=bin86.ee.ccu.edu.tw authentication failure; logname= uid=0 euid=0 tty=NODEVssh ruser= rhost=137.65.134.61.net.jq.gs.dynamic.163data.com.cn …… #!/usr/bin/perl use strict; # Open log file open(XXX, "/path/to/logfile") || die "Error Reading File : $!"; my @urls = <xxx>; close(XXX); my $i = 0; my @ips = (); for my $ip (@urls) { #if ($ip =~ /rhost=((d{1,3}.d{1,3}.d{1,3}.d{1,3})?.*) /isg) { if ($ip =~ /rhost=(.*) /isg) { $i ++; unless (is_in_array($1, @ips)) { push @ips, $1; } } } print "All attack count : $in"; print "Use $#ips IP(s)n"; print "The ips are : @ipsn"; sub is_in_array { my $ip = shift(); my $s = shift(); my @ips = @$s; my $in = 0; for (@ips) { if ($_ eq $ip) { $in = 1; last; } } return $in; }

2007年9月28日 · 1 分钟 · zgia

php2个方法分析

今天研究了半天终于搞明白UTF-8和Unicode互转。 另:javascript中的escape,把汉字转换后的unicode编码中的数字是16进制的。比如:escape(“文”) = %u6587,如果在html文件中使用,可以写成 【&# x6587】,或者将6587转换为十进制25991,即【&# 25991】。 第一个: utf8_uri_encode,将UTF-8编码的文字转换为%ae%3d格式, 比如,“中”,解析后,是3字节编码的,依次是228(e4)、184(b8)、173(ad)。 最后输出:%e4%b8%ad ...

2007年9月27日 · 3 分钟 · zgia

使用Eclipse PHP Development Tools + xdebug 2.0.0 调试web

Eclipse: Eclipse Platform, Version: 3.3.0, Build id: I20070621-1340 PHP: Version 5.2.0 Xdebug: Version 2.0.0 Apache: Version 2.0.59 1、配置apache+php,网上很多,不细说; 2、配置Xdebug; 1)、下载相应模块:PHP 5.2.1+(php_xdebug-2.0.0-5.2.2.dll); 2)、将下载的dll复制到php.ini所在目录; 3)、编辑php.ini文件,添加: [xdebug] xdebug.remote_enable = 1 xdebug_remote_host = “192.168.1.25” xdebug.remote_port = 9000 xdebug.remote_handler = “dbgp” zend_extension_ts=.\php_xdebug-2.0.0-5.2.2.dll 这些配置比较简单,一看就明白。另,俺上个文章讲的是使用Zend Debugger 5.2.10 + Zend Studio 5.5.0调试web,所以,如果您配置了用Zend Debugger调试web的话,请将 [Zend] zend_extension_ts=.\ZendDebugger.dll zend_debugger.allow_hosts=192.168.1.25 zend_debugger.expose_remotely=always 等4行注释掉。 4)、重启apache,打开浏览器运行:http://192.168.1.25/phpinfo.php,您会看到: 3、配置Eclipse; 1)、可以使用Eclispe的插件功能安装PDT:http://downloads.zend.com/pdt,会用Eclipse的都知道怎么用; 2)、您也可以直接下载org.eclipse.php和org.zend.php.debug,自己安装插件; 3)、Eclipse » Window » Preferences » PHP项; 1)、PHP executables,新建一个,PHP Debugger选择Xdebug。您可以将这个新加的设置默认; 2)、Debug中,PHP Debugger选择Xdebug;Installed Debuggers中,Xdebug的端口设置为您在php.ini中设置的xdebug.remote_port; 3)、Debug子项Launching中,Xdebug不支持“Allow multiple debug sessions”,所以设置为Never即可; 4)、PHP Servers中,您可以根据自己的需要,选择“Publish Projects to this Server”,俺没有选择; 4)、Run » Open Debug Dialog,如图: 请注意:Auto Generate项,如果您的web有子路径,则可能需要自己设置一下。Advanced标签,不选:Open in Browser。Common标签,根据您web的编码,设置Console Encoding。 以上设置后,在Open Debug Dialog的对话框中,点击底部的“Debug”即可进行web调试。以后只要在Run » Debug History中选择此次调试名称就可以了。 在配置中,有很多步骤没有仔细说明,是因为这些步骤是Eclipse的基本概念。 现在eclise和zend studio都可以调试web了,不过我还是喜欢用eclispe。^_^。 相关站点: PDT Project: http://www.eclipse.org/pdt/ Zend.com / pdt : http://www.zend.com/pdt

2007年9月24日 · 3 分钟 · zgia

Graidle

Graidle是一个能够生成各种统计分析图形的PHP项目。它可生成柱状图,饼状图,线状图等。 Graidle is a project that is proposed to realize a web application to generate graphical diagrams. There are several classes specialized in generating histograms(horizontal),line(filled) pie and spider charts. 网址:http://sourceforge.net/projects/graidle/ 使用: ...

2007年9月17日 · 1 分钟 · zgia