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