source: trunk/bookmarks/login.php @ 103

Revision 103, 2.0 KB checked in by admin, 4 years ago (diff)

Merged 1.003 into Trunk

Line 
1<?php
2/*
3       
4        This file is part of omCollab.
5       
6        Copyright (c) 2008 omCollab (Openmethodology Project)
7        http://www.openmethodology.org
8        http://mike2.openmethodology.org/wiki/OmCollab
9       
10        And parts copyright of Scuttle project
11        (http://sourceforge.net/projects/scuttle/, http://scuttle.org/)
12       
13        omCollab is free software: you can redistribute it and/or modify
14        it under the terms of the GNU General Public License as published by
15        the Free Software Foundation, either version 3 of the License, or
16        (at your option) any later version.
17       
18        omCollab is distributed in the hope that it will be useful,
19        but WITHOUT ANY WARRANTY; without even the implied warranty of
20        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21        GNU General Public License for more details.
22
23*/
24
25require_once('header.inc.php');
26$userservice =& ServiceFactory::getServiceInstance('UserService');
27$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
28
29$tplVars = array();
30
31$login = false;
32if (isset($_POST['submitted']) && isset($_POST['username']) && isset($_POST['password'])) {
33    $posteduser = trim(utf8_strtolower($_POST['username']));
34    $login = $userservice->login($posteduser, $_POST['password'], ($_POST['keeppass'] == "yes"));
35    if ($login) {
36        if ($_POST['query'])
37            header('Location: '. createURL('bookmarks', $posteduser .'?'. $_POST['query']));
38        else
39            header('Location: '. createURL('bookmarks', $posteduser));
40    } else {
41        $tplVars['error'] = T_('The details you have entered are incorrect. Please try again.');
42    }
43}
44if (!$login) {
45    if ($userservice->isLoggedOn()) {
46        $cUser = $userservice->getCurrentUser();
47        $cUsername = strtolower($cUser[$userservice->getFieldName('username')]);
48        header('Location: '. createURL('bookmarks', $cUsername));
49    }
50
51    $tplVars['subtitle']    = T_('Log In');
52    $tplVars['formaction']  = createURL('login');
53    $tplVars['querystring'] = filter($_SERVER['QUERY_STRING']);
54    $templateservice->loadTemplate('login.tpl', $tplVars);
55}
56?>
Note: See TracBrowser for help on using the repository browser.