1) die("too many file found!"); // 無い場合は終わり if(count($result) == 0) die("file not found!"); } $rs = explode(" ",$result[0],2); if($rs[0] != ""){ $fname = "$rs[0].html"; $source = file($fname); $s_cnt = count($source); // xhtmlか判別 if( strpos($source[0],"XHTML") !== FALSE){ $doctype="xhtml"; } else{ $doctype="html"; } if(!empty($_REQUEST['start'])){ // ジャンプポイントを求める(start-5 の場所にロケーションジャンプ) $jump = $_REQUEST['start']; if($_REQUEST['start'] > 5) $jump = $_REQUEST['start'] - 5; // BODY TAGに追加 if(($jump > 0)){ for($i=5;$i<20;$i++){ if( strpos($source[$i],"") !== FALSE){ // javascriptで指定行にジャンプ $source[$i] = "\n"; break; } } } // ハイライトする範囲のオフセットを求める $offset=1; if(is_numeric($_REQUEST['end'])) $offset = $_REQUEST['end']-$_REQUEST['start']+1; elseif(is_numeric($_REQUEST['offset'])){ $offset = $_REQUEST['offset']; } if($offset<=0) $offset=1; // 指定行にスタイルを追加 if($doctype == "html"){ $needle = ""; $style="style='color:#de9ede;background:#5a5d5a;margin-top:10px;width:100%;'"; } else{ $needle = ""; $style="class='reverse'"; } $count=0; for($i=$_REQUEST['start'];$i<$s_cnt;$i++){ if( strpos($source[$i],$needle) !== FALSE){ $source[$i] = "
{$source[$i]}"; break; } } for(;$i<$s_cnt;$i++){ $count++; if( $count == $offset){ $source[$i] = str_replace("\n","",$source[$i]) . "
\n"; break; } } } // 表示 for($i=0;$i<$s_cnt;$i++){ echo $source[$i]; } } ?>