droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 1 | <?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 | *******************************************************************************/ |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 13 | define('BABEL_BASE_DIR', "../"); |
| 14 | define('USE_PHOENIX', true); |
| 15 | define("COOKIE_REMEMBER", "cBABEL"); |
| 16 | define("COOKIE_SESSION" , "sBABEL"); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 17 | |
| 18 | |
| 19 | # Load up Phoenix classes |
| 20 | $App; |
| 21 | if(USE_PHOENIX) { |
gobrien | 197d283 | 2007-11-27 18:42:53 +0000 | [diff] [blame^] | 22 | 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"); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 25 | $App = new App(); |
| 26 | $Nav = new Nav(); |
| 27 | $Menu = new Menu(); |
| 28 | } |
| 29 | $GLOBALS['g_LOADTIME'] = microtime(); |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 30 | // require("utils.inc.php"); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 31 | session_name(COOKIE_SESSION); |
| 32 | session_start(); |
| 33 | extract($_SESSION); |
| 34 | |
| 35 | |
| 36 | function 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'] = ""; |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 72 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 73 | |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 74 | function errorLog($str) { |
| 75 | |
| 76 | } |
| 77 | function 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 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | |
| 102 | ?> |