-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.php
executable file
·304 lines (257 loc) · 12.3 KB
/
install.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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<?php
/**************************************************************************
* 0xBB ~ Bullettin Board *
**************************************************************************
* 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/>
* =========================================================================*
* Software: 0xBB
* Software version: 2.0
* Author: KinG-InFeT
* Copyleft: GNU General Public License
* =========================================================================*
* install.php
***************************************************************************/
?>
<html>
<head>
<title>Installazione 0xBB </title>
<style type="text/css">
body {
font-family: monospace;
}
</style>
</head>
<body bgcolor="#000000" text="white" >
<?php
if (!( file_exists('./config.php')))
die("[ERROR] File config.php inesistente!");
if (!(is_writable('./config.php')))
die("[ERROR] File config.php non è scrivibile!");
if(!(phpversion() >= '5.2.0')) {
die('<h2 align="center">In questo server è installata una versione di PHP inferiore alla 5.2.0, quindi 0xBB non potrà essere installato!<br />
Si contatti l\'amministratore del server per aggiornare la versione di PHP installata sul server almeno alla 5.2.0</h2>');
}
if(@$_GET['action'] == 'install') {
if (isset($_POST['descrizione'])
&& isset($_POST['user_admin'])
&& isset($_POST['pass_admin'])
&& isset($_POST['host'])
&& isset($_POST['user'])
&& isset($_POST['name'])
&& isset($_POST['__PREFIX__'])
&& isset($_POST['email_admin'])
&& isset($_POST['site_name'])) {
//Dati Connessione MySQL
$db_host = trim($_POST['host']);
$db_user = trim($_POST['user']);
$db_pass = trim($_POST['pass']);
$db_name = trim($_POST['name']);
/* controllo connessione avvenuta :P */
$db = mysql_connect ($db_host , $db_user ,$db_pass);
if($db == FALSE)
die("<script>alert(\"Errore!\nControllare i dati per la connessione al database MySQL\"); window.location=\"".$_SERVER['PHP_SELF']."\";</script>");
$select_db = mysql_select_db ($db_name,$db);
if($select_db == FALSE)
die("<script>alert(\"Errore!\nControllare i dati per la connessione al database MySQL\"); window.location=\"".$_SERVER['PHP_SELF']."\";</script>");
//*******************************
//Vari Dati
$site_name = mysql_real_escape_string(trim(htmlspecialchars($_POST['site_name'])));
$descrizione = mysql_real_escape_string(trim(htmlspecialchars($_POST['descrizione'])));
$__PREFIX__ = trim($_POST['__PREFIX__']);
//Dati amministrazione
$user_admin = trim(mysql_real_escape_string($_POST['user_admin']));
$pass_admin = md5($_POST['pass_admin']);
$email_admin = trim(mysql_real_escape_string($_POST['email_admin']));
$sql_settings = "CREATE TABLE ". $__PREFIX__ ."settings (
site_name TEXT NOT NULL,
description TEXT NOT NULL,
block_register INT NOT NULL,
maintenance INT NOT NULL
);";
mysql_query($sql_settings) or die ("SQL Error:".mysql_error());
print "Table '". $__PREFIX__ ."settings' creata con successo<br />\n";
mysql_query("INSERT INTO ". $__PREFIX__ ."settings (site_name, description, block_register, maintenance) VALUES ('{$site_name}', '{$descrizione}', '0', '0');") or _err(mysql_error());
$sql_users = "CREATE TABLE ". $__PREFIX__ ."users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR (20) NOT NULL,
password VARCHAR (32) NOT NULL,
level TEXT NOT NULL,
email TEXT NOT NULL,
web_site TEXT,
msn TEXT,
firma TEXT,
theme TEXT
);";
mysql_query($sql_users) or die ("SQL Error:".mysql_error());
print "Table '". $__PREFIX__ ."users' creata con successo<br />\n";
$sql_forum = "CREATE TABLE ". $__PREFIX__ ."forum (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR (20) NOT NULL,
description VARCHAR (100) NOT NULL,
user_access VARCHAR(20),
position INT
);";
mysql_query($sql_forum) or die ("SQL Error:".mysql_error());
print "Table '". $__PREFIX__ ."forum' creata con successo<br />\n";
$sql_topic = "CREATE TABLE ". $__PREFIX__ ."topic (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
f_id INT NOT NULL,
t_id INT NOT NULL,
author VARCHAR (20) NOT NULL,
title VARCHAR (60) NOT NULL,
data TEXT NOT NULL,
replyof INT NOT NULL,
last INT (10) NOT NULL,
ora TEXT NOT NULL,
date TEXT NOT NULL,
block INT NOT NULL,
important INT DEFAULT 0,
announcement INT DEFAULT 0
);";
mysql_query($sql_topic) or die ("SQL Error:".mysql_error());
print "Table '". $__PREFIX__ ."topic' creata con successo<br />\n";
$sql_pm = "CREATE TABLE ". $__PREFIX__ ."pm (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
from_usr VARCHAR (20) NOT NULL,
to_usr VARCHAR (20) NOT NULL,
title VARCHAR (60) NOT NULL,
data TEXT NOT NULL,
new INT NOT NULL
);";
mysql_query($sql_pm) or die ("SQL Error:".mysql_error());
print "Table '". $__PREFIX__ ."pm' creata con successo<br />\n";
$sql_karma = "CREATE TABLE ". $__PREFIX__ ."karma (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
vote_user_id VARCHAR (255) NOT NULL,
vote INT NOT NULL
);";
mysql_query($sql_karma) or die ("SQL Error:".mysql_error());
print "Table '". $__PREFIX__ ."karma' creata con successo<br />\n";
$sql_ban_ip = "CREATE TABLE ". $__PREFIX__ ."ban_ip (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
user_id VARCHAR (255) NOT NULL,
ip VARCHAR (255) NOT NULL,
banned INT NOT NULL
);";
mysql_query($sql_ban_ip) or die ("SQL Error:".mysql_error());
print "Table '". $__PREFIX__ ."ban_ip' creata con successo<br />\n";
/*inserisco i dati dell'admin in ban ip */
mysql_query("INSERT INTO ". $__PREFIX__ ."ban_ip (user_id, ip, banned) VALUES ('1', '".$_SERVER['REMOTE_ADDR']."', '0');") or _err(mysql_error());
/* fine inserimento */
$sql_admin_user = "INSERT INTO ". $__PREFIX__ ."users (
id, username, password, level, email, web_site, msn, firma, theme
) VALUES (
'1', '{$user_admin}', '{$pass_admin}', 'admin', '{$email_admin}', 'NULL', 'NULL', 'Administrator Site', 'default.css');";
mysql_query($sql_admin_user) or die ("SQL Error:".mysql_error());
print "User '<i>". $user_admin ."</i>' Added with success<br />\n";
$sql_first_forum = "INSERT INTO ". $__PREFIX__ ."forum (
title, description, user_access, position
) VALUES (
'Benvenuto in 0xBB', 'Questo è il primo forum di 0xBB', 'user', 1);";
mysql_query($sql_first_forum) or die ("SQL Error:".mysql_error());
$sql_first_topic = "INSERT INTO ". $__PREFIX__ ."topic (
f_id, author, title, data, replyof, last, ora, date, important, announcement
) VALUES (
1, '{$user_admin}', 'Benvenuto', 'Comunico che la board 0xBB è stata installata con successo!<br /><br />
Per segnalazioni di Bug alla board o semplicemente supporto cliccate <a href=\"http://0xproject.netsons.org/bug_tracker\">QUI</a>', -1, 0, '".date("G:i")."', '".date("d-m-y")."', 0, 1
);";
mysql_query($sql_first_topic) or die ("SQL Error:".mysql_error());
$sql_karma = "INSERT INTO ". $__PREFIX__ ."karma (`vote_user_id`, `vote`) VALUES ('1', '0');";
mysql_query($sql_karma) or _err(mysql_error());
mysql_close($db);
// creazione contenuto file config.php
$config = '<?php
/**************************************************************************
* 0xBB ~ Bullettin Board *
**************************************************************************
* 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/>
* =======================================================================*
* Software: 0xBB
* Software version: Config File v2.x
* Author: KinG-InFeT
* Copyleft: GNU General Public License
* =======================================================================*
* config.php
**************************************************************************/
define("__PREFIX__", "'.$__PREFIX__.'"); //prefisso tabelle
define("SERVER_NAME", "'.$_SERVER['SERVER_NAME'].'"); //url base del sito per l\'anti csrf/xsrf
//Dati per la connessione al Database MySQL
$db_host = "'.$db_host.'";
$db_user = "'.$db_user.'";
$db_pass = "'.$db_pass.'";
$db_name = "'.$db_name.'";
mysql_connect ($db_host, $db_user, $db_pass) or die (mysql_error());
mysql_select_db ($db_name) or die (mysql_error());
?>';
// Scriviamo sul config.php i dati che ci occorrono
$open = fopen('config.php', 'w'); // se il file già esiste verrà totalmente sovrascritto
fwrite ($open, $config);//Scrivo sul file config.php
fclose ($open); // chiudo il file
print "config.php creato con successo<br />\n";
if(@unlink("./install.php")) { //cancello il file
print "File install.php cancellato<br />"
. "\n<br /><font color=green>Installazione avvenuta con successo!</font>\n"
. "\nTornare alla <a href=\"index.php\">Home-Page</a>";
}else // se non ci riesco esplicito che deve essere cancellato manualmente
print '<font color=red>Errore! File install.php ancora esistente, settare i permetti a 777 (chmod) sul file install.php<br />'."\n".'
Ed eliminarlo successivamente!<br />Torna alla <a href="index.php">Home-Page</a></font>';
}else
print "<span style=\"color:red; font-weight:bold;\">Errore! Riempire Tutti i Campi</span>\n";
}else{
?>
<center><h1>Installazione 0xBB</h1></center>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr><td>
<form action="?action=install" method="POST">
<tr><td><b>Info Generali</b></td></tr>
<tr><td>*Titolo Forum:</td><td><input type="text" name="site_name" /></td></tr>
<tr><td>*Descrizione:</td><td><input type="text" name="descrizione" /></td></tr>
<tr><td><br /></td></tr>
<tr><td><b>Dati per la connessione al MySQL</b></td></td></tr></tr>
<tr><td>*Hostname:</td><td><input type="text" name="host" value="localhost" /></td></tr>
<tr><td>*Username:</td><td><input type="text" name="user" value="root" /></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" /></td></tr>
<tr><td>*DB Name:</td><td><input type="text" name="name" value="0xBB" /></td></tr>
<tr><td>*Prefisso Tabelle:</td><td><input type="text" name="__PREFIX__" value="0xBB_" /></td></tr>
<tr><td><br /></td></tr>
<tr><td><b>Dati di amministrazione:</b></td></td></tr></tr>
<tr><td>*Username:</td><td><input type="text" name="user_admin" /></td></tr>
<tr><td>*Password:</td><td><input type="password" name="pass_admin" /></td></tr>
<tr><td>*E-Mail:</td><td><input type="text" name="email_admin" /></td></tr>
<tr><td><input type="submit" value="Installa!" name="install" /></td></tr>
</form>
<tr><td><b>*</b>: Campi obbligatori</td></tr>
</td>
</tr>
</tbody>
</table>
<?php
}
?>
<center><pre>Powered By <a href="http://0xproject.netsons.org/#0xBB">0xBB<a/></pre>
</center>
</body>
</html>