"; //array_push($source_page,$xml_data); } } } function endElement($parser_instance, $element_name) //结束标签事件的函数 { global $tagPos; global $index_page; if ($element_name == "ITEM") { $index_page++; } if ($element_name == "PAGES" || $element_name == "MODULES") { $index_page = 0; } $tagPos[$element_name] = false; } $parser = xml_parser_create(); //创建一个parser编辑器 $index_page = 0; if ($parser) { xml_set_element_handler($parser, "startElement", "endElement");//设立标签触发时的相应函数 这里分别为startElement和endElenment xml_set_character_data_handler($parser, "characterData");//设立数据读取时的相应函数 //$xml_file="/zhongsou/page/php/p.xml";//指定所要读取的xml文件,可以是url $ww = urlencode($word); $xml_file="http://i.zhongsou.com/bl/bianlian2.php?tp=$tp&w=$ww&pn=$pn&n=$n&b=$b";//指定所要读取的xml文件,可以是url //echo $xml_file; $filehandler = @fopen($xml_file, "r");//打开文件 if ($filehandler != false) { //echo "open OK!"; while(!feof($filehandler)) { $data.= fread($filehandler, 10240); } // echo $data; $rst = xml_parse($parser, $data, feof($filehandler)); /* if($rst==false) { echo xml_error_string(xml_get_error_code($parser)); printf("Line:%d", xml_get_current_line_number($parser)); }*/ fclose($filehandler); }else { //echo "faile!"; } //每次取出4096个字节进行处理 //start------本行不允许更改 xml_parser_free($parser);//关闭和释放parser解析器*/ } } function FanyePage() { global $word; global $c; global $n; global $pn; global $tp; global $b; global $xml_FanYeCode; global $totalpage_block; global $totalnum_block; global $curpage_block; global $totalpage_page; global $totalnum_page; global $curpage_page; global $xml_FanYeCode; global $fanyeflag; $ww = urlencode($word); if ($tp == "2") { $num = $totalpage_page; }else{ if($fanyeflag == 1) $num = $totalpage_page; else $num = $totalpage_block; } if ($num > 100) { $num = 100; } if ($num <= 1) { return ; } $i = 1; if ($b > 1 && $b <= $num) { $nownum = $b - 1; $xml_FanYeCode.="上一页 "; } //echo $num; if ($b < 6) { for ($i;$i < 10 && $i <= $num;$i++) { if ($i == $b) { $xml_FanYeCode .="$b "; }else{ $xml_FanYeCode .="[$i] "; } } }else { for ($i = $b - 5;($i <= $b + 5) && $i <= 100 && $i <= $num;$i++) { if ($i == $b) { $xml_FanYeCode .="$b "; }else{ $xml_FanYeCode .="[$i] "; } } } if (($b < $num && $b < 100)) { $nownum = $b + 1; $xml_FanYeCode .="下一页"; } } } ?>