blob: 52f200e72eed91305e136e377ba02e247d72ae95 [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
20$App;
21if(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");
droye95652e2007-11-27 18:16:36 +000031session_name(COOKIE_SESSION);
32session_start();
33extract($_SESSION);
34
35
36function InitPage($page) {
37 $lastPage = GetSessionVar('s_pageName');
38 $userName = GetSessionVar('s_userName');
39
40 if (empty($GLOBALS['page']))
41 $GLOBALS['page'] = '';
42
43 if (($lastPage != $_SERVER['PHP_SELF']) AND ($lastPage != "login"))
droy974b6af2007-11-27 19:19:49 +000044 SetSessionVar('s_pageLast',$lastPage);
45 SetSessionVar('s_pageName',$GLOBALS['page']);
droye95652e2007-11-27 18:16:36 +000046
droy974b6af2007-11-27 19:19:49 +000047 $dbc = new DBConnection();
48 $dbh = $dbc->connect();
49
droye95652e2007-11-27 18:16:36 +000050 if (!$userName && isset($_COOKIE[COOKIE_REMEMBER])) {
51 # Try to fetch username from session
droy974b6af2007-11-27 19:19:49 +000052 //$session = new sessions_iu(0);
droye95652e2007-11-27 18:16:36 +000053
droy974b6af2007-11-27 19:19:49 +000054 //if(!$session->validate()) {
55 //SetSessionVar('s_pageLast',$GLOBALS['page']);
56 //exitTo("login.php");
57 //}
58 //else {
59 //$user = new users_iu(0);
60 //$user->sqlLoad($session->_userid);
droye95652e2007-11-27 18:16:36 +000061 # hack! Not every one has a username
droy974b6af2007-11-27 19:19:49 +000062 //SetSessionVar("s_userName", str_replace("@", ".", $user->_email));
63 //}
droye95652e2007-11-27 18:16:36 +000064 }
65
66 $GLOBALS['g_PHPSELF'] = $GLOBALS['page'];
67 $GLOBALS['g_PAGE'] = $page;
68 $GLOBALS['g_SITEURL'] = $_SERVER['HTTP_HOST'];
69 $GLOBALS['g_SITENAME'] = substr($GLOBALS['g_SITEURL'],0,strlen($GLOBALS['g_SITEURL'])-4);
70 $GLOBALS['g_TITLE'] = $GLOBALS['g_SITENAME'];
71 $GLOBALS['g_ERRSTRS'] = array("","","","","","","","","","","",);
72 // $GLOBALS['g_MAINMENU'] = buildMainMenu($page,$userName);
73 $GLOBALS['DEBUG'] = "";
droy10ea8052007-11-27 18:38:06 +000074}
droye95652e2007-11-27 18:16:36 +000075
droy10ea8052007-11-27 18:38:06 +000076function errorLog($str) {
77
78}
79function exitTo() {
80 # TODO: sqlClose();
81 if (func_num_args() == 1) {
82 $url = func_get_arg(0);
83 header("Location: $url");
84 exit;
85 }
86 else if (func_num_args() == 2) {
87 $url = func_get_arg(0);
88 $arg1 = func_get_arg(1);
89 SetSessionVar("errStr",$arg1);
90 header("Location: $url");
91 exit;
92 }
93 else if (func_num_args() == 3) {
94 $url = func_get_arg(0);
95 $arg1 = func_get_arg(1);
96 $arg2 = func_get_arg(2);
97 SetSessionVar($arg1,$arg2);
98 header("Location: $url");
99 exit;
100 }
droye95652e2007-11-27 18:16:36 +0000101}
droy974b6af2007-11-27 19:19:49 +0000102function GetSessionVar($varName) {
103 if (isset($_SESSION[$varName]))
104 return $_SESSION[$varName];
105 return 0;
106}
droye95652e2007-11-27 18:16:36 +0000107
droy974b6af2007-11-27 19:19:49 +0000108function SetSessionVar($varName,$varVal) {
109 global $_SESSION;
110
111 $GLOBALS[$varName] = $varVal;
112 $_SESSION[$varName] = $varVal;
113 return $varVal;
114}
droye95652e2007-11-27 18:16:36 +0000115
116?>