3 include_once('functions/include.install.php');
4 #include_once('functions.php');
5 include_once("db_settings.php");
6 include_once("lang/english.php");
7 include_once("lang/english_add.php");
10 ini_set('arg_separator.output', '&');
11 header('Content-Type: text/html; charset=UTF-8');
12 if (!extension_loaded('mbstring')) include_once('/functions/funcs.mb_replacements.php');
13 mb_internal_encoding('UTF-8');
15 # for details see: http://de.php.net/manual/en/security.magicquotes.disabling.php
16 if (get_magic_quotes_gpc())
18 $_POST = array_map('stripslashes_deep', $_POST);
19 $_GET = array_map('stripslashes_deep', $_GET);
20 $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
21 $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
25 # number of the new version
29 # status of the script
30 # 0: initialization status, start of the update procedure
31 # 1: no connect to the database or no data of an existing forum-DB found
34 $statusOutput[1] = "<p>".$lang_add['db_read_settings_error']."</p>
35 <p>The forum seems not to be installed. Please control the existence and name of the settings table or switch to <a href=\"install.php\">Installation</a>.</p>";
36 $statusOutput[2] = "<p>Database tables have been altered, new tables are created.</p>";
37 $statusOutput[3] = "<p>The given data from the form seems to be wrong.</p>";
38 $statusOutput[4] = "<p>An error occured</p>\n";
40 # initialization of the output
43 # connect the database (return: [status] resource number or false; [errnbr] error number)
44 $sql = auge_connect_db($db_settings);
46 if ($sql["status"] === false)
48 # no contact to the database server
49 # generate error message
50 $errors[] = "MySQL error: ".$sql["errnbr"]."<br />".$lang_add['db_'.$sql["errnbr"]];
51 # status: no connection to database
53 $output .= "<p>The script can not contact the database server. The username, password or database name seems to be wrong.</p>";
57 # List all versions wich can be updated.
58 $updateVersions = array("1.7");
59 # the database is contacted
60 $connid = $sql["status"];
61 # read the current settings from the settings table
62 $oldSettingsQuery = "SELECT name, value FROM ".$db_settings['settings_table'];
63 $ancientSettings = auge_ask_database($oldSettingsQuery,$connid);
64 if (!is_array($ancientSettings['status']))
66 # status: found no data of an existing installation (empty result or error)
67 $output .= $statusOutput[1];
72 # bring the old settings into the needed format
73 foreach ($ancientSettings['status'] as $ancientSetting)
75 $oldSettings[$ancientSetting['name']] = $ancientSetting['value'];
77 # search version number of the old forum version:
78 if (empty($oldSettings['version']))
80 # the old setting for version string is not present
81 $errors[] = $lang_add['no_version_found'];
85 # found string for old version
86 $versionCompare = false;
87 # shorten version string to one digit after first point
88 $oldVersionShort = substr($oldSettings['version'],0,3);
89 if ($oldVersionShort == $newVersion)
91 # identic old and new version
92 $errors[] = $lang_add['version_already_installed'];
94 else if (!in_array($oldVersionShort,$updateVersions))
96 # old version is not supported by the update procedure
97 $errors[] = $lang_add['version_not_supported'];
101 $oldVersion = $oldSettings['version'];
103 } # End: search version number of old forum
104 # include files for the language wich is stored in the old settings
105 include("lang/".$oldSettings['language_file']);
106 include("lang/".$lang['additional_language_file']);
107 # the form was submitted
108 if (isset($_POST['form_submitted'])) {
109 # $output .= '<pre>';
110 # $output .= print_r($_POST, true);
111 # $output .= '</pre>';
112 # all fields filled out?
113 foreach ($_POST as $postKey=>$postVal)
115 $postVal = trim($postVal);
116 if (empty($postVal)) { $errors[] = $lang['error_form_uncompl']; break; }
118 # try to connect the database with posted access data (deprecated):
121 # Umstellung auf meine SQL-Funktionen
122 $tempDBConnData = array('host'=>$db_settings['host'],'user'=>$db_settings['user'],'pw'=>$db_settings['pw'],'db'=>$db_settings['db']);
123 $tempSQL = auge_connect_db($tempDBConnData);
124 if ($tempSQL['status'] === false)
127 # generate error message
128 $errors[] = "MySQL error: ".$tempSQL["errnbr"]."\n".$lang_add['db_'.$tempSQL["errnbr"]];
129 # status: no connection to database
130 # because wrong given data from the form
135 $connid = $tempSQL['status'];
139 # overwrite database settings file:
140 if (empty($errors) and empty($_POST['dont_overwrite_settings']))
143 $chmod = decoct(fileperms("db_settings.php"));
145 $db_settings['usersettings_table'] = $_POST['table_prefix'].'usersettings';
146 $db_settings['us_templates_table'] = $_POST['table_prefix'].'fu_settings';
147 $db_settings['banned_ips_table'] = $_POST['table_prefix'].'banned_ips';
148 $db_settings['usersubscripts_table'] = $_POST['table_prefix'].'subscripts';
149 # content of db_settings.php
150 $SetCont = "<?php\n";
151 $SetCont .= "\$db_settings['host'] = \"".$db_settings['host']."\";\n";
152 $SetCont .= "\$db_settings['user'] = \"".$db_settings['user']."\";\n";
153 $SetCont .= "\$db_settings['pw'] = \"".$db_settings['pw']."\";\n";
154 $SetCont .= "\$db_settings['db'] = \"".$db_settings['db']."\";\n";
155 $SetCont .= "\$db_settings['settings_table'] = \"".$db_settings['settings_table']."\";\n";
156 $SetCont .= "\$db_settings['forum_table'] = \"".$db_settings['forum_table']."\";\n";
157 $SetCont .= "\$db_settings['category_table'] = \"".$db_settings['category_table']."\";\n";
158 $SetCont .= "\$db_settings['userdata_table'] = \"".$db_settings['userdata_table']."\";\n";
159 $SetCont .= "\$db_settings['smilies_table'] = \"".$db_settings['smilies_table']."\";\n";
160 $SetCont .= "\$db_settings['banlists_table'] = \"".$db_settings['banlists_table']."\";\n";
161 $SetCont .= "\$db_settings['banned_ips_table'] = \"".$db_settings['banned_ips_table']."\";\n";
162 $SetCont .= "\$db_settings['useronline_table'] = \"".$db_settings['useronline_table']."\";\n";
163 $SetCont .= "\$db_settings['usersettings_table'] = \"".$db_settings['usersettings_table']."\";\n";
164 $SetCont .= "\$db_settings['us_templates_table'] = \"".$db_settings['us_templates_table']."\";\n";
165 $SetCont .= "\$db_settings['usersubscripts_table'] = \"".$db_settings['usersubscripts_table']."\";\n";
167 # Start: debug output
168 # $output .= '<pre>';
169 # $output .= htmlspecialchars(print_r($SetCont, true));
170 # $output .= '</pre>';
173 $db_settings_file = @fopen
("db_settings.php", "w") or $errors[] = str_replace("CHMOD",$chmod,$lang_add['no_writing_permission']);
174 flock($db_settings_file, LOCK_EX
);
175 fwrite($db_settings_file, $SetCont);
176 flock($db_settings_file, LOCK_UN
);
177 fclose($db_settings_file);
178 } # End: if (empty($errors) and empty($_POST['dont_overwrite_settings']))
182 switch($oldVersionShort)
185 $errors = update17to18($oldSettings, $connid);
186 if ($errors === false) {
187 $output .= '<p>errors ist <code>false</code>.</p>';
191 $output .= '<p>errors ist nicht <code>false</code>.</p>';
195 $errors[] = $lang_add['version_not_supported'];
197 } # End: switch($oldVersion)
198 } # End: structure update procedure
199 # structure update was successful, set $scriptStatus to 2
202 # the update was successful
203 # the database tables was updated, new settings are saved
205 $output .= $statusOutput[2];
209 # an error occured while the update process
210 $output .= $statusOutput[4];
211 if (!empty($errors) and is_array($errors))
213 $output .= errorMessages($errors);
216 } # End: if (isset($_POST['form_submitted']))
219 # the form was not submitted, standard output with the initial form
220 $passLength = strlen($db_settings['pw']);
221 $prefix = substr($db_settings['settings_table'], 0, -8);
222 $passWord = str_repeat("*", $passLength);
223 $output .= '<p>'.$lang_add['update_instructions'].'</p>'."\n";
224 $output .= '<h2>'.$lang_add['update_current_dbsettings'].'</h2>'."\n";
225 $output .= '<table class="admintab">'."\n";
226 $output .= ' <tr>'."\n";
227 $output .= ' <td class="definition">'.$lang_add['inst_db_host'].'<br />'."\n";
228 $output .= ' <span class="small">'.$lang_add['inst_db_host_d'].'</span></td>'."\n";
229 $output .= ' <td class="description">'.$db_settings['host'].'</td>'."\n";
230 $output .= ' </tr><tr>'."\n";
231 $output .= ' <td class="definition">'.$lang_add['inst_db_name'].'<br />'."\n";
232 $output .= ' <span class="small">'.$lang_add['inst_db_name_d'].'</span></td>'."\n";
233 $output .= ' <td class="description">'.$db_settings['db'].'</td>'."\n";
234 $output .= ' </tr><tr>'."\n";
235 $output .= ' <td class="definition">'.$lang_add['inst_db_user'].'<br />'."\n";
236 $output .= '<span class="small">'.$lang_add['inst_db_user_d'].'</span></td>'."\n";
237 $output .= ' <td class="description">'.$db_settings['user'].'</td>'."\n";
238 $output .= ' </tr><tr>'."\n";
239 $output .= ' <td class="definition">'.$lang_add['inst_db_pw'].'<br />'."\n";
240 $output .= ' <span class="small">'.$lang_add['inst_db_pw_d'].'</span></td>'."\n";
241 $output .= ' <td class="description">'.$passWord.'</td>'."\n";
242 $output .= ' </tr><tr>'."\n";
243 $output .= ' <td class="definition">'.$lang_add['inst_table_prefix'].'<br />'."\n";
244 $output .= ' <span class="small">'.$lang_add['inst_table_prefix_d'].'</span></td>'."\n";
245 $output .= ' <td class="description">'.$prefix.'</td>'."\n";
246 $output .= ' </tr>'."\n";
247 $output .= '</table>'."\n";
248 $output .= '<h2>'.$lang_add['update_current_dbtables'].'</h2>'."\n";
249 $output .= '<ol>'."\n";
250 foreach ($db_settings as $key => $val) {
251 $found = strpos($key, '_table');
252 if ($found !== false) {
253 $output .= ' <li>'.$val.'</li>'."\n";
256 $output .= '</ol>'."\n";
257 if ($oldVersionShort < $settings['version'])
259 $output .= '<h2>'.$lang_add['update_new_dbtables'].'</h2>'."\n";
260 if ($settings['version'] == "1.8")
262 $output .= '<p>'.$lang_add['update_news_message_1.8'].'</p>';
265 $output .= '<form action="update.php" method="post">'."\n";
266 $output .= '<table class="admintab">'."\n";
267 $output .= ' <tr>'."\n";
268 $output .= ' <td class="definition">'.$lang_add["delete_2char_smilies"].'<br />'."\n";
269 $output .= ' <span class="small">'.$lang_add['delete_2char_smilies_d'].'</td>'."\n";
270 $output .= ' <td class="description">'."\n";
271 $output .= ' <input type="radio" id="DeleteSmilies" name="DeleteSmilies" value="delete" checked="checked" /><label for="DeleteSmilies">'.$lang['yes'].'</label>'."\n";
272 $output .= ' <input type="radio" id="StoreSmilies" name="DeleteSmilies" value="store" /><label for="StoreSmilies">'.$lang['no'].'</label></td>'."\n";
273 $output .= ' </tr>'."\n";
274 $output .= '</table>'."\n";
276 # $output .= '<li><input type="checkbox" name="dont_overwrite_settings" value="true"';
277 # $output .= isset($_POST['dont_overwrite_settings']) ? ' checked="checked"' : '';
278 # $output .= '>'.$lang_add['dont_overwrite_settings'].'</li>';
279 # $output .= '</ul>';
280 $output .= '<p><input type="submit" name="form_submitted" value="'.$lang_add['forum_update_ok'].'" /></p>'."\n";
281 $output .= '<input type="hidden" name="language" value="'.$lang['language'].'" />'."\n";
282 $output .= '<input type="hidden" name="installation_mode" value="update" />'."\n";
283 $output .= '<input type="hidden" name="table_prefix" value="'.$prefix.'" />'."\n";
284 $output .= '</form>'."\n";
285 } # End: if (isset($_POST['form_submitted'])) (else)
286 } # End: if (!is_array($oldSettings)) (else)
287 } # End: if ($connid === false) (else)
289 ?
><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
290 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="<?php echo $lang['language']; ?>">
292 <meta http
-equiv
="content-type" content
="text/html; charset=UTF-8" />
293 <title
><?php
echo $settings['forum_name']." - ".$lang_add['install_title']; ?
></title
>
294 <style type
="text/css">
297 font
-family
: sans
-serif
;
300 background
-color
: #fff;
319 border
: 1px solid
#bacbdf;
320 border
-collapse
: collapse
;
324 background
-color
: #f5f5f5;
328 border
-right
: 1px dotted
#bacbdf;
329 border
-bottom
: 1px solid
#bacbdf;
331 table
.admintab td
:nth
-child(n+
2):nth
-child(n+
2) {
332 background
-color
: #f8f8f8;
336 table
.admintab td
.definition
{
339 table
.admintab td
.definition
.small
{
342 .caution
{ color
: red
; font
-weight
: bold
; }
343 .small
{ font
-size
: 0.86em
; line
-height
:150%
; }
344 a
:link
{ color
: #0000cc; text-decoration: none; }
345 a
:visited
{ color
: #0000cc; text-decoration: none; }
346 a
:focus
, a
:hover
{ color
: #0000ff; text-decoration: underline; }
347 a
:active
{ color
: #ff0000; text-decoration: none; }
353 <h1
><?php
echo $lang_add['installation_mode_update']; ?
></h1
>
355 #if (!empty($errors) and is_array($errors)) {
356 # echo errorMessages($errors);