droy | 43456e4 | 2007-11-27 18:55:10 +0000 | [diff] [blame] | 1 | <?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 | *******************************************************************************/ |
droy | 43456e4 | 2007-11-27 18:55:10 +0000 | [diff] [blame] | 13 | include("global.php"); |
droy | 2d5fd19 | 2007-11-28 14:42:45 +0000 | [diff] [blame] | 14 | InitPage(""); |
droy | 43456e4 | 2007-11-27 18:55:10 +0000 | [diff] [blame] | 15 | |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 16 | require_once(BABEL_BASE_DIR . "classes/system/user.class.php"); |
| 17 | require_once(BABEL_BASE_DIR . "classes/system/session.class.php"); |
| 18 | |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 19 | $pageTitle = "Contribute Translations to Babel"; |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 20 | $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"); |
droy | 4036c24 | 2008-01-30 16:41:55 +0000 | [diff] [blame] | 25 | $SUBMIT = $App->getHTTPParameter("submit"); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 26 | |
gobrien | a3d4992 | 2008-03-07 21:05:55 +0000 | [diff] [blame] | 27 | if(!isset($_SESSION['login_failed_attempts'])){ |
| 28 | $_SESSION['login_failed_attempts'] = array(); |
| 29 | } |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 30 | |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 31 | if($SUBMIT == "Login") { |
| 32 | if($USERNAME != "" && $PASSWORD != ""){ |
| 33 | $User = new User(); |
| 34 | if(!$User->load($USERNAME, $PASSWORD)) { |
gobrien | a3d4992 | 2008-03-07 21:05:55 +0000 | [diff] [blame] | 35 | 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 | } |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 46 | } |
| 47 | else { |
| 48 | # create session |
| 49 | $Session = new Session(); |
| 50 | $Session->create($User->userid, $REMEMBER); |
| 51 | SetSessionVar('User', $User); |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 52 | exitTo("translate.php"); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | else { |
| 56 | $GLOBALS['g_ERRSTRS'][0] = "Your username and password must not be empty."; |
| 57 | } |
| 58 | } |
droy | b93e4a2 | 2007-11-28 16:08:51 +0000 | [diff] [blame] | 59 | if($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 | } |
droy | 43456e4 | 2007-11-27 18:55:10 +0000 | [diff] [blame] | 64 | |
| 65 | # TODO: finish the intro text |
| 66 | |
| 67 | |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 68 | include("head.php"); |
| 69 |
|
droy | 43456e4 | 2007-11-27 18:55:10 +0000 | [diff] [blame] | 70 | include("content/en_login.php"); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 71 | |
droy | 43456e4 | 2007-11-27 18:55:10 +0000 | [diff] [blame] | 72 | include("foot.php");
|
| 73 | ?> |