Update killglobals.php
[iDB.git] / install.php
blob99dc111b4b1334a86cf5f8078a656bd1cf4a6487
1 <?php
2 /*
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-2023 iDB Support - https://idb.osdn.jp/support/category.php?act=view&id=1
12 Copyright 2004-2023 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: 6/22/2023 SVN 984 - Author: cooldude2k $
16 *//*
17 if(ini_get("register_globals")) {
18 require_once('inc/misc/killglobals.php'); }
19 *//* Some ini setting changes uncomment if you need them.
20 Display PHP Errors */
21 $disfunc = @ini_get("disable_functions");
22 $disfunc = @trim($disfunc);
23 $disfunc = @preg_replace("/([\\s+|\\t+|\\n+|\\r+|\\0+|\\x0B+])/i", "", $disfunc);
24 if($disfunc!="ini_set") { $disfunc = explode(",",$disfunc); }
25 if($disfunc=="ini_set") { $disfunc = array("ini_set"); }
26 if(!in_array("ini_set", $disfunc)) {
27 @ini_set("html_errors", false);
28 @ini_set("track_errors", false);
29 @ini_set("display_errors", false);
30 @ini_set("report_memleaks", false);
31 @ini_set("display_startup_errors", false);
32 //@ini_set("error_log","logs/error.log");
33 //@ini_set("log_errors","On");
34 @ini_set("docref_ext", "");
35 @ini_set("docref_root", "http://php.net/"); }
36 if(!defined("E_DEPRECATED")) { define("E_DEPRECATED", 0); }
37 @error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
38 /* Get rid of session id in urls */
39 if(!in_array("ini_set", $disfunc)) {
40 @ini_set("default_mimetype","text/html");
41 @ini_set("zlib.output_compression", false);
42 @ini_set("zlib.output_compression_level", -1);
43 @ini_set("session.use_trans_sid", false);
44 @ini_set("session.use_cookies", true);
45 @ini_set("session.use_only_cookies", true);
46 @ini_set("url_rewriter.tags","");
47 @ini_set('zend.ze1_compatibility_mode', 0);
48 @ini_set("ignore_user_abort", 1); }
49 @set_time_limit(30); @ignore_user_abort(true);
50 /* Change session garbage collection settings */
51 if(!in_array("ini_set", $disfunc)) {
52 @ini_set("session.gc_probability", 1);
53 @ini_set("session.gc_divisor", 100);
54 @ini_set("session.gc_maxlifetime", 1440);
55 /* Change session hash type here */
56 @ini_set("session.hash_function", 1);
57 @ini_set("session.hash_bits_per_character", 6); }
58 if(file_exists('extrasettings.php')) {
59 require_once('extrasettings.php'); }
60 if(file_exists('extendsettings.php')) {
61 require_once('extendsettings.php'); }
62 if(!isset($Settings['qstr'])) { $Settings['qstr'] = null; }
63 if(!isset($Settings['send_pagesize'])) { $Settings['send_pagesize'] = "off"; }
64 $deftz = new DateTimeZone(date_default_timezone_get());
65 $defcurtime = new DateTime();
66 $defcurtime->setTimezone($deftz);
67 $utctz = new DateTimeZone("UTC");
68 $utccurtime = new DateTime();
69 $utccurtime->setTimestamp($defcurtime->getTimestamp());
70 $utccurtime->setTimezone($utctz);
71 $servcurtime = new DateTime();
72 $servcurtime->setTimestamp($defcurtime->getTimestamp());
73 $usercurtime = new DateTime();
74 $usercurtime->setTimestamp($defcurtime->getTimestamp());
75 /* Do not change anything below this line unless you know what you are doing */
76 if(!isset($Settings['clean_ob'])) { $Settings['clean_ob'] = "off"; }
77 function idb_output_handler($buffer) { return $buffer; }
78 if($Settings['clean_ob']=="on") {
79 /* Check for other output handlers/buffers are open
80 and close and get the contents in an array */
81 $numob = count(ob_list_handlers()); $iob = 0;
82 while ($iob < $numob) {
83 $old_ob_var[$iob] = ob_get_clean();
84 ++$iob; } } ob_start("idb_output_handler");
85 if(ini_get("register_globals")) {
86 if(!isset($SettDir['misc'])) { $SettDir['misc'] = "inc/misc/"; }
87 require_once($SettDir['misc'].'killglobals.php'); }
88 if(!isset($preact['idb'])) { $preact['idb'] = null; }
89 if(!isset($_GET['act'])) { $_GET['act'] = null; }
90 if(!isset($_POST['act'])) { $_POST['act'] = null; }
91 if ($_GET['act']==null||$_GET['act']=="view") { $_GET['act']="Part1"; }
92 if ($_POST['act']==null||$_POST['act']=="view") { $_POST['act']="Part1"; }
93 $_TEG = array(null); $_TEG['part'] = preg_replace("/Part(1|2|3|4)/","\\1",$_GET['act']);
94 $_GET['act'] = strtolower($_GET['act']); if(isset($_TEG['part'])) {
95 if($_TEG['part']<=4&&$_TEG['part']>=1) { $_GET['act'] = "Part".$_TEG['part']; } }
96 if ($_GET['act']!="Part4"&&$_POST['act']!="Part4") {
97 $preact['idb'] = "installing"; }
98 $SetupDir['setup'] = "setup/"; $ConvertDir['setup'] = $SetupDir['setup']; $SetupDir['sql'] = "setup/sql/";
99 $SetupDir['convert'] = "setup/convert/"; $ConvertDir['convert'] = $SetupDir['convert']; $ConvertDir['sql'] = $SetupDir['sql'];
100 $Settings['output_type'] = "html"; $Settings['html_type'] = "html5";
101 if(isset($iD)) {
102 $Settings['board_name'] = $iDB; }
103 if(!isset($Settings['charset'])) {
104 $Settings['charset'] = "ISO-8859-15";
105 header("Content-Type: text/html; charset=ISO-8859-15"); }
106 if(isset($Settings['charset'])) {
107 if($Settings['charset']!="ISO-8859-15"&&$Settings['charset']!="ISO-8859-1"&&
108 $Settings['charset']!="UTF-8"&&$Settings['charset']!="CP866"&&
109 $Settings['charset']!="Windows-1251"&&$Settings['charset']!="Windows-1252"&&
110 $Settings['charset']!="KOI8-R"&&$Settings['charset']!="BIG5"&&
111 $Settings['charset']!="GB2312"&&$Settings['charset']!="BIG5-HKSCS"&&
112 $Settings['charset']!="Shift_JIS"&&$Settings['charset']!="EUC-JP") {
113 $Settings['charset'] = "ISO-8859-15";
114 header("Content-Type: text/html; charset=ISO-8859-15"); } }
115 $SQLCharset = "latin1";
116 if(isset($_POST['charset'])) {
117 if($_POST['charset']=="ISO-8859-1") {
118 $SQLCharset = "latin1"; }
119 if($_POST['charset']=="ISO-8859-15") {
120 $SQLCharset = "latin1"; }
121 if($_POST['charset']=="UTF-8") {
122 $SQLCharset = "utf8"; }
123 $Settings['charset'] = $_POST['charset']; }
124 $ServHTTPS = "off";
125 if(isset($_SERVER['HTTPS'])) { $ServHTTPS=="on"; }
126 if(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']=="on") { $ServHTTPS=="on"; }
127 if(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']=="off") { $ServHTTPS=="off"; }
128 if(!isset($_SERVER['HTTPS'])) { $ServHTTPS=="off"; }
129 if($ServHTTPS=="on") { $prehost = "https://"; }
130 if($ServHTTPS=="off") { $prehost = "http://"; }
131 $this_dir = null;
132 if(dirname($_SERVER['SCRIPT_NAME'])!="."||
133 dirname($_SERVER['SCRIPT_NAME'])!=null) {
134 $this_dir = dirname($_SERVER['SCRIPT_NAME'])."/"; }
135 if($this_dir==null||$this_dir==".") {
136 if(dirname($_SERVER['SCRIPT_NAME'])=="."||
137 dirname($_SERVER['SCRIPT_NAME'])==null) {
138 $this_dir = dirname($_SERVER['PHP_SELF'])."/"; } }
139 if($this_dir=="\/") { $this_dir="/"; }
140 $this_dir = str_replace("//", "/", $this_dir);
141 $idbdir = addslashes(str_replace("\\","/",dirname(__FILE__)."/"));
142 if(!isset($_POST['BoardURL'])) {
143 $Settings['idburl'] = $prehost.$_SERVER["HTTP_HOST"].$this_dir; }
144 if(isset($_POST['BoardURL'])) {
145 $Settings['idburl'] = $_POST['BoardURL']; }
146 $Settings['qstr'] = "&";
147 $Settings['qsep'] = "=";
148 require($SetupDir['setup'].'preinstall.php');
149 require_once($SettDir['misc'].'utf8.php');
150 require_once($SettDir['inc'].'filename.php');
151 require_once($SettDir['inc'].'function.php');
152 if($_GET['act']=="README"||$_GET['act']=="ReadME") { $_GET['act']="readme"; }
153 if($_GET['act']=="readme"||$_GET['act']=="ReadMe") {
154 header("Content-Type: text/plain; charset=".$Settings['charset']);
155 require("README"); fix_amp(null); die(); }
156 if($_GET['act']=="LICENSE"||$_GET['act']=="License") { $_GET['act']="license"; }
157 if($_GET['act']=="license"||$_GET['act']=="BSD") {
158 header("Content-Type: text/plain; charset=".$Settings['charset']);
159 require("LICENSE"); fix_amp(null); die(); }
160 if($_GET['act']=="TOS"||$_GET['act']=="ToS") { $_GET['act']="tos"; }
161 if($_GET['act']=="tos"||$_GET['act']=="terms") {
162 header("Content-Type: text/plain; charset=".$Settings['charset']);
163 require("TOS"); fix_amp(null); die(); }
164 $Settings['board_name'] = $RFullName;
165 function get_theme_values($matches) {
166 global $ThemeSet;
167 $return_text = null;
168 if(isset($ThemeSet[$matches[1]])) { $return_text = $ThemeSet[$matches[1]]; }
169 if(!isset($ThemeSet[$matches[1]])) { $return_text = null; }
170 return $return_text; }
171 foreach($ThemeSet AS $key => $value) {
172 if(isset($ThemeSet[$key])) {
173 $ThemeSet[$key] = preg_replace("/%%/s", "{percent}p", $ThemeSet[$key]);
174 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}T/s", "get_theme_values", $ThemeSet[$key]);
175 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}e/s", "get_env_values", $ThemeSet[$key]);
176 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}i/s", "get_server_values", $ThemeSet[$key]);
177 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}s/s", "get_setting_values", $ThemeSet[$key]);
178 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}t/s", "get_time", $ThemeSet[$key]);
179 $ThemeSet[$key] = preg_replace("/\{percent\}p/s", "%", $ThemeSet[$key]); } }
180 require($SetupDir['convert'].'info.php');
181 require($SetupDir['setup'].'html5.php');
182 $Error = null; $_GET['time'] = false;
183 $title_html = htmlentities("Installing ".$VerInfo['iDB_Ver_Show'], ENT_QUOTES, $Settings['charset']);
185 <meta itemprop="title" property="og:title" content="<?php echo $title_html; ?>" />
186 <meta itemprop="sitename" property="og:site_name" content="<?php echo $title_html; ?>" />
187 <meta itemprop="title" property="twitter:title" content="<?php echo $title_html; ?>" />
188 <meta name="title" content="<?php echo $title_html; ?>" />
189 <title> <?php echo "Installing ".$VerInfo['iDB_Ver_Show']; ?> </title>
190 </head>
191 <body>
192 <?php require($SettDir['inc'].'navbar.php'); ?>
193 <div class="Table1Border">
194 <?php if($ThemeSet['TableStyle']=="div") { ?>
195 <div class="TableRow1">
196 <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>
197 </div>
198 <?php } ?>
199 <table class="Table1">
200 <?php if($ThemeSet['TableStyle']=="table") { ?>
201 <tr class="TableRow1">
202 <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>
203 </td>
204 </tr><?php } ?>
205 <tr class="TableRow2">
206 <th class="TableColumn2" style="width: 100%; text-align: left;">
207 <span style="float: left;">&#160;Inert your install info: </span>
208 <span style="float: right;">&#160;</span>
209 </th>
210 </tr>
211 <?php
212 if($ServHTTPS=="on") { $prehost = "https://"; }
213 if($ServHTTPS!="on") { $prehost = "http://"; }
214 $this_dir = null;
215 if(dirname($_SERVER['SCRIPT_NAME'])!="."||
216 dirname($_SERVER['SCRIPT_NAME'])!=null) {
217 $this_dir = dirname($_SERVER['SCRIPT_NAME'])."/"; }
218 if($this_dir==null||$this_dir==".") {
219 if(dirname($_SERVER['SCRIPT_NAME'])=="."||
220 dirname($_SERVER['SCRIPT_NAME'])==null) {
221 $this_dir = dirname($_SERVER['PHP_SELF'])."/"; } }
222 if($this_dir=="\/") { $this_dir="/"; }
223 $this_dir = str_replace("//", "/", $this_dir);
224 $idbdir = addslashes(str_replace("\\","/",dirname(__FILE__)."/"));
225 function sql_list_dbs() {
226 $result = sql_query("SHOW DATABASES;",$SQLStat);
227 while( $data = sql_fetch_row($result) ) {
228 $array[] = $data[0];
229 } return $array; }
230 if ($_GET['act']=="Part1"&&$_POST['act']=="Part1") {
231 if ($_GET['act']!="Part2"&&$_POST['act']!="Part2") {
232 if ($_GET['act']!="Part3"&&$_POST['act']!="Part3") {
233 if ($_GET['act']!="Part4"&&$_POST['act']!="Part4") {
234 require($SetupDir['setup'].'license.php'); } } } }
235 if ($_GET['act']!="Part1"&&$_POST['act']!="Part1") {
236 if ($_GET['act']=="Part2"&&$_POST['act']=="Part2") {
237 if ($_GET['act']!="Part3"&&$_POST['act']!="Part3") {
238 if ($_GET['act']!="Part4"&&$_POST['act']!="Part4") {
239 require($SetupDir['setup'].'presetup.php'); } } } }
240 if($_POST['SetupType']=="convert") {
241 require($ConvertInfo['ConvertFile']); }
242 if($_POST['SetupType']=="install") {
243 if ($_GET['act']!="Part1"&&$_POST['act']!="Part1") {
244 if ($_GET['act']!="Part2"&&$_POST['act']!="Part2") {
245 if ($_GET['act']=="Part3"&&$_POST['act']=="Part3") {
246 if ($_GET['act']!="Part4"&&$_POST['act']!="Part4") {
247 require($SetupDir['setup'].'setup.php'); } } } } }
248 if($_POST['SetupType']=="install") {
249 if ($_GET['act']!="Part1"&&$_POST['act']!="Part1") {
250 if ($_GET['act']!="Part2"&&$_POST['act']!="Part2") {
251 if ($_GET['act']!="Part3"&&$_POST['act']!="Part3") {
252 if ($_GET['act']=="Part4"&&$_POST['act']=="Part4") {
253 require($SetupDir['setup'].'mkconfig.php'); } } } } }
254 if ($Error=="Yes") { ?>
255 <br />Install Failed with errors. <a href="<?php echo url_maker("install",".php","act=Part1","&","=",null,null); ?>">Click here</a> to restart install. &lt;_&lt;
256 <br /><br />
257 </td>
258 </tr>
259 <?php } ?>
260 <tr class="TableRow4">
261 <td class="TableColumn4">&#160;<a href="<?php echo url_maker("install",".php","act=ReadMe","&","=",null,null); ?>">Readme.txt</a>&#160;|&#160;<a href="<?php echo url_maker("install",".php","act=License","&","=",null,null); ?>">License.txt</a>&#160;</td>
262 </tr>
263 </table></div>
264 <div>&#160;</div>
265 <?php
266 require($SettDir['inc'].'endpage.php');
268 </body>
269 </html>
270 <?php
271 fix_amp(null);