- Updated default filetypes used for system tags
[scuttle] / login.php
1 <?php
2 /***************************************************************************
3 Copyright (c) 2004 - 2006 Marcus Campbell
4 http://scuttle.org/
5
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.
10
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.
15
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 ***************************************************************************/
20
21 require_once 'header.inc.php';
22 $userservice     =& ServiceFactory::getServiceInstance('UserService');
23 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
24
25 $tplVars = array();
26
27 $login = false;
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); 
31     if ($login) {
32         if ($_POST['query'])
33             header('Location: '. createURL('bookmarks', $posteduser .'?'. $_POST['query']));
34         else
35             header('Location: '. createURL('bookmarks', $posteduser));
36     } else {
37         $tplVars['error'] = T_('The details you have entered are incorrect. Please try again.');
38     }
39 }
40 if (!$login) { 
41     if ($userservice->isLoggedOn()) {
42         $cUser = $userservice->getCurrentUser();
43         $cUsername = strtolower($cUser[$userservice->getFieldName('username')]);
44         header('Location: '. createURL('bookmarks', $cUsername));
45     }
46
47     $tplVars['subtitle']    = T_('Log In');
48     $tplVars['formaction']  = createURL('login');
49     $tplVars['querystring'] = filter($_SERVER['QUERY_STRING']);
50     $templateservice->loadTemplate('login.tpl', $tplVars);
51 }
52 ?>

Benjamin Mako Hill || Want to submit a patch?