level 1
yxn1910
楼主
01./**
02.+----------------------------------------------------------
03.* 遍历目录,输出树状结构数组
04.+----------------------------------------------------------
05.* @param string $path 目录路径
06.+----------------------------------------------------------
07.* @return array
08.+----------------------------------------------------------
09.*/
10.function foreachDir($path){
11.foreach (scandir($path) as $file){
12.if(in_array($file,array('.','..'))) continue;
13.$fullPath = $path.'/'.$file;
14.if(is_dir($fullPath)){
15.$result[$file] = foreachDir($fullPath);
16.}else{
17.$temp[]=$file;
18.}
19.}
20.foreach ($temp as $key){
21.$result[]=$key;
22.}
23.return $result;
24.}
25./**
26.+----------------------------------------------------------
27.* 返回对应搜索引擎蜘蛛
28.+----------------------------------------------------------
29.* @return string
30.+----------------------------------------------------------
31.*/
32.function spider(){
33.$agent = $_SERVER['HTTP_USER_AGENT'];
34.if(strpos($agent,'Baiduspider')){
35.$ip = get_client_ip();
36.if(strpos(`host $ip`,'baiduspider')){
37.return 'Baidu';
38.}
39.}
40.if(strpos($agent,'Googlebot')) return 'Google';
41.if(strpos($agent,'Sosospider')) return 'Soso';
42.if(strpos($agent,'Sogou')) return 'Sogou';
43.return false;
44.}
复制代码
2011年07月28日 14点07分
1
02.+----------------------------------------------------------
03.* 遍历目录,输出树状结构数组
04.+----------------------------------------------------------
05.* @param string $path 目录路径
06.+----------------------------------------------------------
07.* @return array
08.+----------------------------------------------------------
09.*/
10.function foreachDir($path){
11.foreach (scandir($path) as $file){
12.if(in_array($file,array('.','..'))) continue;
13.$fullPath = $path.'/'.$file;
14.if(is_dir($fullPath)){
15.$result[$file] = foreachDir($fullPath);
16.}else{
17.$temp[]=$file;
18.}
19.}
20.foreach ($temp as $key){
21.$result[]=$key;
22.}
23.return $result;
24.}
25./**
26.+----------------------------------------------------------
27.* 返回对应搜索引擎蜘蛛
28.+----------------------------------------------------------
29.* @return string
30.+----------------------------------------------------------
31.*/
32.function spider(){
33.$agent = $_SERVER['HTTP_USER_AGENT'];
34.if(strpos($agent,'Baiduspider')){
35.$ip = get_client_ip();
36.if(strpos(`host $ip`,'baiduspider')){
37.return 'Baidu';
38.}
39.}
40.if(strpos($agent,'Googlebot')) return 'Google';
41.if(strpos($agent,'Sosospider')) return 'Soso';
42.if(strpos($agent,'Sogou')) return 'Sogou';
43.return false;
44.}
复制代码
