版本:taoCMS2.5Beta5
在中include/common.php中:
30 if(!function_exists('get_magic_quotes_gpc') || get_magic_quotes_gpc())
31 {搜狗电脑知识网
32 $_GET = Base::magic2word( $_GET );
33 $_POST = Base::magic2word( $_POST );
34 $_COOKIE = Base::magic2word( $_COOKIE );
35 }
magic2word在include/Model/Base.php中定义:
230 static function magic2word($text){
231 if (is_array($text)) {
232 foreach($text as $k=>$v){
233 $text[$k]=self::magic2word($v);
234 }
235 }else{
236 $text=stripslashes($text);
237 }
238 return $text;
239 }
总体就是一开始就去除魔术引号
然后在:
123 static function safeword($text,$level=8){
124 if(is_array($text))
125 {
126 foreach( $text as $key=>$value){
127 $safeword[$key]=self::safeword($value);
128 }
129 }
130 else
131 {
132 switch ($level)
133 {
134 case 0:
135 if (get_magic_quotes_gpc()) {// 检查magic_quotes_gpc是否打开,如果没有打开,用addslashes进行转义
136 $safeword = stripcslashes($text);
137 }else{
138 $safeword=$text;
139 }
140 break;
141 case 1:
142 $safeword=intval($text);
143 break;
144 case 3:
145 $safeword=strip_tags($text);
146 break;
147 case 5:
148 $safeword=nl2br(htmlspecialchars($text));
149 break;
150 case 6:
151 $safeword=str_replace("'","",addslashes($text));
152 $safeword=str_replace("select","",$safeword);
153 $safeword=str_replace("union","",$safeword);
154 $safeword=str_replace("=","",$safeword);
155 break;
156 default:
157 if(ucfirst(DB)=='Sqlite'){
158 $safeword=str_replace("'","''",$text);
159 }
160 else{