blob: d2d3a842c290a2f6a1491b94c2ce80f3f1993283 [file] [log] [blame]
droye95652e2007-11-27 18:16:36 +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*******************************************************************************/
droy10ea8052007-11-27 18:38:06 +000013define('BABEL_BASE_DIR', "../");
14define('USE_PHOENIX', true);
15define("COOKIE_REMEMBER", "cBABEL");
16define("COOKIE_SESSION" , "sBABEL");
droye95652e2007-11-27 18:16:36 +000017
18
19# Load up Phoenix classes
droyfd2bab22007-11-27 21:08:43 +000020global $App;
droye95652e2007-11-27 18:16:36 +000021if(USE_PHOENIX) {
gobrien197d2832007-11-27 18:42:53 +000022 require_once('eclipse.org-common/system/app.class.php');
23 require_once("eclipse.org-common/system/nav.class.php");
24 require_once("eclipse.org-common/system/menu.class.php");
droy974b6af2007-11-27 19:19:49 +000025 $App = new App();
26 $Nav = new Nav();
droye95652e2007-11-27 18:16:36 +000027 $Menu = new Menu();
28}
29$GLOBALS['g_LOADTIME'] = microtime();
droy974b6af2007-11-27 19:19:49 +000030require(BABEL_BASE_DIR . "classes/system/dbconnection.class.php");
droyfd2bab22007-11-27 21:08:43 +000031require_once(BABEL_BASE_DIR . "classes/system/user.class.php");
droye95652e2007-11-27 18:16:36 +000032session_name(COOKIE_SESSION);
33session_start();
34extract($_SESSION);
35
36
37function InitPage($page) {
38 $lastPage = GetSessionVar('s_pageName');
droyfd2bab22007-11-27 21:08:43 +000039 $User = GetSessionVar('User');
droye95652e2007-11-27 18:16:36 +000040
41 if (empty($GLOBALS['page']))
42 $GLOBALS['page'] = '';
43
44 if (($lastPage != $_SERVER['PHP_SELF']) AND ($lastPage != "login"))
droy974b6af2007-11-27 19:19:49 +000045 SetSessionVar('s_pageLast',$lastPage);
46 SetSessionVar('s_pageName',$GLOBALS['page']);
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
52 //if(!isset($User) && isset($_COOKIE[COOKIE_REMEMBER])) {
droye95652e2007-11-27 18:16:36 +000053 # Try to fetch username from session
droyfd2bab22007-11-27 21:08:43 +000054 //require_once(BABEL_BASE_DIR . "classes/system/session.class.php");
55 //$Session = new Session();
droye95652e2007-11-27 18:16:36 +000056
droy974b6af2007-11-27 19:19:49 +000057 //if(!$session->validate()) {
58 //SetSessionVar('s_pageLast',$GLOBALS['page']);
59 //exitTo("login.php");
60 //}
61 //else {
62 //$user = new users_iu(0);
63 //$user->sqlLoad($session->_userid);
droye95652e2007-11-27 18:16:36 +000064 # hack! Not every one has a username
droy974b6af2007-11-27 19:19:49 +000065 //SetSessionVar("s_userName", str_replace("@", ".", $user->_email));
66 //}
droyfd2bab22007-11-27 21:08:43 +000067 //}
droye95652e2007-11-27 18:16:36 +000068
69 $GLOBALS['g_PHPSELF'] = $GLOBALS['page'];
70 $GLOBALS['g_PAGE'] = $page;
71 $GLOBALS['g_SITEURL'] = $_SERVER['HTTP_HOST'];
72 $GLOBALS['g_SITENAME'] = substr($GLOBALS['g_SITEURL'],0,strlen($GLOBALS['g_SITEURL'])-4);
73 $GLOBALS['g_TITLE'] = $GLOBALS['g_SITENAME'];
74 $GLOBALS['g_ERRSTRS'] = array("","","","","","","","","","","",);
75 // $GLOBALS['g_MAINMENU'] = buildMainMenu($page,$userName);
76 $GLOBALS['DEBUG'] = "";
droy10ea8052007-11-27 18:38:06 +000077}
droye95652e2007-11-27 18:16:36 +000078
droy10ea8052007-11-27 18:38:06 +000079function errorLog($str) {
80
81}
droyfd2bab22007-11-27 21:08:43 +000082
droy10ea8052007-11-27 18:38:06 +000083function exitTo() {
84 # TODO: sqlClose();
85 if (func_num_args() == 1) {
86 $url = func_get_arg(0);
87 header("Location: $url");
88 exit;
89 }
90 else if (func_num_args() == 2) {
91 $url = func_get_arg(0);
92 $arg1 = func_get_arg(1);
93 SetSessionVar("errStr",$arg1);
94 header("Location: $url");
95 exit;
96 }
97 else if (func_num_args() == 3) {
98 $url = func_get_arg(0);
99 $arg1 = func_get_arg(1);
100 $arg2 = func_get_arg(2);
101 SetSessionVar($arg1,$arg2);
102 header("Location: $url");
103 exit;
104 }
droye95652e2007-11-27 18:16:36 +0000105}
droy974b6af2007-11-27 19:19:49 +0000106function GetSessionVar($varName) {
107 if (isset($_SESSION[$varName]))
108 return $_SESSION[$varName];
109 return 0;
110}
droye95652e2007-11-27 18:16:36 +0000111
droy974b6af2007-11-27 19:19:49 +0000112function SetSessionVar($varName,$varVal) {
113 global $_SESSION;
114
115 $GLOBALS[$varName] = $varVal;
116 $_SESSION[$varName] = $varVal;
117 return $varVal;
118}
droye95652e2007-11-27 18:16:36 +0000119
120?>