forked from science-ation/science-ation
778 lines
27 KiB
PHP
778 lines
27 KiB
PHP
<?
|
|
/*
|
|
This file is part of the 'Science Fair In A Box' project
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
|
Copyright (C) 2005-2010 James Grant <james@lightbox.org>
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public
|
|
License as published by the Free Software Foundation, version 2.
|
|
|
|
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; see the file COPYING. If not, write to
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA.
|
|
*/
|
|
?>
|
|
<?
|
|
//if we dont set the charset any page that doesnt call send_header() (where it used to be set) would defualt to the server's encoding,
|
|
//which in many cases (like ysf-fsj.ca/sfiab) is UTF-8. This was causing a lot of the newly AJAX'd editors to fail on french characters,
|
|
//becuase they were being encoded improperly. Ideally, all the databases will be switched to UTF-8, but thats not a near-term possibility,
|
|
//so this is kind of a band-aid solution until we can make everything UTF8. Hope it doesnt break anything anywhere else!
|
|
header("Content-Type: text/html; charset=UTF-8");
|
|
|
|
//set error reporting to not show notices, for some reason some people's installation dont set this by default
|
|
//so we will set it in the code instead just to make sure
|
|
error_reporting(E_ALL ^ E_NOTICE);
|
|
|
|
define('REQUIREDFIELD','<span class="requiredfield">*</span>');
|
|
|
|
//figure out the directory to prepend to directoroy names, depending on if we are in a subdirectory or not
|
|
if(substr(getcwd(),-6)=="/admin")
|
|
$prependdir="../";
|
|
else if(substr(getcwd(),-6)=="/super")
|
|
$prependdir="../";
|
|
else if(substr(getcwd(),-7)=="/config")
|
|
$prependdir="../";
|
|
else if(substr(getcwd(),-3)=="/db")
|
|
$prependdir="../";
|
|
else if(substr(getcwd(),-8)=="/scripts")
|
|
$prependdir="../";
|
|
else
|
|
$prependdir="";
|
|
|
|
$sfiabversion=@file($prependdir."version.txt");
|
|
$config['version']=trim($sfiabversion[0]);
|
|
|
|
//make sure the data subdirectory is writable, if its not, then we're screwed, so make sure it is!
|
|
if(!is_writable($prependdir."data")) {
|
|
echo "<html><head><title>SFIAB ERROR</title></head><body>";
|
|
echo "<h1>Science Fair In A Box - ERROR</h1>";
|
|
echo "data/ subdirectory is not writable by the web server";
|
|
echo "<br>";
|
|
echo "<h2>Details</h2>";
|
|
echo "The data/ subdirectory is used to store files uploaded through the SFIAB software. The web server must have write access to this directory in order to function properly. Please contact your system administrator (if you are the system administrator, chown/chmod the data directory appropriately).";
|
|
echo "<br>";
|
|
echo "</body></html>";
|
|
exit;
|
|
}
|
|
|
|
if(file_exists($prependdir."data/config.inc.php")) {
|
|
require_once($prependdir."data/config.inc.php");
|
|
}
|
|
else {
|
|
echo "<html><head><title>SFIAB</title></head><body>";
|
|
echo "<h1>Science Fair In A Box - Installation</h1>";
|
|
echo "It looks like this is a new installation of SFIAB, and the database has not yet been configured. Please choose from the following options: <br />";
|
|
echo "<br />";
|
|
echo "<a href=\"install.php\">Proceed with Fresh SFIAB Installation</a>";
|
|
echo "<br />";
|
|
echo "</body></html>";
|
|
exit;
|
|
}
|
|
|
|
if(!mysql_connect($DBHOST,$DBUSER,$DBPASS)) {
|
|
echo "<html><head><title>SFIAB ERROR</title></head><body>";
|
|
echo "<h1>Science Fair In A Box - ERROR</h1>";
|
|
echo "Cannot connect to database!";
|
|
echo "</body></html>";
|
|
exit;
|
|
}
|
|
|
|
if(!mysql_select_db($DBNAME)) {
|
|
echo "<html><head><title>SFIAB ERROR</title></head><body>";
|
|
echo "<h1>Science Fair In A Box - ERROR</h1>";
|
|
echo "Cannot select database!";
|
|
echo "</body></html>";
|
|
exit;
|
|
}
|
|
|
|
//this will silently fail on mysql 4.x, but is needed on mysql5.x to ensure we're only using utf8 encodings
|
|
@mysql_query("SET NAMES utf8");
|
|
|
|
//find out the fair year and any other 'year=0' configuration parameters (things that dont change as the years go on)
|
|
$q=@mysql_query("SELECT * FROM config WHERE conferences_id=0 OR year=0");
|
|
|
|
//we might get an error if installation step 2 is not done (ie, the config table doesnt even exist)
|
|
if(mysql_error()) {
|
|
echo "<html><head><title>SFIAB ERROR</title></head><body>";
|
|
echo "<h1>Science Fair In A Box - ERROR</h1>";
|
|
echo "SFIAB installation is not complete. Please go to <A href=\"install2.php\">Installer Step 2</a> to complete the installation process";
|
|
echo "<br>";
|
|
echo "</body></html>";
|
|
exit;
|
|
}
|
|
//if we have 0 (<1) then install2 is not done, which would get caught above,
|
|
//if we have 1 (<2) then insatll3 is not done (no entries for FAIRYEAR and SFIABDIRECTORY)
|
|
if(mysql_num_rows($q)<2) {
|
|
echo "<html><head><title>SFIAB ERROR</title></head><body>";
|
|
echo "<h1>Science Fair In A Box - ERROR</h1>";
|
|
echo "SFIAB installation is not complete. Please go to <A href=\"install3.php\">Installer Step 3</a> to complete the installation process";
|
|
echo "<br>";
|
|
echo "</body></html>";
|
|
exit;
|
|
|
|
}
|
|
else {
|
|
while($r=mysql_fetch_object($q)) {
|
|
$config[$r->var]=$r->val;
|
|
}
|
|
}
|
|
|
|
$dbdbversion=$config['DBVERSION'];
|
|
$dbcodeversion=@file($prependdir."db/db.code.version.txt");
|
|
$dbcodeversion=trim($dbcodeversion[0]);
|
|
|
|
if(!$dbdbversion) {
|
|
echo "<html><head><title>SFIAB ERROR</title></head><body>";
|
|
echo "<h1>Science Fair In A Box - ERROR</h1>";
|
|
echo "SFIAB installation is not complete. Please go to <A href=\"install2.php\">Installer Step 2</a> to complete the installation process";
|
|
echo "<br>";
|
|
echo "</body></html>";
|
|
exit;
|
|
}
|
|
|
|
if($dbcodeversion!=$dbdbversion) {
|
|
echo "<html><head><title>SFIAB ERROR</title></head><body>";
|
|
echo "<h1>Science Fair In A Box - ERROR</h1>";
|
|
echo "SFIAB database and code are mismatched";
|
|
echo "<br>";
|
|
echo "Please run the db_update.php script in order to update";
|
|
echo "<br>";
|
|
echo "your database to the same version as the code";
|
|
echo "<br>";
|
|
echo "<br>";
|
|
echo "<br>";
|
|
echo "<h2>Details</h2>";
|
|
echo "Current SFIAB codebase requires DB version: ".$dbcodeversion;
|
|
echo "<br>";
|
|
echo "Current SFIAB database is detected as version: ".$dbdbversion;
|
|
echo "<br>";
|
|
echo "</body></html>";
|
|
exit;
|
|
}
|
|
|
|
/* Check that magic_quotes is OFF */
|
|
if(get_magic_quotes_gpc()) {
|
|
?>
|
|
<html><head><title>SFIAB ERROR</title></head><body>
|
|
<h1>Science Fair In A Box - ERROR</h1>
|
|
<p>Your PHP configuration has magic_quotes ENABLED. They should be
|
|
disabled, and are disabled in the .htaccess file, so your server is
|
|
ignoring the .htaccess file or overriding it.
|
|
<p>Magic quotes is DEPRECATED as of PHP 5.3.0, REMOVE as of 6.0, but ON
|
|
by default for any PHP < 5.3.0.
|
|
<p>Add <pre>php_flag magic_quotes_gpc off</pre> to the .htacces, or add
|
|
<pre>php_flag magic_quotes_gpc=off</pre> to php.ini
|
|
<br></body></html>
|
|
<?
|
|
exit;
|
|
}
|
|
|
|
if($config['SFIABDIRECTORY'] == '') {
|
|
session_name("SFIABSESSID");
|
|
session_set_cookie_params(0,'/');
|
|
} else {
|
|
session_name("SFIABSESSID".ereg_replace("[^A-Za-z]","_",$config['SFIABDIRECTORY']));
|
|
session_set_cookie_params(0,$config['SFIABDIRECTORY']);
|
|
}
|
|
session_start();
|
|
|
|
if(!$_SESSION['conferences_id']) {
|
|
$q=mysql_query("SELECT * FROM conferences WHERE status='running' ORDER BY name LIMIT 1");
|
|
if($r=mysql_fetch_object($q)) {
|
|
$_SESSION['conferences_id']=$r->id;
|
|
}
|
|
else {
|
|
echo "No conferences defined!";
|
|
}
|
|
}
|
|
|
|
//move the conference stuff before the configuration loading, so we can load the right configuration for the conference :)
|
|
if(isset($_GET['switchconference'])) {
|
|
//make sure its good
|
|
$cid=intval($_GET['switchconference']);
|
|
// echo "cid=$cid";
|
|
$q=mysql_query("SELECT * FROM conferences WHERE id='$cid' AND status='running'");
|
|
if($r=mysql_fetch_object($q)) {
|
|
$_SESSION['conferences_id']=$cid;
|
|
}
|
|
}
|
|
|
|
if(intval($_SESSION['conferences_id'])>0) {
|
|
$q=mysql_query("SELECT * FROM conferences WHERE id='{$_SESSION['conferences_id']}'");
|
|
$conference=mysql_fetch_assoc($q);
|
|
|
|
/*
|
|
******* THIS IS TEMPORARY.. probably remove it in a year or so ********
|
|
if the conference year is set, this is temporary for migratory purposes, so set the FAIRYEAR = confierence year - this will
|
|
gracefully handle the science fair parts that still rely on FAIRYEAR
|
|
|
|
if conference year is NOT set, then make sure config['FAIRYEAR'] is NOT set, so we can weed out any code that relies on
|
|
FAIRYEAR from the conference system
|
|
*/
|
|
if($conference['year'])
|
|
$config['FAIRYEAR']=$conference['year'];
|
|
else
|
|
$config['FAIRYEAR']=NULL;
|
|
}
|
|
|
|
//now pull the rest of the configuration
|
|
$q=mysql_query("SELECT * FROM config WHERE conferences_id='".$conference['id']."'");
|
|
while($r=mysql_fetch_object($q)) {
|
|
$config[$r->var]=$r->val;
|
|
}
|
|
|
|
//now pull the dates
|
|
if($conference['id'])
|
|
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."'");
|
|
else
|
|
$config['dates']=array();
|
|
|
|
while($r=mysql_fetch_object($q)) {
|
|
$config['dates'][$r->name]=$r->date;
|
|
}
|
|
|
|
//load roles
|
|
$roles=array();
|
|
$q = mysql_query("SELECT * FROM roles");
|
|
while(($r = mysql_fetch_assoc($q))) {
|
|
$roles[$r['type']] = $r;
|
|
}
|
|
|
|
//and now pull the theme
|
|
require_once("theme/{$config['theme']}/theme.php");
|
|
require_once("theme/{$config['theme_icons']}/icons.php");
|
|
|
|
//detect the browser first, so we know what icons to use - we store this in the config array as well
|
|
//even though its not configurable by the fair
|
|
if(stristr($_SERVER['HTTP_USER_AGENT'],"MSIE"))
|
|
$config['icon_extension']="gif";
|
|
else
|
|
$config['icon_extension']="png";
|
|
|
|
//now get the languages, and make sure we have at least one active language
|
|
$q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname");
|
|
if(mysql_num_rows($q)==0) {
|
|
echo "No active languages defined, defaulting to English";
|
|
$config['languages']['en']="English";
|
|
}
|
|
else {
|
|
while($r=mysql_fetch_object($q)) {
|
|
$config['languages'][$r->lang]=$r->langname;
|
|
}
|
|
}
|
|
//now if no language has been set yet, lets set it to the default language
|
|
if(!$_SESSION['lang']) {
|
|
//first try the default language, if that doesnt work, use "en"
|
|
if($config['default_language'])
|
|
$_SESSION['lang']=$config['default_language'];
|
|
else
|
|
$_SESSION['lang']="en";
|
|
}
|
|
|
|
//only allow debug to get set if we're using a development version (odd numbered ending)
|
|
if(substr($config['version'], -1) % 2 != 0)
|
|
if($_GET['debug']) $_SESSION['debug']=$_GET['debug'];
|
|
|
|
//if the user has switched languages, go ahead and switch the session variable
|
|
if($_GET['switchlanguage']) {
|
|
//first, make sure its a valid language:
|
|
if($config['languages'][$_GET['switchlanguage']]) {
|
|
$_SESSION['lang']=$_GET['switchlanguage'];
|
|
}
|
|
else {
|
|
//invalid language, dont do anything
|
|
}
|
|
}
|
|
|
|
$CWSFDivisions=array(
|
|
1=>"Automotive",
|
|
2=>"Biotechnology & Pharmaceutical Sciences",
|
|
3=>"Computing & Information Technology",
|
|
4=>"Earth & Environmental Sciences",
|
|
5=>"Engineering",
|
|
6=>"Environmental Innovation",
|
|
7=>"Health Sciences",
|
|
8=>"Life Sciences",
|
|
9=>"Physical & Mathematical Sciences"
|
|
);
|
|
|
|
//refator all functions except for the header/footer functions to another file
|
|
require_once("common.inc.functions.php");
|
|
|
|
$HEADER_SENT=false;
|
|
function send_header($title="", $nav=null, $icon=null, $titletranslated=false) {
|
|
global $HEADER_SENT;
|
|
global $config;
|
|
global $roles;
|
|
global $prependdir;
|
|
global $conference;
|
|
|
|
//do this so we can use send_header() a little more loosly and not worry about it being sent more than once.
|
|
if($HEADER_SENT) return;
|
|
else $HEADER_SENT=true;
|
|
|
|
?>
|
|
<!doctype html>
|
|
<html>
|
|
<head><title><? if($title && !$titletranslated) echo i18n($title); else if($title) echo $title; else echo i18n($config['fairname']); ?></title>
|
|
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/theme/<?=$config['theme']?>/jquery-ui-1.7.2.custom.css" type="text/css" media="all" />
|
|
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/theme/<?=$config['theme']?>/sfiab.css" type="text/css" media="all" />
|
|
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type="text/css" media="all" />
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jquery/1.3.2/jquery.min.js"></script>
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jqueryui/1.7.2/jquery-ui.min.js"></script>
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/sfiab.js"></script>
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/tablesorter/jquery.tablesorter.min.js"></script>
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/validate/jquery.validate.pack.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
$('.tableview').tablesorter();
|
|
if($("#importantdatesbox").length)
|
|
$("#importantdatesbox").load("important_dates.php?display=box");
|
|
});
|
|
|
|
|
|
function taskNav(id,pid,level) {
|
|
switch(level) {
|
|
case 0: //clicked on a top-level nav, so populate the secondary menu
|
|
$("#secondarymenu").load("<?=$config['SFIABDIRECTORY']?>/nav.php?level=1&id="+id);
|
|
$("#secondarymenu").show();
|
|
$("#tertiarymenu").hide();
|
|
$(".primarynav-selected").removeClass("primarynav-selected");
|
|
$("#primary_nav_"+id).addClass("primarynav-selected");
|
|
break;
|
|
|
|
case 1: //clicked on a secondary nav, so populate the left-menu
|
|
$(".secondarynav-selected").removeClass("secondarynav-selected");
|
|
$("#secondary_nav_"+id).addClass("secondarynav-selected");
|
|
|
|
$("#tertiarymenu_accordion").accordion("destroy");
|
|
$("#tertiarymenu_accordion").load("<?=$config['SFIABDIRECTORY']?>/nav.php?level=2&id="+id,null,function() {
|
|
$("#tertiarymenu_accordion").accordion({clearStyle: true}); //"option", "collapsible", true);
|
|
});
|
|
$("#tertiarymenu").show();
|
|
break;
|
|
|
|
}
|
|
return false;
|
|
}
|
|
</script>
|
|
<?
|
|
//if we're under /admin or /config we also want the translation editor
|
|
if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config")
|
|
require_once("../translationseditor.inc.php");
|
|
?>
|
|
|
|
<div id="notice_area" class="notice_area"></div>
|
|
<div id="topnav">
|
|
<?
|
|
echo "<form name=\"languageselect\" method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
|
|
echo "<a href=\"{$config["SFIABDIRECTORY"]}/contact.php\">".i18n("Contact Us")."</a> | \n";
|
|
if(count($config['languages'])>1) {
|
|
echo i18n("Language").": ";
|
|
echo "<select name=\"switchlanguage\" onchange=\"document.forms.languageselect.submit()\">\n";
|
|
foreach($config['languages'] AS $key=>$val) {
|
|
if($_SESSION['lang']==$key) $selected="selected=\"selected\""; else $selected="";
|
|
|
|
echo "<option $selected value=\"$key\">$val</option>";
|
|
}
|
|
echo "</select>";
|
|
}
|
|
echo "</form>";
|
|
?>
|
|
</div>
|
|
<div id="header">
|
|
<div id="header_logo">
|
|
<?
|
|
echo "<a href=\"{$config['SFIABDIRECTORY']}/index.php\">";
|
|
if(file_exists($prependdir."data/{$conference['id']}-logo-100.gif")) {
|
|
echo "<img style=\"border: 0px;\" height=\"70\" src=\"".$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-100.gif\">";
|
|
} else if(file_exists($prependdir."data/logo-100.gif")) {
|
|
echo "<img style=\"border: 0px;\" height=\"70\" src=\"".$config['SFIABDIRECTORY']."/data/logo-100.gif\">";
|
|
} else {
|
|
echo i18n("Home Page");
|
|
}
|
|
echo "</a>";
|
|
?>
|
|
</div>
|
|
<div id="header_title">
|
|
<?
|
|
|
|
if(!$_SESSION['conferences_id']) {
|
|
echo "<h1>".i18n($config['fairname'])."</h1>";
|
|
} else {
|
|
global $conference;
|
|
echo "<h1>".i18n($conference['name'])."</h1>";
|
|
|
|
}
|
|
?>
|
|
</div>
|
|
<div id="header_conferences">
|
|
<?
|
|
$q=mysql_query("SELECT * FROM conferences WHERE status='running' ORDER BY name");
|
|
if(mysql_num_rows($q)) {
|
|
echo "<ul class=\"conferencenav\">";
|
|
while($r=mysql_fetch_object($q)) {
|
|
if($_SESSION['conferences_id']==$r->id)
|
|
$cl="class=\"selected\"";
|
|
else
|
|
$cl="";
|
|
echo "<li $cl><a $cl href=\"".$_SERVER['PHP_SELF']."?switchconference=$r->id\">$r->name</a></li>\n";
|
|
}
|
|
echo "</ul>\n";
|
|
}
|
|
?>
|
|
|
|
</div>
|
|
<div id="header_login">
|
|
<?
|
|
if(isset($_SESSION['roles']) && $_SESSION['username']) {
|
|
echo i18n("Logged in as %1",array($_SESSION['username']))."<br />";
|
|
echo "<a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout")."</a>";
|
|
|
|
} else if(isset($_SESSION['email'])) {
|
|
/* Backwards compatible login settings */
|
|
if(isset($_SESSION['registration_id'])) {
|
|
echo i18n('Participant');
|
|
echo " {$_SESSION['email']}: ";
|
|
echo "<a href=\"{$config['SFIABDIRECTORY']}/register_participants.php?action=logout\">[".i18n("Logout")."]</a>";
|
|
} else {
|
|
echo " ";
|
|
}
|
|
|
|
} else {
|
|
?>
|
|
<form method="post" action="user_login.php">
|
|
<input type="hidden" name="action" value="login" />
|
|
<table cellspacing=1 cellpadding=1><tr><td>
|
|
<?=i18n("Username")?>:</td><td><input type="text" size="14" name="username" />
|
|
</td></tr><tr><td>
|
|
<?=i18n("Password")?>:</td><td><input type="password" size="14" name="password" />
|
|
</td></tr>
|
|
<tr><td align="center" colspan="2">
|
|
<a href="register.php"><?=i18n("Register")?></a>
|
|
|
|
<input type="submit" value=<?=i18n("Login")?> />
|
|
</td></tr>
|
|
</table>
|
|
</form>
|
|
<?
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div id="primarymenu">
|
|
<?
|
|
if(is_array($nav)) {
|
|
$navkeys=array_keys($nav);
|
|
switch($navkeys[2]) {
|
|
case "Fundraising":
|
|
echo "<ul class=\"primarynav\">\n";
|
|
echo "<li><h4 style=\"text-align: center;\">".i18n("Fundraising")."</h4></li>\n";
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/admin/fundraising.php\">".i18n("Fundraising Dashboard").'</a></li>';
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/admin/fundraising_setup.php\">".i18n("Fundraising Setup").'</a></li>';
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/admin/fundraising_campaigns.php\">".i18n("Manage Appeals").'</a></li>';
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/admin/donors.php\">".i18n("Manage Donors/Sponsors").'</a></li>';
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/admin/fundraising_reports.php\">".i18n("Fundraising Reports").'</a></li>';
|
|
echo "</ul><br />\n";
|
|
break;
|
|
default:
|
|
//no special menu
|
|
break;
|
|
}
|
|
}
|
|
?>
|
|
<ul class="primarynav">
|
|
<?
|
|
if ($config['website']) {
|
|
if ($config['website_name']) {
|
|
echo "<li><a href=\"{$config['website']}\">{$config['website_name']}</a></li>";
|
|
} else {
|
|
echo "<li><a href=\"{$config['website']}\">".i18n("Fair Home").'</a></li>';
|
|
}
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/index.php\">".i18n("Registration Home").'</a></li>';
|
|
} else {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/index.php\">".i18n("Home").'</a></li>';
|
|
}
|
|
|
|
//if the date is greater than the date/time that the confirmed participants gets posted,
|
|
//then we will show the registration confirmation page as a link in the menu,
|
|
$registrationconfirmationlink="";
|
|
|
|
//only display it if a date is set to begin with.
|
|
if($config['dates']['postparticipants'] && $config['dates']['postparticipants']!="0000-00-00 00:00:00") {
|
|
$q=mysql_query("SELECT (NOW()>'".$config['dates']['regclose']."') AS test");
|
|
$r=mysql_fetch_object($q);
|
|
if($r->test==1) {
|
|
$registrationconfirmationlink="<li><a href=\"".$config['SFIABDIRECTORY']."/confirmed_participants.php\">".i18n("Confirmed Participants")."</a></li>";
|
|
}
|
|
}
|
|
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/important_dates.php\">".i18n("Important Dates").'</a></li>';
|
|
echo $registrationconfirmationlink;
|
|
/*
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants.php\">".i18n("Participant Registration").'</a></li>';
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?type=judge\">".i18n("Judges Registration").'</a></li>';
|
|
if($config['volunteer_enable'] == 'yes') {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_login.php?type=volunteer\">".i18n("Volunteer Registration").'</a></li>';
|
|
}
|
|
*/
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/committees.php\">".i18n("Committee").'</a></li>';
|
|
if($config['show_winners'] == "yes") {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/winners.php\">".i18n("Winners").'</a></li>';
|
|
}
|
|
|
|
if(is_array($_SESSION['roles'])) {
|
|
foreach($_SESSION['roles'] AS $roletype) {
|
|
$roleid=$roles[$roletype]['id'];
|
|
$q=mysql_query("SELECT * FROM rolestasks WHERE roles_id='$roleid' AND pid=0 ORDER BY task");
|
|
if(mysql_num_rows($q)==1) {
|
|
$setPrimaryNav=true;
|
|
}
|
|
$cl="";
|
|
while($r=mysql_fetch_object($q)) {
|
|
if($setPrimarynav) {
|
|
$_SESSION['nav']['primary']=$r->id;
|
|
$cl="class=\"selected\"";
|
|
}
|
|
echo "<li id=\"primary_nav_{$r->id}\" $cl><a href=\"#\" onclick=\"return taskNav($r->id,$r->pid,$r->level)\">".i18n($r->task)."</a></li>\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
<?
|
|
if(array_key_exists('users_id', $_SESSION)) {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_main.php\">".i18n("Main Page").'</a></li>';
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/user_personal.php\">".i18n("My Profile").'</a></li>';
|
|
if(in_array('committee', $_SESSION['roles'])) {
|
|
// echo "<li><a href=\"{$config['SFIABDIRECTORY']}/committee_main.php\">".i18n("Committee Home").'</a></li>';
|
|
}
|
|
if(in_array('admin', $_SESSION['roles'])) {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/admin/\">".i18n("Administration").' (old) </a></li>';
|
|
}
|
|
if(in_array('config', $_SESSION['roles'])) {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/config/\">".i18n("Configuration").' (old) </a></li>';
|
|
}
|
|
if($_SESSION['superuser'] == 'yes') {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/super/\">".i18n("System Setup").'</a></li>';
|
|
}
|
|
if(in_array('volunteer', $_SESSION['roles'])) {
|
|
// echo "<li><a href=\"{$config['SFIABDIRECTORY']}/volunteer_main.php\">".i18n("Volunteer Home").'</a></li>';
|
|
}
|
|
if(in_array('sponsor', $_SESSION['roles'])) {
|
|
// echo "<li><a href=\"{$config['SFIABDIRECTORY']}/sponsor_main.php\">".i18n("Sponsor Home").'</a></li>';
|
|
}
|
|
/* FIXME: setting the schoolid should move to the user_login routine, so we can just test for
|
|
* the presence of the school/teacher/principal role here */
|
|
if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php\">".i18n("School Home").'</a></li>';
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/schoolaccess.php?action=logout\">".i18n("Logout").'</a></li>';
|
|
}
|
|
if(in_array('student', $_SESSION['roles'])) {
|
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants_main.php\">".i18n("Participant Home").'</a></li>';
|
|
}
|
|
}
|
|
?>
|
|
</ul>
|
|
</div>
|
|
<div id="secondarymenu">
|
|
</div>
|
|
<div id="tertiarymenu">
|
|
<div id="tertiarymenu_accordion">
|
|
</div>
|
|
</div>
|
|
|
|
<?
|
|
if($_SESSION['nav']['primary']) {
|
|
echo "<script type=\"text/javascript\">";
|
|
echo " $(document).ready(function() {\n";
|
|
echo "taskNav({$_SESSION['nav']['primary']},0,0);";
|
|
echo " });";
|
|
echo "</script>\n";
|
|
}
|
|
|
|
if($_SESSION['nav']['secondary']) {
|
|
echo "<script type=\"text/javascript\">";
|
|
echo " $(document).ready(function() {\n";
|
|
echo "taskNav({$_SESSION['nav']['secondary']},{$_SESSION['nav']['primary']},1);";
|
|
echo " });";
|
|
echo "</script>\n";
|
|
}
|
|
|
|
|
|
//take SFIABDIRECTORY off of the current URL
|
|
$pageurl=substr($_SERVER['PHP_SELF'],strlen($config['SFIABDIRECTORY']));
|
|
$q=mysql_query("SELECT * FROM rolestasks WHERE link='".mysql_real_escape_string($pageurl)."'");
|
|
if($r=mysql_fetch_object($q)) {
|
|
//okay we found it, now what do we do?
|
|
//FIXME: we need to populate the secondarynva, tertiarynav, and select the right thing in the accordion,
|
|
//because we cannot assume that the user navigated to this page via the pri/sec/ter nav menus
|
|
$navTree=array();
|
|
upTree($r->id,&$navTree);
|
|
foreach($navTree AS $t) {
|
|
print_r($t);
|
|
echo "<br />";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
<?
|
|
/*
|
|
if(is_array($nav)) {
|
|
echo "<div id=\"mainwhere\">".i18n('You are here:').' ';
|
|
foreach($nav as $t=>$l) {
|
|
echo "<a href=\"{$config['SFIABDIRECTORY']}/$l\">".i18n($t).'</a> » ';
|
|
}
|
|
if(!$titletranslated)
|
|
echo i18n($title);
|
|
else
|
|
echo $title;
|
|
echo '</div>';
|
|
}
|
|
*/
|
|
?>
|
|
|
|
<div id="main">
|
|
<?
|
|
|
|
if(is_array($_SESSION['roles'])) {
|
|
$has_config = array_key_exists('config', $_SESSION['roles']);
|
|
$has_admin = array_key_exists('admin', $_SESSION['roles']);
|
|
|
|
if($has_config || $has_admin)
|
|
committee_warnings();
|
|
if($has_config)
|
|
config_warnings();
|
|
if($has_admin)
|
|
admin_warnings();
|
|
}
|
|
|
|
if(substr(getcwd(),-6)!="/admin" && substr(getcwd(),-7)!="/config" && substr(getcwd(),-6)!="/super") {
|
|
?>
|
|
<div id="importantdatesbox">
|
|
</div>
|
|
<?
|
|
}
|
|
|
|
if($icon && theme_icon($icon)) {
|
|
echo "<div style=\"float: left; margin-right: 5px;\">";
|
|
echo theme_icon($icon);
|
|
echo "</div>";
|
|
}
|
|
|
|
//if we're under /admin or /config then we want to show the ? help icon
|
|
if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config" || substr(getcwd(),-6)=="/super") {
|
|
if($_SERVER['REDIRECT_SCRIPT_URL'])
|
|
$fname=substr($_SERVER['REDIRECT_SCRIPT_URL'],strlen($config['SFIABDIRECTORY'])+1);
|
|
else
|
|
$fname=substr($_SERVER['PHP_SELF'],strlen($config['SFIABDIRECTORY'])+1);
|
|
echo "<div style=\"float: right;\"<a target=\"_sfiabhelp\" href=\"http://www.sfiab.ca/wiki/index.php/Help_$fname\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/32/help.".$config['icon_extension']."\"></a></div>";
|
|
}
|
|
|
|
if($title && !$titletranslated)
|
|
echo "<h2>".i18n($title)."</h2>";
|
|
else if($title)
|
|
echo "<h2>".$title."</h2>";
|
|
|
|
display_messages();
|
|
|
|
}
|
|
/* END OF send_header */
|
|
|
|
function send_footer() {
|
|
global $config;
|
|
?>
|
|
</div>
|
|
<div id="footer">
|
|
<?
|
|
//we only show the debug session variables if we have an ODD numbered version.
|
|
if(substr($config['version'], -1) % 2 != 0)
|
|
{
|
|
$revision=exec("svn info |grep Revision");
|
|
$extra=" (Development $revision)";
|
|
if($_SESSION['debug']=="true")
|
|
$extra.=" DEBUG: ".print_r($_SESSION,true);
|
|
}
|
|
echo "<a target=\"blank\" href=\"http://www.sfiab.ca\">SFIAB Version ".$config['version']."{$extra}</a>";
|
|
?>
|
|
</div>
|
|
<div id="debug" style="display:<?=($_SESSION['debug']=='true')?'block':'none'?>; font-family:monospace; white-space:pre; " >Debug...</div>
|
|
<iframe id="content" src="" style="visibility:hidden; width:0px; height:0px"></iframe>
|
|
|
|
</body>
|
|
</html>
|
|
|
|
<?
|
|
}
|
|
|
|
function send_popup_header($title="") {
|
|
global $HEADER_SENT;
|
|
global $config;
|
|
|
|
//do this so we can use send_header() a little more loosly and not worry about it being sent more than once.
|
|
if($HEADER_SENT) return;
|
|
else $HEADER_SENT=true;
|
|
|
|
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
|
|
?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
|
|
<head><title><?=i18n($title)?></title>
|
|
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/theme/<?=$config['theme']?>/jquery-ui-1.7.2.custom.css" type="text/css" media="all" />
|
|
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/theme/<?=$config['theme']?>/sfiab.css" type="text/css" media="all" />
|
|
<link media=all href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type=text/css rel=stylesheet>
|
|
</head>
|
|
<body onload="window.focus()">
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jquery/1.3.2/jquery.min.js"></script>
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jqueryui/1.7.2/jquery-ui.min.js"></script>
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/sfiab.js"></script>
|
|
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/validate/jquery.validate.pack.js"></script>
|
|
<div id="notice_area" class="notice_area"></div>
|
|
|
|
<?
|
|
if($title)
|
|
echo "<h2>".i18n($title)."</h2>";
|
|
|
|
}
|
|
|
|
function send_popup_footer() {
|
|
?>
|
|
<br />
|
|
<br />
|
|
<div id="footer">
|
|
<?
|
|
global $config;
|
|
$lastdigit=$config['version'][strlen($config['version'])-1];
|
|
if($lastdigit%2!=0)
|
|
{
|
|
echo "DEBUG:";
|
|
print_r($_SESSION);
|
|
}
|
|
echo "SFIAB Version ".$config['version'];
|
|
?>
|
|
</div>
|
|
<div id="debug" style="display:<?=($_SESSION['debug']=='true')?'block':'none'?>">Debug...</div>
|
|
<iframe id="content" src="" style="visibility:hidden; width:0px; height:0px"></iframe>
|
|
|
|
</body>
|
|
</html>
|
|
<?
|
|
}
|
|
|
|
|
|
?>
|