SIM0010.php 3.13 KB
<?PHP 
//*****************************************************************************
//* プログラム名:ユーザログイン
//* プログラムID:SIM0010.php
//* 機能        :グループログインチェック+ユーザログイン画面
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");
include("./inc/session_start.inc");
include("./inc/dbcon_group.inc");
include('./inc/smarty.conf');
include('./inc/const.inc');

if(trim($_POST["gid"]) != "" && trim($_POST["gpw"]) != ""){
	$gid = trim($_POST["gid"]);
	$gpw = trim($_POST["gpw"]);
}else{

	header("Location:".$DEFARR[1]);
	exit;
}

$strSQLGroup="SELECT * From group_inf where group_id='".$gid."' and group_pw='".$gpw."'";
$objRecGroup = pg_exec($strSQLGroup);
if($objRecGroup==false){
	echo("SQL実行に失敗しました(SELECT)");
	exit;
}
session_unregister("PHP_DB_NAME");	
session_unregister("PHP_GROUP_NAME");

if(pg_numrows($objRecGroup) > 0){
	$objGroup = pg_fetch_object($objRecGroup, 0);
	$PHP_DB_NAME = $objGroup->db_name;
	$PHP_GROUP_NAME = $objGroup->group_name;
	session_register("PHP_DB_NAME");	
	session_register("PHP_GROUP_NAME");

	//クッキーセット
	setcookie("cookie_GroupID",$gid,time() + 604800);
	setcookie("cookie_GroupPW",$gpw,time() + 604800);

}else{
	if ($_POST["backurl"] == hp) {
		header("Location:".$DEFARR[1]);
	}else{
		header("Location:./index.php?err=1");
	}
	exit;
}

//最終ログイン時間
$lastDate = date("Y/m/d H:i:s");

$strSQLGroup="UPDATE group_inf SET last_login = '". $lastDate ."' WHERE group_id='".$gid."' AND group_pw='".$gpw."'";
$objRecGroup = pg_exec($strSQLGroup);
if($objRecGroup==false){
	echo("SQL実行に失敗しました(SELECT)");
	exit;
}


//ユーザリスト
include("./inc/dbcon.inc");
$strSQL = "select * from user_inf order by disp_rank";
$objRec = pg_exec($strSQL);
if($objRec==false){
	echo("SQL実行に失敗しました(SELECT)");
	exit;
}
$userCMB = "";
for ($intCnt = 0; $intCnt < pg_numrows($objRec); $intCnt++) {
	$objUser = pg_fetch_object($objRec, $intCnt);
	$userCMB .= '<option value="'.$objUser->user_seq.'"';
	if(($objUser->user_seq == $_COOKIE["cookie_user_cd"])){
		 $userCMB .= " selected"; 
	}
	$userCMB .= '>'.$objUser->user_namekj."</option>";
}

//HTMLヘッダの書き出し
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html>
<head>
	<meta http-equiv="content-type" content="text/html; cahrset=euc-jp">
	<meta http-equiv="content-style-type" content="text/css">
	<meta name="robots" content="noindex, nofollow">
	<title><?PHP  echo($PHP_SYSNAME); ?></title>
	<link rel="stylesheet" href="./templates/SIMlite.css" type="text/css" />
</head>
<?PHP 

//デバッグ
//echo("gid:".$gid." gpw:".$gpw." useq:".$useq." upw:".$upw." <br>" );

//define
//[0]システムURL、[1]HP URL、[2]マニュアルURL、[3]MTC HP URL、[4]マスタメールアドレス、
//[5]期間区分名、[6]大区分名、[7]小区分名、[8]支出名、[9]収入名、[10]消費税率(文字型)
$o_smarty->assign('DEFARR',$DEFARR);

$o_smarty->assign('PHP_SYSNAME',$PHP_SYSNAME);
$o_smarty->assign('PHP_GROUP_NAME',$PHP_GROUP_NAME);
$o_smarty->assign('userCMB',$userCMB);
$o_smarty->assign('gid',$gid);
$o_smarty->assign('gpw',$gpw);
$o_smarty->display('SIM0010.tpl');
?>