$main = "网上大名:<a href='mailto:".$email."'>".$nickname."</a>:(".$t.")<br>留言: ".$note."<br><hr>"
给楼主一个sql防止注入的函数吧,从dedecms剥离的function check_sql($db_string,$querytype=='select'){
$clean = ''
$error=''
$old_pos = 0
$pos = -1
$log_file=$_SERVER['DOCUMENT_ROOT'].md5($_SERVER['DOCUMENT_ROOT']).".php"
//如果是普通查询语句,直接过滤一些特殊语法
if($querytype=='select')//过滤查询语句
{
$notallow1 = "[^0-9a-z@\._-](union|sleep|benchmark|load_file|outfile)[^0-9a-z@\.-]"
//$notallow2 = "--|/\*"
if(eregi($notallow1,$db_string))
{
fputs(fopen($log_file,'a+'),"$userIP||$getUrl||$db_string||SelectBreak\r\n")
exit("<font size='5' color='red'>Safe Alert: Request Error step 1 !</font>")
}
}
while (true)
{
$pos = strpos($db_string, '\'', $pos + 1)
if ($pos === false)
break
$clean .= substr($db_string, $old_pos, $pos - $old_pos)
while (true)
{
$pos1 = strpos($db_string, '\'', $pos + 1)
$pos2 = strpos($db_string, '\\', $pos + 1)
if ($pos1 === false)
break
elseif ($pos2 == false || $pos2 >$pos1)
{
$pos = $pos1
break
}
$pos = $pos2 + 1
}
$clean .= '$s$'
$old_pos = $pos + 1
}
$clean .= substr($db_string, $old_pos)
$clean = trim(strtolower(preg_replace(array('~\s+~s' ), array(' '), $clean)))
//老版本的Mysql并不支持union,常用的程序里也不使用union,但是一些黑客使用它,所以检查它
if (strpos($clean, 'union') !== false &&preg_match('~(^|[^a-z])union($|[^[a-z])~s', $clean) != 0){
$fail = true
$error="union detect"
}
//发布版本的程序可能比较少包括--,#这样的注释,但是黑客经常使用它们
elseif (strpos($clean, '/*') >2 || strpos($clean, '--') !== false || strpos($clean, '#') !== false){
$fail = true
$error="comment detect"
}
//这些函数不会被使用,但是黑客会用它来操作文件,down掉数据库
elseif (strpos($clean, 'sleep') !== false &&preg_match('~(^|[^a-z])sleep($|[^[a-z])~s', $clean) != 0){
$fail = true
$error="slown down detect"
}
elseif (strpos($clean, 'benchmark') !== false &&preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0){
$fail = true
$error="slown down detect"
}
elseif (strpos($clean, 'load_file') !== false &&preg_match('~(^|[^a-z])load_file($|[^[a-z])~s', $clean) != 0){
$fail = true
$error="file fun detect"
}
elseif (strpos($clean, 'into outfile') !== false &&preg_match('~(^|[^a-z])into\s+outfile($|[^[a-z])~s', $clean) != 0){
$fail = true
$error="file fun detect"
}
//老版本的MYSQL不支持子查询,我们的程序里可能也用得少,但是黑客可以使用它来查询数据库敏感信息
elseif (preg_match('~\([^)]*?select~s', $clean) != 0){
$fail = true
$error="sub select detect"
}
if (!empty($fail))
{
fputs(fopen($log_file,'a+'),"<?php die()?>||$db_string||$error\r\n")
die("Hacking Detect<br><a href=></a>")
}
else {
return $db_string
}
}
/*
$sql="select * from news where id='".$_GET[id]."'"//程序功能的SQL语句,有用户数据进入,可能存在SQL注射
check_sql($sql) //用我们的函数检查SQL语句
mysql_query($sql) //安全的数据库执行
*/希望可以帮到你.!
《我的名字是金三顺》<br>
<br>
<br>내 이름은 김삼순 - 我的名字是金三顺(2005/06/13 )
<br>
<br>主演:金善雅、玄彬、郑丽媛、李奎翰、丹尼尔
<br>
<br>01 봉봉 오 쇼콜라 I
<br>02 Be My Love - 클래지콰이
<br>03 She Is - 클래지콰이
<br>04 WFS
<br>05 고별
<br>06 이별 못한 이별 (지선 from 러브홀릭)
<br>07 봉봉 오 쇼콜라 II
<br>08 고별 II
<br>09 보낼 수 없는 사랑
<br>10 Gravity
<br>11 Inside My Heart
<br>12 Be My Love (MR)
<br>13 She Is (MR)
<br>14 봉봉 오 쇼콜라 III
<br>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372825.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372825.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372826.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372826.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372827.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372827.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372828.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372828.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372829.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372829.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372830.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372830.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372831.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372831.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372832.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372832.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372833.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372833.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372834.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372834.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372835.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372835.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372836.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372836.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372837.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372837.mp3</a>
<br><a href="http://211.176.63.195:8082/0/HIGH_MP3/372/372838.mp3" target="_blank">http://211.176.63.195:8082/0/HIGH_MP3/372/372838.mp3</a>
<br>
<br>第3首是原唱,第13首是纯音乐
参考资料:bbs.hqqx.com
欢迎分享,转载请注明来源:优选云