![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
[php]
<?
function unhtml($matches )
{
$str=$matches[2];
//$str = str_replace ( '&', '&', $str );
//$str = str_replace ( ''', '\'', $str );
//$str = str_replace ( '"', '\"', $str );
$str = str_replace ( '<', '<', $str );
$str = str_replace ( '>', '>', $str );
return $str;
}
function myhtml($str )
{
$str = str_replace ( '<', '<', $str );
$str = str_replace ( '>', '>', $str );
$str = str_replace ( ' ', ' ', $str );
$str = str_replace ( "\r", '', $str );
$str = str_replace ( "\n", '
', $str );
return $str;
}
function myout(&$a) {
if (is_array($a)) {
array_walk($a,'out');
} else {
$a = stripslashes($a);
$a = str_replace('"', '"', $a);
}
}
function myin(&$a) {
if (is_array($a)) {
array_walk($a,'myin');
} else {
$a = addslashes($a);
}
}
if (get_magic_quotes_gpc() != 1) {
isset($_GET) ? myin($_GET) : '';
isset($_POST) ? myin($_POST) : '';
isset($_COOKIE) ? myin($_COOKIE) : '';
isset($_REQUEST) ? myin($_REQUEST) : '';
@extract($_GET, EXTR_SKIP);
@extract($_POST, EXTR_SKIP);
@extract($_COOKIE, EXTR_SKIP);
@extract($_REQUEST, EXTR_SKIP);
}
if($action=="add"){
print'
"); } if($action=="show") { include_once("../include/mysql.php"); //连接数据库 $db=new db; $db->obj["sql_user"]="root" ; $db->obj["sql_pass"]=""; $db->obj ["sql_host" ]="localhost"; $db->obj["sql_database"]="test"; $db-> connect(); $sql="select * from test"; $db->query($sql); while($info=$db->fetch_row()) { print "{$info['id']}
"; } } //$code=$artext; //myout($code); //$str=$code; //$str=myhtml($code); //$str=preg_replace_callback("/(\[php\])(.+?)(\[\\/php\])/is","unhtml",$str); print('test add test show'); ?>[/php] 从文本框提交如下文本
CODE: <table width="100%" border="0" cellspacing="1" cellpadding="2" style=" font-size:9pt">
<form enctype="multipart/form-data" method="post" action="t1.php?action=addnew" >
<tr>
<td width="10%" bgcolor="#999999" align="center">文章内容<br><FONT COLOR="#FF6600"><b>(必填)</b></FONT></td>
<td width="90%" bgcolor="#999999">
<textarea name="artext" cols="80" rows="20" style="border:1px solid #333333"></textarea>
</td>
</tr>
<tr >
<td colspan="2" bgcolor="#CCCCCC">
<div align="center">
<input type="submit" name="post" value="发表">
<input type="reset" name="resert" value="重写">
</div>
</td>
</tr>
</form>
</table> |
显示如下:

