public static function findAuthor($paste) { /* join table user_paste with user on user id for paste id */ $res = Lunor::$base->dbi->selectAllFrom(PASTE_TABLE_PREFIX . 'user_paste', array('paste_id' => $paste->id)); if ($res !== false) { $row = $res[0]; $user = new Account_User(); $user->forId('account_user', $row['user_id']); if (isset($user->name) && !empty($user->name)) { return $user->name; } } return 'Guest'; }
public static function getLoggedIn() { if (isset($_SESSION['user']) && isset($_SESSION['ip'])) { /* need to verify the ip hasn't changed */ if ($_SESSION['ip'] === findIPLong()) { /* if the user variable is set then they are logged in for this session */ /* we can assume the pw's are right as the session variable is server side */ return true; } else { } /* ip has changed need to create new session for them based on cookies or log them out */ } /* else we need to check cookies for the id & hash */ $pl = new Account_PersistantLogin(); /* fill the class with data from cookie data */ $pl->fromCookies(); /* if the persistant login is valid we can have them logged in */ if ($pl->isValid()) { $user = new Account_User(); $user->read(array('name' => $pl->username)); $_SESSION['user'] = $user; $_SESSION['ip'] = findIPLong(); return true; } else { } return false; }