blob: 98a10bf0b2751ada86e47ff9ea7b07f2eb457bf1 [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*******************************************************************************/
droy513207e2007-11-28 21:51:47 +000013define('BABEL_BASE_DIR', "../");
droy10ea8052007-11-27 18:38:06 +000014define('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");
droy3e7f3a82007-11-29 19:35:51 +000031require(BABEL_BASE_DIR . "classes/system/event_log.class.php");
droyfd2bab22007-11-27 21:08:43 +000032require_once(BABEL_BASE_DIR . "classes/system/user.class.php");
droy3e7f3a82007-11-29 19:35:51 +000033
droye95652e2007-11-27 18:16:36 +000034session_name(COOKIE_SESSION);
35session_start();
36extract($_SESSION);
37
38
droy2d5fd192007-11-28 14:42:45 +000039function InitPage($login) {
40 $page = $login;
droye95652e2007-11-27 18:16:36 +000041 $lastPage = GetSessionVar('s_pageName');
droyfd2bab22007-11-27 21:08:43 +000042 $User = GetSessionVar('User');
droye95652e2007-11-27 18:16:36 +000043
44 if (empty($GLOBALS['page']))
45 $GLOBALS['page'] = '';
46
47 if (($lastPage != $_SERVER['PHP_SELF']) AND ($lastPage != "login"))
droy974b6af2007-11-27 19:19:49 +000048 SetSessionVar('s_pageLast',$lastPage);
49 SetSessionVar('s_pageName',$GLOBALS['page']);
droye95652e2007-11-27 18:16:36 +000050
droy974b6af2007-11-27 19:19:49 +000051 $dbc = new DBConnection();
droyfd2bab22007-11-27 21:08:43 +000052 global $dbh;
droy974b6af2007-11-27 19:19:49 +000053 $dbh = $dbc->connect();
droyfd2bab22007-11-27 21:08:43 +000054
droy2d5fd192007-11-28 14:42:45 +000055 if($login == "login" && !$User) {
56 # Login required, but the User object isn't there.
57
58 if(isset($_COOKIE[COOKIE_REMEMBER])) {
59 # Try to fetch username from session
60 require_once(BABEL_BASE_DIR . "classes/system/session.class.php");
61 $Session = new Session();
droye95652e2007-11-27 18:16:36 +000062
droy2d5fd192007-11-28 14:42:45 +000063 if(!$Session->validate()) {
64 SetSessionVar('s_pageLast', $GLOBALS['page']);
droy0ab70092007-12-01 02:14:47 +000065 exitTo("login.php");
droy2d5fd192007-11-28 14:42:45 +000066 }
67 else {
68 $User = new User();
69 $User->loadFromID($Session->_userid);
70 SetSessionVar("User", $User);
71 }
72 }
73 else {
droy0ab70092007-12-01 02:14:47 +000074 exitTo("login.php");
droy2d5fd192007-11-28 14:42:45 +000075 }
76 }
droye95652e2007-11-27 18:16:36 +000077
78 $GLOBALS['g_PHPSELF'] = $GLOBALS['page'];
79 $GLOBALS['g_PAGE'] = $page;
80 $GLOBALS['g_SITEURL'] = $_SERVER['HTTP_HOST'];
81 $GLOBALS['g_SITENAME'] = substr($GLOBALS['g_SITEURL'],0,strlen($GLOBALS['g_SITEURL'])-4);
82 $GLOBALS['g_TITLE'] = $GLOBALS['g_SITENAME'];
83 $GLOBALS['g_ERRSTRS'] = array("","","","","","","","","","","",);
droye95652e2007-11-27 18:16:36 +000084 $GLOBALS['DEBUG'] = "";
droy10ea8052007-11-27 18:38:06 +000085}
droye95652e2007-11-27 18:16:36 +000086
droy10ea8052007-11-27 18:38:06 +000087function errorLog($str) {
88
89}
droyfd2bab22007-11-27 21:08:43 +000090
droy10ea8052007-11-27 18:38:06 +000091function exitTo() {
92 # TODO: sqlClose();
93 if (func_num_args() == 1) {
94 $url = func_get_arg(0);
95 header("Location: $url");
96 exit;
97 }
98 else if (func_num_args() == 2) {
99 $url = func_get_arg(0);
100 $arg1 = func_get_arg(1);
101 SetSessionVar("errStr",$arg1);
102 header("Location: $url");
103 exit;
104 }
105 else if (func_num_args() == 3) {
106 $url = func_get_arg(0);
107 $arg1 = func_get_arg(1);
108 $arg2 = func_get_arg(2);
109 SetSessionVar($arg1,$arg2);
110 header("Location: $url");
111 exit;
112 }
droye95652e2007-11-27 18:16:36 +0000113}
droy974b6af2007-11-27 19:19:49 +0000114function GetSessionVar($varName) {
115 if (isset($_SESSION[$varName]))
116 return $_SESSION[$varName];
117 return 0;
118}
droye95652e2007-11-27 18:16:36 +0000119
droy974b6af2007-11-27 19:19:49 +0000120function SetSessionVar($varName,$varVal) {
121 global $_SESSION;
122
123 $GLOBALS[$varName] = $varVal;
124 $_SESSION[$varName] = $varVal;
125 return $varVal;
126}
droye95652e2007-11-27 18:16:36 +0000127
gobrien35e23782007-11-28 21:37:18 +0000128function getLanguagebyID($id){
129 global $dbh;
130 $query = "select name from languages where language_id = '".addslashes($id)."' limit 1";
131 $res = mysql_query($query,$dbh);
132 $ret = mysql_fetch_array($res, MYSQL_ASSOC);
133 return $ret['name'];
134}
135
136
droye95652e2007-11-27 18:16:36 +0000137?>