<?php
require_once("../../lib/func.php");
define("MY_DIR", relpath_to_abspath("."));
define("APP_ID", "LoginTest");
define("LOGIN_TABLE", check_login_table(APP_ID));
// セッションを開始する
start_my_session();
// ログイン状態を取得
$user_id = peek_session_var("user_id");
if ($user_id > 0) {
$safe_name = htmlspecialchars(peek_session_var("user_name") ?? "");
$status = "ログイン中: ${safe_name}<br>\n";
}
else {
$status = "あなたは現在ログインしていません。<br>\n";
}
// ユーザーのデータを取得
$table = "";
foreach (get_table_data(DB_NAME, LOGIN_TABLE) as $data) {
$id = $data["id"];
$name = htmlspecialchars(db_decode($data["name"]));
$pass = htmlspecialchars(db_decode($data["pass"]));
$total = get_user_var(APP_ID, $id, "total") ?? 0;
$input = "<input type=\"checkbox\" name=\"ids[]\" value=\"$id\">";
$table .= "<tr><td>$input<td>$id<td>$name<td>$pass<td>$total</tr>\n";
}
// 追加メッセージがあれば取得
$message = get_session_var("message") ?? "";
if ($message != "") {
$message = "<span style=\"color: blue;\">$message</span><br>\n";
}
// HTTPヘッダの出力
header("Cache-Control: no-cache"); // ブラウザにキャッシュさせない
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>管理室</title>
<script>
function copy(src) {
for (var e of src.form.elements) e.checked = src.checked;
}
</script>
</head>
<body>
<form method="POST" action="<?= MY_DIR ?>/s01.php">
<p>■<a href="<?= MY_DIR ?>/s01.php">簡単なログイン処理</a> > 管理室</p>
<?= $status ?>
<table border="1">
<tr><th><input type="checkbox" onclick="copy(this);"><th>ID<th>名前<th>パスワード<th>合計点</tr>
<?= $table ?>
</table>
<?= $message ?>
<p><button name="cmd" value="deluser">チェックしたユーザーを削除する</button></p>
</form>
</body>
</html>