Small update and bug fix. ^_^
[iDB.git] / setup / setup.php
blobdd7ed96d060ea9b0a319571797c428e3dd1bd553
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-2011 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
13 iDB Installer made by Game Maker 2k - http://idb.berlios.net/
15 $FileInfo: setup.php - Last Update: 04/05/2011 SVN 627 - Author: cooldude2k $
17 $File3Name = basename($_SERVER['SCRIPT_NAME']);
18 if ($File3Name=="setup.php"||$File3Name=="/setup.php") {
19 require('index.php');
20 exit(); }
21 if(!isset($SetupDir['setup'])) { $SetupDir['setup'] = "setup/"; }
22 if(!isset($SetupDir['convert'])) { $SetupDir['convert'] = "setup/convert/"; }
24 <tr class="TableRow3">
25 <td class="TableColumn3">
26 <?php
27 $checkfile="settings.php";
28 $iDBRDate = $SVNDay[0]."/".$SVNDay[1]."/".$SVNDay[2];
29 $iDBRSVN = $VER2[2]." ".$SubVerN;
30 $LastUpdateS = "Last Update: ".$iDBRDate." ".$iDBRSVN;
31 $pretext = "<?php\n/*\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n Revised BSD License for more details.\n\n Copyright 2004-".$SVNDay[2]." iDB Support - http://idb.berlios.de/\n Copyright 2004-".$SVNDay[2]." Game Maker 2k - http://gamemaker2k.org/\n iDB Installer made by Game Maker 2k - http://idb.berlios.net/\n\n \$FileInfo: settings.php & settingsbak.php - ".$LastUpdateS." - Author: cooldude2k \$\n*/\n";
32 $pretext2 = array("/* Board Setting Section Begins */\n\$Settings = array();","/* Board Setting Section Ends \n Board Info Section Begins */\n\$SettInfo = array();","/* Board Setting Section Ends \n Board Dir Section Begins */\n\$SettDir = array();","/* Board Dir Section Ends */");
33 $settcheck = "\$File3Name = basename(\$_SERVER['SCRIPT_NAME']);\nif (\$File3Name==\"settings.php\"||\$File3Name==\"/settings.php\"||\n \$File3Name==\"settingsbak.php\"||\$File3Name==\"/settingsbak.php\") {\n header('Location: index.php');\n exit(); }\n";
34 $BoardSettingsBak = $pretext.$settcheck;
35 $BoardSettings = $pretext.$settcheck;
36 $fp = fopen("settings.php","w+");
37 fwrite($fp, $BoardSettings);
38 fclose($fp);
39 // cp("settings.php","settingsbak.php");
40 $fp = fopen("settingsbak.php","w+");
41 fwrite($fp, $BoardSettingsBak);
42 fclose($fp);
43 if (!is_writable($checkfile)) {
44 echo "<br />Settings is not writable.";
45 chmod("settings.php",0755); $Error="Yes";
46 chmod("settingsbak.php",0755);
47 } else { /* settings.php is writable install iDB. ^_^ */ }
48 if(!function_exists("mysql_connect")&&!function_exists("mysqli_connect")&&
49 !function_exists("pg_connect")&&!function_exists("sqlite_open")) { $Error="Yes";
50 echo "<span class=\"TableMessage\">You need to enbale a database php extension to install ".$VerInfo['iDB_Ver_Show']." on this server.<br />\n";
51 echo "You can use MySQL, MySQLi, PostgreSQL, or SQLite</span>"; }
52 if ($Error!="Yes") {
53 $StatSQL = sql_connect_db($_POST['DatabaseHost'],$_POST['DatabaseUserName'],$_POST['DatabasePassword']);
54 if(!$StatSQL) { $Error="Yes";
55 echo "<span class=\"TableMessage\">";
56 echo "<br />".sql_errorno($StatSQL)."\n</span>\n"; } }
57 if ($Error!="Yes") {
58 $iDBRDate = $SVNDay[0]."/".$SVNDay[1]."/".$SVNDay[2];
59 $iDBRSVN = $VER2[2]." ".$SubVerN;
60 $LastUpdateS = "Last Update: ".$iDBRDate." ".$iDBRSVN;
61 $pretext = "<?php\n/*\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n Revised BSD License for more details.\n\n Copyright 2004-".$SVNDay[2]." iDB Support - http://idb.berlios.de/\n Copyright 2004-".$SVNDay[2]." Game Maker 2k - http://gamemaker2k.org/\n iDB Installer made by Game Maker 2k - http://idb.berlios.net/\n\n \$FileInfo: settings.php & settingsbak.php - ".$LastUpdateS." - Author: cooldude2k \$\n*/\n";
62 $BoardSettings=$pretext."\$Settings = array();\n\$Settings['sqlhost'] = '".$_POST['DatabaseHost']."';\n\$Settings['sqluser'] = '".$_POST['DatabaseUserName']."';\n\$Settings['sqlpass'] = '".$_POST['DatabasePassword']."';\n?>";
63 $fp = fopen("./settings.php","w+");
64 fwrite($fp, $BoardSettings);
65 fclose($fp);
66 // cp("settings.php","settingsbak.php");
67 $fp = fopen("./settingsbak.php","w+");
68 fwrite($fp, $BoardSettings);
69 fclose($fp);
71 <form style="display: inline;" method="post" id="install" action="install.php?act=Part4">
72 <table style="text-align: left;">
73 <tr style="text-align: left;">
74 <td style="width: 50%;"><label class="TextBoxLabel" for="NewBoardName">Insert Board Name:</label></td>
75 <td style="width: 50%;"><input type="text" name="NewBoardName" class="TextBox" id="NewBoardName" size="20" /></td>
76 </tr><tr>
77 <td style="width: 50%;"><label class="TextBoxLabel" for="DatabaseName">Insert Database Name:</label></td>
78 <td style="width: 50%;"><input type="text" name="DatabaseName" class="TextBox" id="DatabaseName" size="20" />
79 <?php /*<select id="dblist" name="dblist" class="TextBox" onchange="document.install.DatabaseName.value=this.value">
80 <option value=" ">none on list</option>
81 <?php $dblist = sql_list_dbs();
82 $num = count($dblist); $i = 0;
83 while ($i < $num) {
84 echo "<option value=\"".$dblist[$i]."\">";
85 echo $dblist[$i]."</option>\n";
86 ++$i;
87 } ?></select><?php */ ?></td>
88 </tr><tr>
89 <td style="width: 50%;"><label class="TextBoxLabel" for="tableprefix">Insert Table Prefix:<br /></label></td>
90 <td style="width: 50%;"><input type="text" name="tableprefix" class="TextBox" id="tableprefix" value="idb_" size="20" /></td>
91 </tr><tr>
92 <td style="width: 50%;"><label class="TextBoxLabel" for="AdminUser">Insert Admin User Name:</label></td>
93 <td style="width: 50%;"><input type="text" name="AdminUser" class="TextBox" id="AdminUser" size="20" /></td>
94 </tr><tr>
95 <td style="width: 30%;"><label class="TextBoxLabel" for="AdminEmail">Insert Admin Email:</label></td>
96 <td style="width: 70%;"><input type="text" class="TextBox" name="AdminEmail" size="20" id="AdminEmail" /></td>
97 </tr><tr>
98 <td style="width: 50%;"><label class="TextBoxLabel" for="AdminPassword">Insert Admin Password:</label></td>
99 <td style="width: 50%;"><input type="password" name="AdminPasswords" class="TextBox" id="AdminPassword" size="20" maxlength="30" /></td>
100 </tr><tr>
101 <td style="width: 50%;"><label class="TextBoxLabel" for="ReaPassword">ReInsert Admin Password:</label></td>
102 <td style="width: 50%;"><input type="password" class="TextBox" name="ReaPassword" size="20" id="ReaPassword" maxlength="30" /></td>
103 </tr><tr>
104 <td style="width: 50%;"><label class="TextBoxLabel" for="BoardURL">Insert The Board URL:</label></td>
105 <td style="width: 50%;"><input type="text" class="TextBox" name="BoardURL" size="20" id="BoardURL" value="<?php echo $prehost.$_SERVER['HTTP_HOST'].$this_dir; ?>" /></td>
106 </tr><tr>
107 <td style="width: 50%;"><label class="TextBoxLabel" for="WebURL">Insert The WebSite URL:</label></td>
108 <td style="width: 50%;"><input type="text" class="TextBox" name="WebURL" size="20" id="WebURL" value="<?php echo $prehost.$_SERVER['HTTP_HOST']."/"; ?>" /></td>
109 </tr><?php if($_POST['DatabaseType']=="mysql"||$_POST['DatabaseType']=="mysqli") { ?><tr>
110 <td style="width: 50%;"><label class="TextBoxLabel" for="sqlcollate">MySQL Collate:</label></td>
111 <td style="width: 50%;"><select size="1" class="TextBox" name="sqlcollate" id="sqlcollate">
112 <?php if($_POST['charset']=="ISO-8859-1"||$_POST['charset']=="ISO-8859-15") { ?>
113 <option value="latin1_general_ci">Latin1 Case-Insensitive</option>
114 <option value="latin1_general_cs">Latin1 Case-Sensitive</option>
115 <option value="latin1_bin">Latin1 Binary</option>
116 <option value="ascii_generel_ci">ASCII Case-Insensitive</option>
117 <option value="ascii_bin">ASICC Binary</option>
118 <?php } if($_POST['charset']=="UTF-8") { ?>
119 <option value="utf8_unicode_ci">UTF-8 Unicode Case-Insensitive</option>
120 <option value="utf8_general_ci">UTF-8 General Case-Insensitive</option>
121 <option value="utf8_bin">UTF-8 Binary</option>
122 <?php } ?>
123 </select></td>
124 </tr><?php } ?><tr>
125 <td style="width: 50%;"><label class="TextBoxLabel" title="Can save some bandwidth." for="UseGzip">Enable HTTP Compression:</label></td>
126 <td style="width: 50%;"><select size="1" class="TextBox" name="GZip" id="UseGzip">
127 <option value="off">No</option>
128 <option value="on">Yes</option>
129 <option value="gzip">Only GZip</option>
130 <option value="deflate">Only Deflate</option>
131 </select></td>
132 </tr><tr>
133 <td style="width: 50%;"><label class="TextBoxLabel" for="HTMLType">HTML Type to use:</label></td>
134 <td style="width: 50%;"><select size="1" class="TextBox" name="HTMLType" id="HTMLType">
135 <option value="xhtml10">XHTML 1.0</option>
136 <option value="xhtml11">XHTML 1.1</option>
137 <option value="html5">HTML 5</option>
138 <option value="xhtml5">XHTML 5</option>
139 </select></td>
140 </tr><tr>
141 <td style="width: 50%;"><label class="TextBoxLabel" for="HTMLLevel">HTML Level only for XHTML 1.0:</label></td>
142 <td style="width: 50%;"><select size="1" class="TextBox" name="HTMLLevel" id="HTMLLevel">
143 <option value="Transitional">Transitional</option>
144 <option value="Strict">Strict</option>
145 </select></td>
146 </tr><tr>
147 <td style="width: 50%;"><label class="TextBoxLabel" for="OutPutType">Output file as:</label></td>
148 <td style="width: 50%;"><select size="1" class="TextBox" name="OutPutType" id="OutPutType">
149 <option value="html">HTML</option>
150 <option value="xhtml">XHTML</option>
151 </select></td>
152 </tr><tr>
153 <td style="width: 50%;"><label class="TextBoxLabel" title="Store userinfo as a cookie so you dont need to login again." for="storecookie">Store as cookie?</label></td>
154 <td style="width: 50%;"><select id="storecookie" name="storecookie" class="TextBox">
155 <option value="true">Yes</option>
156 <option value="false">No</option>
157 </select></td>
158 </tr><tr>
159 <td style="width: 50%;"><label class="TextBoxLabel" for="usehashtype">Hash user passwords with?</label></td>
160 <td style="width: 50%;"><select id="usehashtype" name="usehashtype" class="TextBox">
161 <?php // PHP 5 hash algorithms to functions :o
162 if(function_exists('hash')&&function_exists('hash_algos')) {
163 if(in_array("md2",hash_algos())) { ?>
164 <option value="md2">MD2</option>
165 <?php } if(in_array("md4",hash_algos())) { ?>
166 <option value="md4">MD4</option>
167 <?php } if(in_array("md5",hash_algos())) { ?>
168 <option value="md5">MD5</option>
169 <?php } if(in_array("gost",hash_algos())) { ?>
170 <option value="gost">GOST</option>
171 <?php } if(in_array("sha1",hash_algos())) { ?>
172 <option value="sha1">SHA1</option>
173 <?php } if(in_array("sha224",hash_algos())) { ?>
174 <option value="sha224">SHA224</option>
175 <?php } if(in_array("sha256",hash_algos())) { ?>
176 <option value="sha256" selected="selected">SHA256</option>
177 <?php } if(in_array("sha384",hash_algos())) { ?>
178 <option value="sha384">SHA384</option>
179 <?php } if(in_array("sha512",hash_algos())) { ?>
180 <option value="sha512">SHA512</option>
181 <?php } if(in_array("salsa10",hash_algos())) { ?>
182 <option value="salsa10">SALSA10</option>
183 <?php } if(in_array("salsa20",hash_algos())) { ?>
184 <option value="salsa20">SALSA20</option>
185 <?php } if(in_array("snefru256",hash_algos())) { ?>
186 <option value="snefru256">SNEFRU256</option>
187 <?php } if(in_array("ripemd128",hash_algos())) { ?>
188 <option value="ripemd128">RIPEMD128</option>
189 <?php } if(in_array("ripemd160",hash_algos())) { ?>
190 <option value="ripemd160">RIPEMD160</option>
191 <?php } if(in_array("ripemd256",hash_algos())) { ?>
192 <option value="ripemd256">RIPEMD256</option>
193 <?php } if(in_array("ripemd320",hash_algos())) { ?>
194 <option value="ripemd320">RIPEMD320</option>
195 <?php } }
196 if(!function_exists('hash')&&!function_exists('hash_algos')) { ?>
197 <option value="md5">MD5</option>
198 <option value="sha1" selected="selected">SHA1</option>
199 <?php } ?>
200 </select></td>
201 </tr><tr>
202 <td style="width: 50%;"><label class="TextBoxLabel" for="YourOffSet">Your TimeZone:</label></td>
203 <td style="width: 50%;"><select id="YourOffSet" name="YourOffSet" class="TextBox"><?php
204 if(date("I")!=1) { $myofftime = SeverOffSet(); $mydstime = "off"; }
205 if(date("I")==1) { $myofftime = SeverOffSet()-1; $mydstime = "on"; }
206 $plusi = 1; $minusi = 12;
207 $plusnum = 15; $minusnum = 0;
208 while ($minusi > $minusnum) {
209 if($myofftime==-$minusi) {
210 echo "<option selected=\"selected\" value=\"-".$minusi."\">UTC - ".$minusi.":00 hours</option>\n"; }
211 if($myofftime!=-$minusi) {
212 echo "<option value=\"-".$minusi."\">UTC - ".$minusi.":00 hours</option>\n"; }
213 --$minusi; }
214 if($myofftime==0) { ?>
215 <option selected="selected" value="0">UTC +/- 0:00 hours</option>
216 <?php } if($myofftime!=0) { ?>
217 <option value="0">UTC +/- 0:00 hours</option>
218 <?php }
219 while ($plusi < $plusnum) {
220 if($myofftime==$plusi) {
221 echo "<option selected=\"selected\" value=\"".$plusi."\">UTC + ".$plusi.":00 hours</option>\n"; }
222 if($myofftime!=$plusi) {
223 echo "<option value=\"".$plusi."\">UTC + ".$plusi.":00 hours</option>\n"; }
224 ++$plusi; }
225 ?></select></td>
226 </tr><tr>
227 <td style="width: 50%;"><label class="TextBoxLabel" for="MinOffSet">Minute OffSet:</label></td>
228 <td style="width: 50%;"><select id="MinOffSet" name="MinOffSet" class="TextBox"><?php
229 $mini = 0; $minnum = 60;
230 while ($mini < $minnum) {
231 if(strlen($mini)==2) { $showmin = $mini; }
232 if(strlen($mini)==1) { $showmin = "0".$mini; }
233 if($mini==0) {
234 echo "\n<option selected=\"selected\" value=\"".$showmin."\">0:".$showmin." minutes</option>\n"; }
235 if($mini!=0) {
236 echo "<option value=\"".$showmin."\">0:".$showmin." minutes</option>\n"; }
237 ++$mini; }
238 ?></select></td>
239 </tr><tr>
240 <td style="width: 50%;"><label class="TextBoxLabel" for="DST">Is <span title="Daylight Savings Time">DST</span> / <span title="Summer Time">ST</span> on or off:</label></td>
241 <td style="width: 50%;"><select id="DST" name="DST" class="TextBox"><?php echo "\n" ?>
242 <?php if($mydstime=="off"||$mydstime!="on") { ?>
243 <option selected="selected" value="off">off</option><?php echo "\n" ?><option value="on">on</option>
244 <?php } if($mydstime=="on") { ?>
245 <option selected="selected" value="on">on</option><?php echo "\n" ?><option value="off">off</option>
246 <?php } echo "\n" ?></select></td>
247 </tr><tr>
248 <td style="width: 50%;"><label class="TextBoxLabel" for="TestReferer">Test Referering URL:</label></td>
249 <td style="width: 50%;"><select id="TestReferer" name="TestReferer" class="TextBox">
250 <option selected="selected" value="off">off</option>
251 <option value="on">on</option>
252 </select></td>
253 </tr><tr>
254 <td style="width: 50%;"><label class="TextBoxLabel" for="DefaultTheme">Default Theme</label></td>
255 <td style="width: 50%;"><select id="DefaultTheme" name="DefaultTheme" class="TextBox"><?php
256 $skindir = dirname(realpath("settings.php"))."/".$SettDir['themes'];
257 if ($handle = opendir($skindir)) { $dirnum = null;
258 while (false !== ($file = readdir($handle))) {
259 $selected = null;
260 if ($dirnum==null) { $dirnum = 0; }
261 if (file_exists($skindir.$file."/info.php")) {
262 if ($file != "." && $file != "..") {
263 include($skindir.$file."/info.php");
264 if($file=="iDB") {
265 $themelist[$dirnum] = "<option value=\"".$file."\" selected=\"selected\">".$ThemeInfo['ThemeName']."</option>"; }
266 if($file!="iDB") {
267 $themelist[$dirnum] = "<option value=\"".$file."\">".$ThemeInfo['ThemeName']."</option>"; }
268 ++$dirnum; } } }
269 closedir($handle); asort($themelist);
270 $themenum=count($themelist); $themei=0;
271 while ($themei < $themenum) {
272 echo $themelist[$themei]."\n";
273 ++$themei; }
274 } ?></select></td>
275 </tr><tr>
276 <td style="width: 50%;"><label class="TextBoxLabel" for="SQLThemes">Store Themes in SQL Database:</label></td>
277 <td style="width: 50%;"><select id="SQLThemes" name="SQLThemes" class="TextBox">
278 <option selected="selected" value="off">off</option>
279 <option value="on">on</option>
280 </select></td>
281 </tr><tr>
282 <td style="width: 50%;"><label class="TextBoxLabel" title="Might not work" for="unlink">Delete Installer?</label></td>
283 <td style="width: 50%;"><select id="unlink" name="unlink" class="TextBox">
284 <option value="true">Yes</option>
285 <option value="false">No</option>
286 </select></td>
287 </tr></table>
288 <table style="text-align: left;">
289 <tr style="text-align: left;">
290 <td style="width: 100%;">
291 <input type="hidden" name="charset" value="<?php echo $_POST['charset']; ?>" style="display: none;" />
292 <input type="hidden" name="SetupType" value="install" style="display: none;" />
293 <input type="hidden" name="DatabaseType" value="<?php echo $Settings['sqltype']; ?>" style="display: none;" />
294 <input type="hidden" name="act" value="Part4" style="display: none;" />
295 <input type="submit" class="Button" value="Install Board" name="Install_Board" />
296 <input type="reset" value="Reset Form" class="Button" name="Reset_Form" />
297 </td></tr></table>
298 </form>
299 </td>
300 </tr>
301 <?php } ?>