2005-05-13 18:23:31 +00:00
< ?
2009-10-11 03:32:14 +00:00
require_once ( 'common.inc.php' );
require_once ( 'user.inc.php' );
2010-06-15 16:57:50 +00:00
// authenticate the login
2005-05-13 18:23:31 +00:00
if ( $_POST [ 'schoolid' ] && $_POST [ 'accesscode' ])
{
$q = mysql_query ( " SELECT * FROM schools WHERE id=' " . $_POST [ 'schoolid' ] . " ' AND accesscode=' " . $_POST [ 'accesscode' ] . " ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
if ( mysql_num_rows ( $q ) == 1 )
{
$_SESSION [ 'schoolid' ] = $_POST [ 'schoolid' ];
$_SESSION [ 'schoolaccesscode' ] = $_POST [ 'accesscode' ];
mysql_query ( " UPDATE schools SET lastlogin=NOW() WHERE id=' " . $_POST [ 'schoolid' ] . " ' " );
}
else
$errormsg = " Invalid School ID or Access Code " ;
}
2010-06-15 16:57:50 +00:00
// handle a logout request
2005-05-13 18:23:31 +00:00
if ( $_GET [ 'action' ] == " logout " )
{
unset ( $_SESSION [ 'schoolid' ]);
unset ( $_SESSION [ 'schoolaccesscode' ]);
2006-10-16 17:31:55 +00:00
$happymsg = i18n ( " You have been logged out from the school access page " );
2005-05-13 18:23:31 +00:00
}
2010-06-15 16:57:50 +00:00
if ( $_SESSION [ 'schoolid' ] && $_SESSION [ 'schoolaccesscode' ]){
// we're logged in, draw the dashboard
2005-05-13 18:23:31 +00:00
$q = mysql_query ( " SELECT * FROM schools WHERE id=' " . $_SESSION [ 'schoolid' ] . " ' AND accesscode=' " . $_SESSION [ 'schoolaccesscode' ] . " ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
echo mysql_error ();
$school = mysql_fetch_object ( $q );
2009-10-11 03:32:14 +00:00
if ( $school ) {
2010-06-15 16:57:50 +00:00
draw_dashboard ();
2010-06-14 18:30:39 +00:00
} else {
2008-03-27 04:33:00 +00:00
echo error ( i18n ( " Invalid School ID or Access Code " ));
2005-05-13 18:23:31 +00:00
}
2010-06-15 16:57:50 +00:00
} else {
2010-06-14 18:30:39 +00:00
draw_login ();
}
send_footer ();
2010-06-15 16:57:50 +00:00
2010-06-14 18:30:39 +00:00
// FIXME - this needs to be beautified
function draw_dashboard (){
2010-06-16 17:50:12 +00:00
send_header ( " School Home " ,
array (),
" events_scheduling " );
2010-06-14 18:30:39 +00:00
global $config ;
global $conference ;
echo " <ul> \n " ;
2010-06-15 16:57:50 +00:00
echo '<li><a href="schoolinfo.php">' . i18n ( " School Information " ) . " </a></li> \n " ;
if ( $conference [ 'id' ] == 0 || $conference [ 'type' ] == 'sciencefair' ){
2010-06-14 18:30:39 +00:00
if ( $config [ 'participant_registration_type' ] == " schoolpassword "
|| $config [ 'participant_registration_type' ] == " invite "
|| $config [ 'participant_registration_type' ] == " openorinvite "
){
2010-06-15 16:57:50 +00:00
echo '<li><a href="schoolinvite.php">' . i18n ( " Participant Registration " ) . " </a></li> \n " ;
2010-06-14 18:30:39 +00:00
}
2010-06-15 16:57:50 +00:00
} else if ( $conference [ 'type' ] == 'scienceolympics' ){
2010-06-15 18:14:01 +00:00
echo '<li><a href="schoolstudents.php">' . i18n ( " Manage Students " ) . " </a></li> \n " ;
echo '<li><a href="schoolteams.php">' . i18n ( " Manage Teams " ) . " </a></li> \n " ;
2010-06-15 21:43:21 +00:00
echo '<li><a href="schoolschedule.php">' . i18n ( " Register Teams for Events " ) . " </a></li> \n " ;
2010-06-14 18:30:39 +00:00
}
2010-06-15 16:57:50 +00:00
echo '<li><a href="schoolfeedback.php">' . i18n ( " School Feedback / Questions " ) . " </a></li> " ;
2010-06-14 18:30:39 +00:00
echo " </ul> \n " ;
}
function draw_login (){
2010-06-16 17:50:12 +00:00
send_header ( " School Home " );
2010-06-14 18:30:39 +00:00
global $errormsg , $happymsg , $config ;
2005-05-13 18:23:31 +00:00
if ( $errormsg ) echo " <font color=red><b> $errormsg </b></font> " ;
2006-10-16 17:31:55 +00:00
if ( $happymsg ) echo happy ( $happymsg );
2005-05-13 18:23:31 +00:00
2005-11-24 20:21:55 +00:00
echo " <form method=POST action= \" schoolaccess.php \" > \n " ;
2008-01-22 19:22:51 +00:00
echo output_page_text ( " schoolaccess " );
2005-11-24 20:21:55 +00:00
2007-02-26 20:15:07 +00:00
if ( $config [ 'participant_registration_type' ] == " open " || $config [ 'participant_registration_type' ] == " openorinvite " )
{
2008-01-22 19:22:51 +00:00
echo " <br><br> \n " ;
2007-02-26 20:15:07 +00:00
echo i18n ( " Note: Schools do not need to login in order to have students register from their school. Students can register by going to the Participant Registration Page. The only benefit of logging in is to update your school contact information or submit feedback.: " );
echo " <br /> " ;
echo " <a href= \" register_participants.php \" > " , i18n ( " Participant Registration " ) . " </a><br /> " ;
}
echo " <br /> " ;
2005-11-24 20:21:55 +00:00
echo i18n ( " Please login below by selecting your school and entering your school <b>Access Code</b> that you received in your package " );
?>
2005-05-13 18:23:31 +00:00
< br >< br >
< table border = 0 cellspacing = 0 cellpadding = 5 >
2005-11-25 19:37:10 +00:00
< tr >< td >< ? = i18n ( " School " ) ?> :</td><td>
2005-11-24 20:21:55 +00:00
< select name = " schoolid " >
2005-11-25 19:37:10 +00:00
< option value = " " >< ? = i18n ( " Choose your school " ) ?> </option>
2005-11-24 20:21:55 +00:00
< ?
2008-03-27 04:33:00 +00:00
$q = mysql_query ( " SELECT id,school,city FROM schools WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY school " );
$prev = " somethingthatdoesnotexist " ;
while ( $r = mysql_fetch_object ( $q ))
{
if ( $r -> school == $prev )
echo " <option value= \" $r->id\ " > $r -> school ( $r -> city ) </ option > \n " ;
else
echo " <option value= \" $r->id\ " > $r -> school </ option > \n " ;
$prev = $r -> school ;
2005-11-24 20:21:55 +00:00
}
?>
</ select >
</ td ></ tr >
2005-11-25 19:37:10 +00:00
< tr >< td >< ? = i18n ( " Access Code " ) ?> :</td><td><input type=text name=accesscode></td></tr>
< tr >< td align = center >< input type = submit value = " <?=i18n( " Login " )?> " ></ td ></ tr >
2005-05-13 18:23:31 +00:00
</ table >
</ form >
< br >< br >
< ?
}