Google

星期二, 四月 29, 2008

TRegExpr正则表达式

DELPHi中的REGEXPR
[ 2006-03-29 11:33:46 am | Author: Admin ]
其实这个Pascal单元我在几个论坛上面都推荐过,也是我唯一会用的DELPHI下面的正则表达式实现。
  正则表达式是个极其繁琐和强大的东西,小生才疏学浅,也不准备写正则表达式的教程,借着对这个单元的介绍,会有一些浅显且有用的例子。
  首先介绍的是这个单元的主角:TRegExpr类,这个类包括很多成员,这里仅简单的介绍一下一般匹配的过程。下面是一段在文本中提取邮件地址的代码:

Procedure GetName(TextToCheck:String;aList:TStringList);
Var
myExpr: TRegExpr;
begin
myExpr := TRegExpr.Create;
Try
myExpr.Expression := 'name="(.*?)"';
if myExpr.Exec(TextToCheck) then
repeat
aList.Add(myExpr.Match[1]);
until not MyExpr.ExecNext;
finally
myExpr.Free;
end;
end;

  下面对这段代码进行一点简要的说明.
  首先是myExpr.Expression := 'name="(.*?)"';这个语句用以匹配name="XXXXX"形式的字符串。
“.*?”是很常见的一段,表示对任意字符串的“非贪婪匹配”,代表符合匹配条件的最短字符串,关于贪婪非贪婪的问题,会在后面说明。
  括号表示对这段文字的引用,匹配中出现符合该模式的字符串将会存储在TRegExpr的Match数组中。
  接下来是if myExpr.Exec(TextToChceck)这一句,这一语句就是开始利用上文提到的正则表达式对TextToCheck进行匹配。Exec方法有三个重载:
function Exec (const AInputString : AnsiString) : boolean; //对AInputString参数进行匹配
function Exec : boolean; overload; //对InputString成员进行匹配
function Exec (AOffset: integer) : boolean; overload; //对InputString成员,从AOffset位置开始进行匹配
  该方法返回一个布尔型的值,如果为真,则表明InputString中包含表达式所匹配的模式,例如'Name="Hello.Gif"'作为参数,就会返回True。

  接下来的语句中出现的myExpr.Match[1],则用以取出本次匹配结果

  最后的ExecNext其实是使用了上面提到的第三个重载,用来对重复出现的字符串进行连续匹配,返回结果的含义同Exec相同

  接下来谈谈Match成员,其中Match[0]表示整个表达式的匹配结果,之后的数组元素则代表括号中的匹配结果,元素编号按照括号从左到右的顺序递增,嵌套括号则以从内向外的顺序递增。例如一个简单的对E-Mail地址的匹配:
Quotes From ???
输入字符串:'"dirt@sina.com","v@d2g.com"'
正则表达式:'"((.*?)@(.*?))",'
执行结果如下:
0 "dirt@sina.com",
1 dirt@sina.com
2 dirt
3 sina.com
  从中即可看出Match数组中的结果排列顺序。


  而上文中出现的.*?经常用于不很严谨的场合,例如前面用到的邮件地址提取,有人就写出几百字符的的验证表达式。其中“.”表示任意单个字符,“*” 表示前面的字符(串)至少出现一次,而'?'在这里就是非贪婪限定符,举一个简单的例子:"aaa""bbb",这样一个字符串,如果用'" (.*?)"'进行匹配,则Match[1]的内容就是'aaa',如果去掉了其中的'?',则Match[1]就变成了'aaa""bbb',这就可以 看出贪婪和非贪婪的区别。

  一个基本的匹配过程就到这里,有空会再继续写一些其他的相关内容,敬请丢砖

转自:http://www.delphibbs.com/keylife/iblog_show.asp?xid=13902
作者:coolbaby

TRegExpr是正则表达式在delphi中的一个很好的实现。
是一个单独的单元,使用时直接引用即可。还自带了几个sample。

对其中的SelfTest例子加了几行注释如下:
{ basic tests }

r := TRegExpr.Create;

r.Expression := '[A-Z]';
r.Exec ('234578923457823659GHJK38');
Check (0, 19, 1);
//?在此处表示让*处于非贪婪模式
r.Expression := '[A-Z]*?';
r.Exec ('234578923457823659ARTZU38');
Check (0, 1, 0);

r.Expression := '[A-Z]+';
r.Exec ('234578923457823659ARTZU38');
Check (0, 19, 5);
//和上面的+方式,功能一样
r.Expression := '[A-Z][A-Z]*';
r.Exec ('234578923457823659ARTZU38');
Check (0, 19, 5);
//?这里表示匹配[A-Z]0次或者一次
r.Expression := '[A-Z][A-Z]?';
r.Exec ('234578923457823659ARTZU38');
Check (0, 19, 2);
// \d代表数字,^代表非,总得来说就是一个或者多个非数字字符
r.Expression := '[^\d]+';
r.Exec ('234578923457823659ARTZU38');
Check (0, 19, 5);

半小时精通正则表达式
作者:Web应用网 来源:Web应用网

跟我学正则表达式!
想必很多人都对正则表达式都头疼.今天,我以我的认识,加上网上一些文章,希望用常人都可以理解的表达方式.来和大家分享学习经验.
开篇,还是得说说 ^ 和 $ 他们是分别用来匹配字符串的开始和结束,以下分别举例说明

"^The": 开头一定要有"The"字符串;
"of despair$": 结尾一定要有"of despair" 的字符串;

那么,
"^abc$": 就是要求以abc开头和以abc结尾的字符串,实际上是只有abc匹配
"notice": 匹配包含notice的字符串

你可以看见如果你没有用我们提到的两个字符(最后一个例子),就是说 模式(正则表达式) 可以出现在被检验字符串的任何地方,你没有把他锁定到两边
接着,说说 '*', '+',和 '?',
他们用来表示一个字符可以出现的次数或者顺序. 他们分别表示:
"zero or more"相当于{0,},
"one or more"相当于{1,},
"zero or one."相当于{0,1}, 这里是一些例子:

"ab*": 和ab{0,}同义,匹配以a开头,后面可以接0个或者N个b组成的字符串("a", "ab", "abbb", 等);
"ab+": 和ab{1,}同义,同上条一样,但最少要有一个b存在 ("ab", "abbb", 等.);
"ab?":和ab{0,1}同义,可以没有或者只有一个b;
"a?b+$": 匹配以一个或者0个a再加上一个以上的b结尾的字符串.
要点, '*', '+',和 '?'只管它前面那个字符.

你也可以在大括号里面限制字符出现的个数,比如

"ab{2}": 要求a后面一定要跟两个b(一个也不能少)("abb");
"ab{2,}": 要求a后面一定要有两个或者两个以上b(如"abb", "abbbb", 等.);
"ab{3,5}": 要求a后面可以有2-5个b("abbb", "abbbb", or "abbbbb").

现在我们把一定几个字符放到小括号里,比如:
"a(bc)*": 匹配 a 后面跟0个或者一个"bc";
"a(bc){1,5}": 一个到5个 "bc."

还有一个字符 '│', 相当于OR 操作:

"hi│hello": 匹配含有"hi" 或者 "hello" 的 字符串;
"(b│cd)ef": 匹配含有 "bef" 或者 "cdef"的字符串;
"(a│b)*c": 匹配含有这样多个(包括0个)a或b,后面跟一个c
的字符串;

一个点('.')可以代表所有的单一字符,不包括"\n"
如果,要匹配包括"\n"在内的所有单个字符,怎么办?
对了,用'[\n.]'这种模式.

"a.[0-9]": 一个a加一个字符再加一个0到9的数字
"^.{3}$": 三个任意字符结尾 .


中括号括住的内容只匹配一个单一的字符

"[ab]": 匹配单个的 a 或者 b ( 和 "a│b" 一样);
"[a-d]": 匹配'a' 到'd'的单个字符 (和"a│b│c│d" 还有 "[abcd]"效果一样); 一般我们都用[a-zA-Z]来指定字符为一个大小写英文
"^[a-zA-Z]": 匹配以大小写字母开头的字符串
"[0-9]%": 匹配含有 形如 x% 的字符串
",[a-zA-Z0-9]$": 匹配以逗号再加一个数字或字母结尾的字符串

你也可以把你不想要得字符列在中括号里,你只需要在总括号里面使用'^' 作为开头 "%[^a-zA-Z]%" 匹配含有两个百分号里面有一个非字母的字符串.
要点:^用在中括号开头的时候,就表示排除括号里的字符
为了PHP能够解释,你必须在这些字符面前后加'',并且将一些字符转义.
不要忘记在中括号里面的字符是这条规路的例外—在中括号里面, 所有的特殊字符,包括(''), 都将失去他们的特殊性质 "[*\+?{}.]"匹配含有这些字符的字符串.
还有,正如regx的手册告诉我们: "如果列表里含有 ']', 最好把它作为列表里的第一个字符(可能跟在'^'后面). 如果含有'-', 最好把它放在最前面或者最后面, or 或者一个范围的第二个结束点[a-d-0-9]中间的‘-’将有效.
看了上面的例子,你对{n,m}应该理解了吧.要注意的是,n和m都不能为负整数,而且n总是小于m. 这样,才能 最少匹配n次且最多匹配m次. 如"p{1,5}"将匹配 "pvpppppp"中的前五个p
下面说说以\开头的
\b 书上说他是用来匹配一个单词边界,就是...比如've\b',可以匹配love里的ve而不匹配very里有ve
\B 正好和上面的\b相反.例子我就不举了
.....突然想起来....可以到http://www.phpv.net/article.php/251 看看其它用\ 开头的语法

好,我们来做个应用:
如何构建一个模式来匹配 货币数量 的输入
构建一个匹配模式去检查输入的信息是否为一个表示money的数字。我们认为一个表示money的数量有四种方式: "10000.00" 和 "10,000.00",或者没有小数部分, "10000" and "10,000". 现在让我们开始构建这个匹配模式:
^[1-9][0-9]*$
这是所变量必须以非0的数字开头.但这也意味着 单一的 "0" 也不能通过测试. 以下是解决的方法:
^(0│[1-9][0-9]*)$
"只有0和不以0开头的数字与之匹配",我们也可以允许一个负号在数字之前:
^(0│-?[1-9][0-9]*)$
这就是: "0 或者 一个以0开头 且可能 有一个负号在前面的数字." 好了,现在让我们别那么严谨,允许以0开头.现在让我们放弃 负号 , 因为我们在表示钱币的时候并不需要用到. 我们现在指定 模式 用来匹配小数部分:
^[0-9]+(\.[0-9]+)?$
这暗示匹配的字符串必须最少以一个阿拉伯数字开头. 但是注意,在上面模式中 "10." 是不匹配的, 只有 "10" 和 "10.2" 才可以. (你知道为什么吗)
^[0-9]+(\.[0-9]{2})?$
我们上面指定小数点后面必须有两位小数.如果你认为这样太苛刻,你可以改成:
^[0-9]+(\.[0-9]{1,2})?$
这将允许小数点后面有一到两个字符. 现在我们加上用来增加可读性的逗号(每隔三位), 我们可以这样表示:
^[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{1,2})?$
不要忘记 '+' 可以被 '*' 替代 如果你想允许空白字符串被输入话 (为什么?). 也不要忘记反斜杆 ’\’ 在php字符串中可能会出现错误 (很普遍的错误).
现在,我们已经可以确认字符串了, 我们现在把所有逗号都去掉 str_replace(",", "", $money) 然后在把类型看成 double然后我们就可以通过他做数学计算了.

再来一个:
构造检查email的正则表达式
在一个完整的email地址中有三个部分:
1. 用户名 (在 '@' 左边的一切),
2.'@',
3. 服务器名(就是剩下那部分).
用户名可以含有大小写字母阿拉伯数字,句号 ('.'), 减号('-'), and 下划线 ('_'). 服务器名字也是符合这个规则,当然下划线除外.
现在, 用户名的开始和结束都不能是句点. 服务器也是这样. 还有你不能有两个连续的句点他们之间至少存在一个字符,好现在我们来看一下怎么为用户名写一个匹配模式:
^[_a-zA-Z0-9-]+$
现在还不能允许句号的存在. 我们把它加上:
^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*$
上面的意思就是说: "以至少一个规范字符(除了.)开头,后面跟着0个或者多个以点开始的字符串."
简单化一点, 我们可以用 eregi()取代 ereg().eregi()对大小写不敏感, 我们就不需要指定两个范围 "a-z" 和 "A-Z" – 只需要指定一个就可以了:
^[_a-z0-9-]+(\.[_a-z0-9-]+)*$
后面的服务器名字也是一样,但要去掉下划线:
^[a-z0-9-]+(\.[a-z0-9-]+)*$
好. 现在只需要用”@”把两部分连接:
^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$

这就是完整的email认证匹配模式了,只需要调用
eregi(‘^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$ ’,$eamil)
就可以得到是否为email了
正则表达式的其他用法
提取字符串
ereg() and eregi() 有一个特性是允许用户通过正则表达式去提取字符串的一部分(具体用法你可以阅读手册). 比如说,我们想从 path/URL 提取文件名 – 下面的代码就是你需要:
ereg("([^\\/]*)$", $pathOrUrl, $regs);
echo $regs[1];
高级的代换
ereg_replace() 和 eregi_replace()也是非常有用的: 假如我们想把所有的间隔负号都替换成逗号:
ereg_replace("[ \n\r\t]+", ",", trim($str));
最后,我把另一串检查EMAIL的正则表达式让看文章的你来分析一下.
"^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$"
如果能方便的读懂,那这篇文章的目的就达到了.

JScript 和 VBScript 正则表达式 的语法规则

一个正则表达式就是由普通字符(例如字符 a 到 z)以及特殊字符(称为元字符)组成的文字模式。该模式描述在查找文字主体时待匹配的一个或多个字符串。正则表达式作为一个模板,将某个字符模式与所搜索的字符串进行匹配。

这里有一些可能会遇到的正则表达式示例:



JScript VBScript 匹配
/^\[ \t]*$/ "^\[ \t]*$" 匹配一个空白行。
/\d-\d/ "\d-\d" 验证一个ID 号码是否由一个2位数字,一个连字符以及一个5位数字组成。
/<(.*)>.*<\/>/ "<(.*)>.*<\/>" 匹配一个 HTML 标记。

下表是元字符及其在正则表达式上下文中的行为的一个完整列表:

字符 描述
\ 将下一个字符标记为一个特殊字符、或一个原义字符、或一个 向后引用、或一个八进制转义符。例如,'n' 匹配字符 "n"。'\n' 匹配一个换行符。序列 '\' 匹配 "\" 而 "\(" 则匹配 "("。
^ 匹配输入字符串的开始位置。如果设置了 RegExp 对象的 Multiline 属性,^ 也匹配 '\n' 或 '\r' 之后的位置。
$ 匹配输入字符串的结束位置。如果设置了RegExp 对象的 Multiline 属性,$ 也匹配 '\n' 或 '\r' 之前的位置。
* 匹配前面的子表达式零次或多次。例如,zo* 能匹配 "z" 以及 "zoo"。* 等价于。
+ 匹配前面的子表达式一次或多次。例如,'zo+' 能匹配 "zo" 以及 "zoo",但不能匹配 "z"。+ 等价于 。
? 匹配前面的子表达式零次或一次。例如,"do(es)?" 可以匹配 "do" 或 "does" 中的"do" 。? 等价于 。
n 是一个非负整数。匹配确定的 n 次。例如,'o' 不能匹配 "Bob" 中的 'o',但是能匹配 "food" 中的两个 o。
n 是一个非负整数。至少匹配n 次。例如,'o' 不能匹配 "Bob" 中的 'o',但能匹配 "foooood" 中的所有 o。'o' 等价于 'o+'。'o' 则等价于 'o*'。
m 和 n 均为非负整数,其中n <= m。最少匹配 n 次且最多匹配 m 次。例如,"o" 将匹配 "fooooood" 中的前三个 o。'o' 等价于 'o?'。请注意在逗号和两个数之间不能有空格。
? 当该字符紧跟在任何一个其他限制符 (*, +, ?, , , ) 后面时,匹配模式是非贪婪的。非贪婪模式尽可能少的匹配所搜索的字符串,而默认的贪婪模式则尽可能多的匹配所搜索的字符串。例如,对于字符串 "oooo",'o+?' 将匹配单个 "o",而 'o+' 将匹配所有 'o'。
. 匹配除 "\n" 之外的任何单个字符。要匹配包括 '\n' 在内的任何字符,请使用象 '[.\n]' 的模式。
(pattern) 匹配 pattern 并获取这一匹配。所获取的匹配可以从产生的 Matches 集合得到,在VBScript 中使用 SubMatches 集合,在JScript 中则使用 … 属性。要匹配圆括号字符,请使用 '\(' 或 '\)'。
(?:pattern) 匹配 pattern 但不获取匹配结果,也就是说这是一个非获取匹配,不进行存储供以后使用。这在使用 "或" 字符 (|) 来组合一个模式的各个部分是很有用。例如, 'industr(?:y|ies) 就是一个比 'industry|industries' 更简略的表达式。
(?=pattern) 正向预查,在任何匹配 pattern 的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如,'Windows (?=95|98|NT|2000)' 能匹配 "Windows 2000" 中的 "Windows" ,但不能匹配 "Windows 3.1" 中的 "Windows"。预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开始下一次匹配的搜索,而不是从包含预查的字符之后开始。
(?!pattern) 负向预查,在任何不匹配 pattern 的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如'Windows (?!95|98|NT|2000)' 能匹配 "Windows 3.1" 中的 "Windows",但不能匹配 "Windows 2000" 中的 "Windows"。预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开始下一次匹配的搜索,而不是从包含预查的字符之后开始
x|y 匹配 x 或 y。例如,'z|food' 能匹配 "z" 或 "food"。'(z|f)ood' 则匹配 "zood" 或 "food"。
[xyz] 字符集合。匹配所包含的任意一个字符。例如, '[abc]' 可以匹配 "plain" 中的 'a'。
[^xyz] 负值字符集合。匹配未包含的任意字符。例如, '[^abc]' 可以匹配 "plain" 中的'p'。
[a-z] 字符范围。匹配指定范围内的任意字符。例如,'[a-z]' 可以匹配 'a' 到 'z' 范围内的任意小写字母字符。
[^a-z] 负值字符范围。匹配任何不在指定范围内的任意字符。例如,'[^a-z]' 可以匹配任何不在 'a' 到 'z' 范围内的任意字符。
\b 匹配一个单词边界,也就是指单词和空格间的位置。例如, 'er\b' 可以匹配"never" 中的 'er',但不能匹配 "verb" 中的 'er'。
\B 匹配非单词边界。'er\B' 能匹配 "verb" 中的 'er',但不能匹配 "never" 中的 'er'。
\cx 匹配由 x 指明的控制字符。例如, \cM 匹配一个 Control-M 或回车符。x 的值必须为 A-Z 或 a-z 之一。否则,将 c 视为一个原义的 'c' 字符。
\d 匹配一个数字字符。等价于 [0-9]。
\D 匹配一个非数字字符。等价于 [^0-9]。
\f 匹配一个换页符。等价于 \x0c 和 \cL。
\n 匹配一个换行符。等价于 \x0a 和 \cJ。
\r 匹配一个回车符。等价于 \x0d 和 \cM。
\s 匹配任何空白字符,包括空格、制表符、换页符等等。等价于 [ \f\n\r\t\v]。
\S 匹配任何非空白字符。等价于 [^ \f\n\r\t\v]。
\t 匹配一个制表符。等价于 \x09 和 \cI。
\v 匹配一个垂直制表符。等价于 \x0b 和 \cK。
\w 匹配包括下划线的任何单词字符。等价于'[A-Za-z0-9_]'。
\W 匹配任何非单词字符。等价于 '[^A-Za-z0-9_]'。
\xn 匹配 n,其中 n 为十六进制转义值。十六进制转义值必须为确定的两个数字长。例如,'\x41' 匹配 "A"。'\x041' 则等价于 '\x04' & "1"。正则表达式中可以使用 ASCII 编码。.
\num 匹配 num,其中 num 是一个正整数。对所获取的匹配的引用。例如,'(.)' 匹配两个连续的相同字符。
\n 标识一个八进制转义值或一个向后引用。如果 \n 之前至少 n 个获取的子表达式,则 n 为向后引用。否则,如果 n 为八进制数字 (0-7),则 n 为一个八进制转义值。
\nm 标识一个八进制转义值或一个向后引用。如果 \nm 之前至少有 nm 个获得子表达式,则 nm 为向后引用。如果 \nm 之前至少有 n 个获取,则 n 为一个后跟文字 m 的向后引用。如果前面的条件都不满足,若 n 和 m 均为八进制数字 (0-7),则 \nm 将匹配八进制转义值 nm。
\nml 如果 n 为八进制数字 (0-3),且 m 和 l 均为八进制数字 (0-7),则匹配八进制转义值 nml。
\un 匹配 n,其中 n 是一个用四个十六进制数字表示的 Unicode 字符。例如, \u00A9 匹配版权符号 (©)。

2005-5-23 10:26:21 piao40993470 发表评论。
所有中文(不包括标点):
([\xB0-\xF7][\xA1-\xFE])+
所有GB2312-80编码
([\xA1-\xFE][\xA1-\xFE])+
所有中文空格
(\xA1\xA1)+

英文标点:[\x20-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]

2005-5-23 10:32:03 piao40993470 发表评论。
补充一下:
在delphi下使用TPerlRegEx也是不错的

http://hi.baidu.com/program8/blog/item/31800b0801b32030e824885f.html

标签: , , ,

星期一, 四月 28, 2008

什么是 Kohana? Kohana 与 CodeIgniter 的区别?

作者:沧蓝 / Fred Wu

Kohana 是一款基于 CodeIgniter 的 PHP5 框架,其与 CI 最大的区别便是 Kohana 完全采用 PHP5。

2007 年 6 月 1 日,CI 社区用户 Todd Wilson (Tido) 发布了 BlueFlame 1.0 的帖子。BlueFlame 1.0 正式发布,团队成员有九人,其中包括 Todd(原团队 lead developer)、现在 Kohana 的 lead developer、以及本人。该发布贴引起了 CI 社区用户的广泛关注。然而由于 BlueFlame 团队事前没有与 CodeIgniter 团队进行沟通,导致一些理解上的小插曲,包括 Rick (CI 的祖父)要求 BlueFlame 团队停止使用 CI 的社区资源来发布 BlueFlame 相关的信息,以及对 BlueFlame 源代码中的授权部分表示疑义。

最终通过 BlueFlame 与 CodeIgniter 团队的协调沟通,双方的小小误解很快便被解化。Rick 在此期间提到 BlueFlame 名称的潜在版权问题,于是 BlueFlame 几天后便正式更名为 Kohana,并注册了现在的官方网站:kohanaphp.com

在 BlueFlame 1.0 之后,Kohana 团队一直没有发布新的版本,之后整个项目一度处于僵化期。尽管如此,trac 上还是有更新进度。在 Todd Wilson “消失”了一阵子后,成员之一 Woody Gilk (Shadow Hand) 接下重任,担当团队 leader。

之后 Woody 联络本人,希望本人承担 Kohana 官方网站以及 logo 的设计制作。论坛上仍然可以找到当时我发的帖子(内有网站以及 logo 的草案)。可惜由于时间的因素,我最终没有将设计草案转化为 HTML。可喜的是,Geert De Deckere 之后设计了一个相当出色的方案,这也就是大家现在所见到的 Kohana 的官方网站。 :)

2007 年 11 月,经过了团队成员以及社区用户的努力,Kohana 终于发布了 2.0 版本。

下面我来翻译一下 Wikipedia 对于 Kohana 的介绍。

历史

Kohana 是基于 CodeIgniter PHP 框架开发的。

开发 Kohana 最主要的原因是 CI 对于 bug 的修复和处理用户提交的建议所需的时间过长。许多 bug 在用户报告后很久才会纳入到新版本中,甚至一些 bug 一直没有被纳入。另外,由于 EllisLab 是 CodeIgniter 唯一开发者,部分用户对于框架的开放性产生异议,他们希望框架可以更自由开放,从而使社区对框架的发展产生一定的影响。

Kohana 与 CodeIgniter 的区别


  • 严谨的 PHP5 面向对象编程。优势:可见性保护、自动类装载、超载、接口类、抽象类以及单件类。
  • 延续 CodeIgniter 的设计模式。CodeIgniter 的用户能迅速的理解 Kohana 的架构和设计模式。
  • 社区向,而非商业向。Kohana 是一款基于社区的作品。Kohana 的开发者们来自世界各地,有着各自的天赋。这使得开发速度得以提高,并在短时间内提供bug修复以及反馈用户提出的建议。
  • GET、POST、COOKIE 以及 SESSION 数组得到改进。Kohana 不对全局数据做读取限制,但依旧提供与 CodeIgniter 相同的数据过滤以及 XSS 防护。
  • 层叠式资源、模块以及类继承。控制器、数据模型、库、助手以及视图均能够在系统中的任何地方进行载入。程序的配置选项可被继承或覆盖。
  • 无命名空间的冲突。类均添加了如“_Controller”之类的后缀,从而使得用户的控制器和数据模型可被同时同地装载。
  • 真正的自动类装载。这包括库、控制器、数据模型以及助手。与 CodeIgniter 不同,Kohana 的自动装载是真正意义上的动态装载,而并非预先装载。
  • 助手为静态类,而非函数。例如,在 CI 中使用的 form_open(),在 Kohana 中为 form::open()。
  • 库驱动以及 API 的一致性。库能够使用不同的驱动来处理不同的外部 API。例如,session 的储存有数据库、cookie 和 native 几种,但它们均使用相同的接口。这使得库可以不断的添加新的驱动,但不会影响到 API 的一致性。
  • 强大的事件处理器。Kohana 的事件可被动态的添加、替换或删除。这使得用户能在 Kohana 执行的过程中动态做更改,而不影响原有的系统代码。


特性


  • 高安全性
  • 轻量级代码
  • 学习周期短
  • MVC 设计模式
  • 100% UTF-8 兼容
  • 松弛耦合架构
  • 易扩展性


技术


  • 严谨的 PHP5 面向对象编程
  • 用 SQL 助手实现简单的数据库抽象层
  • 多 session 驱动(native、数据库、cookie)
  • 动态事件处理器


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

最后更新:2007 年 12 月 03 日

http://codeigniter.org.cn/forums/thread-91-1-1.html

标签: , , , , , ,

Notes on Choosing a PHP Framework: A Quick Comparison of CodeIgniter and Kohana

When I was reading through my subscribed feeds I came across this post: Notes on Choosing a PHP Framework: A Comparison of CakePHP and the Zend Framework by Chad Kieffer.

Chad has done a great job comparing the two frameworks that he’s interested in. That inspired me to write something up for the frameworks that I prefer and use. :)

I began hunting for PHP frameworks ever since Ruby on Rails hit the street. Coincidentally one of the first PHP frameworks I played with was CakePHP. At that time CakePHP’s documentation was nearly non-existent so I had to seek for an alternative. I did a lot of searches, and researches, and finally I was happy to see CodeIgniter. Its user guide was what impressed me the most, I am sure many of the fellow CI users would agree with me on this one. Because of the excellent documentation, I was able to start working on projects right after I spent a few hours on the user guide! Developing apps on CI was such a breeze! Today, I develop web applications in CodeIgniter, Kohana and Zend Framework. If you want to find out how to use Zend Framework components with CI or Kohana, please read my previous blog entry: Using Zend Framework with CodeIgniter.

From version 1.2 when I first started coding on CI, to the newly released version 1.6.1 it sure is a long way. CodeIgniter has progressed well and gained many web developers’ trust, despite a few glitches. One of which was the spawn of the fork: Kohana.

CodeIgniter had some low periods where developers were all focused on pushing out new releases of ExpressionEngine, their commercial blogging/cms product. Some of the users on the CI forum got frustrated because their bug reports and feature requests were ignored. As a result of that, BlueFlame was born, and later renamed to Kohana.

Kohana is relatively unknown to the public. In fact, most of the Kohana users are ex-CI users or users that uses both CI and Kohana (like myself). According to the Kohana homepage and Wikipedia, the differences between Kohana and CodeIgniter are:

  1. Strict PHP5 OOP. Offers many benefits: visibility protection, automatic class loading, overloading, interfaces, abstracts, and singletons.
  2. Kohana has joined the GoPHP5 initiative. All releases from 2.2 on will conform with this project.
  3. Continues CodeIgniter design patterns. Anyone who has used CodeIgniter will quickly understand Kohana’s structure and design patterns.
  4. Community, not company, driven. Kohana is driven by community discussion, ideas, and code. Kohana developers are from all around the world, each with their own talents. This allows a rapid and flexible development cycle that can respond to bugs and requests within hours, instead of days or months.
  5. GET, POST, COOKIE, and SESSION arrays all work as expected. Kohana does not limit your access to global data, but offers the same filtering and XSS protection that CodeIgniter does.
  6. Cascading resources, modules, and inheritance. Controllers, models, libraries, helpers, and views can be loaded from any location within your system, application, or module paths. Configuration options are inherited and can by dynamically overwritten by each application.
  7. No namespace conflicts. Class suffixes, like _Controller, are used to prevent namespace conflicts. This allows a User’s controller and Users model to both be loaded at the same time.
  8. True auto-loading of classes. This includes libraries, controllers, models, and helpers. This is not pre-loading, but true dynamic loading of classes, as they are requested.
  9. Helpers are static classes, not functions. For example, instead of using form_open(), you would use form::open().
  10. Library drivers and API consistency. Libraries can use different “drivers” to handle different external APIs transparently. For example, multiple session storage options are available (database, cookie, and native), but the same interface is used for all of them. This allows new drivers to be developed for existing libraries, which keeps the API consistent and transparent.
  11. Powerful event handler. Kohana events can by dynamically added to, replaced, or even removed completely. This allows many changes to Kohana execution process, without modification to existing system code.

As you can see, whilst maintaining a certain level of similarity to CodeIgniter, Kohana does offer some advantages (at the same time, some disadvantages). Let’s take a look at a few quick comparisons. Grading scale: Limited <>

Feature Comparison of CodeIgniter and Kohana
Feature CodeIgniter 1.6.1 Kohana 2.1.1 Notes
License Apache/BSD-style new BSD Licenses are similar, although Kohana uses the new BSD license which is slightly more flexible than CI’s modified BSD license.
PHP compatibility 4.3.2+ and 5 5.1.3+ CodeIgniter supports PHP4 whilst Kohana is a stict PHP5 framework. If you are using PHP5 then Kohana offers more OOP and performance advantages. Start from version 2.2 (yet to be released), Kohana will only support PHP 5.2+.
Supported Databases MySQL (4.1+)
MySQLi
MS SQL
PostgreSQL
SQLite
Oracle
ODBC
MySQL
PostgreSQL
SQLite
CodeIgniter’s longer history ensures us a more widely available database support options than Kohana, although in the future Kohana is likely to support more databases too.
Community Forum
Wiki
Bug Tracker
Forum
Trac
IRC
CodeIgniter obviously has a much larger community and offers a wiki for community members to share tutorials and code snippets. Kohana on the other hand, has a smaller community, however the developers are actively online on the forum and IRC.
Documentation / User Guide Excellent Limited CodeIgniter is known for its excellent user guide. Kohana is in the process of improving its documentation.
Tutorial / Sample Availability Good Fair Tutorials are available on both of their forums. CodeIgniter has the advantage of having a wiki for easier navigation. Kohana on the other hand, has a dedicated tutorial page for some of the tutorials.
MVC Strict Strict Both frameworks use the same MVC approach.
Modular / HMVC Via 3rd party libraries Built in Kohana is built with HMVC in mind whilst CodeIgniter has some 3rd party libraries such as Matchbox and Modular HMVC to accomplish the same effect.
Conventions Flexible Flexible Unlike CakePHP, both of the frameworks offer flexible convensions. There are some defaults but most of them can be overwritten.
Configuration PHP files PHP files In my opinion Kohana is more configurable than CodeIgniter yet it is simpler (less clustered) to do so! Most of the Kohana configuration files are stored in the system folder, you only copy and paste the ones you actually need to modify, and modify them accordingly. CodeIgniter’s config files are all stored in the application folder.
Database Abstraction Modified ActiveRecord Modified ActiveRecord
ORM (optional)
Both frameworks use the modified ActiveRecord pattern. Kohana has an optional ORM module. CodeIgniter has some ORM and Rails-style ActiveRecord implementation avaliable via 3rd party libraries.
ACL Via 3rd party libraries Auth library (optional) Neither of the frameworks forces you to use a specific ACL mechanism. CodeIgniter does not have one built in, and Kohana has one available as an optional module.
Validation Good Good Both frameworks offer a good built in validtion layer. Kohana 2.2 is planned to have some significant improvements for the validation library.
Caching Limited Fair In my opinion both of the caching features are limited. Kohana offers a slightly more useful cache library that supports file, SQLite, APC, eAccelerator, memcache, and Xcache based caching, with tag support.
Session Good Excellent CodeIgniter 1.6 has improved its session library, but it’s still inferior to Kohana’s implementation. Kohana’s session library supports both encryption and storing session data in database.
Logging / Debugging Good Excellent Both frameworks offer very good logging and debugging mechanisms. Kohana is a little bit ahead thanks to PHP5’s native Exception class and its powerful event handlers.
Templating Native PHP Native PHP Templating is *very* easy for both frameworks. If you can skin Wordpress, then you’d have no problems at all skinning CI or Kohana. If you want though, you can still incorporate one of the 3rd party templating solutions such as Smarty.
Helpers Good Good Helpers are usually libraries that used for simple, repetitive tasks. Both frameworks offer a wide range of helpers for handling forms, URLs and dates, etc.
JavaScript / AJAX N/A N/A Both frameworks respect your choice of JavaScript / AJAX frameworks. Unlike CakePHP and Ruby on Rails, they don’t have built-in helpers for any of the JavaScript libraries. This offers more flexibility as well as the use of unobtrusive JavaScript.
Web Services Fair Fair I could be wrong but I don’t think either framework supports (or at least encourages) RESTful design…
Localization Limited Good CodeIgniter has limited i18n support whilst Kohana offers a bit more (timezone / full UTF8 layer, etc).
Unit Testing Limited None * CodeIgniter’s built in unit testing class is very limited. * Kohana as of version 2.1.1 does not have a unit testing class, however it is planned for version 2.2.

The Verdict

I had a hard time deciding which of these two I use. In the end, I chose to use both. Why? Because they each have its advantages and disadvantages.

CodeIgniter is great for small to medium sized projects, especially good for legacy servers which have PHP4 installed. The fantastic user guide made coding in CI very efficient.

Kohana is probably better for larger sized projects as well as projects that need more flexible extensions. PHP5 offers better (proper) OOP support as the foundation, plus Kohana’s several better feature implementation make it a strong competitor to its predecessor.

There is no right or wrong for which framework you use, everyone has its own taste. For me, CodeIgniter’s excellent documentation and Kohana’s strict PHP5 + easy to use are the primary reasons to choose them over say, CakePHP and Symfony. That said, CakePHP, Symfony and other frameworks are all excellent choices depending on your taste and experience. On one hand I envy the Ruby community because they obviously have the de facto framework to work with, on another hand, we have more options hey? :)

Feel free to share your opinion and experiences!

Update log:

[2008-02-23]
- Removed MS SQL support for Kohana (confirmed by Shadowhand)
- Updated cache driver description for Kohana (confirmed by Shadowhand)
- Edited unicode / UTF8 description for Kohana (confirmed by Shadowhand)

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • DZone
  • Furl
  • Live
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

标签: , , ,

CodeIgnitor: Query String URL Enhancement

Hi everybody,

I had a problem described in my last post:
http://codeigniter.com/forums/viewthread/68197/

This problem forced me to use query strings and the url I had to parse was as follows:
http://www.mysite.com/index.php?c=mycontroller&m=processAuth&auth_token=3c562b119bd387ec194ade6bab9832c4

I enabled query strings in my config file:
$config[’enable_query_strings’] = TRUE;
$config[’controller_trigger’] = ‘c’;
$config[’function_trigger’] = ‘m’;

I still had issues getting to the auth_token value.

In the end I changed some code in the Router.php file and wanted to submit the code here in case anyone else finds it useful. It makes query strings act pretty much the same as the regular CodeIgniter URLs. For example, if you had a controller like:

class myClass extends Controller {
function myFunction ($myValue) {
}
}

Normally, you could call myFunction with a value using a CodeIgniter URL:

www.mySite.com/index.php/myClass/myFunction/123456

With the changes I made to router.php, you can now call it with:

www.mySite.com/index.php?c=myClass&m=myFunction&value=123456

The way the changed code is written now, you only need the “controller_trigger” key in the query string. The other keys do not matter. The values will go into the segment array in the order they show up in the query string.

There are a few improvements that could be made but what’s there now is a good start.

I can’t seem to attach the changed Router.php file (renaming or zipping didn’t seem to matter). But I only changed the _set_route_mapping() function commenting out the following code at the top:

/*
// Are query strings enabled in the config file?
// If so, we're done since segment based URIs are not used with query strings.
if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
{
$this->set_class(trim($this->_filter_uri($_GET[$this->config->item('controller_trigger')])));

if (isset($_GET[$this->config->item('function_trigger')]))
{
$this->set_method(trim($this->_filter_uri($_GET[$this->config->item('function_trigger')])));
}

return;
}
*/

and adding the following code near the end of the function:

// check if query strings enabled
if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
{
// at this point the uri_string is the query string
$keyValues = split('&', $this->uri_string);
foreach(
$keyValues as $keyValue) {
list($key, $value) = split('=', $keyValue, 2);

// just use the value and add in the order they come in
// at some point may want to utilize keys and ignore order

$value = trim($this->_filter_uri($value));

if (
$value != '')
$this->segments[] = $value;
}

}
else {

the code above goes just above:

// Explode the URI Segments. The individual segments will
// be stored in the $this->segments array.
foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
{
// Filter segments for security
$val = trim($this->_filter_uri($val));

if (
$val != '')
$this->segments[] = $val;
}

}
// do not forget this bracket

make sure to add the closing bracket

Hope someone finds it useful.

http://codeigniter.com/forums/viewthread/68698/

标签: ,

关于IE下实现min-height跟max-height的方法

comment_edit.pngmin-height最简单的方法是用表格来设计:

favorite.gif











comment_edit.png在此基础上增加 min-width 效果
(测试请改变 id=”wh” 层的 height 和 width 值)
favorite.gif











comment_edit.png而对于max-height的设计就要难多了!下面是采用js的方法达到的!
max-height 在 IE6.0 的实现的具体思想是想办法获得可变层的高,宽,样式中使用expression()得到外层的高,宽。代码如下:(测试请改变 id=”wh” 层的 height 和 width 值)
favorite.gif







comment_edit.png不过上面的这种方法采用js的expression,涉及js的计算,对cpu的有一定的占用,不宜采用!建议采用其它方法!(此地以后添加!)

http://www.evetian.cn/?p=22

标签: ,

星期六, 四月 26, 2008

SUN即将完成JAVA语言全部开源工作

SUN公司正在加紧推动JAVA在Linux平台下的完全开源工作,JAVA平台下的最后一些版权问题将在近期解决。  

  如果JAVA能做到完全开源,那么将更容易在Linux平台下进行包装分发。为配合这项行动,SUN正在与Linux厂商进行商谈,为OpenSUSE,Ubuntu以及Fedora提供一个新版的OpenJDK。  

  OpenJDK基于J2SE,开源工作始于2006年11月,其中的一些组成部分,例如加密库,图形库和一些SNMP管理代码仍然不能提供基于GNU通用许可协议的版本。这些组建占到了总平台的4%左右。  

  据SUN表示,“在过去的一年中,我们已经解决了大部分组件的版权问题,但是JAVA的声音引擎和SNMP代码部分仍然有大量的工作要做”预计全部开源可以在今年年内完成。  

  一旦基于Linux系统的JAVA可以百分百开源,那么Ubuntu及其他Linux系统就可以提供完全开源版的JAVA开发平台。对于Linux的开发者来说,现在正缺少一个开源版的JAVA平台。

http://linux.chinaunix.net/news/2008/04/25/995589.shtml

标签: , , , , , , , ,

我的家乡,红石

Google Earth中tdr拍摄的鸡冠砬子山

http://www.redstonelake.cn/

标签:

太贵了

本来想支持一下开源事业,在shopit上买点东西。预订了2件T-Shirt,1顶帽子,2套光盘,一共是54镑不到的样子,不过一看运费40多镑,UPS,太贵了吧。订单先取消了吧。等我有钱了再去支持一下吧。

标签:

Ubuntu 8.04的活动目录:Likewise

据Canonical公司的最新消息表明,Ubuntu 8.04 LTS的进展非常顺利,正式版将于两天后如期发布。这是长久期待的结束,同时,也是另一个时代的开始。
今天,我向大家介绍Ubuntu 8.04中独有的组件:Likewise。


—–
如果你还有印象的话,你应该还记得Ubuntu 8.04中,将新增一个组件,使得系统有能力与Microsoft活动目录相连接。
这个组件是:Likewise,不过默认情况下它未安装,需要的朋友可以在终端下自行安装,分别有CLI和GUI版本可以安装:
sudo apt-get install likewise-open likewise-open-gui
安装完成后,Ubuntu 8.04会启动Likewise-open的daemon,并加入系统启动daemon中(/etc/rc2.d)。
那么,如何加入一个Microsoft的域呢?也非常简单:
命令行方法
在终端下输入以下指令,其中your.domain替代为域的名称, username则是你的用户名
sudo domainjoin-cli join your.domain username
图形方法
在终端下输入sudo domainjoin-gui,然后就会跳出一个图形对话框,相信你知道怎么使用了:
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://pic.yupoo.com/tualatrix/38317570da08/0r38yvyl.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
由于本人并没有一个Microsoft的域可供测试,所以我只能向大家展示到这个步骤了。
据国外Ubuntu用户反应,通过Likewise,他的Ubuntu不仅得以非常方便地加入Microsoft的域,而且识别出了DFS文件系统。附加SMB的话,还能设定网络打印机。更棒的是,他已经有能力让Evolution使用Exchange邮箱了。参见:
Ubuntu 8.04 Active Directory Integration w/ Likewise Open
如果有朋友能进行更深一步的测试,请让大家知道更详尽的情况。
我们很高兴地见到Ubuntu不仅越来越易用,而且支持度越来越好,无论是软件,还是硬件方面。

http://linux.chinaunix.net/news/2008/04/23/994717.shtml

标签: ,

Ubuntu下安装Avast图形界面杀毒软件图文详解

最近咖啡的洗衣店进入了旺季,开始忙碌起来了,有很多资讯很想与大家分享,但是无耐的是没有时间,今天利用一些仅余的时间将咖啡认为还不错的防毒软件介绍给大家,希望能对大家有些帮助,现在就跟著咖啡一起来安装Avast antivirus for ubuntu。



AVAST 是一个著名防毒软体公司,Avast HomeEdition是家庭与非商业用途的版本,Avast Linux版本跟WINDOWS版本的內核是一样的,如果你是安装了包含windows多系统的使用者来说,这无疑的是个很好的防毒杀毒软件,虽然 Linux不太容易中毒,但是你可以在Linux系统下杀除windows下的每个一个有害的病毒,(如果你看完所有刚上档的电影,也听完一些流行歌曲, 真的闲著找不到事情可做时,不妨将Avast拿出来扫扫看你的电脑),Avast更值得一提的是,它是个免费的软件,你只需要到网站上去注册就 可以得到安装的序号,并可无限期的下载更新病毒码。安装方法:
1.首先你必须先上avast的网站免费注册,Avast会根据你注册时用的email寄发给你安装的序号,速度很快几乎注册完成就收到信件了。
注册的网址 选择中文语言网页
http://www.avast.com/cns/home-registration.php
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.ownlinux.cn/wp-content/uploads/2008/04/avast/image001.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
如果是你新注册的用户,选择第一项
接着填写注册所需的相关资讯,特别要注意的是邮箱必须要正确,否则你无法收到安装序号。
如果你完成了注册,那麽便可以开始下载软件,你可以直接到官方网站下载

下载网址:
http://www.avast.com/cns/programs.html
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.ownlinux.cn/wp-content/uploads/2008/04/avast/image002.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
安装

sudo dpkg -i avast4workstation_1.0.7-2_i386.deb
在应用程序里显示快捷图示
cd /usr/lib/avast4workstation/share/avast/desktop
sudo ./install-desktop-entries.sh install

screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.ownlinux.cn/wp-content/uploads/2008/04/avast/image003.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">

第一次执行时,Avast会要求你输入安装序号,去收email 看看你许你的序号已经寄到了

在这里填入你的序号
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.ownlinux.cn/wp-content/uploads/2008/04/avast/image004.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">

开启之后使用者介面如下图:
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.ownlinux.cn/wp-content/uploads/2008/04/avast/image005.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">

第一个优先要处理的那就是更新到最新的病毒库
按下 Update Database
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.ownlinux.cn/wp-content/uploads/2008/04/avast/image006.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">


接着你就可以设置需要扫瞄的区域,如果你是包含windows的双系统,你可以选择第三项Selected Folders ,并加入windows所属的区域,如咖啡会加入 /media:/hda1 (Windows 的C盘)
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.ownlinux.cn/wp-content/uploads/2008/04/avast/image007.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">

其它的设置那就等着你去发觉了。

http://linux.chinaunix.net/news/2008/04/18/993117.shtml

标签: ,

22项Windows或Mac不能而Linux可以的事

1. Upgrade to the newest version legally and without paying money
1。合法升级到最新版本却不花一分钱
2. Have the latest version of the operating system run faster than the previous version on the same hardware
2。同一个硬件平台上最新的操作系统却比老的更快。

3. Easily install and run different graphical interfaces if I don't like the default setup
3。如果你不喜欢默认的桌面环境,可以非常容易的自行安装其他的界面。
4. Install twenty programs with one command
4。一个命令就可以安装二十个程序。 5. Have the system automatically update all my installed programs for me.
5。让系统自动为我所安装的软件更新。
6. Install the same copy of my OS (Ubuntu) on multiple computers without worrying about license restrictions or activation keys
6。可以在N台机器上安装同一份OS拷贝而无须担心协议限制或激活码。
7. Give away copies of the operating system and other programs that run on it without breaking any laws, governmental or ethical or moral, because it was all intended to be used this way
7。可以自由分发该操作系统及其他运行其上的软件而不会违犯法律,政治或伦理道德,因为他本身就提倡这么做的。
8. Have full control over my computer hardware and know that there are no secret back doors in my software, put there by malicious software companies or governments
8。完全控制我的电脑硬件,并可知晓我的软件中没有什么被政府或者某某公司蓄意安放的秘密后门。
9. Run without using a virus scanner, adware/spyware protection, and not reboot my computer for months, even when I do keep up with all of the latest security updates
9。可以裸奔(无杀毒软件,反广告/间谍防护软件),以及可以数月不用重启机器,我甚至一直在更新着安全补丁。
10. Run my computer without needing to defragment my hard drive, ever
10。从来不用磁盘碎片整理。
11. Try out software, decide I don't like it, uninstall it, and know that it didn't leave little bits of stuff in a registry that can build up and slow down my machine
11。尝试软件,觉得不喜欢,就删掉他,而且知道他不会在什么注册表里留下一些垃圾可能导致把我的系统搞慢。
12. Make a major mistake that requires a complete reinstallation and be able to do it in less than an hour, because I put all of my data on a separate partition from the operating system and program files
12。犯了重大错误而导致全新重装系统,也不过花去了1小时不到的时间,因为我把我的数据放在了独立于操作系统和程序的分区。
13. Boot into a desktop with flash and effects as cool as Windows Vista on a three year old computer...in less than 40 seconds, including the time it takes me to type my username and password to login
13。在一台3岁的老电脑上可以有如vista那样超酷的登录效果...少于40秒,这已经是将我输入用户名和密码并登录计算在内了。
14. Customize anything I want, legally, including my favorite programs. I can even track down the software developers to ask them questions, contribute ideas, and get involved in the actual design/software writing process if I want to
14。合法自定义任何我想要的东西,包括我最喜爱的程序。我甚至可以跟踪软件开发者并向他们问问题,提意见,如果我愿意的话,也可以参与到真正的软件设计和开发进程中去。
15. Have 4+ word processor windows open working on papers, listen to music, play with flashy desktop effects, have contact with a largely happy community and have firefox, instant messaging, and email clients all open at the same time, without ever having had to beg someone for a code to make my os work, and without the system running so slow it is useless
15。超过4个的文字处理窗口,听音乐,玩超酷的桌面效果,联系一个大型的社区,并同时运行着firefox,即时通讯以及email客户端,而不必求爷爷告奶奶的要什么令我的系统可以运作的代码,而不会把系统变慢。
16. Use the command "dpkg --get-selections > pkg.list" to make a full, detailed list of all software I have installed, backup my /etc and /home directories on a separate partition, and you are able to recover your system any time, easily
16。使用"dpkg --get-selections > pkg.list"命令来获得一个完整详尽的已装软件列表,备份我的/etc和/home文件夹到一个独立分区,然后你就可以随时恢复你的系统了,而且超简单。
17. Run multiple desktops simultaneously, or even allow multiple users to log in and use the computer simultaneously
17。同时运行多个桌面,甚至可以让多用户同时登录并使用该机器。
18. Resize a hard disk partition without having to delete it and without losing the data on it
18。无损调整分区大小而不用担心会丢失数据。(译者注:应该是LVM)
19. Use the same hardware for more than 5 years before it really needs to be replaced...I have some hardware that is nearly 10 years old, running Linux, and still useful
19。硬件可以使用超过五年而无须更换...我甚至有一些硬件都超过10年的历史了,还依然健在。
20. Browse the web while the OS is being installed!
20。可以在OS安装的同时浏览网页!
21. Use almost any hardware and have a driver for it included with the operating system...eliminating the need to scour the internet to find the hardware manufacturer's website to locate one
21。使用几乎所有的硬件,因为系统已经自带了驱动...而不必再去硬件供应商的主页上去苦苦搜寻。
22. Get the source code for almost anything, including the OS kernel and most of my applications
22。可以任意获得源代码,包括OS内核以及我的大多数应用程序。

http://linux.chinaunix.net/news/2008/04/25/995585.shtml

标签: , ,

xf86-video-intel 2.3.0正式发布

Intel可能是业界开发驱动最积极的硬件厂商之一了(另外一个是nVIDIA),作为最流行的集成显卡,Intel在Win/Lin两个平台均保持比较好的驱动质量。
Linux驱动方面,据上一个里程碑2.2.0至今已有半年了,Intel不断努力,现在又一个里程碑:2.3.0已经正式发布了。


xf86-video-intel2.3.0相对于2.2版本来说,不仅在稳定性和Bug修正方面有非常大的改善,最为重要的一点是,从这个版本开 始,Intel915/945的集成显示芯片已经支持了XvMC(X-Video Motion Compensation)。
什么是XvMC呢?在Mplayer中,我们就能看到Xv的身影,即X11/Xv视频驱动,现在Intel的显卡也支持了。
另外一点是,xf86-video-intel 2.3.0将正式包含在X.Org 7.4中。
详情可见:[ANNOUNCE] xf86-video-intel 2.3.0

http://linux.chinaunix.net/news/2008/04/24/995199.shtml

标签: , , ,

TD之父李世鹤:TD即将安乐死

被誉为“TD-SCDMA之父”的原大唐移动首席科学家李世鹤近日在一个业内会议上表示,TD-SCDMA(以下简称“TD”)安乐死即将成为现实,他呼吁相关部门尽快制订发展TD的明确计划。在近日举办的一个TD专家座谈会上,李世鹤说,“TD从4月1日起开始试商用放号,可是我一点都高兴不起来,我看到的是TD快死了,有人说要让TD安乐死,这个‘伟大的理想’即将实现。”

screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" border="0">



  “TD即将安乐死”

  李世鹤说,他得出TD即将安乐死这一结论的原因有二:一是,世界上没有一个国家让一个通信网试验了又试验,如果技术问题解决了,“是骡子是马,到市场 上去检验”,让最终用户去评判,“靠试验网解决问题,世界上没有先例”;二是,到目前为止,相关部门关于TD依然没有明确的计划,“到底用不用(TD), 没有一个人站出来讲,哪一个运营商会用,不知道,(相关部门)跟所有人打哑谜”,这样的后果是,一些支持TD的厂家日子很难过,“有一家TD手机芯片公司 已经到了破产的边缘。

  李世鹤在发言结束时,动情的说,“我是一个罪人,把很多人骗上了3G”,“TD现在很危险,很可能一下子就全垮掉了,我呼吁大家尽快拿出决策出来,谁上、怎么上,拿出发展计划,拿出运营商计划,不应该走一步看一步。”

  除了李世鹤外,也有其他电信专家呼吁加快TD终端的采购。一位来自高校的电信专家建议运营商大规模集采TD手机,因此这样可以弥补目前TD手机终端匮 乏的现状;另外一位来自政府部门的专家则表示,他通过调研后发现,一些手机厂商在没有明确的需求信号时,对TD手机的生产处于观望状态,因此希望运营商加 大采购量。

  “TD目前的网络状况超过我的预想”

  在本次专家座谈会上,很多专家谈到目前TD的网络状况和GSM相差太远,出现了覆盖率低、接通率低、室内无法覆盖等问题,这些也是首批试用者抱怨比较多的一些问题。

  李世鹤说,“现在的网络状况,我有发言权,包括以前的试验网在内,我都不止一次到各地去实地考察,我到过几个城市,他们的网络状况超过了我的预想,目前基本可以用。”

  李世鹤拿GSM进行对比,“中国移动的GSM网络优化了10几年,TD网络优化才不到半年,当然不能要求现在的TD网络状况和GSM一样,GSM网络 刚建成时,接通率也只有20%-30%,当时的GSM不是试验网,已经是正式的商用网,所以目前的TD网络状况是正常的,而且比正常的还要好一些”。

  知名电信专家李进良也搬出了英国刚上3G时的用户反馈情况进行对比,得出的结论是,TD目前遇到的情况并不比英国3G开通时糟糕,因此,按照国际移动网络的运营经验,3年之后TD网络可以优化到相当好的状况。

http://bbs.chinaunix.net/thread-1084541-1-1.html

标签:

Ubuntu新版Linux免费下载血战Novell

Ubuntu Server 8.04将从本周四开始让用户免费下载。这将使Canonical的Ubuntu与Red Hat Enterprise和Novell平Suse Linux Enterprise更激烈地争夺企业市场。

Ubuntu Server 8.04的支持周期为5年。它能够在Sun的服务器上运行,其中包括Sun Fire X2100 M2、X2200 M2、Sun Fire X4150。Sun负责开放源代码软件业务的经理乔治表示,Ubuntu Server 8.04面向企业市场。

Canonical首席执行官马克表示,Ubuntu Server 8.04一直面临稳定性问题困扰,我们通过更多测试提高了其可靠性。他在接受采访时说,我们将每二年推出一个新的版本。

马克表示,Sun的认证包括1、2、4路x86服务器,Ubuntu没有针对4路以上的系统对Ubuntu Server 8.04进行优化。另外,Canonical还在与惠普、IBM、戴尔就认证问题进行接触。

Ubuntu 8.04中包含Windows整合功能。通过使用第三方厂商Likewise的Likewise Enterprise产品,Ubuntu

8.04能够使用微软活动目录用户身份管理系统的服务。马克说,与Windows网络的整合非常重要。

Ubuntu 8.04还整合有Open JDK,这意味着Ubuntu首次整合了Java虚拟机,能够运行Java应用程序。另外,它还包含有开放源代码版Alfresco内容管理软件、 Bacula网络备份软件、Parallels虚拟软件、Tresys安全软件、PHP、Zimbra电子邮件。

http://linux.chinaunix.net/news/2008/04/23/994703.shtml

标签: , , , ,

Ubuntu Linux 8.04 LTS

Ubuntu Linux是一份完整的桌面Linux操作系统,它可免费获得,并带有社团及专业的支持。最新的Ubuntu 8.04 LTS今天已经发布!它已成为为全球第三大Linux发行厂商。随着它的第四个服务器版本、第二个长期技术支持(LTS)版本的发布,Ubuntu有望得到更多企业用户的青睐。"进入ChinaUnix下载频道下载 安装指南
ubuntu-8.04-desktop-i386.iso ubuntu-8.04-server-i386.iso

虽然Ubuntu 8.04 LTS 正式版还没有发布,但现在已经可以预定.Ubuntu不愧是“Linux for Human Beings ”,除了操作系统本身越来越趋方便和人性化,另外自费为全世界Ubuntu用户提供光盘更是体现了这一信念.

申请Ubuntu 8.04 LTS 的地址还是跟以前一样:


访问https://shipit.ubuntu.com/ ,然后注册一下就可以申请了。

方便自己刻录或会硬盘安装的朋友就没有必要去申请了,毕竟Canonical公司每发送一张光盘成本还是蛮高的!大概要几十欧元吧?

标签: ,

a+b=c跟c=a+b为什么不一样? C新新手问题

弹头:我要把a和b相加,然后赋值给c, 为什么我写成a+b=c就编译出错,写c=a+b就没有问题?? 这2个式子不一样么??为啥呢?谢谢

blankyao : 等号是赋值运算,不能把值赋给a+b
只能把a+b赋给c

弹头 : 我写成a+b=c出错阿,我是linux下gcc

lenovo : 哥们,有c语言教科书吗?
没有去买一本。

弹头 :
书上就说c=a+b这种,可是没说为啥?为啥a+b=c这种不行呢?

motalelf :
哥们我看好你哦。

当年我初学C,也这么问过老师,可能老师忙着去泡妞了,也没给我解释明白。

结果我C考试时也就糊里糊涂,最后不及格。


弹头: 难道说就是语法规定,没有什么为什么,必须这么写??

flw : 编程语言中借鉴了很多数学符号/概念,
但是这些符号和数学课本上的符号/概念还是有很大区别的。

就拿 = 这个符号来说,数学上把它叫做“等号”,
但是 C 语言里,它不是“等号”,而是“赋值号”,
C 语言里的“等号”是 ==,也就是两个等号连起来这样子。
== 满足交换律,c == a+b 和 a+b == c 是同一个意思,
但是 = 不满足交换律,它是有方向的,它的方向,代表了赋值的方向,
也就是数据存取的方向。

c=a 的意思是把 a 的值取出来,存入 c,
a=c 的意思是把 c 的值取出来,存入 a,
它们俩的含义显然是不同的。
反应到你的例子中,
c=a+b 就是把 a 和 b 的值取出来,进行加法运算,然后把结果存入 c,但是 a+b=c 是什么意思呢?难道是把 c 的值取出来存入 a+b 吗?
因为 a+b 不是一个变量,因此无法往里面存入值,
因此 a+b=c 是错误的。

等你后来慢慢学的深入了,就知道 a+b 其实是一个右值(right value),不是左值(left value),
因此不能往它里面存入(store)任何数据,但是 c 就是一个左值(left value),可以往里面存入(store)和它的类型相匹配的值。

一言以蔽之,计算机是“工科”,数学是“理科”,学习时要注意区别对待。计算机是实践性很强的一门科学,它不是纯理论,因此学习理论知识时,应该结合电脑硬件的基本工作流程来学习。
http://bbs.chinaunix.net/thread-1085912-1-1.html
最后:>>> 哲学问题。因为在新手眼里看起来这两个都是等式,没有什么分别。

偶要在新语言里设计符号:->和<-。分别用于赋值。 a+b->c;
c<-a+b;
至于C里常用的指针还是用pascal的^.吧。

标签:

星期三, 四月 23, 2008

Yahoo YUI简介

Yahoo!用户界面库(Yahoo! User Interface Library, YUI)提供一些在开发Web胖客户端时常用到的一些工具和UI控件。工具:拖放(Drag and Drop)操作,连接管理器(XMLHttpRequest),页面特效,浏览器事件(例如鼠标点击和键盘按键)管理。UI控件:自动补全 (AutoComple)、日历(Calendar),容器(Container)类控件包括提示(Tooltip)、面板(Panel)、对话框 (Dialog)等、菜单(Menu)、TabView、TreeView,Logger。YUI 还包括了在创建简洁,灵活的布局并能够兼容多种浏览器时所需要的CSS资源。

http://developer.yahoo.com/yui/

标签: ,

怀念海子

从明天起,和每个亲人通信
告诉他们我的幸福
那幸福的闪电告诉我的
我将告诉每个人
——摘自 海子《面朝大海 春暖花开》