<?php
/*
 *
 * sflog!
 * Copyright (C) 2005 Alberto Sfolcini <a.sfolcini@gmail.com>
 *
 * This file is a part of sflog!.
 *
 * sflog! 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.
 *
 * sflog! 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */
   
  require_once(dirname(__FILE__)."/../../cms/Auth.class.php");
  
  $ok = 0;
  if (isset($_POST['userID'])){
  	if (!($_POST['userID']=='')){
		$auth = new Auth();
	  	
	  	$userID 	  = $_POST['userID'];
	  	$password     = $_POST['password'];  		  		  		

  		if ($auth->authorize($userID,$password)){
			$ok = 1;
			// redirect to first page
			$relative_url = "../index.php";
			//header ("Location: http://".$HTTP_SERVER_VARS['HTTP_HOST'] .dirname($HTTP_SERVER_VARS['PHP_SELF']) ."/".$relative_url); 
			echo '<META HTTP-EQUIV="Refresh" Content="0; URL=http://'.$HTTP_SERVER_VARS['HTTP_HOST'].dirname($HTTP_SERVER_VARS['PHP_SELF']).'/'.$relative_url.'">'; exit;
		} else {
			$ok = 2;
		}
		
  	}
  } 
?>	
<FORM action="<?=$_SERVER['PHP_SELF']?>" method="POST">
	<table cellspacing="0" cellpaddgin="0" border="0">
		<tr>
			<td><b>user ID</b></td>
			<td><input type="TEXT" name="userID" size="16"></td>
		</tr>
		<tr>
			<td><b>password</b>&nbsp;</td>
			<td><input type="PASSWORD" name="password" size="16"></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>
				<input type="SUBMIT" value="Login" size="1">
			</td>
		</tr>
	</table>
</FORM>

<?php
	if ($ok==2){
		print("<font color=\"red\"<b><i>Access denied!</i></b></font>");
	}
?>