日期:2014-05-16 浏览次数:20443 次
吴浩介绍我看看《nodejs》,在我的VPS上配好后,发现它解决了一个问题:如何在PHP里模拟调用javascript环境。《NodeJS探索》写的幽默风趣,较为经典的话莫过于“这对于JS程序员来说,真是一个莫大的福音,因为你们再也不用看着那帮做后台的孙子的脸色干活了,可以翻身做后端了”。
?
拿采集爱漫画的程序举例子,http://imanhua.com/comic/120/list_50567.html?p=3,打开源代码,找到如下代码:
?
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('5 d=c;5 e=["/3/2/1/0/g.f","/3/2/1/0/b.4","/3/2/1/0/7.4","/3/2/1/0/6.4","/3/2/1/0/8.4","/3/2/1/0/9.4","/3/2/1/0/a.4","/3/2/1/0/h.4","/3/2/1/0/p.4","/3/2/1/0/o.4","/3/2/1/0/q.4","/3/2/1/0/s.4","/3/2/1/0/r.4","/3/2/1/0/n.4","/3/2/1/0/j.4","/3/2/1/0/i.4","/3/2/1/0/k.4","/3/2/1/0/m.4"];5 l=0;',29,29,'50567|120|Images|Files|png|var|imanhua_004_095646468|imanhua_003_095646453|imanhua_005_095646468|imanhua_006_095646484|imanhua_007_095646484|imanhua_002_095646453|18|len|pic|jpg|imanhua_001_095646437|imanhua_008_095646500|imanhua_016_095646531|imanhua_015_095646531|imanhua_017_095646531|sid|imanhua_018_095646546|imanhua_014_095646515|imanhua_010_095646500|imanhua_009_095646500|imanhua_011_095646500|imanhua_013_095646515|imanhua_012_095646515'.split('|'),0,{}))
?在netbeans里,换行、缩进之后,变成:
?
eval(function(p,a,c,k,e,d){ e=function(c){ return(c<a?"":e(parseInt(c/a))) + ((c=c%a)>35?String.fromCharCode(c+29):c.toString(36)) }; if(!''.replace(/^/,String)){ while(c--)d[e(c)]=k[c]||e(c); k=[function(e){return d[e]}]; e=function(){return'\\w+'};c=1; }; while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]); return p; }('5 d=c;5 e=["/3/2/1/0/g.f","/3/2/1/0/b.4","/3/2/1/0/7.4","/3/2/1/0/6.4","/3/2/1/0/8.4","/3/2/1/0/9.4","/3/2/1/0/a.4","/3/2/1/0/h.4","/3/2/1/0/p.4","/3/2/1/0/o.4","/3/2/1/0/q.4","/3/2/1/0/s.4","/3/2/1/0/r.4","/3/2/1/0/n.4","/3/2/1/0/j.4","/3/2/1/0/i.4","/3/2/1/0/k.4","/3/2/1/0/m.4"];5 l=0;', 29, 29, '50567|120|Images|Files|png|var|imanhua_004_095646468|imanhua_003_095646453|imanhua_005_095646468|imanhua_006_095646484|imanhua_007_095646484|imanhua_002_095646453|18|len|pic|jpg|imanhua_001_095646437|imanhua_008_095646500|imanhua_016_095646531|imanhua_015_095646531|imanhua_017_095646531|sid|imanhua_018_095646546|imanhua_014_095646515|imanhua_010_095646500|imanhua_009_095646500|imanhua_011_095646500|imanhua_013_095646515|imanhua_012_095646515'.split('|'), 0,{ }) );
?定义一个匿名函数,同时传入参数,运行返回一个值。紧接着,返回值被eval函数接收,并运行。把上述代码抠出来,放到firefox的firebug控制台运行:
?
var s = function(p,a,c,k,e,d){ e=function(c){ return(c<a?"":e(parseInt(c/a))) + ((c=c%a)>35?String.fromCharCode(c+29):c.toString(36)) }; if(!''.replace(/^/,String)){ while(c--)d[e(c)]=k[c]||e(c); k=[function(e){return d[e]}]; e=function(){return'\\w+'};c=1;}; while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]); return p; } ( '5 d=c;5 e=["/3/2/1/0/g.f","/3/2/1/0/b.4","/3/2/1/0/7.4","/3/2/1/0/6.4","/3/2/1/0/8.4","/3/2/1/0/9.4","/3/2/1/0/a.4","/3/2/1/0/h.4","/3/2/1/0/p.4","/3/2/1/0/o.4","/3/2/1/0/q.4","/3/2/1/0/s.4","/3/2/1/0/r.4","/3/2/1/0/n.4","/3/2/1/0/j.4","/3/2/1/0/i.4","/3/2/1/0/k.4","/3/2/1/0/m.4"];5 l=0;',29,29,'50567|120|Images|Files|png|var|imanhua_004_095646468|imanhua_003_095646453|imanhua_005_095646468|imanhua_006_095646484|imanhua_007_095646484|imanhua_002_095646453|18|len|pic|jpg|imanhua_001_095646437|imanhua_008_095646500|imanhua_016_095646531|imanhua_015_095646531|imanhua_017_095646531|sid|imanhua_018_095646546|imanhua_014_095646515|imanhua_010_095646500|imanhua_009_09564