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 |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame^] | 20 | global $App; |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 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 | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 25 | $App = new App(); |
| 26 | $Nav = new Nav(); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 27 | $Menu = new Menu(); |
| 28 | } |
| 29 | $GLOBALS['g_LOADTIME'] = microtime(); |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 30 | require(BABEL_BASE_DIR . "classes/system/dbconnection.class.php"); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame^] | 31 | require_once(BABEL_BASE_DIR . "classes/system/user.class.php"); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 32 | session_name(COOKIE_SESSION); |
| 33 | session_start(); |
| 34 | extract($_SESSION); |
| 35 | |
| 36 | |
| 37 | function InitPage($page) { |
| 38 | $lastPage = GetSessionVar('s_pageName'); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame^] | 39 | $User = GetSessionVar('User'); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 40 | |
| 41 | if (empty($GLOBALS['page'])) |
| 42 | $GLOBALS['page'] = ''; |
| 43 | |
| 44 | if (($lastPage != $_SERVER['PHP_SELF']) AND ($lastPage != "login")) |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 45 | SetSessionVar('s_pageLast',$lastPage); |
| 46 | SetSessionVar('s_pageName',$GLOBALS['page']); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 47 | |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 48 | $dbc = new DBConnection(); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame^] | 49 | global $dbh; |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 50 | $dbh = $dbc->connect(); |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame^] | 51 | |
| 52 | //if(!isset($User) && isset($_COOKIE[COOKIE_REMEMBER])) { |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 53 | # Try to fetch username from session |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame^] | 54 | //require_once(BABEL_BASE_DIR . "classes/system/session.class.php"); |
| 55 | //$Session = new Session(); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 56 | |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 57 | //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); |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 64 | # hack! Not every one has a username |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 65 | //SetSessionVar("s_userName", str_replace("@", ".", $user->_email)); |
| 66 | //} |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame^] | 67 | //} |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 68 | |
| 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'] = ""; |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 77 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 78 | |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 79 | function errorLog($str) { |
| 80 | |
| 81 | } |
droy | fd2bab2 | 2007-11-27 21:08:43 +0000 | [diff] [blame^] | 82 | |
droy | 10ea805 | 2007-11-27 18:38:06 +0000 | [diff] [blame] | 83 | function 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 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 105 | } |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 106 | function GetSessionVar($varName) { |
| 107 | if (isset($_SESSION[$varName])) |
| 108 | return $_SESSION[$varName]; |
| 109 | return 0; |
| 110 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 111 | |
droy | 974b6af | 2007-11-27 19:19:49 +0000 | [diff] [blame] | 112 | function SetSessionVar($varName,$varVal) { |
| 113 | global $_SESSION; |
| 114 | |
| 115 | $GLOBALS[$varName] = $varVal; |
| 116 | $_SESSION[$varName] = $varVal; |
| 117 | return $varVal; |
| 118 | } |
droy | e95652e | 2007-11-27 18:16:36 +0000 | [diff] [blame] | 119 | |
| 120 | ?> |