| <?php | |
| /******************************************************************************* | |
| * Copyright (c) 2006 Eclipse Foundation and others. | |
| * All rights reserved. This program and the accompanying materials | |
| * are made available under the terms of the Eclipse Public License v1.0 | |
| * which accompanies this distribution, and is available at | |
| * http://www.eclipse.org/legal/epl-v10.html | |
| * | |
| * Contributors: | |
| * Wayne Beaton (Eclipse Foundation)- initial API and implementation | |
| *******************************************************************************/ | |
| #***************************************************************************** | |
| # | |
| # common.php | |
| # | |
| # Author: Wayne Beaton | |
| # Date: February 16, 2006 | |
| # | |
| # Description: | |
| # This file contains functions that are used in managing resources. | |
| #**************************************************************************** | |
| function dump_get_parameters() { | |
| foreach($_GET as $key=>$value) | |
| echo "$key => $value<br/>"; | |
| } | |
| function dump_post_parameters() { | |
| foreach($_POST as $key=>$value) | |
| echo "$key => $value<br/>"; | |
| } | |
| function get_get_parameter($parameter, $default='') { | |
| if (array_key_exists($parameter, $_GET)) { | |
| return $_GET[$parameter]; | |
| } else return $default; | |
| } | |
| function get_post_parameter($parameter, $default='') { | |
| if (array_key_exists($parameter, $_POST)) { | |
| return $_POST[$parameter]; | |
| } else return $default; | |
| } | |
| function get_parameter($parameter, $default='') { | |
| return get_post_parameter($parameter, $default); | |
| } | |
| function goto_list_resources() { | |
| header ("Location: list_resources.php"); | |
| exit; | |
| } | |
| function display_messages($messages) { | |
| if (!$messages) return; | |
| echo "<div><font color=\"red\">$messages</font></div>"; | |
| } | |
| function is_authorized_to_edit_resources($userid) { | |
| return in_array($userid, array('wbeaton', 'ngervais', 'iskerrett')); | |
| } | |
| if ($_SERVER['SERVER_NAME'] != 'local.dev.eclipse.org') { | |
| require_once("/home/data/httpd/eclipse-php-classes/system/app.class.php"); | |
| require_once("/home/data/httpd/eclipse-php-classes/people/ldapperson.class.php"); | |
| $App = new App(); | |
| $App->runStdWebAppCacheable(); | |
| $LDAPPerson = new LDAPPerson(); | |
| $LDAPPerson = $LDAPPerson->redirectIfNotLoggedIn(); | |
| if (!is_authorized_to_edit_resources($LDAPPerson->getuid())) { | |
| header ("Location: /committers/resources/restricted.php"); | |
| exit; | |
| } | |
| } | |
| if (file_exists("/home/data/httpd/eclipse-php-classes/system/dbconnection_rw.class.php")) { | |
| require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_rw.class.php"; | |
| $dbc = new DBConnectionRW(); | |
| $dbc->connect(); | |
| } else { | |
| $dbc = mysql_connect(null, "phoenix", "fireB!rd"); | |
| if (!$dbc) { | |
| echo( "<P>Unable to connect to the database server at this time.</P>" ); | |
| return; | |
| } | |
| mysql_select_db("local_eclipse", $dbc); | |
| } | |
| ?> |