<?php

#############################################################################
#           			                   Site@School
# Site@School is a website management system designed for primary schools.
#
# About Site@School:
# Comissioned by: City District 'de Baarsjes', Amsterdam, Netherlands
# Original idea, coding (version 1.0) and design : Mark de Haan (mark@starwave.nl)
# Ideas, improvements, expansions (version 1.1 - 2.3): Fred Stuurman 
# Current coder & maintainer: Fred Stuurman (fc.stuurman@hccnet.nl)
############################################################################
# teacher.php: last changed 20/08/2005   2.4.03                                     
#               by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: user_login.php,v 1.1 2006/10/03 10:47:24 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
# Copyright (C) 2002 - 2005 Municipality of Amsterdam, City District
#  'de Baarsjes', Amsterdam, the Netherlands.
#
# 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; either version 2
# of the License, or (at your option) any later version.
#
# 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
##############################################################################
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}

if (IsSet ($_POST['userlogin']))
{
	$userlogin = $_POST['userlogin'];
}
//teacher
if (IsSet ($_POST['fullname']))
{
	$fullname = $_POST['fullname'];
}
if (IsSet ($_POST['username']))
{
	$username = $_POST['username'];
}
if (IsSet ($_POST['password']))
{
	$password = $_POST['password'];
}
if (IsSet ($_POST['class1']))
{
	$class1 = $_POST['class1'];
}
if (IsSet ($_POST['new_class']))
{
	$new_class = $_POST['new_class'];
}
if (IsSet ($_POST['email']))
{
	$email = $_POST['email'];
}
if (IsSet ($_POST['check']))
{
	$check = $_POST['check'];
}
if (IsSet ($_POST['send_email']))
{
	$send_email = $_POST['send_email'];
}
if (IsSet ($_POST['invisible']))
{
	$invisible = $_POST['invisible'];
}
if (IsSet ($_GET['option']))
{
	$option = $_GET['option'];
}
if (IsSet ($_GET['create']))
{
	$create = $_GET['create'];
}
if (IsSet ($_GET['createpage']))
{
	$createpage = $_GET['createpage'];
}
if (IsSet ($_GET['deletepage']))
{
	$deletepage = $_GET['deletepage'];
}
if (IsSet ($_GET['updatepage']))
{
	$updatepage = $_GET['updatepage'];
}
if (IsSet ($_GET['viewpage']))
{
	$viewpage = $_GET['viewpage'];
}
if (IsSet ($_GET['savestudent']))
{
	$savestudent = $_GET['savestudent'];
}
if (IsSet ($_GET['name']))
{
	$name = rawurldecode($_GET['name']);
}
if (IsSet ($_GET['new_class']))
{
	$new_class = $_GET['new_class'];
}
//student
if (IsSet ($_POST['title']))
{
	$title = $_POST['title'];
}
if (IsSet ($_POST['order']))
{
	$order = $_POST['order'];
}
if (IsSet ($_GET['option']))
{
	$option = $_GET['option'];
}
else
{
	$option = "";
}
if (IsSet ($_GET['savepage']))
{
	$savepage = $_GET['savepage'];
}
if (IsSet ($_GET['editpage']))
{
	$editpage = $_GET['editpage'];
}
$d = date("Y-m-d"); //todays date

if (IsSet ($_POST['newcontent']))
{
	$newcontent = sql_addslashes($_POST['newcontent']);
}

if (IsSet ($userlogin))
{
	if (!verify_logon($_POST['user_username'], $_POST['user_password'], "pupil"))
	{
		print "<script language=\"Javascript\">
					   <!--
					   alert (\"" . $sas_lang['login_error'] . "\");
					   window.location = 'index.php?section=$section&page=$page' ;	
					   //-->
					   </script>";
	}
}

elseif (!IsSet ($_SESSION['userid']))
{
	if (IsSet ($_GET['username']))
	{
		$username = $_GET['username'];
	}

	if ($_GET['error'] == "true")
	{
		print "<script language=\"Javascript\">
						   <!--
						   alert (\"" . $sas_lang['password_change_problem'] . "\");
						   //-->
						   </script>";
	}
	elseif ($_GET['option'] == "new_password") //passwords reset
	{
		print "<script language=\"Javascript\">
						   <!--
						   alert (\"" . $sas_lang['password_need_change'] . "\");
						   //-->
						   </script>";
	}

	print "<table cellpadding=\"4\"><tr><td colspan=\"2\"><font size=\"2\">" . $sas_lang['login_text'] . "</td></tr>";
	print "<FORM METHOD=\"POST\" ACTION=\"index.php?section=$section&page=$page\">";

	print "<td align=\"right\"><b>" . $sas_lang['username'] . " :</b></td>
			 
			 <td><INPUT tabindex=\"1\" TYPE=TEXT NAME=\"user_username\" SIZE=25 value=\"$username\"></td></tr>
			 <td align=\"right\"><b>" . $sas_lang['password'] . " :</b></td>
			 
			 <td><INPUT tabindex=\"2\" TYPE=password NAME=\"user_password\" SIZE=25></td></tr>";
	if ($_GET['option'] == "new_password") //passwords reset
	{
		print "<tr><td>&nbsp;</td></tr><tr><td align=right><b>" . $sas_lang['password_new'] . ":</b></td></tr>
		     <tr><td align=right><font size=\"2\" face=\"Verdana\"><b>" . $sas_lang['password'] . "1:&nbsp;</b></font></td>
		     <td> <input type=\"password\" TABINDEX=3 name=\"password_new1\" size=\"25\" style=\"color : black; font-size : 14px; border : 1px inset #CCDAEC;\">
		     <input type=\"hidden\" name=\"option\" value=\"save_new_password\"></td>
		   </tr>
		   <tr>
		     <td align=right><font size=\"2\" face=\"Verdana\"><b>" . $sas_lang['password'] . "2:&nbsp;</b></font></td>
		     <td> <input type=\"password\" TABINDEX=4 name=\"password_new2\" size=\"25\" style=\"color : black; font-size : 14px; border : 1px inset #CCDAEC;\">
		     </td>
		   </tr>";
	}
	if ($_GET['option'] != "new_password") //passwords reset
	{
		print "<tr>
				   <td>&nbsp;</td>
				   <td><font face=\"verdane,arial\" size=2><a href=\"starnet/sendpw.php?option=public\">" . $sas_lang['logged_password_forget'] . "</a></font></td>       
				 </tr>";
	}
	print "<tr><INPUT TYPE=\"hidden\" NAME=\"userlogin\" value=\"yes\">
			 <td colspan=\"2\" align=\"right\"><INPUT tabindex=\"5\" TYPE=SUBMIT VALUE=\"" . $sas_lang['login'] . "\"></font></td>
			 </tr>      
			</form> </table>";
}
if (IsSet ($_SESSION['usertype']))
{
	$usertype = $_SESSION['usertype'];
}
else
{
	$usertype = "";
}
if (IsSet ($_SESSION['userid']))
{
	$userid = $_SESSION['userid'];
}

if ($usertype == "student")
{
	include ("$cmsdir/modules/sn_studentpages/student.php");
}
if ($usertype == "teacher")
{
	include ("$cmsdir/modules/sn_studentpages/teacher.php");
}
?>
