id)) { if($node->id == TIDY_TAG_A) { $urls[] = $node->attribute['href']; $urls[] = $node->child[0]->value; } } if($node->hasChildren()) { foreach($node->child as $c) { dump_nodes($c, $urls); } } return $urls; } function get_url_list($t_url,$tidy_encode,$mb_encode){ $url = array(); $json = new Services_JSON(); $rdata = http_request($t_url); $data = mb_convert_encoding($rdata['data'],$mb_encode,"auto"); $config = array('indent' => TRUE, 'output-xhtml' => TRUE, 'wrap' => 200); $a = tidy_parse_string($data, $config, $tidy_encode); $a->cleanRepair(); $urls = dump_nodes($a->html()); for ($i = 0 ; $i < count($urls)/2 ; $i++){ array_push($url,array("url"=>$urls[$i*2],"text"=>$urls[$i*2+1])); } $js = $json->encode($url); if ($_GET['callback']<>""){ $src = $_GET['callback']."("; $src .= $js; $src .=");"; echo $src; } } if($_GET["url"] <>"") { if ($_GET["encode"]<>""){ $tidy_encode = "utf8"; $mb_encode = "UTF-8"; }else{ if(stristr($_GET["encode"], 'UTF-8') !== FALSE) { if(stristr($_GET["encode"], 'SJIS') !== FALSE) { if(stristr($_GET["encode"], 'EUC-JP') !== FALSE) { $tidy_encode = "utf-8"; $mb_encode = "UTF-8"; }else{ $tidy_encode = "euc-jp"; $mb_encode = "EUC-JP"; } }else{ $tidy_encode = "shiftjis"; $mb_encode = "SJIS"; } }else{ $tidy_encode = "utf8"; $mb_encode = "UTF-8"; } } get_url_list($_GET["url"],$tidy_encode,$mb_encode); } ?>