好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

php防sql注入攻击(含php6)

网站攻击最常见的就是sql注入式攻击了,防范于未然很重要~

PHP可以开启环境变量配置为POST、GET、REQUEST、COOKIE等用户传过来的参数值自动增加转义字符“\”,以确保这些数据的安全性。

在php.ini配置环境变量magic_quotes_gpc的值为On时开启自动添加转义字符,配置为Off时关闭。

get_magic_quotes_gpc()函数就是获取magic_quotes_gpc的值的函数,On时为1,Off时为0。

开启后,在使用数据之前恢复正常的数据可采用以下函数qingzzDoStripSlashes()。

/**
 * 去除多余的转义字符
 */
function qingzzDoStripslashes() {
    if (PHP_VERSION() < 6 && get_magic_quotes_gpc()) {
	$_GET = qingzzStripslashesDeep($_GET);
	$_POST = qingzzStripslashesDeep($_POST);
	$_COOKIE = qingzzStripslashesDeep($_COOKIE);
	$_REQUEST = qingzzStripslashesDeep($_REQUEST);
    }
}

/**
 * 递归去除转义字符
 */
function qingzzStripslashesDeep($value) {
    $value = is_array($value) ? array_map('stripslashesDeep', $value) : stripslashes($value);
    return $value;
}

PHP6去除了magic quotes机制,因此只能自行添加了。

/**
 * 添加转义字符
 */
function qingzzAddslashes() {
    if (PHP_VERSION >= 6 || !get_magic_quotes_gpc()) {
	$_GET = qingzzAddslashesDeep($_GET);
	$_POST = qingzzAddslashesDeep($_POST);
	$_COOKIE = qingzzAddslashesDeep($_COOKIE);
	$_REQUEST = qingzzAddslashesDeep($_REQUEST);
    }
}

/**
 * 递归增加转义字符
 */
function qingzzAddslashesDeep($value) {
    $value = is_array($value) ? array_map('qingzzAddslashesDeep', $value) : addslashes($value);
    return $value;
}

至于判断是否转义,自己增加一个全局变量就好了~

点赞1
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
bestzixiutang
 bestzixiutang 2019-05-21 19:58回复
#242
<a href="http://www.postthatass.com/louisville-cardinals-top-of-the-world-ncaa-youth-wickler-mesh-cap-hatj">louisville cardinals top of the world ncaa youth wickler mesh cap</a> <a href="http://www.houseoftys.com/converse-tutti-nero-low-cut-scarpej">converse tutti nero low cut</a> <a href="http://www.amvdiplomados.com/nike-air-max-90-ice-sneakerboot-infrarot-schuhei">nike air max 90 ice sneakerboot infrarot</a> <a href="http://www.ybsimports.com/nike-air-max-270-hvid-orange-blanc-orange-skoh">nike air max 270 hvid orange blanc orange</a> <a href="http://www.rochlockyer.com/kyrie-irving-jersey-amazon-nfli">kyrie irving jersey amazon</a> <a href="http://www.allsocialdata.com/adidas-harden-himmelen-bl%C3%A5-svart-obuvk">adidas harden himmelen bl氓 svart</a>
bestzixiutang http://www.bestzixiutang.com/
kaliteankara
 kaliteankara 2019-05-20 19:28回复
#241
<a href="http://www.goodmedusa.com/nike-lebron-13-negro-p%C3%BArpura-oro-zapatosi">nike lebron 13 negro p煤rpura oro</a> <a href="http://www.murskacorp.com/nike-roshe-sort-and-hvid-pris-skoh">nike roshe sort and hvid pris</a> <a href="http://www.prajansim.com/adidas-superstar-scarpe-da-ginnastica-rosa-scarpei">adidas superstar scarpe da ginnastica rosa</a> <a href="http://www.pokersurga.com/air-jordan-retro-13-low-bianca-nero-grigio-scarpej">air jordan retro 13 low bianca nero grigio</a> <a href="http://www.arkmmj.com/brandon-coleman-16-new-orleans-saints-jersey-nflh">brandon coleman 16 new orleans saints jersey</a> <a href="http://www.butterbroad.com/coach-bag-dinky-toy-coachh">coach bag dinky toy</a>
kaliteankara http://www.kaliteankara.com/
davidmgaines
 davidmgaines 2019-05-20 14:43回复
#240
<a href="http://www.cardiachits.com/nike-cortez-mineral-blue-shoesj">nike cortez mineral blue</a> <a href="http://www.zestchannel.com/michael-kors-blue-and-tan-bag-mkh">michael kors blue and tan bag</a> <a href="http://www.eczacinim.com/nike-air-max-khaki-gr%C3%B8nn-obuvi">nike air max khaki gr酶nn</a> <a href="http://www.chilangorails.com/nike-air-max-tailwind-6-femminile-rosso-nero-scarpej">nike air max tailwind 6 femminile rosso nero</a> <a href="http://www.mariusen.com/mens-asics-gel-quantum-360-blue-gold-shoesh">mens asics gel quantum 360 blue gold</a> <a href="http://www.brittonoilco.com/hombres-nike-roshe-yeezy-boost-todas-negro-zapatosp">hombres nike roshe yeezy boost todas negro</a>
davidmgaines http://www.davidmgaines.com/
androidsmith
 androidsmith 2019-05-19 19:03回复
#239
<a href="http://www.mistopup.com/adidas-ultra-boost-white-red-blue-shoesj">adidas ultra boost white red blue</a> <a href="http://www.sporbahispro.com/charlotte-hornets-new-era-nba-jack-knife-9fifty-snapback-cap-hath">charlotte hornets new era nba jack knife 9fifty snapback cap</a> <a href="http://www.kalrakis.com/air-jordan-retro-6-rojo-negro-blanco-zapatosl">air jordan retro 6 rojo negro blanco</a> <a href="http://www.xinyudaili.com/adidas-black-sport-shoes-for-kids-shoesk">adidas black sport shoes for kids</a> <a href="http://www.marieluwasche.com/adidas-pure-boost-raw-olive-gr%C3%B8nn-obuvi">adidas pure boost raw olive gr酶nn</a> <a href="http://www.ferrepress.com/hvit-adidas-indoor-soccer-sko-obuvk">hvit adidas indoor soccer sko</a>
androidsmith http://www.androidsmith.com/
graciecomm
 graciecomm 2019-05-19 15:56回复
#238
<a href="http://www.ptsbarwinslow.com/nike-air-max-2018-hombres-md-rojo-negro-blanco-zapatosi">nike air max 2018 hombres md rojo negro blanco</a> <a href="http://www.sarhallafk.com/kvinders-lyser%C3%B8d-l%C3%A6der-converse-skoh">kvinders lyser酶d l忙der converse</a> <a href="http://www.philippikus.com/air-jordan-12-nero-and-bianca-scarpei">air jordan 12 nero and bianca</a> <a href="http://www.pngoilgas.com/nike-huarache-blu-verde-scarpej">nike huarache blu verde</a> <a href="http://www.goficarwash.com/limited-customized-mens-jersey-tampa-bay-buccaneers-team-alternate-two-tone-nfl-nflh">limited customized mens jersey tampa bay buccaneers team alternate two tone nfl</a> <a href="http://www.getairtijuana.com/coach-caroline-sunglasses-coachh">coach caroline sunglasses</a>
graciecomm http://www.graciecomm.com/
jupickuplines
 jupickuplines 2019-05-18 16:49回复
#237
<a href="http://www.theskifanatic.com/adidas-springblade-ignite-oro-viola-scarpek">adidas springblade ignite oro viola</a> <a href="http://www.bestoftumblr.com/femmes-asics-gel-lyte-5-violet-jaune-chaussuresh">femmes asics gel lyte 5 violet jaune</a> <a href="http://www.thehogrider.com/prada-diaper-bag-ebay-pradah">prada diaper bag ebay</a> <a href="http://www.artpreneure.com/james-harden-white-jersey-nfli">james harden white jersey</a> <a href="http://www.thefarmergirl.com/adidas-neo-canvas-himmelbl%C3%A5-gr%C3%A5-skol">adidas neo canvas himmelbl氓 gr氓</a> <a href="http://www.shetablink.com/grey-ralph-lauren-swim-shorts-poloh">grey ralph lauren swim shorts</a>
jupickuplines http://www.jupickuplines.com/
hoyerequip
 hoyerequip 2019-05-18 04:40回复
#236
<a href="http://www.hutchinsmedia.com/nike-internationalist-svart-metallic-s%C3%B8lv-obuvi">nike internationalist svart metallic s酶lv</a> <a href="http://www.datesfordate.com/adidas-samba-gris-and-azul-zapatosl">adidas samba gris and azul</a> <a href="http://www.spchemtech.com/ray-ban-justin-vs-ray-ban-wayfarer-sunglassesh">ray ban justin vs ray ban wayfarer</a> <a href="http://www.eadamattia.com/indianapolis-colts-sideline-hat-hatj">indianapolis colts sideline hat</a> <a href="http://www.citypixxel.com/adidas-prossoator-accelerator-comprar-scarpej">adidas prossoator accelerator comprar</a> <a href="http://www.megasatinc.com/air-jordan-11-schwarz-schuhei">air jordan 11 schwarz</a>
hoyerequip http://www.hoyerequip.com/
hoyerequip
 hoyerequip 2019-05-18 04:29回复
#235
<a href="http://www.soextfence.com/nike-tiempo-legend-v-fg-negro-zapatosl">nike tiempo legend v fg negro</a> <a href="http://www.amemedgroup.com/ray-ban-aviator-large-metal-ii-sunglassesh">ray ban aviator large metal ii</a> <a href="http://www.shawkreizer.com/st-louis-cardinals-mesh-hat-hatj">st louis cardinals mesh hat</a> <a href="http://www.powerwomanbc.com/adidas-ultra-boost-uncaged-nero-boost-scarpej">adidas ultra boost uncaged nero boost</a> <a href="http://www.kilaswacana.com/nike-huarache-schwarz-wei%C3%9F-lila-schuhei">nike huarache schwarz wei脽 lila</a> <a href="http://www.hobartcomfest.com/adidas-nmd-runner-triple-hvid-out-skoh">adidas nmd runner triple hvid out</a>
hoyerequip http://www.hoyerequip.com/
almarsecurity
 almarsecurity 2019-05-18 02:15回复
#234
<a href="http://www.flushnhunt.com/air-jordan-retro-3-oranger-hommesthe-verte-chaussuresl">air jordan retro 3 oranger hommesthe verte</a> <a href="http://www.evelpa.com/hommes-asics-gel-kinsei-4-jaune-gris-chaussuresq">hommes asics gel kinsei 4 jaune gris</a> <a href="http://www.taaliminfos.com/adidas-damian-lillard-rosa-schwarz-schuhei">adidas damian lillard rosa schwarz</a> <a href="http://www.cacikvideo.com/nike-zoom-hyperrev-blau-gelb-schuheh">nike zoom hyperrev blau gelb</a> <a href="http://www.grossavind.com/nike-shox-turbo-21-hvit-r%C3%B8d-obuvj">nike shox turbo 21 hvit r酶d</a> <a href="http://www.boltsfans.com/femminile-air-jordan-retro-2-oro-rosa-scarpep">femminile air jordan retro 2 oro rosa</a>
[url=http://www.almarsecurity.com/]almarsecurity[/url]
bewustvitaal
 bewustvitaal 2019-05-18 01:50回复
#233
<a href="http://www.flushnhunt.com/air-jordan-retro-3-oranger-hommesthe-verte-chaussuresl">air jordan retro 3 oranger hommesthe verte</a> <a href="http://www.evelpa.com/hommes-asics-gel-kinsei-4-jaune-gris-chaussuresq">hommes asics gel kinsei 4 jaune gris</a> <a href="http://www.taaliminfos.com/adidas-damian-lillard-rosa-schwarz-schuhei">adidas damian lillard rosa schwarz</a> <a href="http://www.cacikvideo.com/nike-zoom-hyperrev-blau-gelb-schuheh">nike zoom hyperrev blau gelb</a> <a href="http://www.grossavind.com/nike-shox-turbo-21-hvit-r%C3%B8d-obuvj">nike shox turbo 21 hvit r酶d</a> <a href="http://www.boltsfans.com/femminile-air-jordan-retro-2-oro-rosa-scarpep">femminile air jordan retro 2 oro rosa</a>
bewustvitaal http://www.bewustvitaal.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸