From 26a90bd98c97f3c762fde3ed9063bac04e05de51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 15 Apr 2012 13:30:08 +0200 Subject: [PATCH] Adding IP-Address in info. --- .../chat/command/commands/Info.class.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/file/lib/system/chat/command/commands/Info.class.php b/file/lib/system/chat/command/commands/Info.class.php index 236da42..3bcfd48 100644 --- a/file/lib/system/chat/command/commands/Info.class.php +++ b/file/lib/system/chat/command/commands/Info.class.php @@ -1,5 +1,6 @@ getParameters(), ',')); + $user = User::getUserByUsername(rtrim($commandHandler->getParameters(), ',')); if (!$user->userID) throw new \wcf\system\chat\command\UserNotFoundException(rtrim($commandHandler->getParameters(), ',')); $room = new \wcf\data\chat\room\ChatRoom(ChatUtil::readUserData('roomID', $user)); $color = ChatUtil::readUserData('color', $user); @@ -33,10 +34,30 @@ public function __construct(\wcf\system\chat\command\CommandHandler $commandHand if ($room->roomID && $room->canEnter()) { $this->lines[WCF::getLanguage()->get('wcf.chat.room')] = $room->getTitle(); } + $session = $this->fetchSession($user); + if ($session) { + // TODO: Check permission + $this->lines['IP_ADDRESS'] = $session->ipAddress; + } $this->didInit(); } + public function fetchSession(User $user) { + $sql = "SELECT + * + FROM + wcf".WCF_N."_session + WHERE + userID = ?"; + $stmt = WCF::getDB()->prepareStatement($sql); + $stmt->execute(array($user->userID)); + $row = $stmt->fetchArray(); + if (!$row) return false; + + return new \wcf\data\session\Session(null, $row); + } + /** * @see \wcf\system\chat\command\ICommand::getType() */