dedecms投票模塊有朋友反映投票主題的選項經(jīng)常被sql注入刪除,經(jīng)過ios100知識庫查看代碼發(fā)現(xiàn)投票模塊代碼沒有對sql參數(shù)進行轉換,導致不法分子sql注入。只要將addslashes()改為mysql_real_escape_string()即可。
打開/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() 是強行加\;
* mysql_real_escape_string() 會判斷字符集,但是對php版本有要求;(php 4 >= 4.0.3, php 5)
* mysql_escape_string不考慮連接的當前字符集。(php 4 >= 4.0.3, php 5, 注意:在php5.3中已經(jīng)棄用這種方法,不推薦使用)