-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathreplay.php
executable file
·120 lines (102 loc) · 2.97 KB
/
replay.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
<?php
define('CURSCRIPT', 'game');
define('IN_REPLAY', TRUE);
require './include/common.inc.php';
$repid=$_GET['repid'];
if (!isset($repid)) { header("Location: winner.php"); exit(); }
//过滤repid
if (!(('0'<=$repid[0] && $repid[0]<='9') || ('a'<=$repid[0] && $repid[0]<='z') || $repid[0]=='.'))
{
header("Location: winner.php"); exit();
}
for ($i=1; $i<strlen($repid); $i++)
if (!(('0'<=$repid[$i] && $repid[$i]<='9') || $repid[$i]=='.'))
{
header("Location: winner.php"); exit();
}
if ('a'<=$repid[0] && $repid[0]<='z')
{
if (strpos($repid,'.')===false)
{
header("Location: winner.php"); exit();
}
$prefix = substr($repid,0,strpos($repid,'.')+1);
$repid = substr($repid,strpos($repid,'.')+1);
}
else $prefix = '';
$cn=0;
for ($i=0; $i<strlen($repid); $i++)
if ($repid[$i]=='.')
$cn++;
if ($cn>1) { header("Location: winner.php"); exit(); }
if (strlen($repid)>20) { header("Location: winner.php"); exit(); }
$repid = $prefix.$repid;
if ($cn==1)
{
if (!file_exists(GAME_ROOT.'./gamedata/replays/'.$repid.'.rep'))
{
if(!file_exists(GAME_ROOT.'./gamedata/replays/'.$repid.'.dat')){
$flag = \replay\get_replay_remote($repid);
if(!$flag) {
include template('no_replay');
exit();
}
}else{
unfold(GAME_ROOT.'./gamedata/replays/'.$repid.'.dat');
}
}
$rgnum=substr($repid,0,strpos($repid,'.'));
$arr=Array(substr($repid,strpos($repid,'.')+1));
}
else
{
if (!file_exists(GAME_ROOT.'./gamedata/replays/'.$repid.'.rep.index'))
{
if(!file_exists(GAME_ROOT.'./gamedata/replays/'.$repid.'.dat')){
include template('no_replay');
exit();
}else{
unfold(GAME_ROOT.'./gamedata/replays/'.$repid.'.dat');
}
}
$rgnum=$repid;
$arr=explode(',',file_get_contents(GAME_ROOT.'./gamedata/replays/'.$repid.'.rep.index'));
$narr=Array();
foreach ($arr as $key)
{
if ($key=='') continue;
$x=(int)$key;
if (file_exists(GAME_ROOT.'./gamedata/replays/'.$repid.'.'.$x.'.rep'))
array_push($narr,((string)$x));
}
$arr=$narr;
}
$replay_player_num_tot=count($arr);
if ($replay_player_num_tot==0)
{
include template('no_replay'); exit();
}
$rfullsz=0;
$repindexdata=Array();
foreach ($arr as $key)
{
$d=Array();
list($repdatalib,$repgnum,$repname,$repsz,$repopcnt,$jdata) = explode(',',file_get_contents(GAME_ROOT.'./gamedata/replays/'.$rgnum.'.'.$key.'.rep'));
$d=json_decode(base64_decode($jdata));
$d['pid']=$key;
$d['repname']=base64_decode($repname);
$d['repsz']=$repsz;
$d['repopcnt']=$repopcnt;
$d['repfileid']=$rgnum.'.'.$key;
if (!isset($d['color'])) $d['color']=\replay\get_ident_textcolor($d['repname']);
array_push($repindexdata,$d);
$rfullsz += ((double)substr($d['repsz'],0,-2));
}
$jrepindexdata=gencode($repindexdata);
$repdatalib=base64_decode($repdatalib);
//$repbg = 'gamedata/replays/'.$repid.'.rep.bmp';
\player\init_playerdata();
\player\parse_interface_profile();
$log = '';
include template('replay');
?>