浏览代码

'trim' was not working as expected and admins file was usable on for one admin without
whitespace. specific to 1.5.1cvs and 1.4.5cvs

tokul 20 年之前
父节点
当前提交
f76caa99e9
共有 1 个文件被更改,包括 12 次插入3 次删除
  1. 12 3
      plugins/administrator/auth.php

+ 12 - 3
plugins/administrator/auth.php

@@ -32,11 +32,11 @@ function adm_check_user() {
         $auth = FALSE;
     } else if (file_exists(SM_PATH . 'plugins/administrator/admins')) {
         $auths = file(SM_PATH . 'plugins/administrator/admins');
-        array_walk($auths, 'trim');
+        array_walk($auths, 'adm_array_trim');
         $auth = in_array($username, $auths);
     } else if (file_exists(SM_PATH . 'config/admins')) {
         $auths = file(SM_PATH . 'config/admins');
-        array_walk($auths, 'trim');
+        array_walk($auths, 'adm_array_trim');
         $auth = in_array($username, $auths);
     } else if (($adm_id = fileowner(SM_PATH . 'config/config.php')) &&
                function_exists('posix_getpwuid')) {
@@ -49,4 +49,13 @@ function adm_check_user() {
     return ($auth);
 }
 
-?>
+/**
+ * Removes whitespace from array values
+ * @param string $value array value that has to be trimmed
+ * @param string $key array key
+ * @since 1.5.1
+ */
+function adm_array_trim(&$value,$key) {
+    $value=trim($value);
+}
+?>