This repository was archived by the owner on Feb 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall.php
More file actions
217 lines (179 loc) · 7.45 KB
/
install.php
File metadata and controls
217 lines (179 loc) · 7.45 KB
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
<?php
/**
* BattlefieldTools.com BFP4F ServerTool
* Version 0.7.2
*
* Copyright (C) 2014 <Danny Li> a.k.a. SharpBunny
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('INSTALL_PAGE', true);
require_once('core/init.php');
$status = '';
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['server_ip']) && isset($_POST['server_port']) && isset($_POST['rcon_pass']) && isset($_POST['name']) && isset($_POST['profile_id']) && isset($_POST['username']) && isset($_POST['pass'])) {
sleep(2);
$errors = array( );
// Clean the post variables
foreach($_POST as $key => $value) {
$_POST[$key] = trim($value);
}
if(!@fsockopen($_POST['server_ip'], $_POST['server_port'], $cn, $cs, 3)) {
$errors[] = 'Could not connect to the server, please try again and check your serverinformation';
}
$data = @json_decode(@file_get_contents("http://battlefield.play4free.com/en/profile/soldiers/" . $_POST['profile_id']), true);
if(count($data['data']) == 0) {
$errors[] = 'Invalid ProfileID';
}
if(strlen($_POST['name']) < 5) {
$errors[] = 'Name has to be at least 5 characters';
}
if(strlen($_POST['username']) < 5) {
$errors[] = 'Username has to be at least 5 characters';
}
if(strlen($_POST['pass']) < 6) {
$errors[] = 'Password has to be at least 6 characters';
}
// Check errors and stuff
if(count($errors) == 0) {
$sql = replace(file_get_contents('SQL.TXT'), array(
'{%prefix%}' => $config['db_prefix'],
'{%sv_ip%}' => encrypt($_POST['server_ip']),
'{%sv_port%}' => encrypt($_POST['server_port']),
'{%sv_pass%}' => encrypt($_POST['rcon_pass']),
'{%profile_id%}' => $_POST['profile_id'],
'{%name%}' => $_POST['name'],
'{%username%}' => $_POST['username'],
'{%password%}' => hash('sha256', $_POST['pass']),
));
if($db->multi_query($sql)) {
$status = '<div class="alert alert-success alert-block"><h4><i class="fa fa-check"></i> Success!</h4><p>Installation succesful, please delete install.php and SQL.TXT<br /><br /><a href="' . HOME_URL . '">Continue »</a></p></div>';
} else {
$status = '<div class="alert alert-danger alert-block"><h4><i class="fa fa-times"></i> Oh oh!</h4><p>Installation failed (' . $db->error . '), please install the database manually using the following SQL:<br /><br /><textarea cols="150" rows="20" class="form-control">' . $sql . '</textarea></p></div>';
}
} else {
$status = '<div class="alert alert-danger alert-block"><h4><i class="fa fa-times"></i> Oh oh!</h4><p>The following error(s) occurred:</p><ul><li>' . implode('</li><li>', $errors) . '</li></ul></div>';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Installation | BattlefieldTools.com Servertool</title>
<meta charset="<?=$lang['lang_charset']?>" />
<meta name="author" content="BattlefieldTools.com" />
<link rel="icon" type="image/png" href="<?=HOME_URL?>panel/img/favicon.png" />
<link rel="stylesheet" href="<?=HOME_URL?>panel/css/bootstrap.min.css" />
<link rel="stylesheet" href="<?=HOME_URL?>panel/css/font-awesome.min.css" />
<link rel="stylesheet" href="<?=HOME_URL?>panel/css/default.css" />
<script src="<?=HOME_URL?>panel/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-header-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?=HOME_URL?>panel"><i class="fa fa-block fa-cog fa-spin blue"></i> BFP4F SERVERTOOL</a>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<h1 class="center"><i class="fa fa-wrench"></i> Battlefield Play4free Servertool</h1>
<h3 class="text-muted center">Installation</h3>
<hr />
<?php
if($status != '') {
?>
<?=$status?>
<?
} else {
?>
<form action="<?=HOME_URL?>install.php" method="post" class="form-horizontal">
<h3><i class="fa fa-hdd-o"></i> Server</h3>
<hr />
<div class="form-group">
<label class="col-sm-3 control-label"><i class="fa fa-hdd-o"></i> Server IP</label>
<div class="col-sm-9">
<input type="text" name="server_ip" class="form-control" autofocus required />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><i class="fa fa-hdd-o"></i> Server RCON port</label>
<div class="col-sm-9">
<input type="text" name="server_port" class="form-control" required />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><i class="fa fa-lock"></i> Server RCON password</label>
<div class="col-sm-9">
<input type="password" name="rcon_pass" class="form-control" required />
</div>
</div>
<br />
<h3><i class="fa fa-user"></i> Account</h3>
<hr />
<div class="form-group">
<label class="col-sm-3 control-label"><i class="fa fa-user"></i> Public name</label>
<div class="col-sm-9">
<input type="text" name="name" class="form-control" required />
<span class="help-block">
<small>E.g. SharpBunny</small>
</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><i class="fa fa-user"></i> BFP4F Profile ID a.k.a. nucleusID</label>
<div class="col-sm-9">
<input type="text" name="profile_id" class="form-control" required />
<span class="help-block">
<small>E.g. (http://battlefield.play4free.com/en/profile/2567963101) => 2567963101</small>
</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><i class="fa fa-user"></i> Username</label>
<div class="col-sm-9">
<input type="text" name="username" class="form-control" required />
<span class="help-block">
<small>E.g. sharpbunny</small>
</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><i class="fa fa-lock"></i> Password</label>
<div class="col-sm-9">
<input type="password" name="pass" class="form-control" required />
<span class="help-block">
<small>At least 6 characters</small>
</span>
</div>
</div>
<br />
<div class="form-group">
<div class="col-sm-5 col-sm-offset-7">
<button type="submit" class="btn btn-block btn-success">Install! <i class="fa fa-arrow-right fa-right"></i></button>
</div>
</div>
</form>
<?php
}
?>
</div>
</div>
<?php include(CORE_DIR . '/cp_footer.php'); ?>