echo '</table>'; echo xhtmlSubmit('Save changes'); echo xhtmlFormClose() . '<br/><br/>'; echo '<h3>Add new user setting</h3>'; echo xhtmlForm('new_setting'); echo 'Name: ' . xhtmlInput('setting_name') . ' '; echo 'Value: ' . xhtmlInput('setting_val') . ' '; echo xhtmlSubmit('Add'); echo xhtmlFormClose() . '<br/><br/>'; echo '<h2>Login history</h2>'; $dt = new YuiDatatable(); $dt->addColumn('timeCreated', 'Timestamp'); $dt->addColumn('IP', 'IP'); $dt->addColumn('userAgent', 'User agent'); $dt->setSortOrder('timeCreated', 'desc'); $dt->setDataSource(LoginEntry::getHistory($user->id)); $dt->setRowsPerPage(10); echo $dt->render(); if ($session->id != $this->owner) { echo '» <a href="' . relurl_add(array('remove' => 1)) . '">Remove user</a><br/><br/>'; } /* echo '<h2>'.t('Userdata').'</h2>'; editUserdataSettings($user->id); echo '<h2>'.t('Events').'</h2>'; $events = getEvents(0, $user->id, ' LIMIT 0,40'); echo '<table>'; foreach ($events as $row) { echo '<tr>';
/** * Handles logins * * @param $username * @param $pwd * @return true on success */ function login($username, $pwd, $type = SESSION_REGULAR) { $error = ErrorHandler::getInstance(); if (!$this->allow_logins) { $error->add('Logins currently not allowed.'); return false; } $username = trim($username); $pwd = trim($pwd); switch ($type) { case SESSION_REGULAR: $user = User::getByName($username); break; case SESSION_FACEBOOK: $user = new FacebookUser($username); break; default: throw new \Exception('hmm ' . $type); } if (!$user || !$user->id) { $error->add('Login failed - user not found1'); return false; } $x = User::getExact($type, $user->id, $username, $pwd); if (!$x) { dp('Failed login attempt: username ' . $username); $error->add('Login failed - user not found2'); return false; } $this->id = $user->id; $this->ip = client_ip(); $this->username = $username; $this->type = $type; $this->usermode = UserGroupHandler::getUserLevel($user->id); if ($this->usermode >= USERLEVEL_WEBMASTER) { $this->isWebmaster = true; } if ($this->usermode >= USERLEVEL_ADMIN) { $this->isAdmin = true; } if ($this->usermode >= USERLEVEL_SUPERADMIN) { $this->isSuperAdmin = true; } $q = 'UPDATE tblUsers SET time_last_login = NOW(), time_last_active = NOW(), last_ip = ?' . ' WHERE id = ?'; Sql::pUpdate($q, 'si', client_ip(), $this->id); LoginEntry::add($this->id, client_ip(), $_SERVER['HTTP_USER_AGENT']); $_SESSION['id'] = $this->id; $_SESSION['username'] = $this->username; $_SESSION['usermode'] = $this->usermode; $_SESSION['isWebmaster'] = $this->isWebmaster; $_SESSION['isAdmin'] = $this->isAdmin; $_SESSION['isSuperAdmin'] = $this->isSuperAdmin; $_SESSION['referer'] = $this->referer; $_SESSION['ip'] = $this->ip; $_SESSION['type'] = $this->type; $_SESSION['last_active'] = time(); session_write_close(); dp($this->username . ' logged in from ' . $this->ip); $error->reset(); // remove previous errors return true; }
echo '<a href="http://www.dnsstuff.com/tools/city.ch?ip=' . $ip . '" target="_blank">Lookup city from IP</a><br/>'; echo '<hr/>'; //Admin notes echo CommentViewer::render(IP, $geoip); break; case 'user': // query user name $user_name = 0; if (!empty($_GET['user'])) { $user_name = $_GET['user']; } $user = User::getByName($user_name); if (!$user) { die('no such user'); } echo '<h1>Query IP information of user ' . $user->name . '</h1>'; $ips = LoginEntry::getIPsByUser($user->id); echo '<table>'; echo '<tr>'; echo '<th>IP</th>'; echo '</tr>'; foreach ($ips as $ip) { echo '<tr>'; echo '<td>' . $ip . '</td>'; echo '</tr>'; } echo '</table>'; break; default: throw new \Exception('no such view: ' . $this->owner); }