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

清空信息
关闭评论
karbasioun
 karbasioun 约 3 小时前回复
#96
<a href="http://www.tailflappers.com/mennns-nike-free-run-2-oransje-gr%C3%A5-kurpesa">mennns nike free run 2 oransje gr氓</a> <a href="http://www.tranhkhoathan.com/nike-free-flyknit-4.0-lilla-orange-kurpesf">nike free flyknit 4.0 lilla orange</a> <a href="http://www.beachtimenow.com/hombres-gris-ralph-lauren-hoodie-polou">hombres gris ralph lauren hoodie</a> <a href="http://www.blogdalata.com/dam%C3%A4nner-air-jordan-retro-5-alle-grau-scarpeb">dam盲nner air jordan retro 5 alle grau</a> <a href="http://www.boosnbrews.com/womens-nike-kansas-city-chiefs-15-patrick-mahomes-ii-white-vapor-untouchable-limited-player-nfl-jersey-nfls">womens nike kansas city chiefs 15 patrick mahomes ii white vapor untouchable limited player nfl jersey</a> <a href="http://www.eventyrklub.com/nike-air-max-thea-rose-rosa-gelb-scarpeg">nike air max thea rose rosa gelb</a>
karbasioun http://www.karbasioun.com/
hinogi
 hinogi 2019-02-15 02:49回复
#95
<a href="http://www.unefinemouche.com/north-face-jacket-blue-jd-northfaceh">north face jacket blue jd</a> <a href="http://www.ayuinc.com/dam%C3%A4nner-nike-sb-stefan-janoski-max-orangen-gold-schuhej">dam盲nner nike sb stefan janoski max orangen gold</a> <a href="http://www.unirlisboa.com/adidas-neo-canvas-r%C3%B8d-lilla-skoh">adidas neo canvas r酶d lilla</a> <a href="http://www.escortfeeds.com/adidas-tubular-runner-jaune-gris-chaussuresh">adidas tubular runner jaune gris</a> <a href="http://www.rdjanitorial.com/san-diego-padres-new-era-mlb-team-out-heather-59fifty-cap-hatl">san diego padres new era mlb team out heather 59fifty cap</a> <a href="http://www.bookoobeats.com/nike-kd-8-hommes-gris-chaussuresh">nike kd 8 hommes gris</a>
hinogi http://www.hinogi.com/
trulsbakken
 trulsbakken 2019-02-13 11:02回复
#94
<a href="http://www.atlantaaiport.com/gold-mens-nike-sb-dunk-high-runninga">gold mens nike sb dunk high</a> <a href="http://www.donareseguros.com/ray-ban-wayfarer-medium-size-sunglassesr">ray ban wayfarer medium size</a> <a href="http://www.royalokavango.com/reebok-gl-6000-white-shoesv">reebok gl 6000 white</a> <a href="http://www.shufiparis.com/nike-mercurial-vapor-9-cr7-skow">nike mercurial vapor 9 cr7</a> <a href="http://www.thegroceri.com/mackage-bag-sale-mackager">mackage bag sale</a> <a href="http://www.roctaam.com/asics-gel-noosa-tri-8-menns-bl%C3%A5-skod">asics gel noosa tri 8 menns bl氓</a>
trulsbakken http://www.trulsbakken.com/
eulatestnews
 eulatestnews 2019-02-13 09:50回复
#93
<a href="http://www.getawayoffer.com/dam%C3%A4nner-reebok-couple-zig-tech-lila-scarpef">dam盲nner reebok couple zig tech lila</a> <a href="http://www.lbsportsguys.com/nike-shox-turbo-21-bl%C3%A5-brun-obuvc">nike shox turbo 21 bl氓 brun</a> <a href="http://www.thesleeperson.com/kvinners-air-jordan-retro-12-gr%C3%A5-hvit-scarpea">kvinners air jordan retro 12 gr氓 hvit</a> <a href="http://www.ubcfellowship.com/nike-zoom-pegasus-32-kvinders-gr%C3%A5-gr%C3%B8n-chaussuresg">nike zoom pegasus 32 kvinders gr氓 gr酶n</a> <a href="http://www.vipartonline.com/nike-air-max-2017-herren-gr%C3%BCn-dot-kurpesf">nike air max 2017 herren gr眉n dot</a> <a href="http://www.zumbajill.com/nike-air-max-87-rouge-jaune-obuva">nike air max 87 rouge jaune</a>
eulatestnews http://www.eulatestnews.com/
rare new era hats
 rare new era hats 2019-02-12 02:11回复
#92
<a href="http://www.giantsfree.com/nike-lebron-12-low-himmelblau-kurpesa">nike lebron 12 low himmelblau</a> <a href="http://www.zalinki.com/air-jordan-13-retro-wolf-gray-sport-blue-sportsd">air jordan 13 retro wolf gray sport blue</a> <a href="http://www.embarquelibre.com/adidas-superstar-2-k-38-shoesc">adidas superstar 2 k 38</a> <a href="http://www.theamaazing.com/free-run-5.0-r%C3%B8d-and-hvit-schuhef">free run 5.0 r酶d and hvit</a> <a href="http://www.prospectgain.com/nike-blazer-vert-argent-kurpesd">nike blazer vert argent</a> <a href="http://www.tommorning.com/adidas-dame-4-pink-zapatosu">adidas dame 4 pink</a>
rare new era hats http://www.brewnost.com/rare-new-era-hats-hatr
dbajournal
 dbajournal 2019-02-11 20:57回复
#91
<a href="http://www.freizeittrend.com/nike-dunk-violet-jaune-schuheb">nike dunk violet jaune</a> <a href="http://www.instanalo.com/womens-nike-indianapolis-colts-78-ryan-kelly-game-black-fashion-nfl-jersey-nflu">womens nike indianapolis colts 78 ryan kelly game black fashion nfl jersey</a> <a href="http://www.olafhuth.com/nike-air-max-for-kids-uk-skou">nike air max for kids uk</a> <a href="http://www.pecanfirewood.com/yellow-pink-womens-nike-air-pegasus-92-shoes-runninge">yellow pink womens nike air pegasus 92 shoes</a> <a href="http://www.ezzolawaz.com/nike-air-max-90-og-vintage-infrared-sail-cool-grey-mens-95-zapatosu">nike air max 90 og vintage infrared sail cool grey mens 95</a> <a href="http://www.suchmeldungen.com/nike-roshe-run-blomstret-b%C3%B8rn-r%C3%B8d-chaussuresa">nike roshe run blomstret b酶rn r酶d</a>
[url=http://www.dbajournal.com/]dbajournal[/url]
hotelfuat
 hotelfuat 2019-02-11 12:06回复
#90
<a href="http://www.khalataxi.com/nike-air-max-2017-kpu-ii-svart-s%C3%B8lv-chaussuresa">nike air max 2017 kpu ii svart s酶lv</a> <a href="http://www.miaclearbras.com/nike-new-england-patriots-70-logan-mankins-elite-navy-blue-team-color-jersey-nflc">nike new england patriots 70 logan mankins elite navy blue team color jersey</a> <a href="http://www.divyangbazar.com/black-and-white-air-max-1-runningg">black and white air max 1</a> <a href="http://www.dixiepundit.com/zdeno-chara-33-boston-bruins-reebok-premier-alternate-jersey-small-nflv">zdeno chara 33 boston bruins reebok premier alternate jersey small</a> <a href="http://www.ifshaildamage.com/nike-lebron-witness-grey-orange-trainersa">nike lebron witness grey orange</a> <a href="http://www.nanterrelec.com/nike-free-5.0-svart-and-s%C3%B8lv-scarpec">nike free 5.0 svart and s酶lv</a>
hotelfuat http://www.hotelfuat.com/
gradualdesing
 gradualdesing 2019-02-11 05:36回复
#89
<a href="http://www.tipicousa.com/mackage-military-coat-mackager">mackage military coat</a> <a href="http://www.reprebates.com/moncler-coat-bloomingdale-discount-liquors-monclerd">moncler coat bloomingdale discount liquors</a> <a href="http://www.goeaglepointe.com/ray-ban-tech-aviator-sunglassesr">ray ban tech aviator</a> <a href="http://www.ykloans.com/mulberry-daria-clutch-purple-haze-mulberryg">mulberry daria clutch purple haze</a> <a href="http://www.servicioswom.com/adidas-porsche-typ-64-wei%C3%9F-blau-sneakerc">adidas porsche typ 64 wei脽 blau</a> <a href="http://www.drlunaworld.com/parajumpers-gobi-femme-beige-talon-parajumpersf">parajumpers gobi femme beige talon</a>
gradualdesing http://www.gradualdesing.com/
cacikvideo
 cacikvideo 2019-02-11 00:14回复
#88
<a href="http://www.mwartsdrama.com/adidas-porsche-design-iv-gr%C3%A5-skok">adidas porsche design iv gr氓</a> <a href="http://www.meshmotors.com/adidas-zx-flux-blu-cielo-blu-scarpeh">adidas zx flux blu cielo blu</a> <a href="http://www.aspenmedisys.com/maschio-nike-air-max-95-nero-arancia-scarpei">maschio nike air max 95 nero arancia</a> <a href="http://www.smartiesland.com/mitchell-and-ness-detroit-lions-jersey-nflh">mitchell and ness detroit lions jersey</a> <a href="http://www.emcetolerie.com/coach-camo-duffle-bag-coachh">coach camo duffle bag</a> <a href="http://www.lapaktoko.com/air-jordan-retro-10-femminile-grigio-maschiota-verde-scarpeh">air jordan retro 10 femminile grigio maschiota verde</a>
cacikvideo http://www.cacikvideo.com/
zotorrent
 zotorrent 2019-02-09 12:16回复
#87
<a href="http://www.keleric.com/mujeres-nike-air-max-bw-rojo-naranja-zapatosk">mujeres nike air max bw rojo naranja</a> <a href="http://www.jeffreya.com/kvinders-air-jordan-retro-11-r%C3%B8d-gr%C3%A5-skoq">kvinders air jordan retro 11 r酶d gr氓</a> <a href="http://www.vuduchoan.com/nike-flyknit-lunar-1-maschio-nero-scarpeh">nike flyknit lunar 1 maschio nero</a> <a href="http://www.gmfamilylaw.com/nike-air-max-zero-femminile-gituttio-verde-scarpei">nike air max zero femminile gituttio verde</a> <a href="http://www.clubephytus.com/dam%C3%A4nner-asics-gel-noosa-tri-8-gold-gelb-schuheh">dam盲nner asics gel noosa tri 8 gold gelb</a> <a href="http://www.findnewcoupon.com/nike-lunarglide-8-blue-pink-shoesq">nike lunarglide 8 blue pink</a>
zotorrent http://www.zotorrent.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸