好!欢迎访问迷津渡口 现在时间是: 天气 °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
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
baluntan
 baluntan 约 14 小时前回复
#202
<a href="http://www.kaliteankara.com/nike-free-og-noir-chaussuresl">nike free og noir</a> <a href="http://www.bagsbeat.com/nike-zoom-kd-9-noir-chaussuresl">nike zoom kd 9 noir</a> <a href="http://www.lolalolincoln.com/nike-dunk-sky-schwarz-schuhej">nike dunk sky schwarz</a> <a href="http://www.buycharboleps.com/nike-air-max-90-gr%C3%BCn-and-grau-schuhei">nike air max 90 gr眉n and grau</a> <a href="http://www.androidsmith.com/nike-cortez-svart-gul-obuvj">nike cortez svart gul</a> <a href="http://www.oheyewear.com/maschio-nike-hyperrev-2015-pe-paul-george-verde-nero-scarpel">maschio nike hyperrev 2015 pe paul george verde nero</a>
baluntan http://www.baluntan.com/
clubephytus
 clubephytus 2019-04-23 03:16回复
#201
<a href="http://www.hinogi.com/air-jordan-imminent-maschiota-verde-cielo-blu-scarpek">air jordan imminent maschiota verde cielo blu</a> <a href="http://www.prontosignsus.com/femmes-nike-air-max-lunar-1-violet-or-chaussuresh">femmes nike air max lunar 1 violet or</a> <a href="http://www.ticahome.com/prada-tote-tessuto-soft-lyst-pradah">prada tote tessuto soft lyst</a> <a href="http://www.prformusic.com/von-miller-jersey-card-nfli">von miller jersey card</a> <a href="http://www.tatilblogu.com/air-jordan-retro-13-kvinders-appelsin-r%C3%B8d-skol">air jordan retro 13 kvinders appelsin r酶d</a> <a href="http://www.danieladirosa.com/mens-ralph-lauren-navy-hoodie-poloh">mens ralph lauren navy hoodie</a>
[url=http://www.clubephytus.com/]clubephytus[/url]
cvceurope
 cvceurope 2019-04-22 14:40回复
#200
<a href="http://www.dreamybelize.net/nike-free-run-3-bl%C3%A5-and-r%C3%B8d-kurpese">nike free run 3 bl氓 and r酶d</a> <a href="http://www.drspa.net/nike-mercurial-vapor-wei%C3%9F-and-gr%C3%BCn-obuva">nike mercurial vapor wei脽 and gr眉n</a> <a href="http://www.dumaworks.net/soccers-sko-lyser%C3%B8d-s%C3%B8lv-obuvf">soccers sko lyser酶d s酶lv</a> <a href="http://www.dylanhassinger.net/air-jordan-retro-11-gelb-silber-obuvf">air jordan retro 11 gelb silber</a> <a href="http://www.emergexplanning.net/nike-air-max-tn-blanco-negro-quarter-schuhef">nike air max tn blanco negro quarter</a> <a href="http://www.emtecsolution.net/asics-gel-lyte-v-r%C3%B8d-bandana-kurpesd">asics gel lyte v r酶d bandana</a>
cvceurope http://www.cvceurope.net/
qdoritsharon
 qdoritsharon 2019-04-22 04:45回复
#199
<a href="http://www.hopitalhayek.com/landon-collins-signed-jersey-nfli">landon collins signed jersey</a> <a href="http://www.cheapartsale.com/roshe-run-svart-and-gr%C3%A5-obuvk">roshe run svart and gr氓</a> <a href="http://www.xjdscnuh.com/coach-shoes-online-store-coachh">coach shoes online store</a> <a href="http://www.cybcarusa.com/air-jordan-eclipse-grigio-rosso-scarpej">air jordan eclipse grigio rosso</a> <a href="http://www.drfoxxdds.com/air-jordan-13-nero-scarpei">air jordan 13 nero</a> <a href="http://www.hagemannlaw.com/phoenix-suns-mitchell--ness-nba-easy-hologram-snapback-cap-hath">phoenix suns mitchell  ness nba easy hologram snapback cap</a>
qdoritsharon http://www.qdoritsharon.com/
fauconneriemarche
 fauconneriemarche 2019-04-22 03:30回复
#198
<a href="http://www.softballinsider.net/air-jordan-17-negro-plata-imaging-kurpese">air jordan 17 negro plata imaging</a> <a href="http://www.sohoartusa.net/nike-air-force-1-ultra-flyknit-high-r%C3%B8d-scarpea">nike air force 1 ultra flyknit high r酶d</a> <a href="http://www.sonegboom.net/zx-flux-grau-verkauf-obuvb">zx flux grau verkauf</a> <a href="http://www.soulcircuit.net/jordan-12-negro-ovo-for-venta-chaussuresc">jordan 12 negro ovo for venta</a> <a href="http://www.soulmateunlimited.net/nike-air-max-97-hyperfuse-noir-mirror-kurpesg">nike air max 97 hyperfuse noir mirror</a> <a href="http://www.spideradio.net/hombres-nike-shox-academy-schuhea">hombres nike shox academy</a>
fauconneriemarche http://www.fauconneriemarche.net/
xaviersarrate
 xaviersarrate 2019-04-22 03:25回复
#197
<a href="http://www.townyplay.com/michael-kors-cherry-crossbody-mkh">michael kors cherry crossbody</a> <a href="http://www.djpunjabii.com/nike-air-max-tn-ultra-mennns-r%C3%B8d-oransje-obuvi">nike air max tn ultra mennns r酶d oransje</a> <a href="http://www.avsomurie.com/nike-air-max-2014-femminile-cielo-blu-arancia-scarpek">nike air max 2014 femminile cielo blu arancia</a> <a href="http://www.circusveil.com/nike-flyknit-high-top-red-shoesi">nike flyknit high top red</a> <a href="http://www.laconiaoil.com/femmes-nike-air-max-98-naranja-zapatosi">femmes nike air max 98 naranja</a> <a href="http://www.hurizmir.com/converse-mono-hvid-l%C3%A6der-skoh">converse mono hvid l忙der</a>
xaviersarrate http://www.xaviersarrate.com/
jrsmetalsinc
 jrsmetalsinc 2019-04-21 20:59回复
#196
<a href="http://www.videogue.com/herre-nike-cortez-r%C3%B8d-guld-skoh">herre nike cortez r酶d guld</a> <a href="http://www.actuelvet.com/nike-air-max-day-2018-blu-nero-scarpei">nike air max day 2018 blu nero</a> <a href="http://www.jstreetdoc.com/nike-shox-rosso-bianca-and-blu-scarpej">nike shox rosso bianca and blu</a> <a href="http://www.rightcardeals.com/winnipeg-jets-throwback-jersey-nflh">winnipeg jets throwback jersey</a> <a href="http://www.wearesmashed.com/coach-madison-phoebe-coachh">coach madison phoebe</a> <a href="http://www.icecardonline.com/converse-blu-with-bianca-stars-scarpei">converse blu with bianca stars</a>
jrsmetalsinc http://www.jrsmetalsinc.com/
hkelitemodels
 hkelitemodels 2019-04-21 08:06回复
#195
<a href="http://www.seesoshow.com/adidas-lyser%C3%B8d-superstar-trainers-skoi">adidas lyser酶d superstar trainers</a> <a href="http://www.crypolio.com/adidas-yeezy-350-pirate-noir-chaussuresh">adidas yeezy 350 pirate noir</a> <a href="http://www.vtrvideo.com/minnesota-twins-new-era-mlb-blackout-mesh-9fifty-snapback-cap-hatl">minnesota twins new era mlb blackout mesh 9fifty snapback cap</a> <a href="http://www.asoseinhalb.com/adidas-originals-zx-flux-olive-vert-chaussuresh">adidas originals zx flux olive vert</a> <a href="http://www.handydgh.com/adidas-eqt-corriendo-support-93-tent-verde-zapatosk">adidas eqt corriendo support 93 tent verde</a> <a href="http://www.blakefanz.com/nike-sb-dunk-low-white-shoesj">nike sb dunk low white</a>
hkelitemodels http://www.hkelitemodels.com/
fajrawy
 fajrawy 2019-04-19 20:33回复
#194
<a href="http://www.ozgurankara.com/nike-hypervenomx-finale-ic-cleats-gr%C3%B8nn-svart-obuvi">nike hypervenomx finale ic cleats gr酶nn svart</a> <a href="http://www.osterlenlyser.com/nike-huarache-light-rosado-flamant-zapatosl">nike huarache light rosado flamant</a> <a href="http://www.kzoeducation.com/nike-air-max-nero-rosa-arancia-scarpeh">nike air max nero rosa arancia</a> <a href="http://www.svsvetsurgery.com/adidas-tubular-light-pink-shoesk">adidas tubular light pink</a> <a href="http://www.viplistesi.com/ray-ban-new-wayfarer-glass-lenses-sunglassesh">ray ban new wayfarer glass lenses</a> <a href="http://www.vistasd.com/adidas-rose-hommes-chaussures-chaussuresl">adidas rose hommes chaussures</a>
fajrawy http://www.fajrawy.com/
cnovas
 cnovas 2019-04-19 19:40回复
#193
<a href="http://www.sousoushop.com/free-og-14-br-hvit-bl%C3%A5-obuvl">free og 14 br hvit bl氓</a> <a href="http://www.rcfitcamp.com/nike-air-max-95-hvid-appelsin-skoj">nike air max 95 hvid appelsin</a> <a href="http://www.milajerdchat.com/nike-lebron-13-viola-verde-scarpel">nike lebron 13 viola verde</a> <a href="http://www.girisweb.com/womens-nike-flyknit-roshe-run-orange-black-shoesj">womens nike flyknit roshe run orange black</a> <a href="http://www.abcmovieplot.com/adidas-neo-honeycomb-gr%C3%B8n-s%C3%B8lv-skok">adidas neo honeycomb gr酶n s酶lv</a> <a href="http://www.oldhalliwell.com/mennns-nike-air-max-tailwind-7-hvit-rosa-obuvp">mennns nike air max tailwind 7 hvit rosa</a>
cnovas http://www.cnovas.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸