搜索
查看: 2432|回复: 2

admin插件里面equal的疑问

[复制链接]
发表于 2009-10-5 16:41:04 | 显示全部楼层 |阅读模式 来自 河南洛阳
这个是admin插件中的一部分
  1. getAccess(id, name[], authid[], ip[], password[]){
  2.   new index = -1
  3.   new result = 0
  4.   for(new i = 0; i < g_aNum; ++i) {
  5.     if (g_aFlags[i] & FLAG_AUTHID) {
  6.       if (equal(authid, g_aName[i])) {
  7.         index = i
  8.         break
  9.       }
  10.     }
  11.     else if (g_aFlags[i] & FLAG_IP) {
  12.       new c = strlen( g_aName[i] )
  13.       if ( g_aName[i][ c - 1 ] == '.' ) { /* check if this is not a xxx.xxx. format */
  14.         if (  equal( g_aName[i] , ip , c ) ) {
  15.           index = i
  16.           break
  17.         }
  18.       } /* in other case an IP must just match */
  19.       else  if ( equal(ip, g_aName[i]) ){
  20.         index = i
  21.         break
  22.       }
  23.     }
  24.     else {
  25.       if (g_aFlags[i] & FLAG_TAG) {
  26.         if (contain(name, g_aName[i])!=-1){
  27.           index = i
  28.           break
  29.         }
  30.       }
  31.       else if (equal(name, g_aName[i])) {
  32.         index = i
  33.         break
  34.       }
  35.     }
  36.   }
  37.   if (index != -1) {
  38.     if (g_aFlags[index] & FLAG_NOPASS){
  39.       result |= 8
  40.       new sflags[32]
  41.       get_flags(g_aAccess[index], sflags, 31)
  42.       set_user_flags(id, g_aAccess[index])
  43.       log_to_file(g_logFile, "Login: ^"%s<%d><%s><>^" become an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")",
  44.         name, get_user_userid(id), authid, g_aName[index] , sflags, ip)
  45.     }
  46.     else if (equal(password, g_aPassword[index])) {
  47.       result |= 12
  48.       set_user_flags(id, g_aAccess[index])
  49.       new sflags[32]
  50.       get_flags(g_aAccess[index], sflags, 31)
  51.       log_to_file(g_logFile, "Login: ^"%s<%d><%s><>^" become an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")",
  52.         name, get_user_userid(id), authid, g_aName[index] , sflags, ip)
  53.     }
  54.     else {
  55.       result |= 1
  56.       if (g_aFlags[index] & FLAG_KICK){
  57.         result |= 2
  58.         log_to_file(g_logFile, "Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")",
  59.           name, get_user_userid(id), authid, g_aName[index], ip)
  60.       }
  61.     }
  62.   }
  63.   else if (get_cvar_float("amx_mode")==2.0) {
  64.     result |= 2
  65.   }
  66.   else {
  67.     new defaccess[32]
  68.     get_cvar_string("amx_default_access", defaccess, 31)
  69.     new idefaccess = read_flags(defaccess)
  70.     if (idefaccess){
  71.       result |= 8
  72.       set_user_flags(id, idefaccess)
  73.     }
  74.   }  
  75.   
  76.   return result
  77. }
复制代码
  1. else if (equal(name, g_aName[i])) {
复制代码
对比用户名的,但是大小写不一致还能进入
例如:
zhangsan在user文件中有权限
但是
ZHANGsan这样大小写不同的id仍然能进入,只是没有权限,但是zhangsan再进入就变成(1)zhangsan ,同样没有权限了!
这个怎么解决呢?

equal这个怎么能不区别大小写呢?
发表于 2009-10-5 18:15:13 | 显示全部楼层 来自 福建漳州
想改成不区分大小写,把 equal 改成 equali 就可以了。
回复

使用道具 举报

 楼主| 发表于 2009-10-5 19:39:11 | 显示全部楼层 来自 河南洛阳
谢谢r版主,去看了下官方才发现原来这个中文说明上面不对!

equali
Core (string.inc)
细节
equali - 比较两个字符串是否匹配. 大小写敏感.
应该是大小写不敏感吧
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表