<?php

$baseDir = dirname(__FILE__);
// ログクラス
require_once($baseDir.'/logger.php');
$logger = new logger(basename(__FILE__));
// 設定
require_once($baseDir.'/../util/settingUtil.php');
$settingUtil = new settingUtil();
// 部品クラス
require_once($baseDir.'/../util/serverUtil.php');
$serverUtil = new serverUtil();
require_once($baseDir.'/../util/dbUtil.php');
//$dbutil = new dbUtil();
require_once($baseDir.'/../util/stringUtil.php');
$stringUtil = new stringUtil();
require_once($baseDir.'/../util/dateUtil.php');
$dateUtil = new dateUtil();
require_once($baseDir.'/../util/csvUtil.php');
require_once($baseDir.'/../util/getListUtil.php');
require_once($baseDir.'/../util/getValueUtil.php');
require_once($baseDir.'/../util/lockAP.php');	//Lock/Release
// 共通部
require_once($baseDir.'/commonSmarty.php');
require_once($baseDir.'/userException.php');
require_once($baseDir.'/../util/version.php');

require_once($baseDir.'/../util/loginUtil.php');

$versionUtil = new versionUtil();

$pdir = $serverUtil->getProductDir();
$p = $serverUtil->getUrlDocumentRoot();

//DB切り替えできるよ -------------------------
  //$p にはURLのディレクトリ名(liv_asp等)が入っている
  $mode = $p;   //ex:liv_asp

  $GLOBALS['SYSTEM_NO'] = $mode;
$logger->info("mode=".$mode);
  $dbutil = new dbUtil();
//DB切り替えできるよ -------------------------
$logger->info("db_ok");

// ==== アプリ設定 ===
  $GLOBALS['HOSP_SUB_DIR_ORG']	= $p;
  $GLOBALS['HOSP_SUB_DIR'] 			= "/".$p."/";

  $GLOBALS['COMPANY_NAME'] 			= $settingUtil->getBaseParam("COMPANY_NAME", $mode);  //会社名
  $GLOBALS['SYSTEM_NAME'] 			= $settingUtil->getBaseParam("SYSTEM_NAME", $mode);  //システム名
  $GLOBALS['ADMIN_SYSTEM_NAME'] = $settingUtil->getBaseParam("ADMIN_SYSTEM_NAME", $mode); //未使用
  $GLOBALS['SYSTEM_NAME_EN'] 		= $settingUtil->getBaseParam("SYSTEM_NAME_EN", $mode); //セッション変数に使用
  $GLOBALS["UPLOAD_DIR"]        = $settingUtil->getBaseParam("UPLOAD_DIR", $mode);  //未使用
  $GLOBALS['SYSTEM_ACCD'] 			= $settingUtil->getBaseParam("SYSTEM_ACCD", $mode);  //ACCD
  $GLOBALS['SYSTEM_VEND'] 			= $settingUtil->getBaseParam("SYSTEM_VEND", $mode);  //VEND

// @@@ ==== アプリ設定(サイト固有種) ===
  $GLOBALS['JAN_IMG_URL'] = "";
  $GLOBALS['NO_IMG_URL'] = "";

// === API URL ===
  $url = $serverUtil->getUrl();
  $GLOBALS['API_URL'] = $url . "/" . $GLOBALS['HOSP_SUB_DIR_ORG'] . "/api/";

  // === 開発環境課銅貨をチェック
  if( strcmp( $_SERVER["SERVER_NAME"], "walt" ) == "0" ){
  	$SYSMODE   = '0'; //社内(http)
  } else {
  	$SYSMODE   = '1';  //本番(https)
  }
  $GLOBALS['SYSMODE'] = $SYSMODE;
$logger->info("SYSMODE=".$SYSMODE);

session_start();

$sid = session_id();

$logger->info("sid=".$sid);

$loginUtil = new loginUtil($dbutil, $logger);
$logger->info("common.php>>");
$ret = $loginUtil->getsession($sid, $GLOBALS['SYSTEM_ACCD'], $GLOBALS['SYSTEM_VEND']);

$ret = $loginUtil->insApr331($sid);
$logger->info("common.php<<",$_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["PAGE_LINE"]);

$serverUtil->checkSession();

//index.phpの場合、apr331に記録 --------------------

// === create smarty class
$smarty = new CommonSmarty();

$_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["UNAGR_CNT"] = 0;

?>
