<? $e=clinchgeturl("http://im286.com/forumdisplay.php?fid=1"); var_dump($e); function clinchgeturl($url) { //$url="http://127.0.0.1/1.htm"; //$rootpath="http://fsrootpathfsfsf/yyyyyy/"; //var_dump($rrr); if(eregi(@#(.)*[\.](.)*@#,$url)){ $roopath=split("\/",$url); $rootpath="http://".$roopath[2]."/"; $nnn=count($roopath)-1;for($yu=3;$yu<$nnn;$yu++){$rootpath.=$roopath[$yu]."/";} // var_dump($rootpath); //http: ,@#@#,127.0.0.1,xnml,index.php } else{$rootpath=$url;//var_dump($rootpath); } if(isset($url)){ echo "$url 有下列裢接:<br>"; $fcontents = file($url); while(list(,$line)=each($fcontents)){ while(eregi(@#(href[[:space:]]*=[[:space:]]*"?[[:alnum:]:@/._-]+[\?]?[^\"]*"?)@#,$line,$regs)){ //$regs[1] = eregi_replace(@#(href[[:space:]]*=[[:space:]]*\"?)([[:alnum:]:@/._-]+)(\"?)@#,"\\2",$regs[1]); $regs[1] = eregi_replace(@#(href[[:space:]]*=[[:space:]]*[\"]?)([[:alnum:]:@/._-]+[\?]?[^\"]*)(\.*)[^\"\/]*([\"]?)@#,"\\2",$regs[1]); if(!eregi(@#^http:\/\/@#,$regs[1])){ if(eregi(@#^\.\.@#,$regs[1])){ // $roopath=eregi_replace(@#(http:\/\/)?([[:alnum:]:@/._-]+)[[:alnum:]+](\.*)[[:alnum:]+]@#,"http:\/\/\\2",$url); $roopath=split("\/",$rootpath); $rootpath="http://".$roopath[2]."/"; //echo "这是根本d :"."\n"; $nnn=count($roopath)-1;for($yu=3;$yu<$nnn;$yu++){$rootpath.=$roopath[$yu]."/";} //var_dump($rootpath); if(eregi(@#^\.\.[\/[:alnum:]]@#,$regs[1])){ //echo "这是../目录/ :"."\n"; //$regs[1]="../xx/xxxxxx.xx"; // $rr=split("\/",$regs[1]); //for($oooi=1;$oooi<count($rr);$oooi++) $rrr=$regs[1]; // {$rrr.="/".$rr[$oooi]; $rrr = eregi_replace("^[\.][\.][\/]",@#@#,$rrr); //} $regs[1]=$rootpath.$rrr; } }else{ if(eregi(@#^[[:alnum:]]@#,$regs[1])){ $regs[1]=$rootpath.$regs[1]; } else{ $regs[1] = eregi_replace("^[\/]",@#@#,$regs[1]);$regs[1]=$rootpath.$regs[1];} } } $line = $regs[2]; if(eregi(@#(.)*[\.](htm|shtm|html|asp|aspx|php|jsp|cgi)(.)*@#,$regs[1])){ $out[0][]=$regs[1]; } } } }for ($ouou=0;$ouou<count($out[0]);$ouou++) { if($out[0][$ouou]==$out[0][$ouou+1]){ $sameurlsum=1; //echo "sameurlsum=1:"; for($sameurl=1;$sameurl<count($out[0]);$sameurl++){ if($out[0][$ouou+$sameurl]==$out[0][$ouou+$sameurl+1]){$sameurlsum++;} else{break;} } for($p=$ouou;$p<count($out[0]);$p++) { $out[0][$p]=$out[0][$p+$sameurlsum];} } } $i=0; while($out[0][++$i]) { //echo $root.$out[0][$i]."\r\n"; $outed[0][$i]=$out[0][$i]; } unset($out); $out=$outed; return $out; } ?> | |