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