2 /***************************************************************************
3 Copyright (c) 2004 - 2006 Marcus Campbell
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ***************************************************************************/
21 require_once 'header.inc.php';
22 $userservice =& ServiceFactory::getServiceInstance('UserService');
23 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
28 if (isset($_POST['submitted']) && isset($_POST['username']) && isset($_POST['password'])) {
29 $posteduser = trim(utf8_strtolower($_POST['username']));
30 $login = $userservice->login($posteduser, $_POST['password'], ($_POST['keeppass'] == 'yes'), $path);
33 header('Location: '. createURL('bookmarks', $posteduser .'?'. $_POST['query']));
35 header('Location: '. createURL('bookmarks', $posteduser));
37 $tplVars['error'] = T_('The details you have entered are incorrect. Please try again.');
41 if ($userservice->isLoggedOn()) {
42 $cUser = $userservice->getCurrentUser();
43 $cUsername = strtolower($cUser[$userservice->getFieldName('username')]);
44 header('Location: '. createURL('bookmarks', $cUsername));
47 $tplVars['subtitle'] = T_('Log In');
48 $tplVars['formaction'] = createURL('login');
49 $tplVars['querystring'] = filter($_SERVER['QUERY_STRING']);
50 $templateservice->loadTemplate('login.tpl', $tplVars);