forked from DrangPo/OpenSim-Manager-Web-V5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
228 lines (191 loc) · 6.83 KB
/
install.php
File metadata and controls
228 lines (191 loc) · 6.83 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
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="img/favicon.ico">
<title>Open Simulator Manager Web</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<h1>Open Simulator Manager Web Installer</h1>
<?php if (!isset($_POST['etape'])): ?>
<form class="form-horizontal" action="" method="post">
<input type="hidden" name="etape" value="1" />
<div class="form-group">
<label for="hote" class="col-sm-2 control-label">Database Host :</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="hote" maxlength="40" />
</div>
</div>
<div class="form-group">
<label for="login" class="col-sm-2 control-label">Database User :</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="login" maxlength="40" />
</div>
</div>
<div class="form-group">
<label for="mdp" class="col-sm-2 control-label">Database Password :</label>
<div class="col-sm-4">
<input class="form-control" type="password" name="mdp" maxlength="40" />
</div>
</div>
<div class="form-group">
<label for="base" class="col-sm-2 control-label">Database Name :</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="base" maxlength="40" />
</div>
</div>
<div class="form-group">
<label for="base" class="col-sm-2 control-label">DNS Name Server :</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="domaine" maxlength="40" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-success" type="submit" name="submit" value="Installer">Install</button>
</div>
</div>
</form>
<?php endif ?>
<?php if (isset($_POST['delete']))
{
unlink('install.php');
header('Location: ./');
}
?>
<?php
if (isset($_POST['etape']) AND $_POST['etape'] == 1)
{
// on crée une constante dont on se servira plus tard
$return = '<input class="btn btn-primary" type="button" value="Return of form" onclick="history.back()">';
$fichier = './inc/config.php';
if (file_exists($fichier) AND filesize($fichier ) > 0)
{
// si le fichier existe et qu'il n'est pas vide alors
exit('<div class="alert alert-danger">Not this configuration file, installation corrupt ...</div>' );
}
// on crée nos variables, et au passage on retire les éventuels espaces
$hote = trim($_POST['hote']);
$login = trim($_POST['login']);
$pass = trim($_POST['mdp']);
$base = trim($_POST['base']);
$domaine = trim($_POST['domaine']);
$conn = mysqli_connect($hote, $login, $pass);
// on vérifie la connectivité avec le serveur avant d'aller plus loin
if (!$conn)
{
exit('<div class="alert alert-danger">Bad connection settings, installation corrupt ...</div>'. $return);
}
// on vérifie la connectivité avec la base avant d'aller plus loin
if (!mysqli_select_db($conn,$base))
{
exit('<div class="alert alert-danger">Wrong database name, installation corrupt ...</div>'. $return);
}
// le texte que l'on va mettre dans le config.php
$texte = '
<?php
$hostnameBDD = "'. $hote .'"; // IP of Bdd
$userBDD = "'. $login .'"; // login
$passBDD = "'. $pass .'"; // password
$database = "'. $base .'"; // Name of BDD
$hostnameSSH = "'.$domaine.'"; // Url of server
/* The below 4 variables will need to be added as entry but will have to manaully edit them for now.*/
/*Save locations base */
$baseSave = "../../";
$baseBackups = "backups";
$baseImages = "images";
$slash = "/";
$cache_dir = "/home/dyount/opensim.spotcheckit.org/cache/";
$cache_dir = $base_dir."cache/";
$exec_dir = $base_dir."exec/";
/* name of files INI */
$FichierINIRegions = "Regions.ini"; // ou RegionConfig.ini
$FichierINIOpensim = "OpenSimDefaults.ini"; // ou OpenSim.ini
/* Themes */
$themes = true;
/* Languages */
$translator = true;
$languages=array(
"fr" => "French",
"en" => "English");
/* Google ReCaptcha */
$recaptcha = false;
$siteKey = "***";
$secret = "***";
$lang = "en";
/* Position center of your MAP */
$px = 1000;
$py = 1000;
?>';
if (!$ouvrir = fopen($fichier, 'w'))
{
exit('<div class="alert alert-danger">Unable to open file : <strong>'. $fichier .'</strong>, installation corrupt ...</div>'. $return);
}
if (fwrite($ouvrir, $texte) == FALSE)
{
exit('<div class="alert alert-danger">Can not write to the file : <strong>'. $fichier .'</strong>, installation corrupt ...</div>'. $return);
}
echo '<div class="alert alert-success">Creation of effected configuration file with success ...</div>';
fclose($ouvrir);
$requetes = '';
$sql = file('./docs/sql/database.sql');
foreach($sql as $lecture)
{
if (substr(trim($lecture), 0, 2) != '--')
{
$requetes .= $lecture;
}
}
$reqs = explode(';', $requetes);
foreach($reqs as $req)
{
if (!mysql_query($req) AND trim($req) != '')
{
exit('ERREUR : '.$req);
}
}
$requetes = '';
$sql = file('./docs/sql/database_NPC.sql');
foreach($sql as $lecture)
{
if (substr(trim($lecture), 0, 2) != '--')
{
$requetes .= $lecture;
}
}
$reqs = explode(';', $requetes);
foreach($reqs as $req)
{
if (!mysql_query($req) AND trim($req) != '')
{
exit('ERREUR : '.$req);
}
}
echo '<div class="alert alert-success">Installing the database tables of data effected with success...</div>';
echo '<div class="alert alert-warning">Please delete the file <strong>install.php</strong> of server ...</div>';
echo '<form class="form-group" action="" method="post">';
echo '<input type="hidden" name="delete" value="1" />';
echo '<div class="form-group">';
echo '<button class="btn btn-danger" type="submit" name="submit" >Delete file install.php</button>';
echo '</div>';
echo '</form>';
}
?>
<div class="clearfix"></div>
<footer class="footer">
<p><CENTER>Open Simulator Manager Web Intaller <?php echo date('Y'); ?></CENTER></p>
</footer>
</div>
</body>
</html>