-
Notifications
You must be signed in to change notification settings - Fork 0
/
history.php
259 lines (243 loc) · 7.05 KB
/
history.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?
$perpage = 50;
if (basename($_SERVER['SCRIPT_NAME']) != $filename)
die("請勿直接使用絕對路徑");
$ebs_id = $_COOKIE['id'];
$ebs_pwd = $_COOKIE['pwd'];
if (!($User = checkpwd($ebs_id, $ebs_pwd, $user_dat)))
msgBox("?","帳號或密碼錯誤,請重新登入");
if (file_exists("$dat_dir/$ebs_id/history"))
$data = array_reverse(file("$dat_dir/$ebs_id/history"));
else
$data = array();
if ($_GET['job'] == "view")
{
}
else if ($_GET['job'] == "delete")
{
file_put_contents("$dat_dir/$ebs_id/history", "");
echo iconv("big5","UTF-8","歷史紀錄已清空");
}
else
{
include_once("header.php");
$page = $_GET['page'];
$data_count = count($data);
$pages = ceil($data_count/$perpage);
if ($page > $pages) $page = $pages;
else if ($page < 1) $page = 1;
$min_page = $page;
$max_page = $page + 9;
if ($min_page > 2)
{
$min_page -= 2;
$max_page -= 2;
}
else if ($min_page > 1)
{
$min_page--;
$max_page--;
}
while ($max_page > $pages)
{
$max_page--;
$min_page--;
}
if ($min_page < 1) $min_page = 1;
$from = ($page-1)*$perpage;
$to = $page*$perpage-1;
if ($data_count < $to) $to = $data_count;
?>
<style type="text/css">
.pagebtn {border-width:1px 0px 1px 0px; border-style: solid; border-color:#222; background-color:#555}
.pagebtn a {float:left; line-height:26px; color:#aaa; text-decoration:none; padding:0px 5px}
.pagebtn a:hover {background-color:#999}
.pagebtn b {float:left; line-height:26px; color:#ccc; background-color:#222; padding:0px 5px}
.pagebtn em {float:left; line-height:26px; background-color:#353535; color:#cc5; font-style:normal; padding:0px 9px}
.Td0 {
background-color: #aaa;
padding:3px;
cursor:hand;
}
.Td1 {
background-color: #999;
padding:3px;
cursor:hand;
}
.date {
font-family:tahoma;
font-size:11px;
color:#335;
width:110px;
}
.auth {
font-weight:bold;
color:#800;
}
.noman {
margin-left:5px;
color:#AA5;
}
.vsopp {
width:90px;
margin-left:5px;
color:#333;
}
.err {
font-weight:bold;
margin-left:5px;
color:#800;
}
.win {
color:#00A;
}
.draw {
color:#CCC;
}
.lose {
color:#0A0;
}
.no {
width:25px;
color:#252;
text-align:right;
}
</style>
<script type="text/javascript" language="javascript">
var http_request = false;
function makeRequest(url)
{
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
http_request.overrideMimeType('text/xml');
}
else if (window.ActiveXObject)
{ // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!http_request)
{
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('GET', url, true);
http_request.send(null);
}
function alertContents()
{
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
alert(http_request.responseText);
location.reload();
}
else
alert("傳送要求時發生錯誤");
}
}
function show(i)
{
var w = 380, h = 450;
var l = (screen.width - w)/2;
var t = (screen.height - h)/2;
if (navigator.appName == "Microsoft Internet Explorer")
window.showModalDialog("?show_battle&index="+i+"&num="+Math.random(),self,"center:yes;resizable:no;scroll:on;status:no;dialogWidth:"+w+"px;dialogHeight:"+h+"px;dialogLeft:"+l+"px;dialogTop:"+t+"px");
else
window.open("?show_battle&index="+i,'newWin',"modal=yes,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes,width="+w+",height="+h+",left="+l+",top="+t);
}
</script>
<div class="box">
<div style="width:100%; padding:5px 0px 5px 0px; background-color:#aaa; text-align:center">History</div>
<div class="pagebtn">
<em><?=$pages?></em>
<?
if ($page != 1)
echo "<a href='#' onclick=\"location.href='?history&page=1'\">|<</a>";
if ($page > 10)
echo "<a href='#' onclick=\"location.href='?history&".($page-10)."'\">‹‹</a>";
if ($page > 1)
echo "<a href='#' onclick=\"location.href='?history&".($page-1)."'\">‹</a>";
for ($i=$min_page; $i<=$max_page; ++$i)
if ($i == $page)
echo "<b>$i</b>";
else
echo "<a href='#' onclick=\"location.href='?history&page=$i'\">$i</a>";
if ($page < $pages)
echo "<a href='#' onclick=\"location.href='?history&page=".($page+1)."'\">›</a>";
if ($page+10 < $pages)
echo "<a href='#' onclick=\"location.href='?history&page=".($page+10)."'\">››</a>";
if ($page != $pages)
echo "<a href='#' onclick=\"location.href='?history&page=$pages'\">>|</a>";
?>
<div style="clear:both"></div>
</div>
<div style="margin:0px; height:390px; Overflow:auto; text-align:left">
<?
for ($i=$from; $i<$to; ++$i)
{
$history_dat = split(";", $data[$i]);
echo "\t<div class='Td".($i%2)."'".(($history_dat[0] == 1)?" onclick='show($i)'":"").">\n";
echo "\t\t<span class='no'>".($i+1)."</span>\n";
echo "\t\t<span class='date'>".$history_dat[1]."</span>\n";
switch ($history_dat[0])
{
case '1':
switch ($history_dat[18])
{
case '1':
case '4':
echo "\t\t<span class='win'>獲勝</span>\n";
break;
case '2':
echo "\t\t<span class='draw'>平手</span>\n";
break;
case '3':
case '5':
echo "\t\t<span class='lose'>戰敗</span>\n";
break;
default:
echo "\t\t<span class='err'>未知</span>\n";
}
echo "\t\t<span class='vsopp'>".$history_dat[2]."</span>\n";
break;
case '2':
echo "\t\t<span class='auth'>認證通過 [".$history_dat[2]."]</span>\n";
break;
case '3':
echo "\t\t<span class='err'>未知情況錯誤</span>\n";
break;
case '4':
echo "\t\t<span class='noman'>無此對手 <b>".$history_dat[2]."</b></span>\n";
break;
default:
echo "未知訊息\n";
}
echo "\t</div>\n";
}
if ($data_count == 0)
echo "<table style='height:100%;'><tr><td style='font-size:16px; color:#CC0'>無 記 錄</td></tr></table>";
?>
</div>
<div style="margin:5px auto">
<input type="button" value="重整" class="submit" onmouseover="this.className='submitH'" onmouseout="this.className='submit'" onclick="location.reload()">
<input type="button" value="清空" class="submit" onmouseover="this.className='submitH'" onmouseout="this.className='submit'" onclick="if (confirm('確定要清空?')) makeRequest('?history&job=delete');">
<input type="button" value="登入紀錄" class="submit" onmouseover="this.className='submitH'" onmouseout="this.className='submit'" onclick="location.href='?login_history'">
<input type="button" value="主頁" class="submit" onmouseover="this.className='submitH'" onmouseout="this.className='submit'" onclick="location.href='?config'">
</div>
</div>
<?
include("footer.php");
}
?>