Location: PHPKode > projects > CoreAsset > coreasset/index.php
<?php
session_start();
$fname="status.txt";
$fp=fopen($fname,"r");
if($fp)
	 {
	  $stat=fgets($fp);
	  if($stat=="false")
	       	echo "<script language='Javascript'>location='initial.php';</script>";
	}
//session_start();
require_once("lib/inc.php");
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$title	  ="::: Login Page :::";
$smarty->assign('title',$title);
// Date & Time to be dispalyed on the header 
$date_time	= date("h:i:s A")." ".date("d-m-Y");
$smarty->assign('date_time',$date_time);
// Done
$mes = "";


if(isset($_SESSION['common_login']) && !isset($_REQUEST['act']))
{
$smarty->assign("login_user",$_SESSION['user_name']);
$smarty->assign("login_password",$_SESSION['user_password']);
$smarty->assign("common_log",1);
}

//echo"after";
if(isset($_GET['act']))
{

 if($_GET['act']=="login")
 {
  $login                   = $_POST['userid'];
  $password                = base64_encode($_POST['password']);
  
	
  $num = $database->no_of_rows("select * from asset_users where login='$login' and password='$password'");

  if($num > 0)
  {
   $row                 = $database->get_from_database("select * from asset_users where login='$login' and password='$password'");
   
   $login_status				= $row['login_status'];
   
/*   $sess_file = session_save_path()."/sess_".$se_id;
   if(file_exists($sess_file))
   {
	   redirect ("index.php", "Error13");
   }
   else
   {
	   session_start();
	   $_SESSION['user_id'] = $row['user_id'];
	   $_SESSION['status']  = $row['status'];
	   $sess_id				= session_id();
	   $database->update("update asset_users set last_login=NOW(), login_sid='$sess_id' where user_id='$_SESSION[user_id]'");
	   redirect ("welcome.php", "Welcome");
   }
   */
// ************ Check here for the new change ************
//   if($login_status==1)
//   {
//	   redirect ("index.php", "Error13");
  // }
//   else
  // {
	  
	   $_SESSION['user_id'] = $row['user_id'];
	   $_SESSION['status']  = $row['status'];
	   $sess_id				= session_id();
	   $database->update("update asset_users set last_login=NOW(), login_status='1' where user_id='$_SESSION[user_id]'");
	   redirect ("welcome.php", "Welcome");
   //}	
  }
  else
  {
	redirect ("index.php", "Error1");
  }
 }

 if($_GET['act']=="Error1")
 {
  $smarty->assign('mes',"Invalid User ID / Password !");
 }

 if($_GET['act']=="Error2")
 {
  $smarty->assign('mes',"You don't have the Privillage. Please Login ... !");
 }
 if($_GET['act']=="Error13")
 {
  $smarty->assign('mes',"Sorry, this User is already Logged in ... !");
 }
 if($_GET['act']=="Logout")
 {
  $smarty->assign('mes',"You had Successfully Logged out ...");
 }
}

$smarty->display('index.tpl');

?>
Return current item: CoreAsset