blob: 18165ddb35b59f2d8367dd32ba81e8f265c97a57 [file] [log] [blame]
droy43456e42007-11-27 18:55:10 +00001<?php
2/*******************************************************************************
3 * Copyright (c) 2007 Eclipse Foundation and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Paul Colton (Aptana)- initial API and implementation
11 * Eclipse Foundation
12*******************************************************************************/
droy43456e42007-11-27 18:55:10 +000013include("global.php");
droy2d5fd192007-11-28 14:42:45 +000014InitPage("");
droy43456e42007-11-27 18:55:10 +000015
droyfd2bab22007-11-27 21:08:43 +000016require_once(BABEL_BASE_DIR . "classes/system/user.class.php");
17require_once(BABEL_BASE_DIR . "classes/system/session.class.php");
18
gobrien1a8e02f2008-01-30 01:46:26 +000019$pageTitle = "Contribute Translations to Babel";
droyfd2bab22007-11-27 21:08:43 +000020$pageKeywords = "translation,language,nlpack,pack,eclipse,babel";
21
22$USERNAME = $App->getHTTPParameter("username", "POST");
23$PASSWORD = $App->getHTTPParameter("password", "POST");
24$REMEMBER = $App->getHTTPParameter("remember", "POST");
droy4036c242008-01-30 16:41:55 +000025$SUBMIT = $App->getHTTPParameter("submit");
droyfd2bab22007-11-27 21:08:43 +000026
gobriena3d49922008-03-07 21:05:55 +000027if(!isset($_SESSION['login_failed_attempts'])){
28 $_SESSION['login_failed_attempts'] = array();
29}
gobrienad11d892007-12-19 08:33:25 +000030
droyfd2bab22007-11-27 21:08:43 +000031if($SUBMIT == "Login") {
32 if($USERNAME != "" && $PASSWORD != ""){
33 $User = new User();
34 if(!$User->load($USERNAME, $PASSWORD)) {
gobriena3d49922008-03-07 21:05:55 +000035 foreach($_SESSION['login_failed_attempts'] as $timestamp){
36 if($timestamp < strtotime("2 minute ago")){
37 unset($_SESSION['login_failed_attempts'][$timestamp]);
38 }
39 }
40 $_SESSION['login_failed_attempts'][] = strtotime('now');
41 if(count($_SESSION['login_failed_attempts']) > 2){
42 $GLOBALS['g_ERRSTRS'][0] = "Authentication failed. <b>If you just created a NEW BUGZILLA ACCOUNT wait a few minutes and try again</b>.";
43 }else{
44 $GLOBALS['g_ERRSTRS'][0] = "Authentication failed. Please verify your username and/or password are correct.";
45 }
droyfd2bab22007-11-27 21:08:43 +000046 }
47 else {
48 # create session
49 $Session = new Session();
50 $Session->create($User->userid, $REMEMBER);
51 SetSessionVar('User', $User);
gobrien755df672008-01-18 01:01:33 +000052 exitTo("translate.php");
droyfd2bab22007-11-27 21:08:43 +000053 }
54 }
55 else {
56 $GLOBALS['g_ERRSTRS'][0] = "Your username and password must not be empty.";
57 }
58}
droyb93e4a22007-11-28 16:08:51 +000059if($SUBMIT == "Logout") {
60 $Session = new Session();
61 $Session->destroy();
62 $GLOBALS['g_ERRSTRS'][0] = "You have successfully logged out. You can login again using the form below.";
63}
droy43456e42007-11-27 18:55:10 +000064
65# TODO: finish the intro text
66
67
droyfd2bab22007-11-27 21:08:43 +000068include("head.php");
69
droy43456e42007-11-27 18:55:10 +000070include("content/en_login.php");
droyfd2bab22007-11-27 21:08:43 +000071
droy43456e42007-11-27 18:55:10 +000072include("foot.php");
73?>