This repository was archived by the owner on Sep 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.php
More file actions
205 lines (179 loc) · 7.96 KB
/
install.php
File metadata and controls
205 lines (179 loc) · 7.96 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
<?php
/**
* brAWebService
* Copyright (c) brAthena, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
// Caso o arquivo de configurações exista, então não permite que a instalação continue.
if(file_exists(dirname(__FILE__) . '/config.xml') === true)
exit;
// Verifica se os dados foram recebidos pelo POST.
if(empty($_POST) === false)
{
$xml = new SimpleXMLElement('<brAWebServerConfig></brAWebServerConfig>');
$xml->addChild('maintence', 'no');
$pdoServer = $xml->addChild('PdoServerConnection');
$pdoServer->addAttribute('user', $_POST['serviceUser']);
$pdoServer->addAttribute('pass', $_POST['servicePass']);
$pdoServer->addAttribute('connectionString', $_POST['serviceConnectionString']);
$pdoRagna = $xml->addChild('PdoRagnaConnection');
$pdoRagna->addAttribute('user', $_POST['ragnaUser']);
$pdoRagna->addAttribute('pass', $_POST['ragnaPass']);
$pdoRagna->addAttribute('connectionString', $_POST['ragnaConnectionString']);
$xml->addChild('maxGroupId', $_POST['maxGroupId']);
$acc = $xml->addChild('accountValidation');
$acc->addChild('username', $_POST['username']);
$acc->addChild('userpass', $_POST['userpass']);
$acc->addChild('sex', $_POST['sex']);
$acc->addChild('email', $_POST['email']);
$ssl = $xml->addChild('openSslSettings');
$ssl->addChild('password', $_POST['openSslPassword']);
$write = file_put_contents(dirname(__FILE__).'/config.xml', $xml->asXML());
if($write === false)
{
echo utf8_decode("OCORREU UM ERRO DURANTE A TENTATIVA DE ESCREVER AS CONFIGURAÇÕES.");
}
else
{
$pdo = new PDO($_POST['serviceConnectionString'], $_POST['serviceUser'], $_POST['servicePass']);
$pdo->exec(file_get_contents(dirname(__FILE__).'/Sql-Files/install.sql'));
$time = time();
$apiKey = hash_hmac('md5', uniqid(), $_POST['openSslPassword'] . $time);
$clientKey = hash_hmac('md5', $_POST['openSslPassword'], $time);
$param = array(
':ApiKey' => $apiKey,
':ApiKeyCreated' => $time,
':ApiExpires' => '2050-12-31',
':ApiPassMethod' => $_POST['cifra']
);
$stmt = $pdo->prepare('
INSERT INTO
brawbkeys
(KeyID, ApiKey, ApiPassMethod, ApiKeyCreated, ApiPermission, ApiAllowed, ApiExpires, ApiUsedCount, ApiLimitCount, ApiUnlimitedCount)
VALUES
(NULL, :ApiKey, :ApiPassMethod, :ApiKeyCreated, "11111111111111111111", "true", :ApiExpires, 0, 2147483647, "true");');
$stmt->execute($param);
$pdo = null;
echo utf8_decode("Configurações foram salvas com sucesso.<br><br>
<strong>Por favor, salve essas configurações. Utilize os dados abaixo para gerar novas chaves de Api para outros utilizarem.</strong>
<br><br>
<strong>ApiKey Mestre:</strong> {$apiKey}<br>
<strong>Chave de Criptografia:</strong> {$clientKey}<br>
<strong>Cifra:</strong> {$_POST['cifra']}<br>
");
}
exit;
}
// Escolhe um algoritmo para gerar a chave aleatóriamente.
$hash_algos = hash_algos();
shuffle($hash_algos);
$hash_algo = $hash_algos[ rand(0, sizeof($hash_algos) - 1) ];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style>
input[type="text"]
{
font-family: Consolas, Courier, "Courier New";
}
</style>
</head>
<body>
<form action="install.php" method="POST">
<fieldset>
<legend>Configuração PDO do serviço</legend>
<label>
String de Conexão:<br>
<input name="serviceConnectionString" value="sqlite:brAWebService.db" size="100" type="text"/>
</label><br>
<label>
Usuário:<br>
<input name="serviceUser" value="" size="30" type="text"/>
</label><br>
<label>
Senha:<br>
<input name="servicePass" value="" size="30" type="text"/>
</label><br>
</fieldset>
<fieldset>
<legend>Configuração PDO do Jogo</legend>
<label>
String de Conexão:<br>
<input name="ragnaConnectionString" value="mysql:host=localhost;dbname=ragnarok;" size="100" type="text"/>
</label><br>
<label>
Usuário:<br>
<input name="ragnaUser" value="ragnarok" size="30" type="text"/>
</label><br>
<label>
Senha:<br>
<input name="ragnaPass" value="ragnarok" size="30" type="text"/>
</label><br>
</fieldset>
<fieldset>
<legend>Criptografia</legend>
<label>
Chave Privada:<br>
<input name="openSslPassword" value="<?php echo hash($hash_algo, microtime(true)); ?>" size="180" maxlength="180" type="text"/>
</label><br>
<label>
Cifra da Chave-Mestra:<br>
<select name="cifra">
<?php
foreach(openssl_get_cipher_methods() as $algo)
{
if(preg_match('/^aes\-([0-9]+)\-[^xts]/', $algo))
{ ?>
<option <?php if($algo == 'aes-256-cbc') { echo 'selected'; } ?>><?php echo $algo; ?></option>
<?php
}
}
?>
</select>
</label><br>
</fieldset>
<fieldset>
<legend>Validação de campos</legend>
<label>
Nome de usuário:<br>
<input name="username" value="^([a-z0-9]{4,24})$" size="50" maxlength="50" type="text"/>
</label><br>
<label>
Senha de usuário:<br>
<input name="userpass" value="^([a-f0-9]{32})$" size="50" maxlength="50" type="text"/>
</label><br>
<label>
Sexo:<br>
<input name="sex" value="^(M|F)$" size="10" maxlength="10" type="text"/>
</label><br>
<label>
Email:<br>
<input name="email" value="^([^@]+)@([^\.]+)\..+$" size="50" maxlength="50" type="text"/>
</label><br>
</fieldset>
<fieldset>
<legend>Outros</legend>
<label>
Nível máximo para login:<br>
<input name="maxGroupId" value="10" size="3" maxlength="3" type="text"/>
</label><br>
</fieldset>
<input type="submit" value="Salvar"/>
<input type="reset" value="Limpar"/>
</form>
</body>
</html>