<?php
	if( !is_array($Project) ){
		ob_clean();
		exit("Forbidden");	
	}
?>
  
<?php

	echo '
	<table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
		<tr class="title">
			<td></td>
			<td>标题</td>
			<td>相关文件</td>
			<td>更新时间</td>
		</tr>';

		$x =0;
		
		$mod = VI_ROOT;
		
		if ($handle = opendir($mod)) {
		
			while (false !== ($file = readdir($handle))) {
				//PHP文件
				if(stripos($file,".php")){
					
					$temp = file_get_contents($file);
					
					preg_match('/html_start\("(.*?)"\)/',$temp, $matches);
					$title = $matches[1];
					
					$title = str_replace(' - VeryIDE','',$title);
					
					$temp = preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si", "", $temp);
					
					$temp = stripScriptTags($temp);
					
					//$temp = preg_replace("/<style>.+<\/style>/is", "", $temp);  
					//$temp = str_replace(" ", "", $temp);  
					//$temp = preg_replace("/<[^>]+>/isU", "", $temp);
					
					$temp = strip_tags($temp);
					
					//$value = preg_match("/.*$q.*/i", $temp, $res); 

					//$res[0] = preg_replace("/$key/i", "<FONT SIZE=\"2\"  COLOR=\"red\">$key</FONT>", $res[0]);
					
					/*
					
					//去除两个标签之外的空白字符
					//$str = preg_replace("~>\s+\r~", ">", preg_replace("~>\s+\n~", ">", $str));
					//$str = preg_replace("~>\s+<~", "><", $str);

					
					//过滤PHP
					$temp = preg_replace("/<\?php.*>.*\?>/isU","",$temp);
					
					//过滤标签
					//$temp = strip_tags($temp,"<strong><p><table><tbody><tr><td><select><form><div>");
					//
					
					*/
					
					//压缩数据
					$temp = str_replace(array(chr(9),chr(10),chr(13)),array('','',''),$temp);
					
					$pos = stripos($temp,$q);
					
					//echo $pos;exit();
					
					if( $pos !== false || stripos($title,$q) !== false ){
						
						//取部分
						//$text = GetSubStr($temp, 100, $pos-50, $Project["charset"]);
						
						//$temp = preg_replace("'^([^\s]*\s.*?)\s[^\s]*$'i", "\\1", $temp);
						
						$text = $temp;
												
						echo '<tr class="line">';
						echo '<td>'.($x+1).'</td>';
						echo '<td>'.str_replace($q,'<span class="text-key">'.$q.'</span>',$title).'</td>';
						echo '<td><a href="'.$file.'" onclick="parent.Mo.Window(\'window\',\''.$title.'\' ,\''.$file.'\' ,\'90%\',\'85%\',false); return false;">'.$file.'</a></td>';
						echo '<td>'.date("Y-m-d H:i:s",filemtime($file)).'</td>';
						echo '</tr>';
						
						if( $text ){
							echo '<tr>';
							echo '<td colspan="4" class="block">
								'.str_replace($q,'<span class="text-key">'.$q.'</span>',htmlspecialchars($text)).'
							</td>';
							echo '</tr>';
						}
						
						$x++;							
					}					
				}
			}
		}        
	
	echo '</table>';

?>