28

日志内容:
……
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; 

}

By 馒头 \\ tags: , ,

27

今天研究了半天终于搞明白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

/**
* Conver utf-8 words to $hex format string
* @author wordpress
* @param $utf8_string string to encoded using utf-8 [STRING]
* @return string of utf8 encode entities [STRING]
* @access public
*/
function utf8_uri_encode( $utf8_string ) {
$unicode = ”;
$values = array();
$num_octets = 1;

for ($i = 0; $i < strlen( $utf8_string ); $i++ ) {

$value = ord( $utf8_string[ $i ] );

if ( $value < 128 ) {
// ASCII
$unicode .= chr($value);
} else {
// 根据第一个字节开头的1的数量,判断当前文字是2字节编码还是3字节编码
// 如果 240=< $value <= 248,则是4字节编码,这里没有考虑,估计也用不上
if ( count( $values ) == 0 ) {
$num_octets = ( $value < 224 ) ? 2 : 3;
}

$values[] = $value;

// 当存放当前文字的字节数组等于当前文字的字节数时,则输入,并重置数组
if ( count( $values ) == $num_octets ) {
if ($num_octets == 3) {
$unicode .= ‘%’ . dechex($values[0]) . ‘%’ . dechex($values[1]) . ‘%’ . dechex($values[2]);
} else {
$unicode .= ‘%’ . dechex($values[0]) . ‘%’ . dechex($values[1]);
}

$values = array();
$num_octets = 1;
}
}
}

return $unicode;
}

更多…

By 馒头 \\ tags: , ,

26

今天做了大量更改,记录如下。

1、- 取消不需要的功能;
2、o 优化上传处理;
3、o 拆分function.php某些功能到core_function.php;
4、+ 增加将某个图片设置为顶级相册的封面;
5、+ 增加页面输出显示处理;
6、o 将config.php从根目录移动到includes下面;
7、+ 可以选择多个相册的相片幻灯片演示。
8、+ 支持中文文件名,并默认使用中文文件名作为相片描述

By 馒头 \\ tags:

24

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,您会看到:
Xdebug

3、配置Eclipse;
1)、可以使用Eclispe的插件功能安装PDT:http://downloads.zend.com/pdt,会用Eclipse的都知道怎么用;
2)、您也可以直接下载org.eclipse.phporg.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,如图:
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

By 馒头 \\ tags: , , , , ,

21

安装php 5.2.0,apache等,以便可以web解析php文件。这个网上多的是,就不细说了。

因为我的工作平台是windows,所以我下载的是为windows编译的dll。
Zend Debugger 5.2.10下载地址:http://downloads.zend.com/pdt/server-debugger/ZendDebugger-5.2.10-cygwin_nt-i386.tar.gz
解压下载的ZendDebugger-5.2.10,目录结构如下:
<DIR> 4_3_x_comp
<DIR> 4_4_x_comp
<DIR> 5_0_x_comp
<DIR> 5_1_x_comp
<DIR> 5_2_x_comp
<DIR> 5_2_x_nts_comp
321 dummy.php
6,934 Inventory.xml
376 md5
832 README.txt

根据你安装的php版本,选择相应的文件。5.2.x有2个编译好的dll,其中5_2_x_nts_comp是“non-tread safe”的,因此我使用5_2_x_comp内的dll。

下面是具体的操作步骤。
1、请将ZendDebugger.dll复制到您的php安装目录下,比如:d:\do\php\。
2、然后将下面的4行内容加到您的php.ini:
[Zend]
zend_extension_ts=D:/do/php/ZendDebugger.dll
zend_debugger.allow_hosts=192.168.1.25
zend_debugger.expose_remotely=always
其中,192.168.1.25是远程调试的文件所在机器的IP;我是本地web调试,我机器的IP是192.168.1.25。
3、将dummy.php复制到apache的document root目录。
4、重启apache。
打开浏览器运行:http://192.168.1.25/phpinfo.php,您会看到:
Zend Debugger v5.2.10
ok,Zend Debugger配置完毕。下面配置Zend Studio 5.5.0。
1、行Zend Studio 5.5.0,菜单:Tools > Preferences,然后选择“debug”项,“Debug Mode”选择“Server”,然后将“Debug Server URL”中的“Server_Address/”替换为:192.168.1.25。
Preferences
2、菜单:Debug >> Debug URL,然后输入要调试的url。
Debug URL

OK,可以调试了吧?

By 馒头 \\ tags: , ,

20

相册URL:http://www.livebaby.net/album/index.php

幻灯片播放时,为IE浏览器(>= IE6)用户增加一些幻灯切换特效。
演示:http://www.livebaby.net/album/slideshow.php?catid=20

By 馒头 \\ tags: , ,

18

=== Plugin Name ===
Contributors: zGia!
Donate link: http://none
Tags: plugin time
Requires at least: 2.0.2
Tested up to: 2.3.2
Stable tag: zgia-babyage-0.2

Show baby’s age.

== Description ==

This plugin can show your baby’s age in wp page, just like: Dear baby is 6 months and 1 days old.
Your can find it here: http://yuntian.name/?p=5.
And you canemail: wuliuqiba(AT)gmail.com.
Thanks for using the plugin.
== Installation ==

1. Unzip babyage.0.2.zip to WPDIR/wp-content/plugins/babyage/. If there is no babyage folder, please create it. You will find 5 files in it.
2. Edit config.php, and select your own language, timezone, and baby’s birthday: $bornYear, $bornMonth, $bornDay.
3 Add “<span id=”babyage” style=”color: red; font-weight: bold;”></span>” to your theme file, such as header.php, sidebar.php, etc.
4. Active the plugin.

== Screenshots ==

1. preview
screenshot

== Frequently Asked Questions ==
Please view: http://yuntian.name/?p=5.

Click here to download babyage 0.2.

========================================================= 

插件是为俺家星月妹妹写的。你可以点击这里看看效果,页面的右上角。

2008.1.18,第二版,使用了配置文件和语言文件 。
使用方法:
1. 压缩包解压到WPDIR/wp-content/plugins/babyage/下,如果没有babyage文件夹,请自己建立。解压后,有5个文件。
2. 编辑config.php,可以修改:设置语言文件、时区和宝宝的出生时间:$bornYear,$bornMonth,$bornDay这些变量。
3. 您当前使用的theme,根据您想显示的位置,编辑相应的文件,增加“<span id=”babyage” style=”color: red; font-weight: bold;”></span>”即可。比如我修改的是sidebar.php,这样就显示在页面的侧边栏。
4. 后台启用插件即可。

点击下载:babyage 0.2

By 馒头 \\ tags: , ,

17

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/

graidle example

使用:

<?php
    include_once("graidle.php");
    $g = new Graidle("收入增长图");
    $g->setValue(array(120,200,300,290,300,350,380,400,420), "b", "收入", "#CC0000");
    $g->setHeight(480);
    $g->setWidth(640);
    $g->setXtitle("月份");
    $g->setYtitle("收入(万元)");
    $g->setBgCl("#FFFFCC");
    $g->setFontCl("#3300FF");
    $g->setAxisCl("#000000");
    $g->setSecondaryAxis(1, 1);
    //$g->setXValue(array(2000,2001,2002,2003,2004,2005,2006,2007));
    //$g->setLegend(array(120,200,300,400,300,350,420,380,290));
    //$g->setExtLegend(2);
    $g->setDivision(50);
    $g->create();
    $g->carry();
?>

By 馒头 \\ tags: ,

13
<?php echo "I am here.";?>
#!/usr/bin/perl
print "I am here.";
public class Hello
{
 public static void main(String[] args) {
  System.out.println("I am here.");
 }
}
<script type="text/javascript">
 <!--
    document.write("I am here.");
 //-->
</script>
SELECT "I am here" AS iamhere

By 馒头