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