blob: 02bda5417389c3a7944e2450d46f22a70e84143d [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*******************************************************************************/
gobrienda3a4502008-01-28 23:43:26 +000014if(!defined('BABEL_BASE_DIR')){
15 define('BABEL_BASE_DIR', "../");
16}
atoulme3e5e9342009-01-23 17:34:30 +000017
droy10ea8052007-11-27 18:38:06 +000018define("COOKIE_REMEMBER", "cBABEL");
19define("COOKIE_SESSION" , "sBABEL");
droye95652e2007-11-27 18:16:36 +000020
atoulme2ed2f5d2009-01-09 23:50:09 +000021require('common_functions.php');
atoulme3e5e9342009-01-23 17:34:30 +000022
droye95652e2007-11-27 18:16:36 +000023$GLOBALS['g_LOADTIME'] = microtime();
droy974b6af2007-11-27 19:19:49 +000024require(BABEL_BASE_DIR . "classes/system/dbconnection.class.php");
droy3e7f3a82007-11-29 19:35:51 +000025require(BABEL_BASE_DIR . "classes/system/event_log.class.php");
droyfd2bab22007-11-27 21:08:43 +000026require_once(BABEL_BASE_DIR . "classes/system/user.class.php");
droy3e7f3a82007-11-29 19:35:51 +000027
gobrien0436d992008-01-31 00:08:04 +000028
droy24242b82008-01-30 18:43:20 +000029
droye95652e2007-11-27 18:16:36 +000030session_name(COOKIE_SESSION);
31session_start();
32extract($_SESSION);
33
34
droy2d5fd192007-11-28 14:42:45 +000035function InitPage($login) {
droy51e2bcc2008-07-16 15:14:43 +000036 $page = $login;
droye95652e2007-11-27 18:16:36 +000037 $lastPage = GetSessionVar('s_pageName');
droyfd2bab22007-11-27 21:08:43 +000038 $User = GetSessionVar('User');
droye95652e2007-11-27 18:16:36 +000039
40 if (empty($GLOBALS['page']))
41 $GLOBALS['page'] = '';
droy51e2bcc2008-07-16 15:14:43 +000042
gobrien3ab43962008-08-18 17:33:41 +000043 if((strpos($_SERVER['REQUEST_URI'], "login.php") == FALSE) &&
44 (strpos($_SERVER['REQUEST_URI'], "callback") == FALSE)) {
45 SetSessionVar('s_pageLast', $_SERVER['REQUEST_URI']);
droy51e2bcc2008-07-16 15:14:43 +000046 }
droye95652e2007-11-27 18:16:36 +000047
droy974b6af2007-11-27 19:19:49 +000048 $dbc = new DBConnection();
droyfd2bab22007-11-27 21:08:43 +000049 global $dbh;
droy974b6af2007-11-27 19:19:49 +000050 $dbh = $dbc->connect();
droyfd2bab22007-11-27 21:08:43 +000051
droy2d5fd192007-11-28 14:42:45 +000052 if($login == "login" && !$User) {
53 # Login required, but the User object isn't there.
54
55 if(isset($_COOKIE[COOKIE_REMEMBER])) {
56 # Try to fetch username from session
57 require_once(BABEL_BASE_DIR . "classes/system/session.class.php");
58 $Session = new Session();
droye95652e2007-11-27 18:16:36 +000059
droy2d5fd192007-11-28 14:42:45 +000060 if(!$Session->validate()) {
droy0ab70092007-12-01 02:14:47 +000061 exitTo("login.php");
droy2d5fd192007-11-28 14:42:45 +000062 }
63 else {
64 $User = new User();
65 $User->loadFromID($Session->_userid);
66 SetSessionVar("User", $User);
67 }
68 }
69 else {
droy0ab70092007-12-01 02:14:47 +000070 exitTo("login.php");
droy2d5fd192007-11-28 14:42:45 +000071 }
72 }
droye95652e2007-11-27 18:16:36 +000073
74 $GLOBALS['g_PHPSELF'] = $GLOBALS['page'];
75 $GLOBALS['g_PAGE'] = $page;
76 $GLOBALS['g_SITEURL'] = $_SERVER['HTTP_HOST'];
77 $GLOBALS['g_SITENAME'] = substr($GLOBALS['g_SITEURL'],0,strlen($GLOBALS['g_SITEURL'])-4);
78 $GLOBALS['g_TITLE'] = $GLOBALS['g_SITENAME'];
79 $GLOBALS['g_ERRSTRS'] = array("","","","","","","","","","","",);
droye95652e2007-11-27 18:16:36 +000080 $GLOBALS['DEBUG'] = "";
droy10ea8052007-11-27 18:38:06 +000081}
droye95652e2007-11-27 18:16:36 +000082
droyfd2bab22007-11-27 21:08:43 +000083
atoulmee9ec6d82008-11-19 14:41:30 +000084
droye95652e2007-11-27 18:16:36 +000085?>