POST TIME:2020-04-05 22:44
DedeCMS投票模塊有朋友反映投票主題的選項(xiàng)經(jīng)常被sql注入刪除,經(jīng)過(guò)iOS100知識(shí)庫(kù)查看代碼發(fā)現(xiàn)投票模塊代碼沒(méi)有對(duì)sql參數(shù)進(jìn)行轉(zhuǎn)換,導(dǎo)致不法分子sql注入。只要講addslashes()改為mysql_real_escape_string()即可。
打 開(kāi)/include/dedevote.class.php文件,查 找$this->dsql->ExecuteNoneQuery("UPDATE `dede_vote` SET totalcount='".($this->VoteInfos['totalcount']+1)."',votenote='".addslashes($items)."' WHERE aid='".$this->VoteID."'");
修改為
$this->dsql->ExecuteNoneQuery("UPDATE `dede_vote` SET totalcount='".($this->VoteInfos['totalcount']+1)."',votenote='".mysql_real_escape_string($items)."' WHERE aid='".mysql_real_escape_string($this->VoteID)."'");
注:
* addslashes() 是強(qiáng)行加;
* mysql_real_escape_string()會(huì)判斷字符集,但是對(duì)PHP版本有要求;(PHP 4 >= 4.0.3, PHP 5)
* mysql_escape_string不考慮連接的當(dāng)前字符集。(PHP 4 >= 4.0.3, PHP 5, 注意:在PHP5.3中已經(jīng)棄用這種方法,不推薦使用)