blob: 34fb88958c48cd3b6d296b81c9dd4742840b325c [file] [log] [blame]
droye95652e2007-11-27 18:16:36 +00001<?php
2/*******************************************************************************
droy0f361be2008-07-18 12:37:19 +00003 * Copyright (c) 2007-2008 Eclipse Foundation and others.
droye95652e2007-11-27 18:16:36 +00004 * 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
droy0f361be2008-07-18 12:37:19 +000012 * Scott Reynen scott at randomchaos com - toescapedunicode
droye95652e2007-11-27 18:16:36 +000013*******************************************************************************/
atoulme3e5e9342009-01-23 17:34:30 +000014
droy10ea8052007-11-27 18:38:06 +000015define("COOKIE_REMEMBER", "cBABEL");
16define("COOKIE_SESSION" , "sBABEL");
droye95652e2007-11-27 18:16:36 +000017
atoulme2ed2f5d2009-01-09 23:50:09 +000018require('common_functions.php');
atoulme3e5e9342009-01-23 17:34:30 +000019
droye95652e2007-11-27 18:16:36 +000020$GLOBALS['g_LOADTIME'] = microtime();
atoulme12882d52009-01-26 18:39:17 +000021require(dirname(__FILE__) . "/../classes/system/dbconnection.class.php");
22require(dirname(__FILE__) . "/../classes/system/event_log.class.php");
23require_once(dirname(__FILE__) . "/../classes/system/user.class.php");
droy3e7f3a82007-11-29 19:35:51 +000024
gobrien0436d992008-01-31 00:08:04 +000025
droy24242b82008-01-30 18:43:20 +000026
droye95652e2007-11-27 18:16:36 +000027session_name(COOKIE_SESSION);
28session_start();
29extract($_SESSION);
30
31
droy2d5fd192007-11-28 14:42:45 +000032function InitPage($login) {
droy51e2bcc2008-07-16 15:14:43 +000033 $page = $login;
droye95652e2007-11-27 18:16:36 +000034 $lastPage = GetSessionVar('s_pageName');
droyfd2bab22007-11-27 21:08:43 +000035 $User = GetSessionVar('User');
droye95652e2007-11-27 18:16:36 +000036
37 if (empty($GLOBALS['page']))
38 $GLOBALS['page'] = '';
droy51e2bcc2008-07-16 15:14:43 +000039
gobrien3ab43962008-08-18 17:33:41 +000040 if((strpos($_SERVER['REQUEST_URI'], "login.php") == FALSE) &&
41 (strpos($_SERVER['REQUEST_URI'], "callback") == FALSE)) {
42 SetSessionVar('s_pageLast', $_SERVER['REQUEST_URI']);
droy51e2bcc2008-07-16 15:14:43 +000043 }
droye95652e2007-11-27 18:16:36 +000044
droy974b6af2007-11-27 19:19:49 +000045 $dbc = new DBConnection();
droyfd2bab22007-11-27 21:08:43 +000046 global $dbh;
droy974b6af2007-11-27 19:19:49 +000047 $dbh = $dbc->connect();
droyfd2bab22007-11-27 21:08:43 +000048
droy2d5fd192007-11-28 14:42:45 +000049 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
atoulme12882d52009-01-26 18:39:17 +000054 require_once(dirname(__FILE__) . "/../classes/system/session.class.php");
droy2d5fd192007-11-28 14:42:45 +000055 $Session = new Session();
droye95652e2007-11-27 18:16:36 +000056
droy2d5fd192007-11-28 14:42:45 +000057 if(!$Session->validate()) {
droy0ab70092007-12-01 02:14:47 +000058 exitTo("login.php");
droy2d5fd192007-11-28 14:42:45 +000059 }
60 else {
61 $User = new User();
62 $User->loadFromID($Session->_userid);
63 SetSessionVar("User", $User);
64 }
65 }
66 else {
droy0ab70092007-12-01 02:14:47 +000067 exitTo("login.php");
droy2d5fd192007-11-28 14:42:45 +000068 }
69 }
droye95652e2007-11-27 18:16:36 +000070
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("","","","","","","","","","","",);
droye95652e2007-11-27 18:16:36 +000077 $GLOBALS['DEBUG'] = "";
droy10ea8052007-11-27 18:38:06 +000078}
droye95652e2007-11-27 18:16:36 +000079
droyfd2bab22007-11-27 21:08:43 +000080
atoulmee9ec6d82008-11-19 14:41:30 +000081
droye95652e2007-11-27 18:16:36 +000082?>