我用dreamweaver做了个页面,想在其中的文本框内显示地址上指定路径的文本文件,请问下该怎么添加修改PHP语句。
页面源代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Examine Rule</title>
</head><body> <h1 align="center">Display Rule</h1>
<div align="center">
<table width="426" height="300" border="1">
<tr>
<td height="34" colspan="2"> <div align="center">choose rules</div>
<form name="form2" method="post" action="">
<div align="center">Location:
<input name="textfield" type="text" size="60">
</div>
</form> </td>
</tr>
<tr>
<td height="213" colspan="2"><p align="center">IDS Rules:</p>
<form name="form1" method="post" action="">
<div align="center">
<textarea name="textarea" cols="80" rows="10"></textarea>
</div>
</form> </td>
</tr>
<tr>
<td width="277" height="25"><form name="form3" method="post" action="">
<div align="center">
<input type="submit" name="Submit" value="Display">
</div>
</form></td>
<td width="290"><form name="form4" method="post" action="">
<div align="center">
<input type="button" class="button1" onclick="document.location.href='../snort/index.php'" value="Return">
</div>
</form></td>
</tr>
</table>
</div>
<p align="center"> </p>
</body>
</html>
页面源代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Examine Rule</title>
</head><body> <h1 align="center">Display Rule</h1>
<div align="center">
<table width="426" height="300" border="1">
<tr>
<td height="34" colspan="2"> <div align="center">choose rules</div>
<form name="form2" method="post" action="">
<div align="center">Location:
<input name="textfield" type="text" size="60">
</div>
</form> </td>
</tr>
<tr>
<td height="213" colspan="2"><p align="center">IDS Rules:</p>
<form name="form1" method="post" action="">
<div align="center">
<textarea name="textarea" cols="80" rows="10"></textarea>
</div>
</form> </td>
</tr>
<tr>
<td width="277" height="25"><form name="form3" method="post" action="">
<div align="center">
<input type="submit" name="Submit" value="Display">
</div>
</form></td>
<td width="290"><form name="form4" method="post" action="">
<div align="center">
<input type="button" class="button1" onclick="document.location.href='../snort/index.php'" value="Return">
</div>
</form></td>
</tr>
</table>
</div>
<p align="center"> </p>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Examine Rule </title>
</head>
<body>
<h1 align="center">Display Rule </h1>
<?php
$path=trim($_POST['textfield']);
@$fp=fopen($path,'r');
if ($fp)
{
$content=fread($fp,filesize($path));
$content=htmlspecialchars($content);
}
?>
<div align="center">
<table width="426" height="300" border="1">
<form name="form2" method="post" action="">
<tr>
<td height="34" colspan="2"> <div align="center">choose rules </div>
<div align="center">Location:
<input name="textfield" type="text" size="60">
</div>
</td>
</tr>
<tr>
<td height="213" colspan="2"> <p align="center">IDS Rules: </p>
<div align="center">
<textarea name="textarea" cols="80" rows="10"><?php if (!empty($_POST['textfield']) && $fp) echo $content;?> </textarea>
</div>
</td>
</tr>
<tr>
<td width="277" height="25">
<div align="center">
<input type="submit" name="Submit" value="Display">
</div>
</td>
<td width="290">
<div align="center">
<input type="button" class="button1" onclick="document.location.href='../snort/index.php'" value="Return">
</div>
</form> </td>
</tr>
</table>
</div>
<p align="center"> </p>
</body>
</html>