8 require_once(dirname(__FILE__) .
'/../../lib/Controller.php');
9 require_once(dirname(__FILE__) .
'/LoginModel.php');
28 $this->param[
'base'] = dirname(__FILE__);
30 if (empty($this->param[
'act'])) {
33 switch ($this->param[
'act']) {
34 case 'check': $this->
_check();
break;
35 default: $this->
_init();
break;
43 $_SESSION[
'minfo'] = [];
46 $_SESSION[
'tseed'] = (string)random_int(1111111111, 9999999999);
48 $this->viewName =
'login';
49 $this->token = password_hash($_SESSION[
'tseed'], PASSWORD_DEFAULT);
54 if ((
int)date(
'Ymd') > (
int)str_replace(
'-',
'',
EXPIRE)) {
55 $this->rest = json_encode([
'sts' =>
'NG',
'err' =>
'有効期限切れです。']);
59 if (!password_verify($_SESSION[
'tseed'], $this->param[
'token'])) {
60 $this->rest = json_encode([
'sts' =>
'NG',
'err' =>
'不正トークン']);
64 if (!$this->model->chkPasswd($this->param[
'account'], $this->param[
'passwd'])) {
65 $this->rest = json_encode([
'sts' =>
'NG',
'err' =>
'アカウン名またはパスワードに誤りがあります。']);
69 $info = $this->model->getMemberInfo($this->param[
'account']);
71 if (empty($info[
'role'])) {
72 $this->rest = json_encode([
'sts' =>
'NG',
'err' =>
'メンバー情報が見つかりません。']);
76 $info[
'bcnt'] = $this->model->cntBasic($info[
'mid']);
78 if ($info[
'bcnt'] == 1) {
79 $info[
'bid'] = $this->model->getBid($info[
'mid']);
84 $_SESSION[
'minfo'] = $info;
86 if ($info[
'role'] ==
'root') {
87 $this->rest = json_encode([
'sts' =>
'OK',
'url' => $this->param[
'url_base'],
'func' =>
'RootMenu']);
89 $this->rest = json_encode([
'sts' =>
'OK',
'url' => $this->param[
'url_base'],
'func' =>
'UserMenu']);