-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
174 lines (166 loc) · 7.5 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
session_start();
include "include/config.php";
$is_login = isset($_SESSION["user_loginid"]);
$is_login ? $page_title = "UserPage | " . SITE_NAME : $page_title = "Login | " . SITE_NAME;
include "include/header.php";
$result = $mysqli->query("SELECT * FROM `users` WHERE `user_loginid`='" . $_SESSION["user_loginid"] . "';");
while ($row = $result->fetch_assoc()) {
$user_loginid = $row["user_loginid"];
$user_mail = $row["user_mail"];
$user_lastlogin = $row["user_lastlogin"];
$user_lastlogin_failure = $row["user_lastlogin_failure"];
$user_created = $row["user_created"];
}
if ($user_lastlogin === "0000-00-00 00:00:00") $user_lastlogin = "(記録なし)";
if ($user_lastlogin_failure === "0000-00-00 00:00:00") $user_lastlogin_failure = "(記録なし)";
if ($user_created === "0000-00-00 00:00:00") $user_created = "(記録なし)";
?>
<?php if ($is_login) : ?>
<div class="ui middle aligned center aligned grid">
<div class="column" style="text-align: left;">
<h2 class="ui teal image header">
<img src="<?= LOGO_IMAGE ?>" class="image">
<div class="content">
<?= $page_title ?>
</div>
</h2>
<div class="ui segment">
<h2 class="ui center aligned icon header">
<i class="circular users icon"></i>
<p><?= $user_loginid ?></p>
</h2>
<div class="ui relaxed divided list">
<div class="item">
<i class="big teal envelope outline icon"></i>
<div class="content">
<div class="header">Mail address</div>
<div class="description"><?= $user_mail ?></div>
</div>
</div>
<div class="item">
<i class="big teal calendar alternate outline icon"></i>
<div class="content">
<div class="header">最終ログイン日時</div>
<div class="description"><?= $user_lastlogin ?></div>
</div>
</div>
<div class="item">
<i class="big teal calendar times outline icon"></i>
<div class="content">
<div class="header">最終ログイン失敗日時</div>
<div class="description"><?= $user_lastlogin_failure ?></div>
</div>
</div>
<div class="item">
<i class="big teal history icon"></i>
<div class="content">
<div class="header">登録日時</div>
<div class="description"><?= $user_created ?></div>
</div>
</div>
</div>
</div>
<div style="margin-bottom: 1em;">
<a href="logout.php" class="ui fluid large button">ログアウト</a>
</div>
<div style="text-align: center;">
<a href="https://github.com/nekocodeX/WebNFC-Auth" target="_blank" class="ui labeled icon button">
<i class="github icon"></i>
GitHub Repo
</a>
<p class="ver"><?= VERSION ?></p>
</div>
</div>
</div>
<?php else : ?>
<div class="ui middle aligned center aligned grid">
<div class="column" style="text-align: left;">
<h2 class="ui teal image header">
<img src="<?= LOGO_IMAGE ?>" class="image">
<div class="content">
<?= $page_title ?>
</div>
</h2>
<div class="ui segment">
<form action="checklogin.php" method="post" class="ui form">
<div class="field">
<label><i class="user outline icon"></i> Login ID</label>
<div class="ui corner labeled input">
<input type="text" pattern="^[a-zA-Z0-9_-]{3,15}$" name="user_loginid" placeholder="Login ID" required>
<div class="ui corner label">
<i class="red asterisk icon"></i>
</div>
</div>
</div>
<div class="field">
<label><i class="id card outline icon"></i> NFC SerialNumber</label>
<div class="ui corner labeled input">
<input type="password" pattern="^[a-fA-F0-9]{2}(:[a-fA-F0-9]{2})+$" name="user_sn" id="get_nfc_sn" placeholder="[読み取り開始] を押してNFCを端末にかざしてください" tabindex=" -1" readonly-mod required>
<div class="ui corner label">
<i class="red asterisk icon"></i>
</div>
</div>
<input type="button" id="start_nfc" value="読み取り開始" class="ui button">
<div class="ui slider checkbox">
<input type="checkbox" id="show_nfc_sn">
<label><i class="eye icon"></i> シリアルナンバーを確認</label>
</div>
</div>
<button type="submit" class="ui fluid large teal button">ログイン</button>
</div>
</form>
<div class="ui message" style="text-align: center;">
アカウントをお持ちでない場合:
<a href="signup.php">Signup</a>
</div>
<div style="text-align: center;">
<a href="https://github.com/nekocodeX/WebNFC-Auth" target="_blank" class="ui labeled icon button">
<i class="github icon"></i>
GitHub Repo
</a>
<p class="ver"><?= VERSION ?></p>
</div>
</div>
</div>
<script>
$("#start_nfc").on("click", function() {
try {
const reader = new NDEFReader()
reader.scan().catch(function() {
alert("[ERROR] " + "NFCへアクセスする権限がありません")
})
reader.addEventListener("error", ({
message
}) => {
switch (message) {
case "This tag is not supported.":
alert("[ERROR] このタグはサポートされていません")
break
default:
alert("[ERROR] " + message)
break
}
})
reader.addEventListener("reading", ({
serialNumber
}) => {
$("#get_nfc_sn").val([serialNumber])
})
} catch (error) {
alert("[ERROR] " + error)
}
})
$("#show_nfc_sn").change(function() {
if ($(this).prop("checked")) {
$("#get_nfc_sn").attr("type", "text")
} else {
$("#get_nfc_sn").attr("type", "password")
}
})
</script>
<?php endif; ?>
<?php
$mysqli->close();
include "include/footer.php";
?>