Repository navigation
Expand file tree
/
Copy pathinstall.php
More file actions
198 lines (153 loc) · 6.73 KB
/
Copy pathinstall.php
File metadata and controls
198 lines (153 loc) · 6.73 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
<!DOCTYPE html><html><head><meta charset="utf-8">
<link id="main" rel="stylesheet" href="http://www.w3schools.com/lib/w3.css" type="text/css" media="screen"/>
</head>
<title>openSIMULATOR-Map-Karte Config Setup</title>
</head>
<body>
<div class="w3-container w3-blue-grey">
<h1>openSIMULATOR-Map-Karte Config Setup</h1>
</div>
<?php if (!isset($_POST['etape'])): ?>
<form class="w3-container" action="" method="post">
<input type="hidden" name="etape" value="1" />
<!-- General items -->
<div class="form-group">
<label for="base" class="w3-label w3-text-blue-grey control-label">DNS Name Server :</b></label>
<div class="col-sm-4">
<input class="w3-input w3-border" type="text" placeholder="http://localhost" name="domaine" maxlength="40" />
</div>
</div>
<br>
<div class="form-group">
<label for="base" class="w3-label w3-text-blue-grey control-label">Map Karte path :</b></label>
<div class="col-sm-4">
<input class="w3-input w3-border" type="text" placeholder="/map" name="domainepath" maxlength="40" />
</div>
</div>
<br>
<!-- mysql database items -->
<div class="form-group">
<label for="hote" class="w3-label w3-text-blue-grey control-label">Database Host :</b></label>
<div class="col-sm-4">
<input class="w3-input w3-border" type="text" placeholder="localhost" name="hote" maxlength="40" />
</div>
</div>
<br>
<div class="form-group">
<label for="login" class="w3-label w3-text-blue-grey control-label">Database User :</b></label>
<div class="col-sm-4">
<input class="w3-input w3-border" type="text" placeholder="opensim" name="login" maxlength="40" />
</div>
</div>
<br>
<div class="form-group">
<label for="mdp" class="w3-label w3-text-blue-grey control-label">Database Password :</b></label>
<div class="col-sm-4">
<input class="w3-input w3-border" type="password" placeholder="*********" name="mdp" maxlength="40" />
</div>
</div>
<br>
<div class="form-group">
<label for="base" class="w3-label w3-text-blue-grey control-label">Database Name :</b></label>
<div class="col-sm-4">
<input class="w3-input w3-border" type="text" placeholder="opensim" name="base" maxlength="40" />
</div>
</div>
<br>
<!-- The Coordinates of the Grid-Center -->
<div class="form-group">
<label for="base" class="w3-label w3-text-blue-grey control-label">Center x :</b></label>
<div class="col-sm-4">
<input class="w3-input w3-border" type="text" placeholder="5000 (Grid Center X)" name="imapx" maxlength="40" />
</div>
</div>
<br>
<div class="form-group">
<label for="base" class="w3-label w3-text-blue-grey control-label">Center y :</b></label>
<div class="col-sm-4">
<input class="w3-input w3-border" type="text" placeholder="5000 (Grid Center Y)" name="imapy" maxlength="40" />
</div>
</div>
<br>
<!-- Install Button -->
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button class="w3-btn-block w3-blue-grey" type="submit" name="submit" value="Installer">Install</button>
</div>
</div>
</form>
<?php endif ?>
</div>
<!-- Keine ahnung -->
<?php if (isset($_POST['delete']))
{
unlink('install.php');
header('Location: ./');
}
?>
<?php
if (isset($_POST['etape']) AND $_POST['etape'] == 1)
{
// eine Konstante erzeugen, die später verwendet wird
define('RETOUR', '<input class="w3-btn-block w3-blue-grey" type="button" value="Return of form" onclick="history.back()">');
$datei = './includes/config.php';
if (file_exists($datei) AND filesize($datei ) > 0)
{
// wenn die Datei existiert und nicht leer ist, dann
exit('<div class="alert alert-danger">Not this configuration file, installation corrupt ...</div>'. RETOUR);
}
// wir schaffen unsere Variablen und alle Leerzeichen beiläufig entfernen
$domaine = trim($_POST['domaine']);
$domainepath = trim($_POST['domainepath']);
$hote = trim($_POST['hote']);
$login = trim($_POST['login']);
$pass = trim($_POST['mdp']);
$base = trim($_POST['base']);
$imapx = trim($_POST['imapx']);
$imapy = trim($_POST['imapy']);
// überprüft die Verbindung mit dem Server, bevor es weiter geht
if (!mysqli_connect($hote, $login, $pass, $base))
{
exit('<div class="alert alert-danger">Bad connection settings, installation corrupt ...</div>'. RETOUR);
}
// der Text, der in der config.php gesetzt wird
$texte = '
<?php
/* General Domain */
$CONF_sim_domain = "'.$domaine.'"; // Your Grid-Domain
$CONF_install_path = "'.$domainepath.'"; // Installation path
/* MySQL Database */
$CONF_db_server = "'. $hote .'"; //Your Database-Server
$CONF_db_user = "'. $login .'"; // login
$CONF_db_pass = "'. $pass .'"; // password
$CONF_db_database = "'. $base .'"; // Name of BDD
/* The Coordinates of the Grid-Center */
$CONF_center_coord_x = "'. $imapx .'"; // the Center-X-Coordinate
$CONF_center_coord_y = "'. $imapy .'"; // the Center-Y-Koordinate
// style-sheet items
$CONF_style_sheet = "/css/stylesheet.css"; //Link to your StyleSheet
?>';
if (!$offen = fopen($datei, 'w'))
{
exit('<div class="alert alert-danger">Unable to open file : <strong>'. $datei .'</strong>, installation corrupt. Create the file manually (/includes/config.php.example) or change the permissions on the /includes directory.</div>'. RETOUR);
}
if (fwrite($offen, $texte) == FALSE)
{
exit('<div class="alert alert-danger">Can not write to the file : <strong>'. $datei .'</strong>, installation corrupt. Create the file manually (/includes/config.php.example) or change the permissions on the /includes directory.</div>'. RETOUR);
}
echo '<div class="alert alert-success">Creation of effected configuration file with success ...</div>';
fclose($offen);
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="w3-btn-block w3-red" type="submit" name="submit" >Delete file install.php</button>';
echo '</div>';
echo '</form>';
}
?>
<div class="clearfix"></div>
</div>
</body>
</html>