$usersToken = $_SESSION['admin_users_token']; } sendResponseCodeAndExitIfTrue(!isset($_GET['nick'], $_GET['token']), 400); sendResponseCodeAndExitIfTrue(!isset($usersToken) || md5($usersToken) !== $_GET['token'], 422); $mysqlConn = connectToDatabase(); //Get list of all groups in the system $availableGroups = getArrayFromSQLQuery($mysqlConn, 'SELECT groupId, name FROM groups ORDER BY name ASC'); //Get user data for requested name $matchingUsers = getArrayFromSQLQuery($mysqlConn, 'SELECT userId, nick, email FROM users WHERE nick = ? LIMIT 1', 's', [$_GET['nick']]); //Verify that there is one user matching attempted nick printAndExitIfTrue(count($matchingUsers) !== 1, 'Invalid user nick.'); $user = $matchingUsers[0]; //Get user groups $assignedGroups = getGroupsForUser($mysqlConn, $user['userId'], false); $allGroupsForUser = getGroupsForUser($mysqlConn, $user['userId'], true); //Generate token for admin action $_SESSION['admin_userview_token' . $user['userId']] = uniqid(mt_rand(), true); //Print all user attributes foreach ($user as $attributeName => $attributeValue) { echo $attributeName . ': ' . $attributeValue . '<br />'; } //Print user groups echo '<br />Groups (excluding inherited): ' . implode(', ', $assignedGroups); echo '<br />Groups (including inherited): ' . implode(', ', $allGroupsForUser); ?> <br /> <br /> <form action="userset.php" method="post"> <select name="grouptoadd" required>
case 50: //群组单个减人 $group_id = "122633509780062768"; $username = "******"; var_dump(deleteGroupMember($group_id, $username)); break; case 51: //群组批量减人------- $group_id = "122633509780062768"; //$usernames['usernames']=array("lisi","wangwu"); $usernames = 'lisi,wangwu'; var_dump(deleteGroupMembers($group_id, $usernames)); break; case 52: //获取一个用户参与的所有群组 var_dump(getGroupsForUser("zhangsan")); break; case 53: //群组转让 $group_id = "122633509780062768"; $options['newowner'] = "lisi"; var_dump(changeGroupOwner($group_id, $options)); break; case 54: //查询一个群组黑名单用户名列表 $group_id = "122633509780062768"; var_dump(getGroupBlackList($group_id)); break; case 55: //群组黑名单单个加人----- $group_id = "122633509780062768";
return $array; } session_start(); $now = time(); if (isset($_SESSION['last_active']) && $now > $_SESSION['last_active'] + 60 * 60) { //If the user has been inactive for 1 hour... //...their session expires session_unset(); session_destroy(); } if (isset($_SESSION['user_id'], $_SESSION['user_token'])) { $mysqlConn = connectToDatabase(); $matchingUsers = getArrayFromSQLQuery($mysqlConn, 'SELECT nick FROM users WHERE userId = ? AND token = ? LIMIT 1', 'ss', [$_SESSION['user_id'], $_SESSION['user_token']]); //Get user nickname if (count($matchingUsers) === 1) { //Get user nickname $_SESSION['user_nick'] = $matchingUsers[0]['nick']; //Get user groups $_SESSION['user_groups'] = getGroupsForUser($mysqlConn, $_SESSION['user_id']); //Get information about unread notifications $notificationManager = new notification_manager($mysqlConn); $unreadNotificationCount = $notificationManager->getUnreadNotificationCount(); $unreadNotificationSummaries = $notificationManager->getUnreadNotificationSummaries(2); } else { session_unset(); session_destroy(); } $mysqlConn->close(); } $_SESSION['last_active'] = $now; //Set last activity time to now