<?php
/*
* ConPortal - Pomona College ITS scheduling appplication
* Copyright (C) 2005-2006 Pomona College
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Determine the base path for all included files.
* This was originally written because the SSL web URL
* was different than the non-SSLed one. That is no longer
* the case, but this stuff allows us to have subdirectories
* with site pages at them (not including /redirects)
*/
$path = '.';
$count = 0;
while (!file_exists("$path/standard.php")) {
++$count;
if ($count == 10)
die("Unable to find path");
$path = "../$path";
}
/* Remove trailing /. from path if necessary
*/
if (strlen($path) > 1)
$path = substr($path, 0, -2);
define('BASE_PATH', $path);
unset($path);
/*
* Include the config file before other includes so anything else that
* needs it can access it.
*/
require_once('inc/config.php');
/*
* Iterate through inc and make a list of all .php files. We'll
* include them all at once automagically.
*/
$directories = array(BASE_PATH.'/inc');
$files = array();
while (count($directories))
{
$dir = array_shift($directories);
$d = dir($dir);
while (false !== ($entry = $d->read()))
{
if ($entry[0] == ".")
continue;
$entry = $dir."/".$entry;
if (is_dir($entry))
$directories[] = $entry;
elseif (is_file($entry) || is_link($entry))
{
if ('php' == pathinfo($entry, PATHINFO_EXTENSION))
$files[] = $entry;
}
else
die("Unknown file type for file $entry\n");
}
}
foreach($files as $file)
require_once($file);
unset ($directories);
unset ($files);
unset ($dir);
unset ($d);
unset ($entry);
unset ($file);
/*
* Set a session name based on the server so we can differentiate
* conportal from conportaltest
*/
$session_name = SERVER_NAME . "SessionId";
$session_name = preg_replace('/\s+/', '', $session_name);
session_name($session_name);
session_start();
unset($session_name);
db_connect($db);
//now that we've connected, load preferences
loadPrefs();
/*
* Include the strings file
*/
require_once('inc/strings.php');
?>