blob: c6cd93cf07d989cdae00230fc78a23bac0387a05 [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*******************************************************************************/
gobrienda3a4502008-01-28 23:43:26 +000013if(!defined('BABEL_BASE_DIR')){
14 define('BABEL_BASE_DIR', "../");
15}
droy10ea8052007-11-27 18:38:06 +000016define('USE_PHOENIX', true);
17define("COOKIE_REMEMBER", "cBABEL");
18define("COOKIE_SESSION" , "sBABEL");
droye95652e2007-11-27 18:16:36 +000019
droye95652e2007-11-27 18:16:36 +000020# Load up Phoenix classes
droyfd2bab22007-11-27 21:08:43 +000021global $App;
droye95652e2007-11-27 18:16:36 +000022if(USE_PHOENIX) {
gobrien197d2832007-11-27 18:42:53 +000023 require_once('eclipse.org-common/system/app.class.php');
24 require_once("eclipse.org-common/system/nav.class.php");
25 require_once("eclipse.org-common/system/menu.class.php");
droy974b6af2007-11-27 19:19:49 +000026 $App = new App();
27 $Nav = new Nav();
droye95652e2007-11-27 18:16:36 +000028 $Menu = new Menu();
droy8aedeec2008-01-25 19:04:14 +000029 $MenuItemList = array();
30 $MenuItemList[0] = new MenuItem("Home", "./", "_self", 0);
31 $MenuItemList[1] = new MenuItem("For committers", "map_files.php", "_self", 0);
32 $MenuItemList[2] = new MenuItem("About Babel", "http://www.eclipse.org/babel", "_self", 0);
33 $Menu->setMenuItemList($MenuItemList);
34
35 # set Phoenix defaults to prevent errors. These can be overridden on the page.
36 $pageTitle = "";
37 $pageAuthor = "";
38 $pageKeywords = "";
droye95652e2007-11-27 18:16:36 +000039}
40$GLOBALS['g_LOADTIME'] = microtime();
droy974b6af2007-11-27 19:19:49 +000041require(BABEL_BASE_DIR . "classes/system/dbconnection.class.php");
droy3e7f3a82007-11-29 19:35:51 +000042require(BABEL_BASE_DIR . "classes/system/event_log.class.php");
droyfd2bab22007-11-27 21:08:43 +000043require_once(BABEL_BASE_DIR . "classes/system/user.class.php");
droy3e7f3a82007-11-29 19:35:51 +000044
droye95652e2007-11-27 18:16:36 +000045session_name(COOKIE_SESSION);
46session_start();
47extract($_SESSION);
48
49
droy2d5fd192007-11-28 14:42:45 +000050function InitPage($login) {
51 $page = $login;
droye95652e2007-11-27 18:16:36 +000052 $lastPage = GetSessionVar('s_pageName');
droyfd2bab22007-11-27 21:08:43 +000053 $User = GetSessionVar('User');
droye95652e2007-11-27 18:16:36 +000054
55 if (empty($GLOBALS['page']))
56 $GLOBALS['page'] = '';
57
58 if (($lastPage != $_SERVER['PHP_SELF']) AND ($lastPage != "login"))
droy974b6af2007-11-27 19:19:49 +000059 SetSessionVar('s_pageLast',$lastPage);
60 SetSessionVar('s_pageName',$GLOBALS['page']);
droye95652e2007-11-27 18:16:36 +000061
droy974b6af2007-11-27 19:19:49 +000062 $dbc = new DBConnection();
droyfd2bab22007-11-27 21:08:43 +000063 global $dbh;
droy974b6af2007-11-27 19:19:49 +000064 $dbh = $dbc->connect();
droyfd2bab22007-11-27 21:08:43 +000065
droy2d5fd192007-11-28 14:42:45 +000066 if($login == "login" && !$User) {
67 # Login required, but the User object isn't there.
68
69 if(isset($_COOKIE[COOKIE_REMEMBER])) {
70 # Try to fetch username from session
71 require_once(BABEL_BASE_DIR . "classes/system/session.class.php");
72 $Session = new Session();
droye95652e2007-11-27 18:16:36 +000073
droy2d5fd192007-11-28 14:42:45 +000074 if(!$Session->validate()) {
75 SetSessionVar('s_pageLast', $GLOBALS['page']);
droy0ab70092007-12-01 02:14:47 +000076 exitTo("login.php");
droy2d5fd192007-11-28 14:42:45 +000077 }
78 else {
79 $User = new User();
80 $User->loadFromID($Session->_userid);
81 SetSessionVar("User", $User);
82 }
83 }
84 else {
droy0ab70092007-12-01 02:14:47 +000085 exitTo("login.php");
droy2d5fd192007-11-28 14:42:45 +000086 }
87 }
droye95652e2007-11-27 18:16:36 +000088
89 $GLOBALS['g_PHPSELF'] = $GLOBALS['page'];
90 $GLOBALS['g_PAGE'] = $page;
91 $GLOBALS['g_SITEURL'] = $_SERVER['HTTP_HOST'];
92 $GLOBALS['g_SITENAME'] = substr($GLOBALS['g_SITEURL'],0,strlen($GLOBALS['g_SITEURL'])-4);
93 $GLOBALS['g_TITLE'] = $GLOBALS['g_SITENAME'];
94 $GLOBALS['g_ERRSTRS'] = array("","","","","","","","","","","",);
droye95652e2007-11-27 18:16:36 +000095 $GLOBALS['DEBUG'] = "";
droy10ea8052007-11-27 18:38:06 +000096}
droye95652e2007-11-27 18:16:36 +000097
droy10ea8052007-11-27 18:38:06 +000098function errorLog($str) {
99
100}
droyfd2bab22007-11-27 21:08:43 +0000101
droy10ea8052007-11-27 18:38:06 +0000102function exitTo() {
103 # TODO: sqlClose();
104 if (func_num_args() == 1) {
105 $url = func_get_arg(0);
106 header("Location: $url");
107 exit;
108 }
109 else if (func_num_args() == 2) {
110 $url = func_get_arg(0);
111 $arg1 = func_get_arg(1);
112 SetSessionVar("errStr",$arg1);
113 header("Location: $url");
114 exit;
115 }
116 else if (func_num_args() == 3) {
117 $url = func_get_arg(0);
118 $arg1 = func_get_arg(1);
119 $arg2 = func_get_arg(2);
120 SetSessionVar($arg1,$arg2);
121 header("Location: $url");
122 exit;
123 }
droye95652e2007-11-27 18:16:36 +0000124}
droy974b6af2007-11-27 19:19:49 +0000125function GetSessionVar($varName) {
126 if (isset($_SESSION[$varName]))
127 return $_SESSION[$varName];
128 return 0;
129}
droye95652e2007-11-27 18:16:36 +0000130
droy974b6af2007-11-27 19:19:49 +0000131function SetSessionVar($varName,$varVal) {
132 global $_SESSION;
133
134 $GLOBALS[$varName] = $varVal;
135 $_SESSION[$varName] = $varVal;
136 return $varVal;
137}
droye95652e2007-11-27 18:16:36 +0000138
gobrien35e23782007-11-28 21:37:18 +0000139function getLanguagebyID($id){
140 global $dbh;
141 $query = "select name from languages where language_id = '".addslashes($id)."' limit 1";
142 $res = mysql_query($query,$dbh);
143 $ret = mysql_fetch_array($res, MYSQL_ASSOC);
144 return $ret['name'];
145}
146
147
droye95652e2007-11-27 18:16:36 +0000148?>