Location: PHPKode > projects > ACollab > sign_in.php
<?php
/****************************************************************************************/
/* ACollab                                                                              */
/****************************************************************************************/
/* Copyright (c) 2002-2004  Adaptive Technology Resource Centre / University of Toronto */
/*                                                                                      */
/* http://atutor.ca/acollab                                                             */
/*                                                                                      */
/* This program is free software. You may 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 may access the GNU General Public License at:                                    */
/* http://www.opensource.org/licenses/gpl-license.php                                   */
/*                                                                                      */
/* You may contact the Adaptive Technology Resource Centre at                           */
/* Robarts Library, University of Toronto                                               */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
/* Further contact information is available at http://www.utoronto.ca/atrc/             */
/****************************************************************************************/
/* Programmer:                                                                          */
/* Joel Kronenberg - ATRC                                                               */
/****************************************************************************************/
// $Id: sign_in.php 468 2005-03-21 15:21:13Z shozubq $

define('AC_INCLUDE_PATH', 'include/');


require(AC_INCLUDE_PATH.'vitals.inc.php');

if (isset($_POST['submit'])) {
	if (($_POST['login'] == ADMIN_USERNAME) && (stripslashes($_POST['password']) == stripslashes(ADMIN_PASSWORD))) {
		$_SESSION['login']	= $_POST['login'];
		$_SESSION['status'] = USER_ADMIN;
		$_SESSION['course_id']  = 0;
		$_SESSION['courtyard_priv'] = COURTYARD_PRIV_GROUP_ACCESS_CREATE;
		header('Location: admin/index.php');
		exit;
	}

	if (defined('AT_PATH') && AT_PATH && ($_POST['site'] == 'atutor')) {
		$sql	= "SELECT * FROM ".AT_TABLE_PREFIX."members WHERE login='$_POST[login]' AND PASSWORD(password)=PASSWORD('$_POST[password]')";
	} else {
		$sql	= "SELECT * FROM ".TABLE_PREFIX."members WHERE login='$_POST[login]' AND PASSWORD(password)=PASSWORD('$_POST[password]')";
	}
	$result	= mysql_query($sql, $db);
	if ($row = mysql_fetch_assoc($result)) {
		$_SESSION['member_id']	= intval($row['member_id']);
		$_SESSION['status']		= USER_CLIENT;
		$_SESSION['login']	    = $row['login'];
		$_SESSION['lang']		= $row['language'];
		
		$_SESSION['course_id']  = 0;

		if (defined('AT_PATH') && AT_PATH && $_POST['site'] == "atutor") {
				$_SESSION['valid_user']	= true;
				header ('Location: '.AT_PATH.'bounce.php?course=0');
				exit;
		} else {
			if (!defined('EUSA') || !EUSA || ($row['eusa'] != '0000-00-00')) {
				header('Location: index.php');
				exit;
			}
			else {
				header('Location: terms.php');
			}
			exit;
		}	
		exit;

	} else {
		$error = E_BAD_LOGIN_INFO;
	}
}

if (isset($_SESSION['member_id'])) {
	$sql = "DELETE FROM ".TABLE_PREFIX."users_online WHERE member_id=$_SESSION[member_id]";
	$result = @mysql_query($sql, $db);
}
unset($_SESSION['member_id']);
unset($_SESSION['status']);
unset($_SESSION['login']);
unset($_SESSION['group_id']);
unset($_SESSION['show_feedback']);
unset($_SESSION['courtyard_priv']);
session_write_close();

$onload = 'onload="document.form.login.focus()"';
require(AC_INCLUDE_PATH.'pub/header.inc.php');

?>
<br /><br /><br /><br />
<?php
	if (isset($error)) {
		print_errors($error);
	}

if (isset($_GET['f'])) {
	print_feedback($_GET['f']);
}
?>
<br />

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
	<table border="0" cellspacing="0" cellpadding="2" align="center" class="box">
	<tr>
		<th colspan="4" class="box"><h3><?php echo _AC('member_sign_in'); ?></h3></th>
	</tr>
	<tr>
		<td colspan="4" style="border-left: 2px solid white; border-right: 2px solid white; border-top: 2px solid white;"><img src="images/clr.gif" height="0" width="0" alt="" /></td>
	</tr>
	<tr>
		<td rowspan="3" style="border-left: 2px solid white;" valign="top">&nbsp;<img src="images/fingerprint.gif" width="40" height="56" alt="test" />&nbsp;&nbsp;&nbsp;</td>
		<td colspan="3" style="border-right: 2px solid white;">&nbsp;&nbsp;<br /><br /></td>
	</tr>
	<tr>
		<td align="right"><label for="username"><b><?php echo _AC('username'); ?>:</b></label></td>
		<td align="left"><input type="text" name="login" class="input" size="15" id="username" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td style="border-right: 2px solid white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
	</tr>
	<tr>
		<td align="right"><label for="password"><b><?php echo _AC('password'); ?>:</b></label></td>
		<td align="left"><input type="password" name="password" class="input" size="15" id="password" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>

<?php
if (defined('AT_PATH') && AT_PATH) {
	echo '<tr><td></td><td align="right"><b>'._AC('use').':</b></td>';
	echo '<td align="left"><input type="radio" name="site" value="atutor" checked="checked" id="at" /><label for="at">ATutor '._AC('account').'</label></td></tr>';
	echo '<tr><td></td><td></td><td align="left"><input type="radio" name="site" value="acollab" id="ac" /><label for="ac">ACollab '._AC('account').'</label></td></tr>';
}
?>
	
	<tr>
		<td style="border-left: 2px solid white;">&nbsp;</td>
		<td colspan="2" align="right"><br /><input type="submit" name="submit" value="<?php echo _AC('sign_in'); ?>" class="submit" onfocus="this.className='submit highlight'" onblur="this.className='submit'" /><br /><br /></td>
		<td style="border-right: 2px solid white;">&nbsp;</td>
	</tr>
	</table>
</form>
<br />
<?php
	require(AC_INCLUDE_PATH . 'html/languages.inc.php');

	require(AC_INCLUDE_PATH.'pub/footer.inc.php');
?>
Return current item: ACollab