3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the Revised BSD License.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 Revised BSD License for more details.
11 Copyright 2004-2010 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2010 Game Maker 2k - http://gamemaker2k.org/
14 $FileInfo: sql.php - Last Update: 04/12/2010 SVN 466 - Author: cooldude2k $
16 /* Some ini setting changes uncomment if you need them.
18 //@ini_set("display_errors", true);
19 //@ini_set("display_startup_errors", true);
20 @error_reporting(E_ALL ^ E_NOTICE);
21 //@ini_set("error_prepend_string","<span style=\"color: ff0000;\">");
22 //@ini_set("error_append_string","</span>");
23 //@ini_set("docref_root","http://us.php.net/manual-lookup.php?pattern=");
24 //@ini_set("docref_ext","");
25 /* Get rid of session id in urls */
26 //@ini_set("session.use_trans_sid", false);
27 //@ini_set("session.use_cookies", true);
28 //@ini_set("session.use_only_cookies", true);
29 //@ini_set("url_rewriter.tags","");
30 @set_time_limit(30); @ignore_user_abort(true);
31 /* Change session garbage collection settings */
32 //@ini_set("session.gc_probability", 1);
33 //@ini_set("session.gc_divisor", 100);
34 //@ini_set("session.gc_maxlifetime", 1440);
35 $File3Name = basename($_SERVER['SCRIPT_NAME']);
36 if ($File3Name=="sql.php"||$File3Name=="/sql.php") {
37 header('Location: index.php');
39 if(file_exists('settings.php')) {
40 require_once('settings.php'); }
41 if(!isset($Settings['idburl'])) { $Settings['idburl'] = null; }
42 if(!isset($Settings['fixbasedir'])) { $Settings['fixbasedir'] = null; }
43 if(!isset($Settings['fixpathinfo'])) { $Settings['fixpathinfo'] = null; }
44 if(!isset($Settings['fixcookiedir'])) { $Settings['fixcookiedir'] = null; }
45 $Settings['bid'] = base64_encode(urlencode($Settings['idburl']));
46 if(!isset($Settings['showverinfo'])) {
47 $Settings['showverinfo'] = "on"; }
48 if($Settings['fixpathinfo']=="off") {
49 $Settings['fixpathinfo'] = null; }
50 if($Settings['fixbasedir']=="off") {
51 $Settings['fixbasedir'] = null; }
52 if($Settings['fixcookiedir']=="off") {
53 $Settings['fixcookiedir'] = null; }
54 if($Settings['idburl']=="localhost") {
55 header("Content-Type: text/plain; charset=UTF-8");
56 echo "500 Error: URL is malformed. Try reinstalling iDB."; die(); }
57 if($Settings['fixbasedir']=="on") {
58 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
59 $PathsTest = parse_url($Settings['idburl']);
60 $Settings['fixbasedir'] = $PathsTest['path']."/";
61 $Settings['fixbasedir'] = str_replace("//", "/", $Settings['fixbasedir']); } }
62 if($Settings['fixcookiedir']=="on") {
63 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
64 $PathsTest = parse_url($Settings['idburl']);
65 $Settings['fixcookiedir'] = $PathsTest['path']."/";
66 $Settings['fixcookiedir'] = str_replace("//", "/", $Settings['fixcookiedir']); } }
67 if(!isset($Settings['charset'])) {
68 $Settings['charset'] = "ISO-8859-15"; }
69 if(isset($Settings['charset'])) {
70 if($Settings['charset']!="ISO-8859-15"&&$Settings['charset']!="ISO-8859-1"&&
71 $Settings['charset']!="UTF-8"&&$Settings['charset']!="CP866"&&
72 $Settings['charset']!="Windows-1251"&&$Settings['charset']!="Windows-1252"&&
73 $Settings['charset']!="KOI8-R"&&$Settings['charset']!="BIG5"&&
74 $Settings['charset']!="GB2312"&&$Settings['charset']!="BIG5-HKSCS"&&
75 $Settings['charset']!="Shift_JIS"&&$Settings['charset']!="EUC-JP") {
76 $Settings['charset'] = "ISO-8859-15"; } }
77 $chkcharset = $Settings['charset'];
78 @ini_set('default_charset', $Settings['charset']);
79 //session_save_path($SettDir['inc']."temp/");
80 if(!isset($Settings['sqldb'])) {
81 if(file_exists("install.php")) { header('Location: install.php'); die(); }
82 if(!file_exists("install.php")) { header("Content-Type: text/plain; charset=UTF-8");
83 echo "403 Error: Sorry could not find install.php\nTry uploading files again and if that dose not work try download iDB again."; die(); } }
84 if(isset($Settings['sqldb'])&&
85 function_exists("date_default_timezone_set")) {
86 @date_default_timezone_set("UTC"); }
87 if(!isset($Settings['sqlhost'])) { $Settings['sqlhost'] = "localhost"; }
88 if($Settings['fixpathinfo']=="on") {
89 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
90 putenv("PATH_INFO=".$_SERVER['ORIG_PATH_INFO']); }
91 // Check to see if variables are set
92 if(!isset($SettDir['inc'])) { $SettDir['inc'] = "inc/"; }
93 if(!isset($SettDir['misc'])) { $SettDir['misc'] = "inc/misc/"; }
94 if(!isset($SettDir['sql'])) { $SettDir['sql'] = "inc/misc/sql/"; }
95 if(!isset($SettDir['admin'])) { $SettDir['admin'] = "inc/admin/"; }
96 if(!isset($SettDir['sqldumper'])) { $SettDir['sqldumper'] = "inc/admin/sqldumper/"; }
97 if(!isset($SettDir['mod'])) { $SettDir['mod'] = "inc/mod/"; }
98 if(!isset($SettDir['themes'])) { $SettDir['themes'] = "themes/"; }
99 if(!isset($Settings['use_iniset'])) { $Settings['use_iniset'] = null; }
100 if(!isset($Settings['clean_ob'])) { $Settings['clean_ob'] = "off"; }
101 if(!isset($_SERVER['PATH_INFO'])) { $_SERVER['PATH_INFO'] = null; }
102 if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
103 $_SERVER['HTTP_ACCEPT_ENCODING'] = null; }
104 if(!isset($_SERVER["HTTP_ACCEPT"])) { $_SERVER["HTTP_ACCEPT"] = null; }
105 if(!isset($_SERVER['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = null; }
106 if(!isset($_GET['page'])) { $_GET['page'] = null; }
107 if(!isset($_GET['act'])) { $_GET['act'] = null; }
108 if(!isset($_POST['act'])) { $_POST['act'] = null; }
109 if(!isset($_GET['modact'])) { $_GET['modact'] = null; }
110 if(!isset($_POST['modact'])) { $_POST['modact'] = null; }
111 if(!isset($_GET['id'])) { $_GET['id'] = null; }
112 if(!isset($_GET['debug'])) { $_GET['debug'] = "off"; }
113 if(!isset($_GET['post'])) { $_GET['post'] = null; }
114 if(!isset($_POST['License'])) { $_POST['License'] = null; }
115 if(!isset($_SERVER['HTTPS'])) { $_SERVER['HTTPS'] = "off"; }
116 require_once($SettDir['misc'].'utf8.php');
117 require_once($SettDir['inc'].'filename.php');
118 if(!isset($Settings['use_hashtype'])) {
119 $Settings['use_hashtype'] = "sha1"; }
120 if(!function_exists('hash')||!function_exists('hash_algos')) {
121 if($Settings['use_hashtype']!="md5"&&
122 $Settings['use_hashtype']!="sha1") {
123 $Settings['use_hashtype'] = "sha1"; } }
124 if(function_exists('hash')&&function_exists('hash_algos')) {
125 if(!in_array($Settings['use_hashtype'],hash_algos())) {
126 $Settings['use_hashtype'] = "sha1"; }
127 if($Settings['use_hashtype']!="md2"&&
128 $Settings['use_hashtype']!="md4"&&
129 $Settings['use_hashtype']!="md5"&&
130 $Settings['use_hashtype']!="sha1"&&
131 $Settings['use_hashtype']!="sha224"&&
132 $Settings['use_hashtype']!="sha256"&&
133 $Settings['use_hashtype']!="sha386"&&
134 $Settings['use_hashtype']!="sha512"&&
135 $Settings['use_hashtype']!="ripemd128"&&
136 $Settings['use_hashtype']!="ripemd160"&&
137 $Settings['use_hashtype']!="ripemd256"&&
138 $Settings['use_hashtype']!="ripemd320") {
139 $Settings['use_hashtype'] = "sha1"; } }
140 // Check to see if variables are set
141 require_once($SettDir['misc'].'setcheck.php');
142 require_once($SettDir['inc'].'function.php');
143 $iDBVerName = "iDB|".$VER2[1]."|".$VER1[0].".".$VER1[1].".".$VER1[2]."|".$VER2[2]."|".$SubVerN;
145 This way checks iDB version by sending the iDBVerName to the iDB Version Checker.
146 $Settings['vercheck'] = 1;
147 This way checks iDB version by sending the board url to the iDB Version Checker.
148 $Settings['vercheck'] = 2;
150 if(!isset($Settings['vercheck'])) {
151 $Settings['vercheck'] = 2; }
152 if($Settings['vercheck']!=1&&
153 $Settings['vercheck']!=2) {
154 $Settings['vercheck'] = 2; }
155 if($Settings['vercheck']===2) {
156 if($_GET['act']=="vercheckxsl") {
157 if(stristr($_SERVER["HTTP_ACCEPT"],"application/xml") ) {
158 header("Content-Type: application/xml; charset=".$Settings['charset']); }
159 else { header("Content-Type: text/xml; charset=".$Settings['charset']); }
160 xml_doc_start("1.0",$Settings['charset']);
162 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
164 <xsl:template match="/">
165 <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
166 <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
167 <xsl:for-each select="versioninfo/version">
168 <div style="background-color:teal;color:white;padding:4px">
169 <span style="font-weight:bold"><xsl:value-of select="vname"/></span>
171 <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
172 <span style="font-style:italic">
173 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>
181 <?php die(); } if($_GET['act']=="versioninfo") {
182 if(stristr($_SERVER["HTTP_ACCEPT"],"application/xml") ) {
183 header("Content-Type: application/xml; charset=".$Settings['charset']); }
184 else { header("Content-Type: text/xml; charset=".$Settings['charset']); }
185 xml_doc_start("1.0",$Settings['charset']);
186 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"; ?>
188 <!DOCTYPE versioninfo [
189 <!ELEMENT versioninfo (version*)>
190 <!ELEMENT version (charset,title,name,vname)>
191 <!ELEMENT charset (#PCDATA)>
192 <!ELEMENT title (#PCDATA)>
193 <!ELEMENT name (#PCDATA)>
194 <!ELEMENT vname (#PCDATA)>
200 <charset><?php echo $Settings['charset']; ?></charset>
201 <title><?php echo $Settings['board_name']; ?></title>
202 <?php echo "<name>".$iDBVerName."</name>\n"; ?>
203 <vname>iDB Version Checker</vname>
207 <?php die(); } } if($Settings['vercheck']===1) {
208 if($_GET['act']=="versioninfo") { header("Content-Type: text/plain; charset=UTF-8");
209 header("Location: ".$VerCheckURL."&name=".urlencode($iDBVerName)); die(); } }
210 if($Settings['enable_pathinfo']=="on") {
211 mrstring(); /* Change Path info to Get Vars :P */ }
212 // Check to see if variables are set
213 $qstrhtml = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
214 if($Settings['enable_https']=="on"&&$_SERVER['HTTPS']=="on") {
215 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
216 $HTTPsTest = parse_url($Settings['idburl']); if($HTTPsTest['scheme']=="http") {
217 $Settings['idburl'] = preg_replace("/http\:\/\//i", "https://", $Settings['idburl']); } } }
218 $cookieDomain = null; $cookieSecure = false;
219 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
220 $URLsTest = parse_url($Settings['idburl']);
221 $cookieDomain = $URLsTest['host'];
222 if($cookieDomain=="localhost") { $cookieDomain = false; }
223 if($Settings['enable_https']=="on") {
224 if($URLsTest['scheme']=="https") { $cookieSecure = true; }
225 if($URLsTest['scheme']!="https") { $cookieSecure = false; } } }
226 @ini_set("default_charset",$Settings['charset']);
227 $File1Name = dirname($_SERVER['SCRIPT_NAME'])."/";
228 $File2Name = $_SERVER['SCRIPT_NAME'];
229 $File3Name=str_replace($File1Name, null, $File2Name);
230 if ($File3Name=="sql.php"||$File3Name=="/sql.php") {
231 require($SettDir['inc'].'forbidden.php');
233 //error_reporting(E_ERROR);
234 // Check if gzip is on and if user's browser can accept gzip pages
235 if($_GET['act']=="MkCaptcha"||$_GET['act']=="Captcha") {
236 $Settings['use_gzip'] = 'off'; }
237 if($Settings['use_gzip']=="on") {
238 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) {
239 $GZipEncode['Type'] = "gzip"; } else {
240 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "deflate")) {
241 $GZipEncode['Type'] = "deflate"; } else {
242 $Settings['use_gzip'] = "off"; $GZipEncode['Type'] = "none"; } } }
243 if($Settings['use_gzip']=="gzip") {
244 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) { $Settings['use_gzip'] = "on";
245 $GZipEncode['Type'] = "gzip"; } else { $Settings['use_gzip'] = "off"; } }
246 if($Settings['use_gzip']=="deflate") {
247 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "deflate")) { $Settings['use_gzip'] = "on";
248 $GZipEncode['Type'] = "deflate"; } else { $Settings['use_gzip'] = "off"; } }
249 if($Settings['clean_ob']=="on") {
250 /* Check for other output handlers/buffers are open
251 and close and get the contents in an array */
252 $numob = count(ob_list_handlers()); $iob = 0;
253 while ($iob < $numob) {
254 $old_ob_var[$iob] = ob_get_clean();
255 ++$iob; } } ob_start();
256 if($Settings['use_gzip']=="on") {
257 if($GZipEncode['Type']!="gzip") { if($GZipEncode['Type']!="deflate") { $GZipEncode['Type'] = "gzip"; } }
258 if($GZipEncode['Type']=="gzip") {
259 header("Content-Encoding: gzip"); }
260 if($GZipEncode['Type']=="deflate") {
261 header("Content-Encoding: deflate"); } }
262 /* if(eregi("msie",$browser) && !eregi("opera",$browser)){
263 header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); } */
265 $SQLStat = sql_connect_db($Settings['sqlhost'],$Settings['sqluser'],$Settings['sqlpass'],$Settings['sqldb']);
266 $SQLCollate = "latin1_general_ci";
267 $SQLCharset = "latin1";
268 if($Settings['charset']=="ISO-8859-1") {
269 $SQLCollate = "latin1_general_ci";
270 $SQLCharset = "latin1"; }
271 if($Settings['charset']=="ISO-8859-15") {
272 $SQLCollate = "latin1_general_ci";
273 $SQLCharset = "latin1"; }
274 if($Settings['charset']=="UTF-8") {
275 $SQLCollate = "utf8_unicode_ci";
276 $SQLCharset = "utf8"; }
277 sql_set_charset($SQLCharset,$SQLStat);
278 if($SQLStat===false) {
279 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);
280 ob_clean(); echo "Sorry could not connect to mysql database.\nContact the board admin about error. Error log below.";
281 echo "\n".sql_errorno($SQLStat);
282 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
283 $sqltable = $Settings['sqltable'];
284 function sqlsession_open( $save_path, $session_name ) {
285 global $sess_save_path;
286 $sess_save_path = $save_path;
288 function sqlsession_close() {
290 function sqlsession_read($id) {
291 global $sqltable,$SQLStat,$SQLSType;
293 $time = GMTimeStamp();
294 $sqlr = sql_pre_query("SELECT * FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '%s'", array($id,$time));
295 $rs = sql_query($sqlr,$SQLStat);
296 $a = sql_num_rows($rs);
298 $row = sql_fetch_assoc($rs);
299 $data = $row['session_data']; }
301 $SQLSType = $Settings['sqltype'];
302 function sqlsession_write($id,$data) {
303 global $sqltable,$SQLStat,$SQLSType;
304 $time = GMTimeStamp();
305 if($SQLSType=="mysql"||
306 $SQLSType=="mysqli") {
307 $sqlw = sql_pre_query("REPLACE \"".$sqltable."sessions\" VALUES('$id','$data', $time)", array($id,$data,$time));
308 $rs = sql_query($sqlw,$SQLStat); }
309 if($SQLSType=="pgsql"||
310 $SQLSType=="sqlite") {
311 $sqlr = sql_pre_query("SELECT * FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '%s'", array($id,$time));
312 $rs = sql_query($sqlr,$SQLStat);
313 $a = sql_num_rows($rs);
315 $sqlw = sql_pre_query("UPDATE \"".$sqltable."sessions\" SET \"session_data\"='%s',\"expires\"=%i WHERE \"session_id\"='%s'", array($data,$time,$id));
316 $rs = sql_query($sqlw,$SQLStat); }
318 $sqlw = sql_pre_query("INSERT INTO \"".$sqltable."sessions\" (\"session_id\", \"session_data\", \"expires\") VALUES\n".
319 "('%s', '%s', %i)", array($id,$time,$data));
320 $rs = sql_query($sqlw,$SQLStat); } }
322 function sqlsession_destroy($id) {
323 global $sqltable,$SQLStat;
324 $sqld = sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '$id'", array($id));
325 sql_query($sqld,$SQLStat);
327 function sqlsession_gc($maxlifetime) {
328 global $sqltable,$SQLStat;
329 $time = GMTimeStamp() - $maxlifetime;
330 //$sqlg = sql_pre_query('DELETE FROM \"'.$sqltable.'sessions\" WHERE \"expires\" < UNIX_TIMESTAMP();', array(null));
331 $sqlg = sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"expires\" < %i", array($time));
332 sql_query($sqlg,$SQLStat);
334 session_set_save_handler("sqlsession_open", "sqlsession_close", "sqlsession_read", "sqlsession_write", "sqlsession_destroy", "sqlsession_gc");
335 if($cookieDomain==null) {
336 session_set_cookie_params(0, $cbasedir); }
337 if($cookieDomain!=null) {
338 if($cookieSecure===true) {
339 session_set_cookie_params(0, $cbasedir, $cookieDomain, 1); }
340 if($cookieSecure===false) {
341 session_set_cookie_params(0, $cbasedir, $cookieDomain); } }
342 session_cache_limiter("private, no-cache, must-revalidate");
343 header("Cache-Control: private, no-cache, must-revalidate");
344 header("Pragma: private, no-cache, must-revalidate");
345 header("Date: ".gmdate("D, d M Y H:i:s")." GMT");
346 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
347 header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
348 session_name($Settings['sqltable']."sess");
350 //header("Set-Cookie: PHPSESSID=" . session_id() . "; path=".$cbasedir);
351 output_reset_rewrite_vars();
352 if($_GET['act']=="bsdl"||$_GET['act']=="BSDL"||$_GET['act']=="license"||
353 $_GET['act']=="LICENSE"||$_GET['act']=="License") { $_GET['act']="bsd"; }
354 if($_GET['act']=="bsd") {
355 header("Content-Type: text/plain; charset=".$Settings['charset']);
356 require("LICENSE"); gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
357 if($_GET['act']=="README"||$_GET['act']=="ReadME") { $_GET['act']="readme"; }
358 if($_GET['act']=="readme"||$_GET['act']=="ReadMe") {
359 header("Content-Type: text/plain; charset=".$Settings['charset']);
360 require("README"); gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
361 if($_GET['act']=="js"||$_GET['act']=="javascript") {
362 header("Content-Script-Type: text/javascript");
363 if(stristr($_SERVER["HTTP_ACCEPT"],"application/x-javascript") ) {
364 header("Content-Type: application/x-javascript; charset=".$Settings['charset']); } else {
365 if(stristr($_SERVER["HTTP_ACCEPT"],"application/javascript") ) {
366 header("Content-Type: application/javascript; charset=".$Settings['charset']); } else {
367 header("Content-Type: text/javascript; charset=".$Settings['charset']); } }
368 require($SettDir['inc'].'javascript.php');
369 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
370 if($Settings['use_captcha']=="on") {
371 if($_GET['act']=="MkCaptcha"||$_GET['act']=="Captcha") {
372 if($Settings['captcha_clean']=="on") { ob_clean(); }
373 require($SettDir['inc']."captcha.php");
374 $aFonts = array('inc/fonts/VeraBd.ttf', 'inc/fonts/VeraBI.ttf', 'inc/fonts/VeraIt.ttf', 'inc/fonts/Vera.ttf');
375 $oPhpCaptcha = new PhpCaptcha($aFonts, 200, 60);
376 $RNumSize = rand(7,17); $i=0; $RandNum = null;
377 while ($i <= $RNumSize) {
378 $RandNum=$RandNum.dechex(rand(1,15)); ++$i; }
379 $RandNum=strtoupper($RandNum);
380 $oPhpCaptcha->SetOwnerText("Fake Code: ".$RandNum);
381 $oPhpCaptcha->UseColour(true);
382 $oPhpCaptcha->Create(); session_write_close(); die(); } }
383 if(!isset($_SESSION['CheckCookie'])) {
384 if(isset($_COOKIE['SessPass'])&&isset($_COOKIE['MemberName'])) {
385 require($SettDir['inc'].'prelogin.php'); } }
386 require($SettDir['inc'].'groupsetup.php');
387 if($Settings['board_offline']=="on"&&$GroupInfo['CanViewOffLine']!="yes") {
388 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);
389 ob_clean(); if(!isset($Settings['offline_text'])) {
390 echo "Sorry the board is off line.\nIf you are a admin you can login by the admin cp."; }
391 if(isset($Settings['offline_text'])) { echo $Settings['offline_text']; }
392 //echo "\n".sql_errorno($SQLStat);
393 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
394 $dayconv = array('second' => 1, 'minute' => 60, 'hour' => 3600, 'day' => 86400, 'week' => 604800, 'month' => 2630880, 'year' => 31570560, 'decade' => 15705600);
396 if(!isset($_SESSION['UserTimeZone'])) {
397 if(isset($Settings['DefaultTimeZone'])) {
398 $_SESSION['UserTimeZone'] = $Settings['DefaultTimeZone'];
399 if(!isset($Settings['DefaultTimeZone'])) {
400 $_SESSION['UserTimeZone'] = SeverOffSet().":00"; } } }
401 $checktime = explode(":",$_SESSION['UserTimeZone']);
402 if(count($checktime)!=2) {
403 if(!isset($checktime[0])) { $checktime[0] = "0"; }
404 if(!isset($checktime[1])) { $checktime[1] = "00"; }
405 $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
406 if(!is_numeric($checktime[0])) { $checktime[0] = "0"; }
407 if($checktime[0]>12) { $checktime[0] = "12"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
408 if($checktime[0]<-12) { $checktime[0] = "-12"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
409 if(!is_numeric($checktime[1])) { $checktime[1] = "00"; }
410 if($checktime[1]>59) { $checktime[1] = "59"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
411 if($checktime[1]<0) { $checktime[1] = "00"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
412 $checktimea = array("offset" => $_SESSION['UserTimeZone'], "hour" => $checktime[0], "minute" => $checktime[1]);
413 if(!isset($_SESSION['UserDST'])) { $_SESSION['UserDST'] = null; }
414 if($_SESSION['UserDST']==null) {
415 if($Settings['DefaultDST']=="off") {
416 $_SESSION['UserDST'] = "off"; }
417 if($Settings['DefaultDST']=="on") {
418 $_SESSION['UserDST'] = "on"; } }
420 if(isset($_SESSION['MemberName'])||
421 isset($_COOKIE['MemberName'])) {
422 $_SESSION['GuestName'] = null;
423 $_COOKIE['GuestName'] = null; }
424 if(!isset($_SESSION['MemberName'])&&!isset($_COOKIE['MemberName'])) {
425 if(!isset($_SESSION['GuestName'])&&isset($_COOKIE['GuestName'])) {
426 $_SESSION['GuestName'] = $_COOKIE['GuestName']; } }
427 if(!isset($_SESSION['LastPostTime'])) { $_SESSION['LastPostTime'] = "0"; }
429 if(!isset($_SESSION['Theme'])) { $_SESSION['Theme'] = null; }
430 if(!isset($_GET['theme'])) { $_GET['theme'] = null; }
431 if(!isset($_POST['theme'])) { $_POST['theme'] = null; }
432 if(!isset($_GET['skin'])) { $_GET['skin'] = null; }
433 if(!isset($_POST['skin'])) { $_POST['skin'] = null; }
434 if(!isset($_GET['style'])) { $_GET['style'] = null; }
435 if(!isset($_POST['style'])) { $_POST['style'] = null; }
436 if(!isset($_GET['css'])) { $_GET['css'] = null; }
437 if(!isset($_POST['css'])) { $_POST['css'] = null; }
438 if($_GET['theme']==null) {
439 if($_POST['theme']!=null) {
440 $_GET['theme'] = $_POST['theme']; }
441 if($_POST['skin']!=null) {
442 $_GET['theme'] = $_POST['skin']; }
443 if($_POST['style']!=null) {
444 $_GET['theme'] = $_POST['style']; }
445 if($_POST['css']!=null) {
446 $_GET['theme'] = $_POST['css']; }
447 if($_GET['skin']!=null) {
448 $_GET['theme'] = $_GET['skin']; }
449 if($_GET['style']!=null) {
450 $_GET['theme'] = $_GET['style']; }
451 if($_GET['css']!=null) {
452 $_GET['theme'] = $_GET['css']; } }
453 if($_GET['theme']!=null) {
454 $_GET['theme'] = chack_themes($_GET['theme']);
455 if($_GET['theme']=="../"||$_GET['theme']=="./") {
456 $_GET['theme']="iDB"; $_SESSION['Theme']="iDB"; }
457 if (file_exists($SettDir['themes'].$_GET['theme']."/settings.php")) {
458 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
459 $NewDay=GMTimeStamp();
460 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_GET['theme'],$NewDay,$_SESSION['UserID']));
461 sql_query($qnewskin,$SQLStat); }
462 /* The file Theme Exists */ }
463 else { $_GET['theme'] = $Settings['DefaultTheme'];
464 $_SESSION['Theme'] = $Settings['DefaultTheme'];
465 /* The file Theme Dose Not Exists */ } }
466 if($_GET['theme']==null) {
467 if($_SESSION['Theme']!=null) {
468 $OldTheme = $_SESSION['Theme'];
469 $_SESSION['Theme'] = chack_themes($_SESSION['Theme']);
470 if($OldTheme!=$_SESSION['Theme']) {
471 $NewDay=GMTimeStamp();
472 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_SESSION['Theme'],$NewDay,$_SESSION['UserID']));
473 sql_query($qnewskin,$SQLStat); }
474 $_GET['theme']=$_SESSION['Theme']; }
475 if($_SESSION['Theme']==null) {
476 $_SESSION['Theme']=$Settings['DefaultTheme'];
477 $_GET['theme']=$Settings['DefaultTheme']; } }
478 $PreSkin['skindir1'] = $_SESSION['Theme'];
479 $PreSkin['skindir2'] = $SettDir['themes'].$_SESSION['Theme'];
480 require($SettDir['themes'].$_GET['theme']."/settings.php");
481 $_SESSION['Theme'] = $_GET['theme'];
482 if(!isset($ThemeSet['TableStyle'])) {
483 $ThemeSet['TableStyle'] = "table"; }
484 if(isset($ThemeSet['TableStyle'])) {
485 if($ThemeSet['TableStyle']!="div"&&
486 $ThemeSet['TableStyle']!="table") {
487 $ThemeSet['TableStyle'] = "table"; } }
488 if(!isset($_SESSION['DBName'])) { $_SESSION['DBName'] = null; }
489 if($_SESSION['DBName']==null) {
490 $_SESSION['DBName'] = $Settings['sqldb']; }
491 if($_SESSION['DBName']!=null) {
492 if($_SESSION['DBName']!=$Settings['sqldb']) {
493 redirect("location",$basedir.url_maker($exfile['member'],$Settings['file_ext'],"act=logout",$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'],false)); } }