blob: b32e60c0ddfab94f8ab3ac624ac588420f645a88 [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");
droye95652e2007-11-27 18:16:36 +000025 $App = new App();
26 $Nav = new Nav();
27 $Menu = new Menu();
28}
29$GLOBALS['g_LOADTIME'] = microtime();
droy10ea8052007-11-27 18:38:06 +000030// require("utils.inc.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"))
44 SetSessionVar('s_pageLast',$lastPage);
45 SetSessionVar('s_pageName',$GLOBALS['page']);
46
47 sqlOpen(NULL);
48 if (!$userName && isset($_COOKIE[COOKIE_REMEMBER])) {
49 # Try to fetch username from session
50 $session = new sessions_iu(0);
51
52 if(!$session->validate()) {
53 SetSessionVar('s_pageLast',$GLOBALS['page']);
54 exitTo("login.php");
55 }
56 else {
57 $user = new users_iu(0);
58 $user->sqlLoad($session->_userid);
59 # hack! Not every one has a username
60 SetSessionVar("s_userName", str_replace("@", ".", $user->_email));
61 }
62 }
63
64 $GLOBALS['g_PHPSELF'] = $GLOBALS['page'];
65 $GLOBALS['g_PAGE'] = $page;
66 $GLOBALS['g_SITEURL'] = $_SERVER['HTTP_HOST'];
67 $GLOBALS['g_SITENAME'] = substr($GLOBALS['g_SITEURL'],0,strlen($GLOBALS['g_SITEURL'])-4);
68 $GLOBALS['g_TITLE'] = $GLOBALS['g_SITENAME'];
69 $GLOBALS['g_ERRSTRS'] = array("","","","","","","","","","","",);
70 // $GLOBALS['g_MAINMENU'] = buildMainMenu($page,$userName);
71 $GLOBALS['DEBUG'] = "";
droy10ea8052007-11-27 18:38:06 +000072}
droye95652e2007-11-27 18:16:36 +000073
droy10ea8052007-11-27 18:38:06 +000074function errorLog($str) {
75
76}
77function exitTo() {
78 # TODO: sqlClose();
79 if (func_num_args() == 1) {
80 $url = func_get_arg(0);
81 header("Location: $url");
82 exit;
83 }
84 else if (func_num_args() == 2) {
85 $url = func_get_arg(0);
86 $arg1 = func_get_arg(1);
87 SetSessionVar("errStr",$arg1);
88 header("Location: $url");
89 exit;
90 }
91 else if (func_num_args() == 3) {
92 $url = func_get_arg(0);
93 $arg1 = func_get_arg(1);
94 $arg2 = func_get_arg(2);
95 SetSessionVar($arg1,$arg2);
96 header("Location: $url");
97 exit;
98 }
droye95652e2007-11-27 18:16:36 +000099}
100
101
102?>