<?php
//session_start();
function start_session($session_name, $secure) {
	
	$httponly = true;
	//$secure 	= true; //new
	$secure 	= false;
	$session_hash = 'sha512'; // Hash algorithm to use for the session. (use hash_algos() to get a list of available hashes.)
 
   		
   	if (in_array($session_hash, hash_algos())) {
      // Set the has function.
      	ini_set('session.hash_function', $session_hash);
  	 }
   // How many bits per character of the hash.
   // The possible values are '4' (0-9, a-f), '5' (0-9, a-v), and '6' (0-9, a-z, A-Z, "-", ",").
   
   		ini_set('session.hash_bits_per_character', 5);
   		ini_set('session.use_only_cookies', 1);  // Force the session to only use cookies, not URL variables.
 		ini_set('session.use_strict_mode', 1); //use strict mode
		ini_set("session.cookie_httponly",true);
		ini_set('session.entropy_file', "/dev/urandom" ); //(better entropy source)
		ini_set('session.entropy_length', 512);
		
		//ini_set('session.save_path', '/home/mb5in2co3jnw/additional_domains/k2-softwaresystems.co.uk/session_data1');
		
		
		//session_save_path('/home/mb5in2co3jnw/additional_domains/k2-softwaresystems.co.uk/session_data/'); 
		// Forces sessions to only use cookies.
    	if (ini_set('session.use_only_cookies', 1) === FALSE) {
        	header("Location: ../error.php?err=Could not initiate a safe session (ini_set)");
        	exit();
    	} //new
	
	

	 // Get session cookie parameters 
   	$cookieParams = session_get_cookie_params(); 
	// Set the parameters
  	session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); 
  
   	// Change the session name 
   	session_name($session_name);
  
	session_start(); // Start the php session
	//session_regenerate_id(true); // regenerated the session, delete the old one.    
	
	if (!(isset($_SESSION['valid_user']))) {

	session_regenerate_id(true);
	
	// Grab current session ID and close both sessions to allow other scripts to use them
	$newSession = session_id();
	session_write_close();

	// Set session ID to the new one, and start it back up again
	session_id($newSession);
	session_start(); // Start the php session
	}


}
start_session('_s', false);



if ((isset($_SESSION['valid_user']) && isset($_SESSION["pepper"]) )) {
	
	$user_id = $_SESSION["userid"];
	/*
		$query_rs_user = sprintf("SELECT * FROM user where id '$user_id'");
		$rs_user = mysqli_query($query_rs_user, $con_safety) or die(mysqli_error());
		$row_rs_user = mysqli_fetch_assoc($rs_user);
		$totalRows_rs_user = mysqli_num_rows($rs_user);
		*/
		echo  "TEST";

		if($_SESSION["pepper"] <> $row_rs_user["pepper_id"])
		{
			header ("Location: logout.php");
			exit;
			
		}
		else
		{
			
			header ("Location: firstpage.php");
			exit;
		}
}

?>
<!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">
<head>
<title>Safety Reporting</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<link href="atomohost/default.css" rel="stylesheet" type="text/css"/>
<link href="buttons.css" rel="stylesheet" type="text/css" media="screen"/>

<style type="text/css">
<!--


-->
</style>
<style type="text/css">
<!--

.btn { display: block; position: relative; background: #aaa; padding: 5px; float: left; color: #fff; text-decoration: none; cursor: pointer; }
.btn * { font-style: normal; background-image: url(images/btn2.png); background-repeat: no-repeat; display: block; position: relative; }
.btn i { background-position: top left; position: absolute; margin-bottom: -5px;  top: 0; left: 0; width: 5px; height: 5px; }
.btn span { background-position: bottom left; left: -5px; padding: 0 0 5px 10px; margin-bottom: -5px; }
.btn span i { background-position: bottom right; margin-bottom: 0; position: absolute; left: 100%; width: 10px; height: 100%; top: 0; }
.btn span span { background-position: top right; position: absolute; right: -10px; margin-left: 10px; top: -5px; height: 0; }
 
* html .btn span,
* html .btn i { float: left; width: auto; background-image: none; cursor: pointer; }
 
.btn.blue { background: #2ae; }
.btn.green { background: #9d4; }
.btn.pink { background: #e1a; }

.btn.red { background:#F00; }

.btn:hover { background-color: #a00; }
.btn:active { background-color: #444; }
.btn[class] {  background-image: url(images/shade.png); background-position: bottom; }
 
* html .btn { border: 3px double #aaa; }
* html .btn.blue { border-color: #2ae; }
* html .btn.green { border-color: #9d4; }
* html .btn.pink { border-color: #e1a; }
* html .btn.red { border-color: #FFF; }


* html .btn:hover { border-color: #a00; }
#outPopUp {
  position: absolute;
  width: 300px;
  height: 100px;
  z-index: 15;
  top: 25%;
  left: 85%;
  margin: -100px 0 0 -150px;
  background:white;

  border-width: 15px; border-style: solid; border-color:#003399;

   


}
-->
</style>
 
<script language="javascript">
function goFocus(){
document.getElementById("user").focus();
}
</script>
<SCRIPT TYPE="text/javascript">
<!--
function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}
//-->
</SCRIPT>

</head>

<body onLoad="goFocus()">
    <?php include("header2.php"); ?>
  

<div id="content">
	<div id="main">
	
	</div>
	<div id="sidebar">
		<div id="login" class="boxed">
			<h2><font color="#FFFFFF" face="Verdana, Geneva, sans-serif"><table width="220"><td bgcolor="#003399"></h2>
			&nbsp;&nbsp;Account Login</td></table></font></h2>
			<div class="content">
			      <form name="form1" method="post" action="login_check.php">
                  <input type="hidden" name="testdb" value="<?php /*echo $GET["testdb"];*/ ?>" />

				
                	<fieldset>
					<legend>&nbsp;&nbsp;Sign-In&nbsp;&nbsp;</legend>
					<label for="user">User ID:</label>
					<input  type="text" id="user" name="user" value="" />
					<label for="pass">Password:</label>
					<input  type="password" name="pass" value="" onKeyPress="return submitenter(this,event)"/>
				       <p><big style="font-size: 230%;"><a href="#" class="btn blue"  onclick="javascript:form1.submit()" >Sign In</a></big></p>  
                       <!-- <input name="" type="submit" class="button" value="Sign In" />-->
                      


					
					</fieldset>
				</form>
           
			</div>
		</div>

		
	</div>
	
	<div id="outPopUp" stye="width:800px; margin:0 auto;">	
	<p>
		<br/>&nbsp;&nbsp;
		To request a new account, please click <a href="https://servicedesk.renold.com/HEAT/Modules/SelfService/#serviceCatalog/request/73756A3F07EA494EBEA6583E0511379D">Here</a></p>
		
	</div>
      
    
</div>


</body>
</html>



