| 1 | <?php |
| 2 | |
| 3 | namespace wcf\data\acp\session; |
| 4 | |
| 5 | use wcf\data\DatabaseObject; |
| 6 | use wcf\system\WCF; |
| 7 | |
| 8 | /** |
| 9 | * Represents an ACP session. |
| 10 | * |
| 11 | * @author Alexander Ebert |
| 12 | * @copyright 2001-2019 WoltLab GmbH |
| 13 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
| 14 | * |
| 15 | * @property-read string $sessionID unique textual identifier of the acp session |
| 16 | * @property-read int|null $userID id of the user the acp session belongs to or `null` if the acp session belongs to a guest |
| 17 | * @property-read string $ipAddress id of the user whom the acp session belongs to |
| 18 | * @property-read string $userAgent user agent of the user whom the acp session belongs to |
| 19 | * @property-read int $lastActivityTime timestamp at which the latest activity occurred |
| 20 | * @property-read string $requestURI uri of the latest request |
| 21 | * @property-read string $requestMethod used request method of the latest request (`GET`, `POST`) |
| 22 | * @property-read string $sessionVariables serialized array with variables stored on a session-basis |
| 23 | * @deprecated 5.4 Distinct ACP sessions have been removed. This class is preserved due to its use in legacy sessions. |
| 24 | */ |
| 25 | class ACPSession extends DatabaseObject |
| 26 | { |
| 27 | /** |
| 28 | * @inheritDoc |
| 29 | */ |
| 30 | protected static $databaseTableIndexIsIdentity = false; |
| 31 | |
| 32 | /** |
| 33 | * Returns true if this session type supports persistent logins. |
| 34 | * |
| 35 | * @return bool |
| 36 | */ |
| 37 | public static function supportsPersistentLogins() |
| 38 | { |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Returns the existing session object for given user id or null if there |
| 44 | * is no such session. |
| 45 | * |
| 46 | * @param int $userID |
| 47 | * @return ACPSession |
| 48 | */ |
| 49 | public static function getSessionByUserID($userID) |
| 50 | { |
| 51 | $sql = "SELECT * |
| 52 | FROM " . static::getDatabaseTableName() . " |
| 53 | WHERE userID = ?"; |
| 54 | $statement = WCF::getDB()->prepareStatement($sql); |
| 55 | $statement->execute([$userID]); |
| 56 | |
| 57 | return $statement->fetchObject(static::class); |
| 58 | } |
| 59 | } |