class_Install.inc.php
13 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
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
<?php
/**
* @file Install.inc.php
* @category freeSN
* @mailto code [at] netz.coop
* @version 0.4.200901
* @link http://netz.coop
*
* @copyright Copyright by netz.coop e.G. 2015
*
*
* 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/>.
*
*/
/**
* class Install
*
*/
class Install {
private $install_text = array('check', 'install', 'check');
private $var_false = FALSE;
public function __construct($param_DB) {
?>
<html>
<head>
<link rel="stylesheet" type="text/css"
href="include/Forest/netz.coop/Design/old/css/default_install.css" title="" />
</head>
<body>
<span class="Title">LOSP Installation</span>
<!-- Menu -->
<span class="Menu"> <span class="Button"><a href="install.php">Menu</a></span>
<?php
for ($i = 0; $i < count($this->install_text); $i++) {
?> <span class="Button"><a
href="install.php?step=<?php echo $this->install_text[$i] ?>"><?php echo $i ?>. <?php echo $this->install_text[$i];?></a></span>
<?php
}
?> </span>
<!-- Screen -->
<span class="Screen"> <?php
// Check the System
if ($_GET["step"] == $this->install_text[0]) {
?> <span class="Box"> <span class="Title">Server System: (Allgemein)</span>
<!-- MySQL --> <span class="row"> <span class="var">MySQL</span> <?php
if (extension_loaded("MySQL")) {
echo "<span class=\"value\">OK</span>";
} else {
$this->var_false = TRUE;
echo "<span class=\"value\">MySQL Modul ist nicht geladen, Installation nicht möglich</span>";
}
?> </span> <!-- PHP --> <span class="row"> <span class="var">PHP</span>
<?php
$version = explode('.', phpversion());
if (((int) $version[0]) >= 5) {
echo "<span class=\"value\">OK Version ist aussreichend (" . phpversion() . ">5)</span>";
} else {
$this->var_false = TRUE;
echo "<span class=\"value\"><b>eine zu alte PHP Version (" . phpversion() . "<5)</b></span>";
}
?> </span> <!-- XSL --> <span class="row"> <span class="var">XSL</span>
<?php
if (extension_loaded("XSL")) {
echo "<span class=\"value\">OK</span>";
} else {
$this->var_false = TRUE;
echo "<span class=\"value\">XSL Modul ist nicht geladen, Installation nicht möglich</span>";
}
?> </span> </span> <?php
if (!$this->var_false) {
?> <span class="Box"> <span class="Title">Datenbank Benutzer Daten:</span>
<br>
<p class=install>Bitte die Datei config/config.php mit den
Datenbankdaten füllen</p>
<p class=install>Folgende Daten werden beim nächsten Schritt
verwendet</p>
<span class="row"><span class="var">MySQL:</span></span> <span
class="row"><span class="var">Server:</span> <span class="value">"<?php echo $param_DB["config_dbserver"] ?>"</span></span>
<span class="row"><span class="var">Benutzer:</span><span class="value">"<?php echo $param_DB["config_user"] ?>"</span></span>
<span class="row"><span class="var">Passwort:</span><span class="value">"***"</span></span>
<span class="row"><span class="var">Datenbank:</span><span class="value">"<?php echo $param_DB["config_db"] ?>"</span></span>
</span> <?php
$link = mysql_connect($param_DB["config_dbserver"], $param_DB["config_user"], $param_DB["config_passwd"]);
if ($link) {
?> <span class="Box"> <span class="Title">MySQL Datenbank</span> <span
class="row"><span class="var">Version:</span> <span class="value"><?php echo mysql_get_server_info() ?></span></span>
<span class="row"><span class="var">Host:</span> <span class="value"><?php echo mysql_get_host_info() ?></span></span>
<span class="row"><span class="var">Client:</span> <span class="value"><?php echo mysql_get_client_info() ?></span></span>
</span> <span class="Box"> <span class="Title">spezielle Datenbank
Rechte</span> <?php
$query = "SELECT * FROM information_schema.`USER_PRIVILEGES` where GRANTEE=\"'" . $param_DB["config_user"] . "'@'" . $param_DB["config_dbserver"] . "'\" and PRIVILEGE_TYPE='ALTER ROUTINE';";
$this->resource = mysql_db_query($param_DB["config_db"], $query);
$row = mysql_fetch_array($this->resource);
?> <span class="row"> <span class="value">(Alter Routine: <?php
if ($row["PRIVILEGE_TYPE"] != "ALTER ROUTINE") {
$var_false = TRUE;
echo "Fehler";
} else {
echo "OK";
}
?> )</span> </span> <?php
$query = "SELECT * FROM information_schema.`USER_PRIVILEGES` where GRANTEE=\"'" . $param_DB["config_user"] . "'@'" . $param_DB["config_dbserver"] . "'\" and PRIVILEGE_TYPE='CREATE ROUTINE';";
// echo "<li>".$query."</li>";
$this->resource = mysql_db_query($param_DB["config_db"], $query);
$row = mysql_fetch_array($this->resource);
?> <span class="row"> <span class="value">Create Routine: <?php
if ($row["PRIVILEGE_TYPE"] != "CREATE ROUTINE") {
$var_false = TRUE;
echo "Fehler";
} else {
echo "OK";
}
?> </span> </span> <?php
if ($row["PRIVILEGE_TYPE"] == "CREATE ROUTINE") {
?> <span class="row"> <span class="var">Test: Erstelle Test Funktion:</span>
<span class="value"> <?php
$sql_fnc = "DROP FUNCTION IF EXISTS testing";
$this->resource = mysql_db_query($param_DB["config_db"], $sql_fnc);
$sql_fnc = "CREATE FUNCTION testing(param_test int)
RETURNS INT
DETERMINISTIC
BEGIN
return param_test;
END";
$this->resource = mysql_db_query($param_DB["config_db"], $sql_fnc);
if (!mysql_error()) {
echo "OK ";
echo mysql_error();
?> </span> <?php
} else {
echo "Fehler: ";
echo mysql_error();
?> </span> <?php
if (strripos(mysql_error(), "log_bin_trust_function_creators")) {
$query = "show variables like 'log_bin_trust_function_creators'";
$this->resource = mysql_db_query($param_DB["config_db"], $query);
$row = mysql_fetch_array($this->resource);
if ($row["Value"] == "ON") {
echo "log_bin_trust_function_creators: = " . $row["Value"] . "<br>";
} else {
$var_false = TRUE;
?> <span class="row"> <span class="value">log_bin_trust_function_creators:
= <?php echo $row["Value"] ?></span> </span> <span class="row"> <span
class="value">in der Datenbank können keine Funktionen angelegt
werden</span> </span> <span class="row"> <span class="value">Sie
müssen die globale Systemvariable log_bin_trust_function_creators
auf 1 setzen.<br>
[mysql> SET GLOBAL log_bin_trust_function_creators = 1;]</span> </span>
<?php
}
}
}
?> <span class="row"> <span class="var">Test: Erstelle Test Prozedur:</span>
<span class="value"> <?php
// $link = mysql_connect($param_DB["config_dbserver"], $param_DB["config_user"], $param_DB["config_passwd"]);
$sql_fnc = "DROP PROCEDURE IF EXISTS testing";
$this->resource = mysql_db_query($param_DB["config_db"], $sql_fnc);
$sql_fnc = "CREATE PROCEDURE testing(IN param_test int) DETERMINISTIC BEGIN END";
$this->resource = mysql_db_query($param_DB["config_db"], $sql_fnc);
if (!mysql_error()) {
echo "OK ";
echo mysql_error();
} else {
echo "Fehler: ";
echo mysql_error();
}
?> </span> </span> <?php
} else {
$var_false = TRUE;
?> <span class="row"> <span class="var">Erstelle Test
Funktion/Procedure:</span> <span class="value">No</span> </span> <span
class="row"> <span class="var">PRIVILEGE_TYPE:</span> <span
class="value">No</span> </span> <span class="row"><span class="value">
<b>in der Datenbank können keine Funktionen angelegt werden
(fehlende Rechte)</b> </span></span> <span class="row"> <span
class="var">externe Dokumentation:</span> <span class="value"><a
href="http://dev.mysql.com/doc/refman/5.1/de/create-procedure.html">MySQL
5.1 Referenzhandbuch 19.2.1. CREATE PROCEDURE und CREATE FUNCTION</a></span>
</span> <span class="row"> <span class="var">Anleitung:</span> <span
class="value">Als priviligierter MySQL Administrator folgende Rechte
dem Nutzer und der Datenbank zur Verfügung stellen</span> </span> <span
class="row"><span class="value"> <!-- mysql> <i>UPDATE mysql.`db` SET `Create_routine_priv` = 'Y', `Alter_routine_priv` = 'Y' WHERE CONVERT( `Db` USING utf8 ) = '<?php echo $param_DB["config_db"] ?>' AND CONVERT( `User` USING utf8 ) = '<?php echo $param_DB["config_user"] ?>';</i> -->
<!-- mysql> <i>UPDATE `mysql`.`db` SET `Host` = 'localhost', `Select_priv` = 'Y', `Insert_priv` = 'Y', `Update_priv` = 'Y', `Delete_priv` = 'Y', `Create_priv` = 'Y', `Drop_priv` = 'Y', `Reload_priv` = 'Y', `Create_view_priv` = 'Y', `Show_view_priv` = 'Y', `Create_routine_priv` = 'Y', `Alter_routine_priv` = 'Y' WHERE CONVERT( `Db` USING utf8 ) = '<?php echo $param_DB["config_db"] ?>' AND `user`.`User`= '<?php echo $param_DB["config_user"] ?>' LIMIT 1 ;</i> -->
mysql> <i>UPDATE `mysql`.`db` SET `Host` = 'localhost', `Select_priv` =
'Y', `Insert_priv` = 'Y', `Update_priv` = 'Y', `Delete_priv` = 'Y',
`Create_priv` = 'Y', `Drop_priv` = 'Y', `Create_view_priv` = 'Y',
`Show_view_priv` = 'Y', `Create_routine_priv` = 'Y',
`Alter_routine_priv` = 'Y' WHERE CONVERT( `Db` USING utf8 ) = '<?php echo $param_DB["config_db"] ?>'
AND `User`= '<?php echo $param_DB["config_user"] ?>' LIMIT 1 ;</i> </span></span>
<span class="row"><span class="value"> <!-- mysql> UPDATE mysql.user SET Create_routine_priv='Y', Alter_routine_priv='Y', ssl_cipher='', x509_issuer='', x509_subject='' WHERE CONVERT(Host USING utf8 )='<?php echo $param_DB["config_dbserver"] ?>' AND CONVERT(User USING utf8 )='<?php echo $param_DB["config_user"] ?>' LIMIT 1; -->
mysql> <i>UPDATE `mysql`.`user` SET `Host` = 'localhost', `Select_priv`
= 'Y', `Insert_priv` = 'Y', `Update_priv` = 'Y', `Delete_priv` = 'Y',
`Create_priv` = 'Y', `Drop_priv` = 'Y', `Reload_priv` = 'Y',
`Create_view_priv` = 'Y', `Show_view_priv` = 'Y', `Create_routine_priv`
= 'Y', `Alter_routine_priv` = 'Y' WHERE `user`.`User`= '<?php echo $param_DB["config_user"] ?>'
LIMIT 1 ;</i> </span></span> <span class="row"><span class="value">
mysql> <i>FLUSH PRIVILEGES ;</i> </span></span> <?php
}
?> </span> <span class="Box"> <span class="Title">Resultat</span> <?php
if ($var_false) {
?> <span class="row"> <a
href="install.php?step=<?php echo $this->install_text[0] ?>" class=install>noch
mal [Schritt 1]</a> </span> <?php
} else {
?> <span class="row"> <a
href="install.php?step=<?php echo $this->install_text[1] ?>" class=install>weiter
[Schritt 1]</a> (Tabellen werden erstellt) </span> <?php
}
?> </span> <?php
} else {
echo "<b>Ueberprüfen sie die Daten für die Datenbankverbindung config/config.php</b><br>";
echo "<a href=\"?install=2\" class=install>zurück [Schritt 2]</a><br>";
echo('Keine Verbindung möglich: ' . mysql_error());
?> <span class="Box"> <span class="row"> <b>evt. soll vielleicht auch
alles erst angelegt werden</b> </span> <span class="row"> rechner:/$ <i>mysql
-u root --password='Passwort'</i> </span> <span class="row"> mysql> <i>create
database lospdb;</i> </span> <span class="row"> mysql> <i>GRANT ALL
PRIVILEGES ON lospdb.* TO lospuser IDENTIFIED BY 'losppassword';</i> </span>
</span> <?php
}
}
} else if ($_GET["step"] == $this->install_text[1]) {
$DB = StorableFactory::create("MySql", $param_DB);
echo $DB->transformFileToDatabase("include/System/sql/MySql_Tables.sql");
echo $DB->transformFileToDatabase("include/System/sql/MySql_Function.sql");
} else {
}
?> </span>
</body>
</html>
<?php
}
}