You are here

Drupal初学者在编写代码时经常存在的问题:

g089h515r806 的头像
Submitted by g089h515r806 on 星期六, 2010-09-11 13:31

Drupal初学者,由于不熟悉Drupal规范。在编写代码时经常存在的问题:

(1),模块中函数的命名没有遵守Drupal规范。

(2)sql语句没有使用占位符,存在sql注入漏洞。

(3),有一半以上的地方没有正确的使用t函数。

(4)hook_menu中没有使用file键,一些函数,表单应该放在inc文件中。
 

论坛:

g089h515r806 的头像

对于复杂的动态语句,比如:

$sqli = " from {userinfo} where test != 'test' and UserExpire > '".date("Y-m-d")."'";
  
if($Susername){
   
$sqli .= " and UserName like '$Susername%' ";
  
}
  
if($Sseuser){
   
$sqli .= " and seuser like '$Sseuser%' ";
  
}
  
if($Sprivateip){
   
$sqli .= " and PrivateIP like '$Sprivateip%' ";
  
}
if($Suserstate){
  
$sqli .= " and UserState = '$Suserstate' ";
 
}
这类sql语句的处理,过于粗糙,没有使用正确的动态查询语句处理方式,正确的可参看http://zhupou.cn/node/1356