Another small update.
[iDB.git] / sql.php
blob2ad179c8582c51f9b88cf1bb85a96425150b057c
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/
14 $FileInfo: sql.php - Last Update: 08/12/2011 SVN 748 - Author: cooldude2k $
16 /* Some ini setting changes uncomment if you need them.
17 Display PHP Errors */
18 $disfunc = @ini_get("disable_functions");
19 $disfunc = @trim($disfunc);
20 $disfunc = @preg_replace("/([\\s+|\\t+|\\n+|\\r+|\\0+|\\x0B+])/i", "", $disfunc);
21 if($disfunc!="ini_set") { $disfunc = explode(",",$disfunc); }
22 if($disfunc=="ini_set") { $disfunc = array("ini_set"); }
23 if(!in_array("ini_set", $disfunc)) {
24 @ini_set("html_errors", false);
25 @ini_set("track_errors", false);
26 @ini_set("display_errors", false);
27 @ini_set("report_memleaks", false);
28 @ini_set("display_startup_errors", false);
29 //@ini_set("error_log","logs/error.log");
30 //@ini_set("log_errors","On");
31 @ini_set("docref_ext", "");
32 @ini_set("docref_root", "http://php.net/"); }
33 @error_reporting(E_ALL ^ E_NOTICE);
34 /* Get rid of session id in urls */
35 if(!in_array("ini_set", $disfunc)) {
36 @ini_set("date.timezone","UTC");
37 @ini_set("default_mimetype","text/html");
38 @ini_set("zlib.output_compression", false);
39 @ini_set("zlib.output_compression_level", -1);
40 @ini_set("session.use_trans_sid", false);
41 @ini_set("session.use_cookies", true);
42 @ini_set("session.use_only_cookies", true);
43 @ini_set("url_rewriter.tags","");
44 @ini_set('zend.ze1_compatibility_mode', 0);
45 @ini_set("ignore_user_abort", 1); }
46 @set_time_limit(30); @ignore_user_abort(true);
47 /* Change session garbage collection settings */
48 if(!in_array("ini_set", $disfunc)) {
49 @ini_set("session.gc_probability", 1);
50 @ini_set("session.gc_divisor", 100);
51 @ini_set("session.gc_maxlifetime", 1440);
52 /* Change session hash type here */
53 @ini_set("session.hash_function", 1);
54 @ini_set("session.hash_bits_per_character", 6); }
55 /* Do not change anything below this line unless you know what you are doing */
56 $File3Name = basename($_SERVER['SCRIPT_NAME']);
57 if ($File3Name=="sql.php"||$File3Name=="/sql.php") {
58 header('Location: index.php');
59 exit(); }
60 if(file_exists('settings.php')) {
61 require_once('settings.php');
62 if(file_exists('extrasettings.php')) {
63 require_once('extrasettings.php'); }
64 if(file_exists('extendsettings.php')) {
65 require_once('extendsettings.php'); }
66 if(!in_array("ini_set", $disfunc)&&$Settings['qstr']!="/"&&$Settings['qstr']!="&") {
67 ini_set("arg_separator.output",htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']));
68 ini_set("arg_separator.input",$Settings['qstr']); } }
69 if(!isset($Settings['idburl'])) { $Settings['idburl'] = null; }
70 if(!isset($Settings['fixbasedir'])) { $Settings['fixbasedir'] = null; }
71 if(!isset($Settings['fixpathinfo'])) { $Settings['fixpathinfo'] = null; }
72 if(!isset($Settings['fixcookiedir'])) { $Settings['fixcookiedir'] = null; }
73 if(!isset($Settings['fixredirectdir'])) { $Settings['fixcookiedir'] = null; }
74 $Settings['bid'] = base64_encode(urlencode($Settings['idburl']));
75 if(!isset($Settings['idb_time_format'])) { $Settings['idb_time_format'] = "g:i A"; }
76 if(!isset($Settings['idb_date_format'])) { $Settings['idb_date_format'] = "F j Y"; }
77 if(!isset($Settings['showverinfo'])) {
78 $Settings['showverinfo'] = "on"; }
79 if(!isset($Settings['sqldb'])) {
80 header("Content-Type: text/plain; charset=UTF-8");
81 header('Location: install.php'); }
82 if(!isset($Settings['fixpathinfo'])) {
83 $Settings['fixpathinfo'] = "off"; }
84 if($Settings['fixpathinfo']=="off") {
85 $Settings['fixpathinfo'] = null; }
86 if(!isset($Settings['fixbasedir'])) {
87 $Settings['fixbasedir'] = "off"; }
88 if($Settings['fixbasedir']=="off") {
89 $Settings['fixbasedir'] = null; }
90 if(!isset($Settings['fixcookiedir'])) {
91 $Settings['fixcookiedir'] = "off"; }
92 if($Settings['fixcookiedir']=="off") {
93 $Settings['fixcookiedir'] = null; }
94 if(!isset($Settings['fixredirectdir'])) {
95 $Settings['fixredirectdir'] = "off"; }
96 if($Settings['fixredirectdir']=="off") {
97 $Settings['fixredirectdir'] = null; }
98 $OldSettings['fixpathinfo'] = $Settings['fixpathinfo'];
99 $OldSettings['fixbasedir'] = $Settings['fixbasedir'];
100 $OldSettings['fixcookiedir'] = $Settings['fixcookiedir'];
101 $OldSettings['fixredirectdir'] = $Settings['fixredirectdir'];
102 if($Settings['idburl']=="localhost") {
103 header("Content-Type: text/plain; charset=UTF-8");
104 echo "500 Error: URL is malformed. Try reinstalling iDB."; die(); }
105 if($Settings['fixbasedir']=="on") {
106 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
107 $PathsTest = parse_url($Settings['idburl']);
108 $Settings['fixbasedir'] = $PathsTest['path']."/";
109 $Settings['fixbasedir'] = str_replace("//", "/", $Settings['fixbasedir']); } }
110 if($Settings['fixcookiedir']=="on") {
111 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
112 $PathsTest = parse_url($Settings['idburl']);
113 $Settings['fixcookiedir'] = $PathsTest['path']."/";
114 $Settings['fixcookiedir'] = str_replace("//", "/", $Settings['fixcookiedir']); } }
115 if($Settings['fixredirectdir']=="on") {
116 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
117 $PathsTest = parse_url($Settings['idburl']);
118 $Settings['fixredirectdir'] = $PathsTest['path']."/";
119 $Settings['fixredirectdir'] = str_replace("//", "/", $Settings['fixredirectdir']); } }
120 if(!isset($Settings['charset'])) {
121 $Settings['charset'] = "ISO-8859-15"; }
122 if(isset($Settings['charset'])) {
123 if($Settings['charset']!="ISO-8859-15"&&$Settings['charset']!="ISO-8859-1"&&
124 $Settings['charset']!="UTF-8"&&$Settings['charset']!="CP866"&&
125 $Settings['charset']!="Windows-1251"&&$Settings['charset']!="Windows-1252"&&
126 $Settings['charset']!="KOI8-R"&&$Settings['charset']!="BIG5"&&
127 $Settings['charset']!="GB2312"&&$Settings['charset']!="BIG5-HKSCS"&&
128 $Settings['charset']!="Shift_JIS"&&$Settings['charset']!="EUC-JP") {
129 $Settings['charset'] = "ISO-8859-15"; } }
130 $chkcharset = $Settings['charset'];
131 if(!in_array("ini_set", $disfunc)) {
132 @ini_set('default_charset', $Settings['charset']); }
133 //session_save_path($SettDir['inc']."temp/");
134 if(!isset($Settings['sqldb'])) {
135 if(file_exists("install.php")) { header('Location: install.php'); die(); }
136 if(!file_exists("install.php")) { header("Content-Type: text/plain; charset=UTF-8");
137 echo "403 Error: Sorry could not find install.php\nTry uploading files again and if that dose not work try download iDB again."; die(); } }
138 if(isset($Settings['sqldb'])&&
139 function_exists("date_default_timezone_set")) {
140 @date_default_timezone_set("UTC"); }
141 if(!isset($Settings['sqlhost'])) { $Settings['sqlhost'] = "localhost"; }
142 if($Settings['fixpathinfo']=="on") {
143 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
144 putenv("PATH_INFO=".$_SERVER['ORIG_PATH_INFO']); }
145 // Check to see if variables are set
146 if(!isset($SettDir['inc'])) { $SettDir['inc'] = "inc/"; }
147 if(!isset($SettDir['archive'])) { $SettDir['archive'] = "archive/"; }
148 if(!isset($SettDir['misc'])) { $SettDir['misc'] = "inc/misc/"; }
149 if(!isset($SettDir['sql'])) { $SettDir['sql'] = "inc/misc/sql/"; }
150 if(!isset($SettDir['admin'])) { $SettDir['admin'] = "inc/admin/"; }
151 if(!isset($SettDir['sqldumper'])) { $SettDir['sqldumper'] = "inc/admin/sqldumper/"; }
152 if(!isset($SettDir['mod'])) { $SettDir['mod'] = "inc/mod/"; }
153 if(!isset($SettDir['themes'])) { $SettDir['themes'] = "themes/"; }
154 if(!isset($SettDir['maindir'])||!file_exists($SettDir['maindir'])||!is_dir($SettDir['maindir'])) {
155 $SettDir['maindir'] = addslashes(str_replace("\\","/",dirname(__FILE__)."/")); }
156 if(isset($SettDir['maindir'])) { @chdir($SettDir['maindir']); }
157 if(!isset($Settings['use_iniset'])) { $Settings['use_iniset'] = null; }
158 if(!isset($Settings['clean_ob'])) { $Settings['clean_ob'] = "off"; }
159 if(!isset($_SERVER['PATH_INFO'])) { $_SERVER['PATH_INFO'] = null; }
160 if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
161 $_SERVER['HTTP_ACCEPT_ENCODING'] = null; }
162 if(!isset($_SERVER["HTTP_ACCEPT"])) { $_SERVER["HTTP_ACCEPT"] = null; }
163 if(!isset($_SERVER['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = null; }
164 if(!isset($_GET['page'])) { $_GET['page'] = null; }
165 if(!isset($_GET['act'])) { $_GET['act'] = null; }
166 if(!isset($_POST['act'])) { $_POST['act'] = null; }
167 if(!isset($_GET['modact'])) { $_GET['modact'] = null; }
168 if(!isset($_POST['modact'])) { $_POST['modact'] = null; }
169 if(!isset($_GET['id'])) { $_GET['id'] = null; }
170 if(!isset($_GET['debug'])) { $_GET['debug'] = "off"; }
171 if(!isset($_GET['post'])) { $_GET['post'] = null; }
172 if(!isset($_POST['License'])) { $_POST['License'] = null; }
173 if(!isset($_SERVER['HTTPS'])) { $_SERVER['HTTPS'] = "off"; }
174 if(!isset($Settings['SQLThemes'])) { $Settings['SQLThemes'] = "off"; }
175 if($Settings['SQLThemes']!="on"&&$Settings['SQLThemes']!="off") {
176 $Settings['SQLThemes'] = "off"; }
177 require_once($SettDir['misc'].'utf8.php');
178 require_once($SettDir['inc'].'filename.php');
179 if(!isset($Settings['use_hashtype'])) {
180 $Settings['use_hashtype'] = "sha1"; }
181 if(!function_exists('hash')||!function_exists('hash_algos')) {
182 if($Settings['use_hashtype']!="md5"&&
183 $Settings['use_hashtype']!="sha1") {
184 $Settings['use_hashtype'] = "sha1"; } }
185 if(function_exists('hash')&&function_exists('hash_algos')) {
186 if(!in_array($Settings['use_hashtype'],hash_algos())) {
187 $Settings['use_hashtype'] = "sha1"; }
188 if($Settings['use_hashtype']!="md2"&&
189 $Settings['use_hashtype']!="md4"&&
190 $Settings['use_hashtype']!="md5"&&
191 $Settings['use_hashtype']!="sha1"&&
192 $Settings['use_hashtype']!="sha224"&&
193 $Settings['use_hashtype']!="sha256"&&
194 $Settings['use_hashtype']!="sha384"&&
195 $Settings['use_hashtype']!="sha512"&&
196 $Settings['use_hashtype']!="ripemd128"&&
197 $Settings['use_hashtype']!="ripemd160"&&
198 $Settings['use_hashtype']!="ripemd256"&&
199 $Settings['use_hashtype']!="ripemd320"&&
200 $Settings['use_hashtype']!="salsa10"&&
201 $Settings['use_hashtype']!="salsa20"&&
202 $Settings['use_hashtype']!="snefru"&&
203 $Settings['use_hashtype']!="snefru256"&&
204 $Settings['use_hashtype']!="gost") {
205 $Settings['use_hashtype'] = "sha1"; } }
206 // Check to see if variables are set
207 require_once($SettDir['misc'].'setcheck.php');
208 $dayconv = array("year" => 29030400, "month" => 2419200, "week" => 604800, "day" => 86400, "hour" => 3600, "minute" => 60, "second" => 1);
209 require_once($SettDir['inc'].'function.php');
210 if($Settings['enable_pathinfo']=="on") {
211 mrstring(); /* Change Path info to Get Vars :P */ }
212 // Check to see if variables are set
213 $qstrhtml = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
214 if($Settings['enable_https']=="on"&&$_SERVER['HTTPS']=="on") {
215 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
216 $HTTPsTest = parse_url($Settings['idburl']); if($HTTPsTest['scheme']=="http") {
217 $Settings['idburl'] = preg_replace("/http\:\/\//i", "https://", $Settings['idburl']); } } }
218 $cookieDomain = null; $cookieSecure = false;
219 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
220 $URLsTest = parse_url($Settings['idburl']);
221 $cookieDomain = $URLsTest['host'];
222 if($cookieDomain=="localhost") { $cookieDomain = false; }
223 if($Settings['enable_https']=="on") {
224 if($URLsTest['scheme']=="https") { $cookieSecure = true; }
225 if($URLsTest['scheme']!="https") { $cookieSecure = false; } } }
226 if(!in_array("ini_set", $disfunc)) {
227 @ini_set('default_charset', $Settings['charset']); }
228 $File1Name = dirname($_SERVER['SCRIPT_NAME'])."/";
229 $File2Name = $_SERVER['SCRIPT_NAME'];
230 $File3Name=str_replace($File1Name, null, $File2Name);
231 if ($File3Name=="sql.php"||$File3Name=="/sql.php") {
232 header('Location: index.php');
233 exit(); }
234 //error_reporting(E_ERROR);
235 // Check if gzip is on and if user's browser can accept gzip pages
236 if($_GET['act']=="MkCaptcha"||$_GET['act']=="Captcha") {
237 $Settings['use_gzip'] = 'off'; }
238 if($Settings['use_gzip']=="on") {
239 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) {
240 $GZipEncode['Type'] = "gzip"; } else {
241 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "deflate")) {
242 $GZipEncode['Type'] = "deflate"; } else {
243 $Settings['use_gzip'] = "off"; $GZipEncode['Type'] = "none"; } } }
244 if($Settings['use_gzip']=="gzip") {
245 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) { $Settings['use_gzip'] = "on";
246 $GZipEncode['Type'] = "gzip"; } else { $Settings['use_gzip'] = "off"; } }
247 if($Settings['use_gzip']=="deflate") {
248 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "deflate")) { $Settings['use_gzip'] = "on";
249 $GZipEncode['Type'] = "deflate"; } else { $Settings['use_gzip'] = "off"; } }
250 $iWrappers = array(null);
251 function idb_output_handler($buffer) { return $buffer; }
252 function idb_suboutput_handler($buffer) { return $buffer; }
253 if($Settings['clean_ob']=="on") {
254 /* Check for other output handlers/buffers are open
255 and close and get the contents in an array */
256 $numob = count(ob_list_handlers()); $iob = 0;
257 while ($iob < $numob) {
258 $old_ob_var[$iob] = ob_get_clean();
259 ++$iob; } } ob_start("idb_output_handler");
260 if($Settings['use_gzip']=="on") {
261 if($GZipEncode['Type']!="gzip") { if($GZipEncode['Type']!="deflate") { $GZipEncode['Type'] = "gzip"; } }
262 if($GZipEncode['Type']=="gzip") {
263 header("Content-Encoding: gzip"); }
264 if($GZipEncode['Type']=="deflate") {
265 header("Content-Encoding: deflate"); } }
266 /* if(eregi("msie",$browser) && !eregi("opera",$browser)){
267 header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); } */
268 // Some http stuff
269 $SQLStat = sql_connect_db($Settings['sqlhost'],$Settings['sqluser'],$Settings['sqlpass'],$Settings['sqldb']);
270 if(isset($Settings['sql_collate'])&&!isset($Settings['sql_charset'])) {
271 if($Settings['sql_collate']=="ascii_bin"||
272 $Settings['sql_collate']=="ascii_generel_ci") {
273 $Settings['sql_charset'] = "ascii"; }
274 if($Settings['sql_collate']=="latin1_bin"||
275 $Settings['sql_collate']=="latin1_general_ci"||
276 $Settings['sql_collate']=="latin1_general_cs") {
277 $Settings['sql_charset'] = "latin1"; }
278 if($Settings['sql_collate']=="utf8_bin"||
279 $Settings['sql_collate']=="utf8_general_ci"||
280 $Settings['sql_collate']=="utf8_unicode_ci") {
281 $Settings['sql_charset'] = "utf8"; } }
282 if(isset($Settings['sql_collate'])&&isset($Settings['sql_charset'])) {
283 if($Settings['sql_charset']=="ascii") {
284 if($Settings['sql_collate']!="ascii_bin"&&
285 $Settings['sql_collate']!="ascii_generel_ci") {
286 $Settings['sql_collate'] = "ascii_generel_ci"; } }
287 if($Settings['sql_charset']=="latin1") {
288 if($Settings['sql_collate']!="latin1_bin"&&
289 $Settings['sql_collate']!="latin1_general_ci"&&
290 $Settings['sql_collate']!="latin1_general_cs") {
291 $Settings['sql_collate'] = "latin1_general_ci"; } }
292 if($Settings['sql_charset']=="utf8") {
293 if($Settings['sql_collate']!="utf8_bin"&&
294 $Settings['sql_collate']!="utf8_general_ci"&&
295 $Settings['sql_collate']!="utf8_unicode_ci") {
296 $Settings['sql_collate'] = "utf8_unicode_ci"; } }
297 $SQLCollate = $Settings['sql_collate'];
298 $SQLCharset = $Settings['sql_charset']; }
299 if(!isset($Settings['sql_collate'])||!isset($Settings['sql_charset'])) {
300 $SQLCollate = "latin1_general_ci";
301 $SQLCharset = "latin1";
302 if($Settings['charset']=="ISO-8859-1") {
303 $SQLCollate = "latin1_general_ci";
304 $SQLCharset = "latin1"; }
305 if($Settings['charset']=="ISO-8859-15") {
306 $SQLCollate = "latin1_general_ci";
307 $SQLCharset = "latin1"; }
308 if($Settings['charset']=="UTF-8") {
309 $SQLCollate = "utf8_unicode_ci";
310 $SQLCharset = "utf8"; }
311 $Settings['sql_collate'] = $SQLCollate;
312 $Settings['sql_charset'] = $SQLCharset; }
313 sql_set_charset($SQLCharset,$SQLStat);
314 if($SQLStat===false) {
315 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);
316 ob_clean(); echo "Sorry could not connect to sql database.\nContact the board admin about error. Error log below.";
317 echo "\n".sql_errorno($SQLStat); $urlstatus = 503;
318 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
319 $sqltable = $Settings['sqltable'];
320 $temp_user_ip = $_SERVER['REMOTE_ADDR'];
321 if(!isset($_SERVER['HTTP_USER_AGENT'])) {
322 $_SERVER['HTTP_USER_AGENT'] = ""; }
323 if(strpos($_SERVER['HTTP_USER_AGENT'], "msie") &&
324 !strpos($_SERVER['HTTP_USER_AGENT'], "opera")){
325 header("X-UA-Compatible: IE=Edge"); }
326 if(strpos($_SERVER['HTTP_USER_AGENT'], "chromeframe")) {
327 header("X-UA-Compatible: IE=Edge,chrome=1"); }
328 $temp_user_agent = $_SERVER['HTTP_USER_AGENT'];
329 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
330 $MkIndexFile = $exfile['index'].$Settings['file_ext']; }
331 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
332 $MkIndexFile = $exfile['index']; }
333 $temp_session_data = "ViewingPage|s:9:\"?act=view\";ViewingFile|s:".strlen($MkIndexFile).":\"".$MkIndexFile."\";PreViewingTitle|s:7:\"Viewing\";ViewingTitle|s:11:\"Board index\";UserID|s:1:\"0\";UserIP|s:".strlen($_SERVER['REMOTE_ADDR']).":\"".$_SERVER['REMOTE_ADDR']."\";UserGroup|s:".strlen($Settings['GuestGroup']).":\"".$Settings['GuestGroup']."\";UserGroupID|s:1:\"4\";UserTimeZone|s:".strlen($Settings['DefaultTimeZone']).":\"".$Settings['DefaultTimeZone']."\";UserDST|s:".strlen($Settings['DefaultDST']).":\"".$Settings['DefaultDST']."\";";
334 $SQLSType = $Settings['sqltype'];
335 //Session Open Function
336 function sql_session_open($save_path, $session_name ) {
337 global $sess_save_path;
338 $sess_save_path = $save_path;
339 return true; }
340 //Session Close Function
341 $iDBSessCloseDB = true;
342 function sql_session_close() {
343 global $SQLStat,$iDBSessCloseDB;
344 if($iDBSessCloseDB===true) {
345 sql_disconnect_db($SQLStat); }
346 return true; }
347 //Session Read Function
348 function sql_session_read($id) {
349 global $sqltable,$SQLStat,$SQLSType,$temp_user_ip,$temp_user_agent,$temp_session_data;
350 $result = sql_query(sql_pre_query("SELECT * FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '%s'", array($id)),$SQLStat);
351 if (!sql_num_rows($result)) {
352 sql_query(sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"session_id\"<>'%s' AND \"ip_address\"='%s' AND \"user_agent\"='%s'", array($id,$temp_user_ip,$temp_user_agent)),$SQLStat);
353 $time = GMTimeStamp();
354 sql_query(sql_pre_query("INSERT INTO \"".$sqltable."sessions\" (\"session_id\", \"session_data\", \"user_agent\", \"ip_address\", \"expires\") VALUES\n".
355 "('%s', '%s', '%s', '%s', %i)", array($id,$temp_session_data,$temp_user_agent,$temp_user_ip,$time)),$SQLStat);
356 return '';
357 } else {
358 $time = GMTimeStamp();
359 $predata = sql_num_rows($result);
360 $data = "";
361 if($predata > 0) {
362 $row = sql_fetch_assoc($result);
363 $data = $row['session_data']; }
364 /*sql_query(sql_pre_query("UPDATE \"".$sqltable."sessions\" SET \"session_data\"='%s',\"expires\"=%i WHERE \"session_id\"='%s'", array($data,$time,$id)),$SQLStat);*/
365 return $data; } }
366 //Session Write Function
367 function sql_session_write($id,$data) {
368 global $sqltable,$SQLStat,$SQLSType,$temp_user_ip,$temp_user_agent;
369 $time = GMTimeStamp();
370 $rs = sql_query(sql_pre_query("UPDATE \"".$sqltable."sessions\" SET \"session_data\"='%s',\"user_agent\"='%s',\"ip_address\"='%s',\"expires\"=%i WHERE \"session_id\"='%s'", array($data,$temp_user_agent,$temp_user_ip,$time,$id)),$SQLStat);
371 return true; }
372 //Session Destroy Function
373 function sql_session_destroy($id) {
374 global $sqltable,$SQLStat;
375 sql_query(sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '$id'", array($id)),$SQLStat);
376 return true; }
377 //Session Garbage Collection Function
378 function sql_session_gc($maxlifetime) {
379 global $sqltable,$SQLStat;
380 $time = GMTimeStamp() - $maxlifetime;
381 //sql_query(sql_pre_query('DELETE FROM \"'.$sqltable.'sessions\" WHERE \"expires\" < UNIX_TIMESTAMP();', array(null)),$SQLStat);
382 sql_query(sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"expires\" < %i", array($time)),$SQLStat);
383 return true; }
384 if (session_id()) { session_destroy(); }
385 session_set_save_handler("sql_session_open", "sql_session_close", "sql_session_read", "sql_session_write", "sql_session_destroy", "sql_session_gc");
386 if($cookieDomain==null) {
387 session_set_cookie_params(0, $cbasedir); }
388 if($cookieDomain!=null) {
389 if($cookieSecure===true) {
390 session_set_cookie_params(0, $cbasedir, $cookieDomain, 1); }
391 if($cookieSecure===false) {
392 session_set_cookie_params(0, $cbasedir, $cookieDomain); } }
393 session_cache_limiter("private, no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0");
394 header("Cache-Control: private, no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0");
395 header("Pragma: private, no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0");
396 header("P3P: CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");
397 header("Date: ".gmdate("D, d M Y H:i:s")." GMT");
398 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
399 header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
400 if(!isset($_COOKIE[$Settings['sqltable']."sess"])) {
401 $exptime = GMTimeStamp() - ini_get("session.gc_maxlifetime");
402 sql_query(sql_pre_query("DELETE FROM \"".$Settings['sqltable']."sessions\" WHERE \"expires\" < %i OR \"ip_address\"='%s' AND \"user_agent\"='%s'", array($exptime,$temp_user_ip,$temp_user_agent)),$SQLStat); }
403 if(!isset($_SESSION['CheckCookie'])) {
404 if(isset($_COOKIE['SessPass'])&&isset($_COOKIE['MemberName'])) {
405 session_set_save_handler("sql_session_open", "sql_session_close", "sql_session_read", "sql_session_write", "sql_session_destroy", "sql_session_gc");
406 session_name($Settings['sqltable']."sess");
407 session_start();
408 if(!isset($_SESSION['UserFormID'])) { $_SESSION['UserFormID'] = null; }
409 $iDBSessCloseDB = false;
410 $_SESSION['ShowActHidden'] = "no";
411 output_reset_rewrite_vars();
412 require($SettDir['inc'].'prelogin.php');
413 session_write_close(); } }
414 session_set_save_handler("sql_session_open", "sql_session_close", "sql_session_read", "sql_session_write", "sql_session_destroy", "sql_session_gc");
415 session_name($Settings['sqltable']."sess");
416 session_start();
417 if(!isset($_SESSION['UserFormID'])) { $_SESSION['UserFormID'] = null; }
418 $iDBSessCloseDB = true;
419 output_reset_rewrite_vars();
420 //@register_shutdown_function("session_write_close");
421 //header("Set-Cookie: PHPSESSID=" . session_id() . "; path=".$cbasedir);
422 if(!in_array("ini_set", $disfunc)) {
423 // Set user agent if we can use ini_set and have to do any http requests. :P
424 $iverstring = "FR 0.0.0 ".$VER2[2]." 0";
425 if($Settings['hideverinfohttp']=="off") {
426 $iverstring = $VER2[1]." ".$VER1[0].".".$VER1[1].".".$VER1[2]." ".$VER2[2]." ".$SubVerN; }
427 if($Settings['hideverinfohttp']=="on") {
428 $iverstring = "FR 0.0.0 ".$VER2[2]." 0"; }
429 $qstrtest = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
430 $qseptest = htmlentities($Settings['qsep'], ENT_QUOTES, $Settings['charset']);
431 $isiteurl = $Settings['idburl'].url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']);
432 @ini_set("user_agent", "Mozilla/5.0 (compatible; ".$UserAgentName."/".$iverstring."; +".$isiteurl.")");
433 if (function_exists("stream_context_create")) {
434 $iopts = array(
435 'http' => array(
436 'method' => "GET",
437 'header' => "Accept-Language: *\r\n".
438 "User-Agent: Mozilla/5.0 (compatible; ".$UserAgentName."/".$iverstring."; +".$isiteurl.")\r\n".
439 "Accept: */*\r\n".
440 "Connection: keep-alive\r\n".
441 "Referer: ".$isiteurl."\r\n".
442 "From: ".$isiteurl."\r\n".
443 "Via: ".$_SERVER['REMOTE_ADDR']."\r\n".
444 "Forwarded: ".$_SERVER['REMOTE_ADDR']."\r\n".
445 "X-Forwarded-For: ".$_SERVER['REMOTE_ADDR']."\r\n".
446 "Client-IP: ".$_SERVER['REMOTE_ADDR']."\r\n"
449 $icontext = stream_context_create($iopts);
450 function file_get_contents_alt($filename,$use_include_path=null,$offset=-1,$maxlen=null) {
451 global $icontext;
452 if($maxlen!==null) {
453 return file_get_contents($filename,$use_include_path,$icontext,$offset,$maxlen); }
454 if($maxlen===null) {
455 return file_get_contents($filename,$use_include_path,$icontext,$offset); } } } }
456 $iDBVerName = $VerCheckName."|".$VER2[1]."|".$VER1[0].".".$VER1[1].".".$VER1[2]."|".$VER2[2]."|".$SubVerN;
458 This way checks iDB version by sending the iDBVerName to the iDB Version Checker.
459 $Settings['vercheck'] = 1;
460 This way checks iDB version by sending the board url to the iDB Version Checker.
461 $Settings['vercheck'] = 2;
463 if(!isset($Settings['vercheck'])) {
464 $Settings['vercheck'] = 2; }
465 if($Settings['vercheck']!=1&&
466 $Settings['vercheck']!=2) {
467 $Settings['vercheck'] = 2; }
468 if($Settings['vercheck']===2) {
469 if($_GET['act']=="vercheckxsl") {
470 if(stristr($_SERVER["HTTP_ACCEPT"],"application/xml") ) {
471 header("Content-Type: application/xml; charset=".$Settings['charset']); }
472 else { header("Content-Type: text/xml; charset=".$Settings['charset']); }
473 xml_doc_start("1.0",$Settings['charset']);
474 echo "\n"; ?>
475 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
477 <xsl:template match="/">
478 <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
479 <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
480 <xsl:for-each select="versioninfo/version">
481 <div style="background-color:teal;color:white;padding:4px">
482 <span style="font-weight:bold"><xsl:value-of select="vname"/></span>
483 </div>
484 <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
485 <span style="font-style:italic">
486 Board Name: <a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>"><xsl:value-of select="title"/></a></span>
487 </div>
488 </xsl:for-each>
489 </body>
490 </html>
491 </xsl:template>
493 </xsl:stylesheet>
494 <?php gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
495 if($_GET['act']=="versioninfo") {
496 if(stristr($_SERVER["HTTP_ACCEPT"],"application/xml") ) {
497 header("Content-Type: application/xml; charset=".$Settings['charset']); }
498 else { header("Content-Type: text/xml; charset=".$Settings['charset']); }
499 xml_doc_start("1.0",$Settings['charset']);
500 echo '<?xml-stylesheet type="text/xsl" href="'.url_maker($exfile['index'],$Settings['file_ext'],"act=vercheckxsl",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']).'"?>'."\n"; ?>
502 <!DOCTYPE versioninfo [
503 <!ELEMENT versioninfo (version*)>
504 <!ELEMENT version (charset,title,name,vname)>
505 <!ELEMENT charset (#PCDATA)>
506 <!ELEMENT title (#PCDATA)>
507 <!ELEMENT name (#PCDATA)>
508 <!ELEMENT vname (#PCDATA)>
511 <versioninfo>
513 <version>
514 <charset><?php echo $Settings['charset']; ?></charset>
515 <title><?php echo $Settings['board_name']; ?></title>
516 <?php echo "<name>".$iDBVerName."</name>\n"; ?>
517 <vname><?php echo $VerCheckName; ?> Version Checker</vname>
518 </version>
520 </versioninfo>
521 <?php gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
522 if($Settings['vercheck']===1) {
523 if($_GET['act']=="versioninfo") { header("Content-Type: text/plain; charset=UTF-8");
524 header("Location: ".$VerCheckURL."&name=".urlencode($iDBVerName)); $urlstatus = 302;
525 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
526 if($_GET['act']=="homepage") { header("Content-Type: text/plain; charset=UTF-8");
527 header("Location: ".$Settings['weburl']); $urlstatus = 302;
528 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
529 if($_GET['act']=="bsdl"||$_GET['act']=="BSDL"||$_GET['act']=="license"||
530 $_GET['act']=="LICENSE"||$_GET['act']=="License") { $_GET['act']="bsd"; }
531 if($_GET['act']=="bsd") {
532 header("Content-Type: text/plain; charset=".$Settings['charset']);
533 require("LICENSE"); gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
534 if($_GET['act']=="README"||$_GET['act']=="ReadME") { $_GET['act']="readme"; }
535 if($_GET['act']=="readme"||$_GET['act']=="ReadMe") {
536 header("Content-Type: text/plain; charset=".$Settings['charset']);
537 require("README"); gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
538 if($_GET['act']=="js"||$_GET['act']=="javascript") {
539 header("Content-Script-Type: text/javascript");
540 if(stristr($_SERVER["HTTP_ACCEPT"],"application/x-javascript") ) {
541 header("Content-Type: application/x-javascript; charset=".$Settings['charset']); } else {
542 if(stristr($_SERVER["HTTP_ACCEPT"],"application/javascript") ) {
543 header("Content-Type: application/javascript; charset=".$Settings['charset']); } else {
544 header("Content-Type: text/javascript; charset=".$Settings['charset']); } }
545 require($SettDir['inc'].'javascript.php');
546 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
547 if($Settings['use_captcha']=="on") {
548 if($_GET['act']=="MkCaptcha"||$_GET['act']=="Captcha") {
549 if($Settings['captcha_clean']=="on") { ob_clean(); }
550 require($SettDir['inc']."captcha.php");
551 $aFonts = array('inc/fonts/VeraBd.ttf', 'inc/fonts/VeraBI.ttf', 'inc/fonts/VeraIt.ttf', 'inc/fonts/Vera.ttf');
552 $oPhpCaptcha = new PhpCaptcha($aFonts, 200, 60);
553 $RNumSize = rand(7,17); $i=0; $RandNum = null;
554 while ($i <= $RNumSize) {
555 $RandNum=$RandNum.dechex(rand(1,15)); ++$i; }
556 $RandNum=strtoupper($RandNum);
557 $oPhpCaptcha->SetOwnerText("Fake Code: ".$RandNum);
558 $oPhpCaptcha->UseColour(true);
559 $oPhpCaptcha->Create(); session_write_close(); die(); } }
560 require($SettDir['inc'].'groupsetup.php');
561 if($Settings['board_offline']=="on"&&$GroupInfo['CanViewOffLine']!="yes") {
562 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);
563 ob_clean(); if(!isset($Settings['offline_text'])) {
564 echo "Sorry the board is off line.\nIf you are a admin you can login by the admin cp."; }
565 if(isset($Settings['offline_text'])) { echo $Settings['offline_text']; } $urlstatus = 503;
566 //echo "\n".sql_errorno($SQLStat);
567 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
568 //Time Format Set
569 if(!isset($_SESSION['iDBDateFormat'])) {
570 if(isset($Settings['idb_date_format'])) {
571 $_SESSION['iDBDateFormat'] = $Settings['idb_date_format'];
572 if(!isset($Settings['idb_date_format'])) {
573 $_SESSION['iDBDateFormat'] = "g:i A"; } } }
574 if(!isset($_SESSION['iDBTimeFormat'])) {
575 if(isset($Settings['idb_time_format'])) {
576 $_SESSION['iDBTimeFormat'] = $Settings['idb_time_format'];
577 if(!isset($Settings['idb_time_format'])) {
578 $_SESSION['iDBTimeFormat'] = "F j Y"; } } }
579 //Time Zone Set
580 if(!isset($_SESSION['UserTimeZone'])) {
581 if(isset($Settings['DefaultTimeZone'])) {
582 $_SESSION['UserTimeZone'] = $Settings['DefaultTimeZone'];
583 if(!isset($Settings['DefaultTimeZone'])) {
584 $_SESSION['UserTimeZone'] = SeverOffSet().":00"; } } }
585 $checktime = explode(":",$_SESSION['UserTimeZone']);
586 if(count($checktime)!=2) {
587 if(!isset($checktime[0])) { $checktime[0] = "0"; }
588 if(!isset($checktime[1])) { $checktime[1] = "00"; }
589 $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
590 if(!is_numeric($checktime[0])) { $checktime[0] = "0"; }
591 if(!is_numeric($checktime[1])) { $checktime[1] = "00"; }
592 if($checktime[1]<0) { $checktime[1] = "00"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
593 $checktimea = array("offset" => $_SESSION['UserTimeZone'], "hour" => $checktime[0], "minute" => $checktime[1]);
594 if(!isset($_SESSION['UserDST'])) { $_SESSION['UserDST'] = null; }
595 if($_SESSION['UserDST']==null) {
596 if($Settings['DefaultDST']=="off") {
597 $_SESSION['UserDST'] = "off"; }
598 if($Settings['DefaultDST']=="on") {
599 $_SESSION['UserDST'] = "on"; } }
600 // Guest Stuff
601 if(isset($_SESSION['MemberName'])||
602 isset($_COOKIE['MemberName'])) {
603 $_SESSION['GuestName'] = null;
604 $_COOKIE['GuestName'] = null; }
605 if(!isset($_SESSION['MemberName'])&&!isset($_COOKIE['MemberName'])) {
606 if(!isset($_SESSION['GuestName'])&&isset($_COOKIE['GuestName'])) {
607 $_SESSION['GuestName'] = $_COOKIE['GuestName']; } }
608 if(!isset($_SESSION['LastPostTime'])) { $_SESSION['LastPostTime'] = "0"; }
609 // Skin Stuff
610 if(!isset($_SESSION['Theme'])) { $_SESSION['Theme'] = null; }
611 if(!isset($_GET['theme'])) { $_GET['theme'] = null; }
612 if(!isset($_POST['theme'])) { $_POST['theme'] = null; }
613 if(!isset($_GET['skin'])) { $_GET['skin'] = null; }
614 if(!isset($_POST['skin'])) { $_POST['skin'] = null; }
615 if(!isset($_GET['style'])) { $_GET['style'] = null; }
616 if(!isset($_POST['style'])) { $_POST['style'] = null; }
617 if(!isset($_GET['css'])) { $_GET['css'] = null; }
618 if(!isset($_POST['css'])) { $_POST['css'] = null; }
619 if($_GET['theme']==null) {
620 if($_POST['theme']!=null) {
621 $_GET['theme'] = $_POST['theme']; }
622 if($_POST['skin']!=null) {
623 $_GET['theme'] = $_POST['skin']; }
624 if($_POST['style']!=null) {
625 $_GET['theme'] = $_POST['style']; }
626 if($_POST['css']!=null) {
627 $_GET['theme'] = $_POST['css']; }
628 if($_GET['skin']!=null) {
629 $_GET['theme'] = $_GET['skin']; }
630 if($_GET['style']!=null) {
631 $_GET['theme'] = $_GET['style']; }
632 if($_GET['css']!=null) {
633 $_GET['theme'] = $_GET['css']; } }
634 if($Settings['SQLThemes']=="off") {
635 if($_GET['theme']!=null) {
636 $_GET['theme'] = chack_themes($_GET['theme']);
637 if($_GET['theme']=="../"||$_GET['theme']=="./") {
638 $_GET['theme']=$Settings['DefaultTheme']; $_SESSION['Theme']=$Settings['DefaultTheme']; }
639 if (file_exists($SettDir['themes'].$_GET['theme']."/settings.php")) {
640 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
641 $NewDay=GMTimeStamp();
642 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_GET['theme'],$NewDay,$_SESSION['UserID']));
643 sql_query($qnewskin,$SQLStat); }
644 /* The file Theme Exists */ }
645 else { $_GET['theme'] = $Settings['DefaultTheme'];
646 $_SESSION['Theme'] = $Settings['DefaultTheme'];
647 /* The file Theme Dose Not Exists */ } }
648 if($_GET['theme']==null) {
649 if($_SESSION['Theme']!=null) {
650 $OldTheme = $_SESSION['Theme'];
651 $_SESSION['Theme'] = chack_themes($_SESSION['Theme']);
652 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
653 if($OldTheme!=$_SESSION['Theme']) {
654 $NewDay=GMTimeStamp();
655 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_SESSION['Theme'],$NewDay,$_SESSION['UserID']));
656 sql_query($qnewskin,$SQLStat); } }
657 $_GET['theme']=$_SESSION['Theme']; }
658 if($_SESSION['Theme']==null) {
659 $_SESSION['Theme']=$Settings['DefaultTheme'];
660 $_GET['theme']=$Settings['DefaultTheme']; } }
661 $PreSkin['skindir1'] = $_SESSION['Theme'];
662 $PreSkin['skindir2'] = $SettDir['themes'].$_SESSION['Theme'];
663 require($SettDir['themes'].$_GET['theme']."/settings.php"); }
664 if($Settings['SQLThemes']=="on") {
665 if($_GET['theme']==null&&$_SESSION['Theme']==null) {
666 $_GET['theme'] = $Settings['DefaultTheme'];
667 $_SESSION['Theme'] = $Settings['DefaultTheme']; }
668 if($_GET['theme']!=null) {
669 $themequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."themes\" WHERE \"Name\"='%s'", array($_GET['theme'])); }
670 if($_GET['theme']==null) {
671 if($_SESSION['Theme']!=null) {
672 $themequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."themes\" WHERE \"Name\"='%s'", array($_SESSION['Theme'])); } }
673 $themeresult=sql_query($themequery,$SQLStat);
674 $themenum=sql_num_rows($themeresult);
675 if($themenum<=0) {
676 $_GET['theme'] = $Settings['DefaultTheme'];
677 $_SESSION['Theme'] = $Settings['DefaultTheme'];
678 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
679 $NewDay=GMTimeStamp();
680 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_SESSION['Theme'],$NewDay,$_SESSION['UserID']));
681 sql_query($qnewskin,$SQLStat); }
682 $themequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."themes\" WHERE \"Name\"='%s'", array($_GET['theme']));
683 $themeresult=sql_query($themequery,$SQLStat);
684 $themenum=sql_num_rows($themeresult); }
685 else {
686 if($_GET['theme']==null) {
687 if($_SESSION['Theme']!=null) {
688 $_GET['theme'] = $_SESSION['Theme']; } }
689 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
690 $NewDay=GMTimeStamp();
691 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_GET['theme'],$NewDay,$_SESSION['UserID']));
692 sql_query($qnewskin,$SQLStat); } }
693 require($SettDir['inc'].'sqlthemes.php');
694 sql_free_result($themeresult); }
695 $_SESSION['Theme'] = $_GET['theme'];
696 function get_theme_values($matches) {
697 global $ThemeSet;
698 $return_text = null;
699 if(isset($ThemeSet[$matches[1]])) { $return_text = $ThemeSet[$matches[1]]; }
700 if(!isset($ThemeSet[$matches[1]])) { $return_text = null; }
701 return $return_text; }
702 foreach($ThemeSet AS $key => $value) {
703 $ThemeSet[$key] = preg_replace("/%%/s", "{percent}p", $ThemeSet[$key]);
704 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}T/s", "get_theme_values", $ThemeSet[$key]);
705 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}e/s", "get_env_values", $ThemeSet[$key]);
706 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}i/s", "get_server_values", $ThemeSet[$key]);
707 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}s/s", "get_setting_values", $ThemeSet[$key]);
708 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}t/s", "get_time", $ThemeSet[$key]);
709 $ThemeSet[$key] = preg_replace("/\{percent\}p/s", "%", $ThemeSet[$key]); }
710 if(!isset($ThemeSet['TableStyle'])) {
711 $ThemeSet['TableStyle'] = "table"; }
712 if(isset($ThemeSet['TableStyle'])) {
713 if($ThemeSet['TableStyle']!="div"&&
714 $ThemeSet['TableStyle']!="table") {
715 $ThemeSet['TableStyle'] = "table"; } }
716 if(!isset($_SESSION['DBName'])) { $_SESSION['DBName'] = null; }
717 if($_SESSION['DBName']==null) {
718 $_SESSION['DBName'] = $Settings['sqldb']; }
719 if($_SESSION['DBName']!=null) {
720 if($_SESSION['DBName']!=$Settings['sqldb']) {
721 redirect("location",$rbasedir.url_maker($exfile['member'],$Settings['file_ext'],"act=logout",$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'],false)); } }