Small update. :o
[iDB.git] / setup / setup.php
blob0eb7b3ade4d716f7f40a845b2da1ad2a232e81ee
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-2010 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2010 Game Maker 2k - http://gamemaker2k.org/
13 iDB Installer made by Game Maker 2k - http://idb.berlios.net/
15 $FileInfo: setup.php - Last Update: 07/01/2010 SVN 528 - 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 $pretext = "<?php\n/*\n This program is free software; you can redistribute it and/or modify\n it under the terms of the Revised BSD License.\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-2007 Cool Dude 2k - http://intdb.sourceforge.net/\n Copyright 2004-2007 Game Maker 2k - http://idb.berlios.de/support/category.php?act=view&id=2\n Emoticons made by Jcink http://tfbb.jcink.com/\n*/\n";
59 $BoardSettings=$pretext."\$Settings = array();\n\$Settings['sqlhost'] = '".$_POST['DatabaseHost']."';\n\$Settings['sqluser'] = '".$_POST['DatabaseUserName']."';\n\$Settings['sqlpass'] = '".$_POST['DatabasePassword']."';\n?>";
60 $fp = fopen("./settings.php","w+");
61 fwrite($fp, $BoardSettings);
62 fclose($fp);
63 // cp("settings.php","settingsbak.php");
64 $fp = fopen("./settingsbak.php","w+");
65 fwrite($fp, $BoardSettings);
66 fclose($fp);
68 <form style="display: inline;" method="post" id="install" action="install.php?act=Part4">
69 <table style="text-align: left;">
70 <tr style="text-align: left;">
71 <td style="width: 50%;"><label class="TextBoxLabel" for="NewBoardName">Insert Board Name:</label></td>
72 <td style="width: 50%;"><input type="text" name="NewBoardName" class="TextBox" id="NewBoardName" size="20" /></td>
73 </tr><tr>
74 <td style="width: 50%;"><label class="TextBoxLabel" for="DatabaseName">Insert Database Name:</label></td>
75 <td style="width: 50%;"><input type="text" name="DatabaseName" class="TextBox" id="DatabaseName" size="20" />
76 <?php /*<select id="dblist" name="dblist" class="TextBox" onchange="document.install.DatabaseName.value=this.value">
77 <option value=" ">none on list</option>
78 <?php $dblist = sql_list_dbs();
79 $num = count($dblist); $i = 0;
80 while ($i < $num) {
81 echo "<option value=\"".$dblist[$i]."\">";
82 echo $dblist[$i]."</option>\n";
83 ++$i;
84 } ?></select><?php */ ?></td>
85 </tr><tr>
86 <td style="width: 50%;"><label class="TextBoxLabel" for="tableprefix">Insert Table Prefix:<br /></label></td>
87 <td style="width: 50%;"><input type="text" name="tableprefix" class="TextBox" id="tableprefix" value="idb_" size="20" /></td>
88 </tr><tr>
89 <td style="width: 50%;"><label class="TextBoxLabel" for="AdminUser">Insert Admin User Name:</label></td>
90 <td style="width: 50%;"><input type="text" name="AdminUser" class="TextBox" id="AdminUser" size="20" /></td>
91 </tr><tr>
92 <td style="width: 30%;"><label class="TextBoxLabel" for="AdminEmail">Insert Admin Email:</label></td>
93 <td style="width: 70%;"><input type="text" class="TextBox" name="AdminEmail" size="20" id="AdminEmail" /></td>
94 </tr><tr>
95 <td style="width: 50%;"><label class="TextBoxLabel" for="AdminPassword">Insert Admin Password:</label></td>
96 <td style="width: 50%;"><input type="password" name="AdminPasswords" class="TextBox" id="AdminPassword" size="20" maxlength="30" /></td>
97 </tr><tr>
98 <td style="width: 50%;"><label class="TextBoxLabel" for="ReaPassword">ReInsert Admin Password:</label></td>
99 <td style="width: 50%;"><input type="password" class="TextBox" name="ReaPassword" size="20" id="ReaPassword" maxlength="30" /></td>
100 </tr><tr>
101 <td style="width: 50%;"><label class="TextBoxLabel" for="BoardURL">Insert The Board URL:</label></td>
102 <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>
103 </tr><tr>
104 <td style="width: 50%;"><label class="TextBoxLabel" for="WebURL">Insert The WebSite URL:</label></td>
105 <td style="width: 50%;"><input type="text" class="TextBox" name="WebURL" size="20" id="WebURL" value="<?php echo $prehost.$_SERVER['HTTP_HOST']."/"; ?>" /></td>
106 </tr><tr>
107 <td style="width: 50%;"><label class="TextBoxLabel" title="Can save some bandwidth." for="UseGzip">Enable HTTP Compression:</label></td>
108 <td style="width: 50%;"><select size="1" class="TextBox" name="GZip" id="UseGzip">
109 <option value="off">No</option>
110 <option value="on">Yes</option>
111 <option value="gzip">Only GZip</option>
112 <option value="deflate">Only Deflate</option>
113 </select></td>
114 </tr><tr>
115 <td style="width: 50%;"><label class="TextBoxLabel" for="HTMLType">HTML Type to use:</label></td>
116 <td style="width: 50%;"><select size="1" class="TextBox" name="HTMLType" id="HTMLType">
117 <option value="xhtml10">XHTML 1.0</option>
118 <option value="xhtml11">XHTML 1.1</option>
119 <option value="html5">HTML 5</option>
120 </select></td>
121 </tr><tr>
122 <td style="width: 50%;"><label class="TextBoxLabel" for="HTMLLevel">HTML Level only for XHTML 1.0:</label></td>
123 <td style="width: 50%;"><select size="1" class="TextBox" name="HTMLLevel" id="HTMLLevel">
124 <option value="Transitional">Transitional</option>
125 <option value="Strict">Strict</option>
126 </select></td>
127 </tr><tr>
128 <td style="width: 50%;"><label class="TextBoxLabel" for="OutPutType">Output file as:</label></td>
129 <td style="width: 50%;"><select size="1" class="TextBox" name="OutPutType" id="OutPutType">
130 <option value="html">HTML</option>
131 <option value="xhtml">XHTML</option>
132 </select></td>
133 </tr><tr>
134 <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>
135 <td style="width: 50%;"><select id="storecookie" name="storecookie" class="TextBox">
136 <option value="true">Yes</option>
137 <option value="false">No</option>
138 </select></td>
139 </tr><tr>
140 <td style="width: 50%;"><label class="TextBoxLabel" for="usehashtype">Hash user passwords with?</label></td>
141 <td style="width: 50%;"><select id="usehashtype" name="usehashtype" class="TextBox">
142 <?php // PHP 5 hash algorithms to functions :o
143 if(function_exists('hash')&&function_exists('hash_algos')) {
144 if(in_array("md2",hash_algos())) { ?>
145 <option value="md2">MD2</option>
146 <?php } if(in_array("md4",hash_algos())) { ?>
147 <option value="md4">MD4</option>
148 <?php } if(in_array("md5",hash_algos())) { ?>
149 <option value="md5">MD5</option>
150 <?php } if(in_array("sha1",hash_algos())) { ?>
151 <option value="sha1">SHA1</option>
152 <?php } if(in_array("sha224",hash_algos())) { ?>
153 <option value="sha224">SHA224</option>
154 <?php } if(in_array("sha256",hash_algos())) { ?>
155 <option value="sha256" selected="selected">SHA256</option>
156 <?php } if(in_array("sha384",hash_algos())) { ?>
157 <option value="sha384">sha384</option>
158 <?php } if(in_array("sha512",hash_algos())) { ?>
159 <option value="sha512">SHA512</option>
160 <?php } if(in_array("ripemd128",hash_algos())) { ?>
161 <option value="ripemd128">RIPEMD128</option>
162 <?php } if(in_array("ripemd160",hash_algos())) { ?>
163 <option value="ripemd160">RIPEMD160</option>
164 <?php } if(in_array("ripemd256",hash_algos())) { ?>
165 <option value="ripemd256">RIPEMD256</option>
166 <?php } if(in_array("ripemd320",hash_algos())) { ?>
167 <option value="ripemd320">RIPEMD320</option>
168 <?php } }
169 if(!function_exists('hash')&&!function_exists('hash_algos')) { ?>
170 <option value="md5">MD5</option>
171 <option value="sha1" selected="selected">SHA1</option>
172 <?php } ?>
173 </select></td>
174 </tr><tr>
175 <td style="width: 50%;"><label class="TextBoxLabel" for="YourOffSet">Your TimeZone:</label></td>
176 <td style="width: 50%;"><select id="YourOffSet" name="YourOffSet" class="TextBox"><?php
177 if(date("I")!=1) { $myofftime = SeverOffSet(); $mydstime = "off"; }
178 if(date("I")==1) { $myofftime = SeverOffSet()-1; $mydstime = "on"; }
179 $plusi = 1; $minusi = 12;
180 $plusnum = 15; $minusnum = 0;
181 while ($minusi > $minusnum) {
182 if($myofftime==-$minusi) {
183 echo "<option selected=\"selected\" value=\"-".$minusi."\">UTC - ".$minusi.":00 hours</option>\n"; }
184 if($myofftime!=-$minusi) {
185 echo "<option value=\"-".$minusi."\">UTC - ".$minusi.":00 hours</option>\n"; }
186 --$minusi; }
187 if($myofftime==0) { ?>
188 <option selected="selected" value="0">UTC +/- 0:00 hours</option>
189 <?php } if($myofftime!=0) { ?>
190 <option value="0">UTC +/- 0:00 hours</option>
191 <?php }
192 while ($plusi < $plusnum) {
193 if($myofftime==$plusi) {
194 echo "<option selected=\"selected\" value=\"".$plusi."\">UTC + ".$plusi.":00 hours</option>\n"; }
195 if($myofftime!=$plusi) {
196 echo "<option value=\"".$plusi."\">UTC + ".$plusi.":00 hours</option>\n"; }
197 ++$plusi; }
198 ?></select></td>
199 </tr><tr>
200 <td style="width: 50%;"><label class="TextBoxLabel" for="MinOffSet">Minute OffSet:</label></td>
201 <td style="width: 50%;"><select id="MinOffSet" name="MinOffSet" class="TextBox"><?php
202 $mini = 0; $minnum = 60;
203 while ($mini < $minnum) {
204 if(strlen($mini)==2) { $showmin = $mini; }
205 if(strlen($mini)==1) { $showmin = "0".$mini; }
206 if($mini==0) {
207 echo "\n<option selected=\"selected\" value=\"".$showmin."\">0:".$showmin." minutes</option>\n"; }
208 if($mini!=0) {
209 echo "<option value=\"".$showmin."\">0:".$showmin." minutes</option>\n"; }
210 ++$mini; }
211 ?></select></td>
212 </tr><tr>
213 <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>
214 <td style="width: 50%;"><select id="DST" name="DST" class="TextBox"><?php echo "\n" ?>
215 <?php if($mydstime=="off"||$mydstime!="on") { ?>
216 <option selected="selected" value="off">off</option><?php echo "\n" ?><option value="on">on</option>
217 <?php } if($mydstime=="on") { ?>
218 <option selected="selected" value="on">on</option><?php echo "\n" ?><option value="off">off</option>
219 <?php } echo "\n" ?></select></td>
220 </tr><tr>
221 <td style="width: 50%;"><label class="TextBoxLabel" for="TestReferer">Test Referering URL:</label></td>
222 <td style="width: 50%;"><select id="TestReferer" name="TestReferer" class="TextBox">
223 <option selected="selected" value="off">off</option>
224 <option value="on">on</option>
225 </select></td>
226 </tr><tr>
227 <td style="width: 50%;"><label class="TextBoxLabel" for="DefaultTheme">Default Theme</label></td>
228 <td style="width: 50%;"><select id="DefaultTheme" name="DefaultTheme" class="TextBox"><?php
229 $skindir = dirname(realpath("settings.php"))."/".$SettDir['themes'];
230 if ($handle = opendir($skindir)) { $dirnum = null;
231 while (false !== ($file = readdir($handle))) {
232 $selected = null;
233 if ($dirnum==null) { $dirnum = 0; }
234 if (file_exists($skindir.$file."/info.php")) {
235 if ($file != "." && $file != "..") {
236 include($skindir.$file."/info.php");
237 if($file=="iDB") {
238 $themelist[$dirnum] = "<option value=\"".$file."\" selected=\"selected\">".$ThemeInfo['ThemeName']."</option>"; }
239 if($file!="iDB") {
240 $themelist[$dirnum] = "<option value=\"".$file."\">".$ThemeInfo['ThemeName']."</option>"; }
241 ++$dirnum; } } }
242 closedir($handle); asort($themelist);
243 $themenum=count($themelist); $themei=0;
244 while ($themei < $themenum) {
245 echo $themelist[$themei]."\n";
246 ++$themei; }
247 } ?></select></td>
248 </tr><tr>
249 <td style="width: 50%;"><label class="TextBoxLabel" for="SQLThemes">Store Themes in SQL Database:</label></td>
250 <td style="width: 50%;"><select id="SQLThemes" name="SQLThemes" class="TextBox">
251 <option selected="selected" value="off">off</option>
252 <option value="on">on</option>
253 </select></td>
254 </tr><tr>
255 <td style="width: 50%;"><label class="TextBoxLabel" title="Might not work" for="unlink">Delete Installer?</label></td>
256 <td style="width: 50%;"><select id="unlink" name="unlink" class="TextBox">
257 <option value="true">Yes</option>
258 <option value="false">No</option>
259 </select></td>
260 </tr></table>
261 <table style="text-align: left;">
262 <tr style="text-align: left;">
263 <td style="width: 100%;">
264 <input type="hidden" name="charset" value="<?php echo $_POST['charset']; ?>" style="display: none;" />
265 <input type="hidden" name="SetupType" value="install" style="display: none;" />
266 <input type="hidden" name="DatabaseType" value="<?php echo $Settings['sqltype']; ?>" style="display: none;" />
267 <input type="hidden" name="act" value="Part4" style="display: none;" />
268 <input type="submit" class="Button" value="Install Board" name="Install_Board" />
269 <input type="reset" value="Reset Form" class="Button" name="Reset_Form" />
270 </td></tr></table>
271 </form>
272 </td>
273 </tr>
274 <?php } ?>