droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
droy | 0f361be | 2008-07-18 12:37:19 +0000 | [diff] [blame] | 3 | * Copyright (c) 2007-2008 Eclipse Foundation and others. |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 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 |
droy | 0f361be | 2008-07-18 12:37:19 +0000 | [diff] [blame] | 12 | * Scott Reynen scott at randomchaos com - toescapedunicode |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 13 | *******************************************************************************/ |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 14 | |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 15 | define("COOKIE_REMEMBER", "cBABEL"); |
| 16 | define("COOKIE_SESSION" , "sBABEL"); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 17 | |
atoulme | a4adf8e | 2009-01-27 19:01:35 +0000 | [diff] [blame] | 18 | require(dirname(__FILE__) . '/html_functions.php'); |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 19 | |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 20 | $GLOBALS['g_LOADTIME'] = microtime(); |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 21 | require(dirname(__FILE__) . "/../classes/system/dbconnection.class.php"); |
| 22 | require(dirname(__FILE__) . "/../classes/system/event_log.class.php"); |
| 23 | require_once(dirname(__FILE__) . "/../classes/system/user.class.php"); |
droy | 3e7f3a8 | 2007-11-29 19:35:51 +0000 | [diff] [blame] | 24 | |
gobrien | 0436d99 | 2008-01-31 00:08:04 +0000 | [diff] [blame] | 25 | |
droy | 24242b8 | 2008-01-30 18:43:20 +0000 | [diff] [blame] | 26 | |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 27 | session_name(COOKIE_SESSION); |
| 28 | session_start(); |
| 29 | extract($_SESSION); |
| 30 | |
| 31 | |
droy | 2d5fd19 | 2007-11-28 14:42:45 +0000 | [diff] [blame] | 32 | function InitPage($login) { |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 33 | $page = $login; |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 34 | $lastPage = GetSessionVar('s_pageName'); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 35 | $User = GetSessionVar('User'); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 36 | |
| 37 | if (empty($GLOBALS['page'])) |
| 38 | $GLOBALS['page'] = ''; |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 39 | |
gobrien | 3ab4396 | 2008-08-18 17:33:41 +0000 | [diff] [blame] | 40 | if((strpos($_SERVER['REQUEST_URI'], "login.php") == FALSE) && |
| 41 | (strpos($_SERVER['REQUEST_URI'], "callback") == FALSE)) { |
| 42 | SetSessionVar('s_pageLast', $_SERVER['REQUEST_URI']); |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 43 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 44 | |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 45 | $dbc = new DBConnection(); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 46 | global $dbh; |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 47 | $dbh = $dbc->connect(); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 48 | |
droy | 2d5fd19 | 2007-11-28 14:42:45 +0000 | [diff] [blame] | 49 | if($login == "login" && !$User) { |
| 50 | # Login required, but the User object isn't there. |
| 51 | |
| 52 | if(isset($_COOKIE[COOKIE_REMEMBER])) { |
| 53 | # Try to fetch username from session |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 54 | require_once(dirname(__FILE__) . "/../classes/system/session.class.php"); |
droy | 2d5fd19 | 2007-11-28 14:42:45 +0000 | [diff] [blame] | 55 | $Session = new Session(); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 56 | |
droy | 2d5fd19 | 2007-11-28 14:42:45 +0000 | [diff] [blame] | 57 | if(!$Session->validate()) { |
droy | 0ab7009 | 2007-12-01 02:14:47 +0000 | [diff] [blame] | 58 | exitTo("login.php"); |
droy | 2d5fd19 | 2007-11-28 14:42:45 +0000 | [diff] [blame] | 59 | } |
| 60 | else { |
| 61 | $User = new User(); |
| 62 | $User->loadFromID($Session->_userid); |
| 63 | SetSessionVar("User", $User); |
| 64 | } |
| 65 | } |
| 66 | else { |
droy | 0ab7009 | 2007-12-01 02:14:47 +0000 | [diff] [blame] | 67 | exitTo("login.php"); |
droy | 2d5fd19 | 2007-11-28 14:42:45 +0000 | [diff] [blame] | 68 | } |
| 69 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 70 | |
| 71 | $GLOBALS['g_PHPSELF'] = $GLOBALS['page']; |
| 72 | $GLOBALS['g_PAGE'] = $page; |
| 73 | $GLOBALS['g_SITEURL'] = $_SERVER['HTTP_HOST']; |
| 74 | $GLOBALS['g_SITENAME'] = substr($GLOBALS['g_SITEURL'],0,strlen($GLOBALS['g_SITEURL'])-4); |
| 75 | $GLOBALS['g_TITLE'] = $GLOBALS['g_SITENAME']; |
| 76 | $GLOBALS['g_ERRSTRS'] = array("","","","","","","","","","","",); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 77 | $GLOBALS['DEBUG'] = ""; |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 78 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 79 | |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame] | 80 | |
atoulme | e9ec6d8 | 2008-11-19 14:41:30 +0000 | [diff] [blame] | 81 | |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 82 | ?> |