3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the Revised BSD License.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 Revised BSD License for more details.
11 Copyright 2004-2024 iDB Support - https://idb.osdn.jp/support/category.php?act=view&id=1
12 Copyright 2004-2024 Game Maker 2k - https://idb.osdn.jp/support/category.php?act=view&id=2
13 iDB Installer made by Game Maker 2k - https://idb.osdn.jp/support/category.php?act=view&id=2support/category.php?act=view&id=2
15 $FileInfo: install.php - Last Update: 8/26/2024 SVN 1048 - Author: cooldude2k $
17 if(ini_get("register_globals")) {
18 require_once('inc/misc/killglobals.php'); }
19 *//* Some ini setting changes uncomment if you need them.
21 $disfunc = @ini_get
("disable_functions");
22 $disfunc = @preg_replace
("/[\s\t\n\r\0\x0B]+/", "", $disfunc);
23 $disfunc = $disfunc ?
explode(",", $disfunc) : [];
24 if (!in_array("ini_set", $disfunc)) {
25 @ini_set
("html_errors", false);
26 @ini_set
("track_errors", false);
27 @ini_set
("display_errors", false);
28 @ini_set
("report_memleaks", false);
29 @ini_set
("display_startup_errors", false);
30 @ini_set
("error_log", "logs/error.log");
31 @ini_set
("log_errors", "On");
32 @ini_set
("docref_ext", "");
33 @ini_set
("docref_root", "http://php.net/");
35 /* Get rid of session id in URLs */
36 @ini_set
("default_mimetype", "text/html");
37 @ini_set
("zlib.output_compression", false);
38 @ini_set
("zlib.output_compression_level", -1);
39 @ini_set
("session.use_trans_sid", false);
40 @ini_set
("session.use_cookies", true);
41 @ini_set
("session.use_only_cookies", true);
42 @ini_set
("url_rewriter.tags", "");
43 @ini_set
('zend.ze1_compatibility_mode', 0);
44 @ini_set
("ignore_user_abort", 1);
46 /* Change session garbage collection settings */
47 @ini_set
("session.gc_probability", 1);
48 @ini_set
("session.gc_divisor", 100);
49 @ini_set
("session.gc_maxlifetime", 1440);
51 /* Change session hash type */
52 @ini_set
("session.hash_function", 1);
53 @ini_set
("session.hash_bits_per_character", 6);
55 if (!defined("E_DEPRECATED")) {
56 define("E_DEPRECATED", 0);
58 @error_reporting
(E_ALL
& ~E_NOTICE
& ~E_DEPRECATED
);
60 @ignore_user_abort
(true);
61 /* Do not change anything below this line unless you know what you are doing */
62 if (file_exists('extrasettings.php')) {
63 require_once('extrasettings.php');
65 if (file_exists('extendsettings.php')) {
66 require_once('extendsettings.php');
68 // Custom error handler for non-fatal errors
69 // Configuration settings
70 $errorDisplay = true; // Set to true to display errors on the screen
71 $errorLogFile = true; // Set to true to log errors to a file
72 if (!isset($SettDir['logs'])) {
73 $SettDir['logs'] = "./logs";
75 $logFilePath = $SettDir['logs'] . 'php_error_log.txt'; // Define your log file path
77 // Custom Error Handler Function
78 function customErrorHandler($errno, $errstr, $errfile, $errline)
80 global $errorDisplay, $errorLogFile, $logFilePath;
82 // List of error types we want to handle
84 E_ERROR
=> 'Fatal Error',
85 E_WARNING
=> 'Warning',
86 E_PARSE
=> 'Parse Error',
88 E_CORE_ERROR
=> 'Core Error',
89 E_CORE_WARNING
=> 'Core Warning',
90 E_COMPILE_ERROR
=> 'Compile Error',
91 E_COMPILE_WARNING
=> 'Compile Warning',
92 E_USER_ERROR
=> 'User Error',
93 E_USER_WARNING
=> 'User Warning',
94 E_USER_NOTICE
=> 'User Notice',
95 E_STRICT
=> 'Strict Notice',
96 E_RECOVERABLE_ERROR
=> 'Recoverable Error',
97 E_DEPRECATED
=> 'Deprecated Notice',
98 E_USER_DEPRECATED
=> 'User Deprecated Notice'
101 // Safely retrieve and clean the output buffer
103 if (ob_get_length()) {
104 $output = ob_get_clean(); // Get and clear the buffer without sending it
107 // Check if the error type is in our list of handled types
108 $errorType = isset($errorTypes[$errno]) ?
$errorTypes[$errno] : 'Unknown Error';
110 // Prepare the error message
111 $errorMessage = "<b>{$errorType}:</b> [$errno] $errstr - $errfile:$errline<br>";
114 $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS
);
115 $backtraceMessage = getBacktraceAsString($backtrace);
117 // Display the error if enabled
120 echo "<b>Backtrace:</b><br>";
121 echo $backtraceMessage;
124 // Log the error to a file if enabled
126 logErrorToFile($logFilePath, $errorType, $errno, $errstr, $errfile, $errline, $backtrace);
129 // Output the captured content again if needed
132 // Depending on the error, you might want to stop the script
133 if ($errno === E_ERROR ||
$errno === E_PARSE ||
$errno === E_CORE_ERROR ||
$errno === E_COMPILE_ERROR
) {
137 // Return true to prevent the PHP internal error handler from executing
141 // Custom Shutdown Handler Function
142 function shutdownHandler()
144 global $errorDisplay, $errorLogFile, $logFilePath;
146 $last_error = error_get_last();
148 // Check if $last_error is not null before accessing its elements
149 if ($last_error !== null) {
150 // Check if the error type is E_ERROR or E_PARSE (fatal errors)
151 if ($last_error['type'] === E_ERROR ||
$last_error['type'] === E_PARSE ||
$last_error['type'] === E_CORE_ERROR ||
$last_error['type'] === E_COMPILE_ERROR
) {
153 // Safely retrieve and clean the output buffer
155 if (ob_get_length()) {
156 $output = ob_get_clean(); // Get and clear the buffer without sending it
159 // Prepare the error message
160 $errorMessage = "<b>Fatal Error:</b> {$last_error['message']} - {$last_error['file']}:{$last_error['line']}<br>";
163 $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS
);
164 $backtraceMessage = getBacktraceAsString($backtrace);
166 // Display the error if enabled
169 echo "<b>Backtrace:</b><br>";
170 echo $backtraceMessage;
173 // Log the error to a file if enabled
175 logErrorToFile($logFilePath, 'Fatal Error', $last_error['type'], $last_error['message'], $last_error['file'], $last_error['line'], $backtrace);
178 // Output the captured content again if needed
184 // Custom Exception Handler Function
185 // Custom Exception Handler Function
186 function customExceptionHandler($exception)
188 global $errorDisplay, $errorLogFile, $logFilePath;
190 // Safely retrieve and clean the output buffer
192 if (ob_get_length()) {
193 $output = ob_get_clean(); // Get and clear the buffer without sending it
196 // Prepare the uncaught exception message
197 $errorMessage = "<b>Uncaught Exception:</b> " . $exception->getMessage() . " in " . $exception->getFile() . " on line " . $exception->getLine() . "<br>";
199 // Get the backtrace from the exception
200 $backtrace = $exception->getTrace();
201 $backtraceMessage = getBacktraceAsString($backtrace);
203 // Display the exception if enabled
206 echo "<b>Backtrace:</b><br>";
207 echo $backtraceMessage;
210 // Log the exception to a file if enabled
212 logErrorToFile($logFilePath, 'Uncaught Exception', 0, $exception->getMessage(), $exception->getFile(), $exception->getLine(), $backtrace);
215 // Output the captured content again if needed
218 // Stop the script after an uncaught exception
222 // Function to Convert Backtrace Array to String for Display/Logging
223 function getBacktraceAsString($backtrace)
225 $backtraceMessage = "";
226 foreach ($backtrace as $trace) {
227 if (isset($trace['file'])) {
228 $backtraceMessage .= "Called in <b>{$trace['file']}</b> on line <b>{$trace['line']}</b>";
229 if (isset($trace['function'])) {
230 $backtraceMessage .= " (function <b>{$trace['function']}</b>)";
232 $backtraceMessage .= "<br>";
235 return $backtraceMessage;
238 // Function to Log Errors to a File
239 function logErrorToFile($logFile, $errorType, $errno, $errstr, $errfile, $errline, $backtrace)
241 $logMessage = "[" . date('Y-m-d H:i:s') . "] {$errorType}: [{$errno}] {$errstr} in {$errfile} on line {$errline}\n";
243 // Append backtrace to the log
244 foreach ($backtrace as $trace) {
245 if (isset($trace['file'])) {
246 $logMessage .= "Called in {$trace['file']} on line {$trace['line']}";
247 if (isset($trace['function'])) {
248 $logMessage .= " (function {$trace['function']})";
254 // Append to the log file
255 file_put_contents($logFile, $logMessage, FILE_APPEND
);
258 // Set the custom error handler
259 set_error_handler("customErrorHandler");
261 // Register the shutdown function to catch fatal errors
262 register_shutdown_function('shutdownHandler');
264 // Set exception handler to catch uncaught exceptions
265 set_exception_handler('customExceptionHandler');
267 if (!isset($Settings['qstr'])) {
268 $Settings['qstr'] = null;
270 if (!isset($Settings['send_pagesize'])) {
271 $Settings['send_pagesize'] = "off";
273 $deftz = new DateTimeZone(date_default_timezone_get());
274 $defcurtime = new DateTime();
275 $defcurtime->setTimezone($deftz);
276 $utctz = new DateTimeZone("UTC");
277 $utccurtime = new DateTime();
278 $utccurtime->setTimestamp($defcurtime->getTimestamp());
279 $utccurtime->setTimezone($utctz);
280 $servcurtime = new DateTime();
281 $servcurtime->setTimestamp($defcurtime->getTimestamp());
282 $usercurtime = new DateTime();
283 $usercurtime->setTimestamp($defcurtime->getTimestamp());
284 /* Do not change anything below this line unless you know what you are doing */
285 if (!isset($Settings['clean_ob'])) {
286 $Settings['clean_ob'] = "off";
288 function idb_output_handler($buffer)
292 function idb_suboutput_handler($buffer)
296 if ($Settings['clean_ob'] == "on") {
297 /* Check for other output handlers/buffers are open
298 and close and get the contents in an array */
299 $numob = count(ob_list_handlers());
301 while ($iob < $numob) {
302 $old_ob_var[$iob] = ob_get_clean();
305 } ob_start("idb_output_handler");
306 if (ini_get("register_globals")) {
307 if (!isset($SettDir['misc'])) {
308 $SettDir['misc'] = "inc/misc/";
310 require_once($SettDir['misc'].'killglobals.php');
312 if (!isset($preact['idb'])) {
313 $preact['idb'] = null;
315 if (!isset($_GET['act'])) {
318 if (!isset($_POST['act'])) {
319 $_POST['act'] = null;
321 if ($_GET['act'] == null ||
$_GET['act'] == "view") {
322 $_GET['act'] = "part1";
324 if ($_POST['act'] == null ||
$_POST['act'] == "view") {
325 $_POST['act'] = "part1";
328 $_TEG['part'] = preg_replace("/Part(1|2|3|4)/", "\\1", $_GET['act']);
329 $_GET['act'] = strtolower($_GET['act']);
330 if (isset($_TEG['part'])) {
331 if ($_TEG['part'] <= 4 && $_TEG['part'] >= 1) {
332 $_GET['act'] = "Part".$_TEG['part'];
335 if ($_GET['act'] != "part4" && $_POST['act'] != "part4") {
336 $preact['idb'] = "installing";
338 $SetupDir['setup'] = "setup/";
339 $ConvertDir['setup'] = $SetupDir['setup'];
340 $SetupDir['sql'] = "setup/sql/";
341 $SetupDir['convert'] = "setup/convert/";
342 $ConvertDir['convert'] = $SetupDir['convert'];
343 $ConvertDir['sql'] = $SetupDir['sql'];
344 $Settings['output_type'] = "html";
345 $Settings['html_type'] = "html5";
347 $Settings['board_name'] = $iDB;
349 if (!isset($Settings['charset'])) {
350 $Settings['charset'] = "ISO-8859-15";
351 header("Content-Type: text/html; charset=ISO-8859-15");
353 if (isset($Settings['charset'])) {
354 if ($Settings['charset'] != "ISO-8859-15" && $Settings['charset'] != "ISO-8859-1" &&
355 $Settings['charset'] != "UTF-8" && $Settings['charset'] != "CP866" &&
356 $Settings['charset'] != "Windows-1251" && $Settings['charset'] != "Windows-1252" &&
357 $Settings['charset'] != "KOI8-R" && $Settings['charset'] != "BIG5" &&
358 $Settings['charset'] != "GB2312" && $Settings['charset'] != "BIG5-HKSCS" &&
359 $Settings['charset'] != "Shift_JIS" && $Settings['charset'] != "EUC-JP") {
360 $Settings['charset'] = "ISO-8859-15";
361 header("Content-Type: text/html; charset=ISO-8859-15");
364 $SQLCharset = "latin1";
365 if (isset($_POST['charset'])) {
366 if ($_POST['charset'] == "ISO-8859-1") {
367 $SQLCharset = "latin1";
369 if ($_POST['charset'] == "ISO-8859-15") {
370 $SQLCharset = "latin1";
372 if ($_POST['charset'] == "UTF-8") {
373 $SQLCharset = "utf8";
375 $Settings['charset'] = $_POST['charset'];
378 if (isset($_SERVER['HTTPS'])) {
381 if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
384 if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "off") {
387 if (!isset($_SERVER['HTTPS'])) {
390 if ($ServHTTPS == "on") {
391 $prehost = "https://";
393 if ($ServHTTPS == "off") {
394 $prehost = "http://";
397 if (dirname($_SERVER['SCRIPT_NAME']) != "." ||
398 dirname($_SERVER['SCRIPT_NAME']) != null) {
399 $this_dir = dirname($_SERVER['SCRIPT_NAME'])."/";
401 if ($this_dir == null ||
$this_dir == ".") {
402 if (dirname($_SERVER['SCRIPT_NAME']) == "." ||
403 dirname($_SERVER['SCRIPT_NAME']) == null) {
404 $this_dir = dirname($_SERVER['PHP_SELF'])."/";
407 if ($this_dir == "\/") {
410 $this_dir = str_replace("//", "/", $this_dir);
411 $idbdir = addslashes(str_replace("\\", "/", dirname(__FILE__
)."/"));
412 if (!isset($_POST['BoardURL'])) {
413 $Settings['idburl'] = $prehost.$_SERVER['HTTP_HOST'].$this_dir;
415 if (isset($_POST['BoardURL'])) {
416 $Settings['idburl'] = $_POST['BoardURL'];
418 $Settings['qstr'] = "&";
419 $Settings['qsep'] = "=";
420 require($SetupDir['setup'].'preinstall.php');
421 require_once($SettDir['misc'].'utf8.php');
422 require_once($SettDir['inc'].'filename.php');
423 require_once($SettDir['inc'].'function.php');
424 if ($_GET['act'] == "README" ||
$_GET['act'] == "ReadME") {
425 $_GET['act'] = "readme";
427 if ($_GET['act'] == "readme" ||
$_GET['act'] == "ReadMe") {
428 header("Content-Type: text/plain; charset=".$Settings['charset']);
433 if ($_GET['act'] == "LICENSE" ||
$_GET['act'] == "License") {
434 $_GET['act'] = "license";
436 if ($_GET['act'] == "license" ||
$_GET['act'] == "BSD") {
437 header("Content-Type: text/plain; charset=".$Settings['charset']);
442 if ($_GET['act'] == "TOS" ||
$_GET['act'] == "ToS") {
443 $_GET['act'] = "tos";
445 if ($_GET['act'] == "tos" ||
$_GET['act'] == "terms") {
446 header("Content-Type: text/plain; charset=".$Settings['charset']);
451 $Settings['board_name'] = $RFullName;
452 function get_theme_values($matches)
456 if (isset($ThemeSet[$matches[1]])) {
457 $return_text = $ThemeSet[$matches[1]];
459 if (!isset($ThemeSet[$matches[1]])) {
464 foreach ($ThemeSet as $key => $value) {
465 if (isset($ThemeSet[$key])) {
466 $ThemeSet[$key] = preg_replace("/%%/s", "{percent}p", $ThemeSet[$key]);
467 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}T/s", "get_theme_values", $ThemeSet[$key]);
468 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}e/s", "get_env_values", $ThemeSet[$key]);
469 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}i/s", "get_server_values", $ThemeSet[$key]);
470 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}s/s", "get_setting_values", $ThemeSet[$key]);
471 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}t/s", "get_time", $ThemeSet[$key]);
472 $ThemeSet[$key] = preg_replace("/\{percent\}p/s", "%", $ThemeSet[$key]);
475 require($SetupDir['convert'].'info.php');
476 require($SetupDir['setup'].'html5.php');
478 $_GET['time'] = false;
479 $title_html = htmlentities("Installing ".$VerInfo['iDB_Ver_Show'], ENT_QUOTES
, $Settings['charset']);
481 <meta itemprop
="title" property
="og:title" content
="<?php echo $title_html; ?>" />
482 <meta itemprop
="sitename" property
="og:site_name" content
="<?php echo $title_html; ?>" />
483 <meta itemprop
="title" property
="twitter:title" content
="<?php echo $title_html; ?>" />
484 <meta name
="title" content
="<?php echo $title_html; ?>" />
485 <title
> <?php
echo "Installing ".$VerInfo['iDB_Ver_Show']; ?
> </title
>
488 <?php
require($SettDir['inc'].'navbar.php'); ?
>
489 <div
class="Table1Border">
490 <?php
if ($ThemeSet['TableStyle'] == "div") { ?
>
491 <div
class="TableRow1">
492 <span style
="font-weight: bold; text-align: left;"><?php
echo $ThemeSet['TitleIcon']; ?
><a href
="<?php echo url_maker("install
", ".php
", "act
=part1
", "&", "=", null, null); ?>">Install
<?php
echo $VerInfo['iDB_Ver_Show']; ?
> </a
></span
>
495 <table
class="Table1">
496 <?php
if ($ThemeSet['TableStyle'] == "table") { ?
>
497 <tr
class="TableRow1">
498 <td
class="TableColumn1"><span style
="font-weight: bold; text-align: left;"><?php
echo $ThemeSet['TitleIcon']; ?
><a href
="<?php echo url_maker("install
", ".php
", "act
=part1
", "&", "=", null, null); ?>">Install
<?php
echo $VerInfo['iDB_Ver_Show']; ?
> </a
></span
>
501 <tr
class="TableRow2">
502 <th
class="TableColumn2" style
="width: 100%; text-align: left;">
503 <span style
="float: left;"> Inert your install info: </span>
504 <span style
="float: right;"> </span>
508 if ($ServHTTPS == "on") {
509 $prehost = "https://";
511 if ($ServHTTPS != "on") {
512 $prehost = "http://";
515 if (dirname($_SERVER['SCRIPT_NAME']) != "." ||
516 dirname($_SERVER['SCRIPT_NAME']) != null) {
517 $this_dir = dirname($_SERVER['SCRIPT_NAME'])."/";
519 if ($this_dir == null ||
$this_dir == ".") {
520 if (dirname($_SERVER['SCRIPT_NAME']) == "." ||
521 dirname($_SERVER['SCRIPT_NAME']) == null) {
522 $this_dir = dirname($_SERVER['PHP_SELF'])."/";
525 if ($this_dir == "\/") {
528 $this_dir = str_replace("//", "/", $this_dir);
529 $idbdir = addslashes(str_replace("\\", "/", dirname(__FILE__
)."/"));
530 function sql_list_dbs()
532 $result = sql_query("SHOW DATABASES;", $SQLStat);
533 while ($data = sql_fetch_row($result)) {
537 if ($_GET['act'] == "part1" && $_POST['act'] == "part1") {
538 if ($_GET['act'] != "part2" && $_POST['act'] != "part2") {
539 if ($_GET['act'] != "part3" && $_POST['act'] != "part3") {
540 if ($_GET['act'] != "part4" && $_POST['act'] != "part4") {
541 require($SetupDir['setup'].'license.php');
546 if ($_GET['act'] != "part1" && $_POST['act'] != "part1") {
547 if ($_GET['act'] == "part2" && $_POST['act'] == "part2") {
548 if ($_GET['act'] != "part3" && $_POST['act'] != "part3") {
549 if ($_GET['act'] != "part4" && $_POST['act'] != "part4") {
550 require($SetupDir['setup'].'presetup.php');
555 if ($_POST['SetupType'] == "convert") {
556 require($ConvertInfo['ConvertFile']);
558 if ($_POST['SetupType'] == "install") {
559 if ($_GET['act'] != "part1" && $_POST['act'] != "part1") {
560 if ($_GET['act'] != "part2" && $_POST['act'] != "part2") {
561 if ($_GET['act'] == "part3" && $_POST['act'] == "part3") {
562 if ($_GET['act'] != "part4" && $_POST['act'] != "part4") {
563 require($SetupDir['setup'].'setup.php');
569 if ($_POST['SetupType'] == "install") {
570 if ($_GET['act'] != "part1" && $_POST['act'] != "part1") {
571 if ($_GET['act'] != "part2" && $_POST['act'] != "part2") {
572 if ($_GET['act'] != "part3" && $_POST['act'] != "part3") {
573 if ($_GET['act'] == "part4" && $_POST['act'] == "part4") {
574 require($SetupDir['setup'].'mkconfig.php');
580 if ($Error == "Yes") { ?
>
581 <br
/>Install Failed with errors
. <a href
="<?php echo url_maker("install
", ".php
", "act
=part1
", "&", "=", null, null); ?>">Click here
</a
> to restart install
. <
;_
<
;
586 <tr
class="TableRow4">
587 <td
class="TableColumn4"> <a href="<?php echo url_maker("install", ".php", "act=ReadMe", "&", "=", null, null); ?>">Readme.txt</a> | <a href="<?php echo url_maker("install", ".php", "act=License", "&", "=", null, null); ?>">License.txt</a> </td>
592 require($SettDir['inc'].'endpage.php');