{$rw[1]} ({$rw[3]})"; } else { $data .= ""; } } return $data; } /** * 输出管理用户列表 * * @return String 用户列表 */ public function getUserListAdmin() { $db = Config::MySQL(); $conn = mysqli_connect($db['host'], $db['user'], $db['pass'], $db['name'], $db['port']); $rs = mysqli_query($conn, "SELECT * FROM `{$db['name']}`.`users`"); $data = ""; while($rw = mysqli_fetch_row($rs)) { $data .= "
{$rw[1]}

{$rw[3]} | 权限:{$rw[4]}

"; } mysqli_close($conn); return $data; } /** * 在数据库中创建新的用户 * * @param $username 用户名 * @param $password 用户密码 * @param $email 用户邮箱 * @param $permission 用户权限 * @return Boolean 创建状态 */ public function createUser($username, $password, $email, $permission) { $uuid = md5(md5(time() . rand(0, 999999))); $db = Config::MySQL(); $conn = mysqli_connect($db['host'], $db['user'], $db['pass'], $db['name'], $db['port']); mysqli_query($conn, "INSERT INTO `{$db['name']}`.`users` (`id`, `username`, `password`, `email`, `permission`) " . "VALUES (NULL, '{$username}', '{$password}', '{$email}', '{$permission}')"); return true; } /** * 更新数据库中的用户数据 * * @param $id 用户 ID * @param $username 用户名 * @param $password 用户密码 * @param $email 用户邮箱 * @param $permission 用户权限 * @return Boolean 更新状态 */ public function updateUser($id, $username, $password = false, $email, $permission) { $db = Config::MySQL(); $conn = mysqli_connect($db['host'], $db['user'], $db['pass'], $db['name'], $db['port']); if($password) { mysqli_query($conn, "UPDATE `{$db['name']}`.`users` SET `username`='{$username}', `password`='{$password}', " . "`email`='{$email}', `permission`='{$permission}' WHERE `id`='{$id}'"); } else { mysqli_query($conn, "UPDATE `{$db['name']}`.`users` SET `username`='{$username}', " . "`email`='{$email}', `permission`='{$permission}' WHERE `id`='{$id}'"); } return true; } /** * 删除数据库中的用户 * * @param $id 用户 ID * @return Boolean 删除状态 */ public function deleteUser($id) { $db = Config::MySQL(); $conn = mysqli_connect($db['host'], $db['user'], $db['pass'], $db['name'], $db['port']); mysqli_query($conn, "DELETE FROM `{$db['name']}`.`users` WHERE `id`='{$id}'"); return true; } }