science-ation/common.inc.php
jacob f61b4b94f3 Quick patches:
- wording changes for creating an account and recovering passwords
 - updated rollover script to copy the conference logo
2012-02-15 16:36:52 +00:00

541 lines
18 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.
*/
?>
<?
//functions contains all the common functions besides the header/footer functions
//must go before bootstrap becuase bootstrap needs some of the functions in it
require_once("common.inc.functions.php");
//bootstrap sets up the session, loads config params, etc, etc.
require_once("common.inc.bootstrap.php");
$HEADER_SENT=false;
function send_header($title="", $nav=null, $icon=null, $titletranslated=false) {
global $HEADER_SENT;
global $config;
global $configjs;
global $roles;
global $prependdir;
global $conference;
global $theme;
//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>
<?
foreach($theme['css'] AS $cssfile) {
echo " <link rel=\"stylesheet\" href=\"{$config['SFIABDIRECTORY']}/theme/{$config['theme']}/{$cssfile}\" type=\"text/css\" media=\"all\" />\n";
}
?>
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type="text/css" media="all" />
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jqueryui/jquery-ui-1.8.9.custom.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");
});
var config=<?=json_encode($configjs)?>;
</script>
<?
//if we're under /admin or /config or /super we also want the translation editor
// Dennis Required for windows or *nix servers
if((substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config" || substr(getcwd(),-6)=="/super") ||
(substr(getcwd(),-6)=="\\admin" || substr(getcwd(),-7)=="\\config" || substr(getcwd(),-6)=="\\super") )
require_once("../translationseditor.inc.php");
?>
<div id="page-wrapper">
<div id="page">
<div id="page-inner">
<div id="upper-section" class="clear">
<div id="notice_area" class="notice_area"></div>
<div id="topnav" class="clear">
<?
echo "<form name=\"languageselect\" method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<a href=\"{$config["SFIABDIRECTORY"]}/contact.php\">".i18n("Contact Us")."</a> &nbsp; | &nbsp; \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" class="clear">
<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-login">
<?
if(isset($_SESSION['roles']) && $_SESSION['username']) {
echo i18n("Logged in as %1",array($_SESSION['username']))."<br />";
echo "<div style=\"margin-top: 8px;\">\n";
echo "My: <a href=\"{$config['SFIABDIRECTORY']}/user_edit.php\">".i18n("Account Profile")."</a>";
echo "&nbsp;|&nbsp;";
echo "<a href=\"{$config['SFIABDIRECTORY']}/user_main.php\">".i18n("Main Page")."</a>";
echo "</div>";
echo "<div style=\"margin-top: 5px;\">\n";
echo "<a href=\"{$config['SFIABDIRECTORY']}/user_login.php?action=logout\">".i18n("Logout")."</a>";
echo "</div>";
} 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 "&nbsp;";
}
} else {
?>
<form method="post" action="user_login.php">
<input type="hidden" name="action" value="login" />
<table><tr><td>
<?=i18n("Username")?>:</td><td><input type="text" size="18" name="username" />
</td></tr><tr><td>
<?=i18n("Password")?>:</td><td><input type="password" size="18" name="password" />
</td></tr>
<tr><td style="text-align: center;" colspan="2">
<a href="register.php"><?=i18n("Create Account")?></a>
&nbsp; &nbsp; &nbsp;
<input type="submit" value=<?=i18n("Login")?> />
</td></tr>
</table>
</form>
<?
}
?>
</div>
<?
$q=mysql_query("SELECT * FROM conferences WHERE status='running' ORDER BY name");
if(mysql_num_rows($q)>1) {
echo " <div id=\"header-conferences\">\n";
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=\"{$config['SFIABDIRECTORY']}/user_login.php?action=switchconference&amp;switchconference=$r->id\">$r->name</a></li>\n";
}
echo " </ul>\n";
echo " </div>\n";
}
?>
</div>
</div>
<div id="navigation-section" class="clear">
<div id="channel-menu" class="clear">
<ul class="primarynav">
<?
//if they arent logged in, we need _some_ sort of navigation
if(!is_array($_SESSION['roles'])) {
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;
if($config['show_winners'] == "yes") {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/winners.php\">".i18n("Winners").'</a></li>';
}
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/committees.php\">".i18n("Committee").'</a></li>';
}
/*
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>';
}
*/
if(is_array($_SESSION['roles'])) {
foreach($_SESSION['roles'] AS $roletype) { //=>$roledata) {
$roleid=$roles[$roletype]['id'];
$q=mysql_query("SELECT * FROM rolestasks WHERE roles_id='$roleid' AND pid=0 AND conferencetype='{$conference['type']}' ORDER BY ord,task");
$cl="";
while($r=mysql_fetch_object($q)) {
if($_SESSION['nav']['primary'] == $r->id) {
$cl="class=\"selected\"";
}
else $cl="";
echo "<li $cl>";
if($r->link) $href=$config['SFIABDIRECTORY'].$r->link;
else $href=$config['SFIABDIRECTORY']."/nav.php?id=$r->id";
//echo "<a href=\"$href\" onclick=\"return taskNavLevel($r->id,0,0,0)\">".i18n($r->task)."</a>";
echo "<a href=\"$href\">".i18n($r->task)."</a>";
echo "</li>\n";
}
}
}
?>
<?
if($_SESSION['superuser'] == 'yes') {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/super/\">".i18n("System Setup").'</a></li>';
}
if(array_key_exists('users_id', $_SESSION)) {
/*
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(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>';
}
if(in_array('participant', $_SESSION['roles'])) {
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/register_participants_main.php\">".i18n("Participant Home").'</a></li>';
}
}
?>
</ul>
</div>
<div id="division-menu" class="clear">
<?
//comment out the secondary menu so we can get the old navigation type still live without having to completely undo everything
/*
$q=mysql_query("SELECT * FROM rolestasks WHERE pid='{$_SESSION['nav']['primary']}' AND conferencetype='{$conference['type']}' ORDER By ord,task");
echo "<ul class=\"secondarynav\">";
$cl="";
while($r=mysql_fetch_object($q)) {
if($_SESSION['nav']['secondary'] == $r->id) {
$cl="class=\"selected\"";
}
else $cl="";
echo "<li $cl>";
//echo "<a href=\"#\" onclick=\"return taskNavLevel($r->id,$r->pid,$r->level)\">".i18n($r->task)."</a>";
if($r->link) $href=$config['SFIABDIRECTORY'].$r->link;
else $href=$config['SFIABDIRECTORY']."/nav.php?id=$r->id";
echo "<a href=\"$href\">".i18n($r->task)."</a>";
echo "</li>\n";
}
echo "</ul>\n";
*/
?>
</div>
</div>
<div id="main" class="clear">
<?
/*
if($_SESSION['nav']['tertiary']) {
$workAreaStyle = 'style="margin-left:230px;"';
}else{
$topicMenuStyle = 'style="display:none;"';
}
*/
$topicMenuStyle = 'style="display:none;"';
echo "<div id=\"topic-menu\" class=\"clear\" $topicMenuStyle>\n";
/*
$q=mysql_query("SELECT * FROM rolestasks WHERE pid='{$_SESSION['nav']['secondary']}' AND conferencetype='{$conference['type']}' ORDER By ord,task");
echo "<ul class=\"tertiarynav\">";
while($r=mysql_fetch_object($q)) {
$cl="class=\"";
if($r->link)
$cl.="link ";
else
$cl.="heading ";
if($_SESSION['nav']['tertiary'] == $r->id) {
$cl.=" selected";
}
$cl.="\"";
echo "<li $cl>";
if($r->link)
echo "<a href=\"".$config['SFIABDIRECTORY']."$r->link\">";
echo i18n($r->task);
if($r->link)
echo "</a>";
echo "</li>\n";
}
echo "</ul>\n";
*/
?>
</div>
<script type="text/javascript">
$(document).ready(function(){
<?
if(!$_SESSION['nav']['secondary']) {
echo "$(\"#division-menu\").hide();\n";
}
/*
if($_SESSION['nav']['tertiary']) {
echo '$("#work-area").css({"margin-left":"230px"});';
}else{
echo "$(\"#topic-menu\").hide();\n";
}*/
?>
});
</script>
<?
/*
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> &raquo; ';
}
if(!$titletranslated)
echo i18n($title);
else
echo $title;
echo '</div>';
}
*/
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>
<?
}
*/
?>
<div id="work-area" <?=$workAreaStyle?>>
<div id="main-title">
<?
if($icon && theme_icon($icon)) {
echo " <div id=\"main-icon\" class=\"link-icon\">";
echo theme_icon($icon);
echo "</div>\n";
}
//if we're under /admin or /config then we want to show the ? help icon
// Dennis 2011-02-18 Required for *nix and Windows servers
if ((substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config" || substr(getcwd(),-6)=="/super") ||
(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 id=\"help-icon\" class=\"link-icon\"><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>\n";
}
if($title && !$titletranslated)
echo "<h2>".i18n($title)."</h2>\n";
else if($title)
echo "<h2>".$title."</h2>\n";
display_messages();
?>
</div><!-- main-title-->
<div id="main-content">
<?
}
/* END OF send_header */
function send_footer() {
global $config;
?>
</div><!--main-content-->
</div><!--work-area-->
</div><!--main-->
<div id="lower-section" class="clear">
<div id="footer">
<?
//we only show the debug session variables if we have an ODD numbered version.
if(substr($config['version'], -1) % 2 != 0)
{
$pos = strpos(getcwd(),'/');
if($pos === false){ // Windows OS
$revision = "na";
}
else{
$revision=exec("svn info |grep Revision");
}
$extra=" (Development $revision)";
if($_SESSION['debug']=="true")
$extradebug="<br />DEBUG SESSION: ".print_r($_SESSION,true);
}
echo "<a target=\"blank\" href=\"http://www.sfiab.ca\">SFIAB Version ".$config['version']."{$extra}</a>{$extradebug}";
?>
</div><!--footer-->
<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>
</div><!--lower-section-->
</div><!--page-inner-->
</div><!--page-->
</div><!--page-wrapper-->
</body>
</html>
<?
}
function send_popup_header($title="") {
global $HEADER_SENT;
global $config;
global $theme;
//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>
<?
foreach($theme['css'] AS $cssfile) {
echo " <link rel=\"stylesheet\" href=\"{$config['SFIABDIRECTORY']}/theme/{$config['theme']}/{$cssfile}\" type=\"text/css\" media=\"all\" />\n";
}
?>
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type="text/css" media="all" />
</head>
<body onload="window.focus()">
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jqueryui/jquery-ui-1.8.9.custom.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>
<?
}
?>