OSDN Git Service

Small bug fix to localhost setcookie.
[idb/iDB.git.git] / sql.php
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.
5
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.
10
11     Copyright 2004-2010 iDB Support - http://idb.berlios.de/
12     Copyright 2004-2010 Game Maker 2k - http://gamemaker2k.org/
13
14     $FileInfo: sql.php - Last Update: 01/01/2010 SVN 438 - Author: cooldude2k $
15 */
16 /* Some ini setting changes uncomment if you need them. 
17    Display PHP Errors */
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');
38         exit(); }
39 require('settings.php');
40 if(!isset($Settings['idburl'])) { $Settings['idburl'] = null; }
41 if(!isset($Settings['fixbasedir'])) { $Settings['fixbasedir'] = null; }
42 if(!isset($Settings['fixpathinfo'])) { $Settings['fixpathinfo'] = null; }
43 if(!isset($Settings['fixcookiedir'])) { $Settings['fixcookiedir'] = null; }
44 $Settings['bid'] = base64_encode(urlencode($Settings['idburl']));
45 if(!isset($Settings['showverinfo'])) { 
46         $Settings['showverinfo'] = "on"; }
47 if($Settings['fixpathinfo']=="off") {
48         $Settings['fixpathinfo'] = null; }
49 if($Settings['fixbasedir']=="off") {
50         $Settings['fixbasedir'] = null; }
51 if($Settings['fixcookiedir']=="off") {
52         $Settings['fixcookiedir'] = null; }
53 if($Settings['idburl']=="localhost") { 
54 header("Content-Type: text/plain; charset=UTF-8");
55 echo "500 Error: URL is malformed. Try reinstalling iDB."; die(); }
56 if($Settings['fixbasedir']=="on") {
57 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
58 $PathsTest = parse_url($Settings['idburl']);
59 $Settings['fixbasedir'] = $PathsTest['path']."/"; 
60 $Settings['fixbasedir'] = str_replace("//", "/", $Settings['fixbasedir']); } }
61 if($Settings['fixcookiedir']=="on") {
62 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
63 $PathsTest = parse_url($Settings['idburl']);
64 $Settings['fixcookiedir'] = $PathsTest['path']."/"; 
65 $Settings['fixcookiedir'] = str_replace("//", "/", $Settings['fixcookiedir']); } }
66 if(!isset($Settings['charset'])) {
67         $Settings['charset'] = "ISO-8859-15"; }
68 if(isset($Settings['charset'])) {
69 if($Settings['charset']!="ISO-8859-15"&&$Settings['charset']!="ISO-8859-1"&&
70         $Settings['charset']!="UTF-8"&&$Settings['charset']!="CP866"&&
71         $Settings['charset']!="Windows-1251"&&$Settings['charset']!="Windows-1252"&&
72         $Settings['charset']!="KOI8-R"&&$Settings['charset']!="BIG5"&&
73         $Settings['charset']!="GB2312"&&$Settings['charset']!="BIG5-HKSCS"&&
74         $Settings['charset']!="Shift_JIS"&&$Settings['charset']!="EUC-JP") {
75         $Settings['charset'] = "ISO-8859-15"; } }
76         $chkcharset = $Settings['charset'];
77 @ini_set('default_charset', $Settings['charset']);
78 //session_save_path($SettDir['inc']."temp/");
79 if(!isset($Settings['sqldb'])) { 
80 if(file_exists("install.php")) { header('Location: install.php'); die(); } 
81 if(!file_exists("install.php")) { header("Content-Type: text/plain; charset=UTF-8");
82 echo "403 Error: Sorry could not find install.php\nTry uploading files again and if that dose not work try download iDB again."; die(); } }
83 if(!isset($Settings['sqlhost'])) { $Settings['sqlhost'] = "localhost"; }
84 if($Settings['fixpathinfo']=="on") {
85         $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
86         putenv("PATH_INFO=".$_SERVER['ORIG_PATH_INFO']); }
87 // Check to see if variables are set
88 if(!isset($SettDir['inc'])) { $SettDir['inc'] = "inc/"; }
89 if(!isset($SettDir['misc'])) { $SettDir['misc'] = "inc/misc/"; }
90 if(!isset($SettDir['sql'])) { $SettDir['sql'] = "inc/misc/sql/"; }
91 if(!isset($SettDir['admin'])) { $SettDir['admin'] = "inc/admin/"; }
92 if(!isset($SettDir['sqldumper'])) { $SettDir['sqldumper'] = "inc/admin/sqldumper/"; }
93 if(!isset($SettDir['mod'])) { $SettDir['mod'] = "inc/mod/"; }
94 if(!isset($SettDir['themes'])) { $SettDir['themes'] = "themes/"; }
95 if(!isset($Settings['use_iniset'])) { $Settings['use_iniset'] = null; }
96 if(!isset($Settings['clean_ob'])) { $Settings['clean_ob'] = "off"; }
97 if(!isset($_SERVER['PATH_INFO'])) { $_SERVER['PATH_INFO'] = null; }
98 if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { 
99         $_SERVER['HTTP_ACCEPT_ENCODING'] = null; }
100 if(!isset($_SERVER["HTTP_ACCEPT"])) { $_SERVER["HTTP_ACCEPT"] = null; }
101 if(!isset($_SERVER['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = null; }
102 if(!isset($_GET['page'])) { $_GET['page'] = null; }
103 if(!isset($_GET['act'])) { $_GET['act'] = null; }
104 if(!isset($_POST['act'])) { $_POST['act'] = null; }
105 if(!isset($_GET['modact'])) { $_GET['modact'] = null; }
106 if(!isset($_POST['modact'])) { $_POST['modact'] = null; }
107 if(!isset($_GET['id'])) { $_GET['id'] = null; }
108 if(!isset($_GET['debug'])) { $_GET['debug'] = "off"; }
109 if(!isset($_GET['post'])) { $_GET['post'] = null; }
110 if(!isset($_POST['License'])) { $_POST['License'] = null; }
111 if(!isset($_SERVER['HTTPS'])) { $_SERVER['HTTPS'] = "off"; }
112 require_once($SettDir['misc'].'utf8.php');
113 require_once($SettDir['inc'].'filename.php');
114 $iDBVerName = "iDB|".$VER2[1]."|".$VER1[0].".".$VER1[1].".".$VER1[2]."|".$VER2[2]."|".$SubVerN;
115 /* 
116 This way checks iDB version by sending the iDBVerName to the iDB Version Checker.
117 $Settings['vercheck'] = 1; 
118 This way checks iDB version by sending the board url to the iDB Version Checker.
119 $Settings['vercheck'] = 2;
120 */
121 if(!isset($Settings['vercheck'])) { 
122         $Settings['vercheck'] = 2; }
123 if($Settings['vercheck']!=1&&
124         $Settings['vercheck']!=2) {
125         $Settings['vercheck'] = 2; }
126 if($Settings['vercheck']===2) {
127 if($_GET['act']=="versioninfo") { header("Content-Type: text/plain; charset=UTF-8"); ?>
128 <charset><?php echo $Settings['charset']; ?></charset> 
129 <title><?php echo $Settings['board_name']; ?></title> 
130 <?php echo "<name>".$iDBVerName."</name>"; die(); } }
131 if($Settings['vercheck']===1) {
132 if($_GET['act']=="versioninfo") { header("Content-Type: text/plain; charset=UTF-8");
133 header("Location: ".$VerCheckURL."&name=".urlencode($iDBVerName)); die(); } }
134 if(!isset($Settings['use_hashtype'])) {
135         $Settings['use_hashtype'] = "sha256"; }
136 if(!function_exists('hash')||!function_exists('hash_algos')) {
137 if($Settings['use_hashtype']!="md5"&&
138    $Settings['use_hashtype']!="sha1"&&
139    $Settings['use_hashtype']!="sha256") {
140         $Settings['use_hashtype'] = "sha256"; } }
141 if(function_exists('hash')&&function_exists('hash_algos')) {
142 if(!in_array($Settings['use_hashtype'],hash_algos())) {
143         $Settings['use_hashtype'] = "sha256"; }
144 if($Settings['use_hashtype']!="md2"&&
145    $Settings['use_hashtype']!="md4"&&
146    $Settings['use_hashtype']!="md5"&&
147    $Settings['use_hashtype']!="sha1"&&
148    $Settings['use_hashtype']!="sha256"&&
149    $Settings['use_hashtype']!="sha386"&&
150    $Settings['use_hashtype']!="sha512") {
151         $Settings['use_hashtype'] = "sha256"; } }
152 // Check to see if variables are set
153 require_once($SettDir['misc'].'setcheck.php');
154 require_once($SettDir['inc'].'function.php');
155 if($Settings['enable_pathinfo']=="on") { 
156         mrstring(); /* Change Path info to Get Vars :P */ }
157 // Check to see if variables are set
158 $qstrhtml = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
159 if($Settings['enable_https']=="on"&&$_SERVER['HTTPS']=="on") {
160 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
161 $HTTPsTest = parse_url($Settings['idburl']); if($HTTPsTest['scheme']=="http") {
162 $Settings['idburl'] = preg_replace("/http\:\/\//i", "https://", $Settings['idburl']); } } }
163 $cookieDomain = null; $cookieSecure = false;
164 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
165 $URLsTest = parse_url($Settings['idburl']); 
166 $cookieDomain = $URLsTest['host'];
167 if($cookieDomain=="localhost") { $cookieDomain = false; }
168 if($Settings['enable_https']=="on") {
169  if($URLsTest['scheme']=="https") { $cookieSecure = true; }
170  if($URLsTest['scheme']!="https") { $cookieSecure = false; } } }
171 @ini_set("default_charset",$Settings['charset']);
172 $File1Name = dirname($_SERVER['SCRIPT_NAME'])."/";
173 $File2Name = $_SERVER['SCRIPT_NAME'];
174 $File3Name=str_replace($File1Name, null, $File2Name);
175 if ($File3Name=="sql.php"||$File3Name=="/sql.php") {
176         require($SettDir['inc'].'forbidden.php');
177         exit(); }
178 //error_reporting(E_ERROR);
179 // Check if gzip is on and if user's browser can accept gzip pages
180 if($_GET['act']=="MkCaptcha"||$_GET['act']=="Captcha") {
181         $Settings['use_gzip'] = 'off'; }
182 if($Settings['use_gzip']=="on") {
183 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) { 
184         $GZipEncode['Type'] = "gzip"; } else { 
185         if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "deflate")) { 
186         $GZipEncode['Type'] = "deflate"; } else { 
187                 $Settings['use_gzip'] = "off"; $GZipEncode['Type'] = "none"; } } }
188 if($Settings['use_gzip']=="gzip") {
189 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) { $Settings['use_gzip'] = "on";
190         $GZipEncode['Type'] = "gzip"; } else { $Settings['use_gzip'] = "off"; } }
191 if($Settings['use_gzip']=="deflate") {
192 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "deflate")) { $Settings['use_gzip'] = "on";
193         $GZipEncode['Type'] = "deflate"; } else { $Settings['use_gzip'] = "off"; } }
194 if($Settings['clean_ob']=="on") {
195 /* Check for other output handlers/buffers are open
196    and close and get the contents in an array */
197 $numob = count(ob_list_handlers()); $iob = 0; 
198 while ($iob < $numob) { 
199         $old_ob_var[$iob] = ob_get_clean(); 
200         ++$iob; } } ob_start();
201 if($Settings['use_gzip']=="on") { 
202 if($GZipEncode['Type']!="gzip") { if($GZipEncode['Type']!="deflate") { $GZipEncode['Type'] = "gzip"; } }
203         if($GZipEncode['Type']=="gzip") {
204         header("Content-Encoding: gzip"); }
205         if($GZipEncode['Type']=="deflate") {
206         header("Content-Encoding: deflate"); } }
207 /* if(eregi("msie",$browser) && !eregi("opera",$browser)){
208 header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); } */
209 // Some http stuff
210 $SQLStat = sql_connect_db($Settings['sqlhost'],$Settings['sqluser'],$Settings['sqlpass'],$Settings['sqldb']);
211 $SQLCollate = "latin1_general_ci";
212 $SQLCharset = "latin1"; 
213 if($Settings['charset']=="ISO-8859-1") {
214         $SQLCollate = "latin1_general_ci";
215         $SQLCharset = "latin1"; }
216 if($Settings['charset']=="ISO-8859-15") {
217         $SQLCollate = "latin1_general_ci";
218         $SQLCharset = "latin1"; }
219 if($Settings['charset']=="UTF-8") {
220         $SQLCollate = "utf8_unicode_ci";
221         $SQLCharset = "utf8"; }
222 sql_set_charset($SQLCharset,$SQLStat);
223 if($SQLStat===false) {
224 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);
225 ob_clean(); echo "Sorry could not connect to mysql database.\nContact the board admin about error. Error log below.";
226 echo "\n".sql_errorno($SQLStat);
227 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
228 $sqltable = $Settings['sqltable'];
229 function sqlsession_open( $save_path, $session_name ) {
230 global $sess_save_path;
231 $sess_save_path = $save_path;
232 return true; }
233 function sqlsession_close() {
234 return true; }
235 function sqlsession_read($id) {
236 global $sqltable,$SQLStat,$SQLSType;
237 $data = "";
238 $time = GMTimeStamp();
239 $sqlr = sql_pre_query("SELECT * FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '%s'", array($id,$time));
240 $rs = sql_query($sqlr,$SQLStat);
241 $a = sql_num_rows($rs);
242 if($a > 0) {
243 $row = sql_fetch_assoc($rs);
244 $data = $row['session_data']; }
245 return $data; }
246 $SQLSType = $Settings['sqltype'];
247 function sqlsession_write($id,$data) {
248 global $sqltable,$SQLStat,$SQLSType;
249 $time = GMTimeStamp();
250 if($SQLSType=="mysql"||
251         $SQLSType=="mysqli") {
252 $sqlw = sql_pre_query("REPLACE \"".$sqltable."sessions\" VALUES('$id','$data', $time)", array($id,$data,$time));
253 $rs = sql_query($sqlw,$SQLStat); }
254 if($SQLSType=="pgsql"||
255         $SQLSType=="sqlite") {
256 $sqlr = sql_pre_query("SELECT * FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '%s'", array($id,$time));
257 $rs = sql_query($sqlr,$SQLStat);
258 $a = sql_num_rows($rs);
259 if($a>0) {
260 $sqlw = sql_pre_query("UPDATE \"".$sqltable."sessions\" SET \"session_data\"='%s',\"expires\"=%i WHERE \"session_id\"='%s'", array($data,$time,$id));
261 $rs = sql_query($sqlw,$SQLStat); }
262 if($a<1) {
263 $sqlw = sql_pre_query("INSERT INTO \"".$sqltable."sessions\" (\"session_id\", \"session_data\", \"expires\") VALUES\n".
264 "('%s', '%s', %i)", array($id,$time,$data)); 
265 $rs = sql_query($sqlw,$SQLStat); } }
266 return true; }
267 function sqlsession_destroy($id) {
268 global $sqltable,$SQLStat;
269 $sqld = sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '$id'", array($id));
270 sql_query($sqld,$SQLStat);
271 return true; }
272 function sqlsession_gc($maxlifetime) {
273 global $sqltable,$SQLStat;
274 $time = GMTimeStamp() - $maxlifetime;
275 //$sqlg = sql_pre_query('DELETE FROM \"'.$sqltable.'sessions\" WHERE \"expires\" < UNIX_TIMESTAMP();', array(null));
276 $sqlg = sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"expires\" < %i", array($time));
277 sql_query($sqlg,$SQLStat);
278 return true; }
279 session_set_save_handler("sqlsession_open", "sqlsession_close", "sqlsession_read", "sqlsession_write", "sqlsession_destroy", "sqlsession_gc");
280 if($cookieDomain==null) {
281 session_set_cookie_params(0, $cbasedir); }
282 if($cookieDomain!=null) {
283 if($cookieSecure===true) {
284 session_set_cookie_params(0, $cbasedir, $cookieDomain, 1); }
285 if($cookieSecure===false) {
286 session_set_cookie_params(0, $cbasedir, $cookieDomain); } }
287 session_cache_limiter("private, no-cache, must-revalidate");
288 header("Cache-Control: private, no-cache, must-revalidate");
289 header("Pragma: private, no-cache, must-revalidate");
290 header("Date: ".gmdate("D, d M Y H:i:s")." GMT");
291 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
292 header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
293 session_name($Settings['sqltable']."sess");
294 session_start();
295 //header("Set-Cookie: PHPSESSID=" . session_id() . "; path=".$cbasedir);
296 output_reset_rewrite_vars();
297 if($_GET['act']=="bsdl"||$_GET['act']=="BSDL"||$_GET['act']=="license"||
298         $_GET['act']=="LICENSE"||$_GET['act']=="License") { $_GET['act']="bsd"; }
299 if($_GET['act']=="bsd") {
300 header("Content-Type: text/plain; charset=".$Settings['charset']);
301 require("LICENSE"); gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
302 if($_GET['act']=="README"||$_GET['act']=="ReadME") { $_GET['act']="readme"; }
303 if($_GET['act']=="readme"||$_GET['act']=="ReadMe") {
304 header("Content-Type: text/plain; charset=".$Settings['charset']);
305 require("README"); gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
306 if($_GET['act']=="js"||$_GET['act']=="javascript") {
307 header("Content-Script-Type: text/javascript");
308 if(stristr($_SERVER["HTTP_ACCEPT"],"application/x-javascript") ) {
309 header("Content-Type: application/x-javascript; charset=".$Settings['charset']); } else {
310 if(stristr($_SERVER["HTTP_ACCEPT"],"application/javascript") ) {
311 header("Content-Type: application/javascript; charset=".$Settings['charset']); } else {
312 header("Content-Type: text/javascript; charset=".$Settings['charset']); } }
313 require($SettDir['inc'].'javascript.php');
314 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
315 if($Settings['use_captcha']=="on") {
316 if($_GET['act']=="MkCaptcha"||$_GET['act']=="Captcha") {
317         if($Settings['captcha_clean']=="on") { ob_clean(); }
318         require($SettDir['inc']."captcha.php");
319         $aFonts = array('inc/fonts/VeraBd.ttf', 'inc/fonts/VeraBI.ttf', 'inc/fonts/VeraIt.ttf', 'inc/fonts/Vera.ttf');
320         $oPhpCaptcha = new PhpCaptcha($aFonts, 200, 60);
321         $RNumSize = rand(7,17); $i=0; $RandNum = null;
322         while ($i <= $RNumSize) {
323         $RandNum=$RandNum.dechex(rand(1,15)); ++$i; }
324         $RandNum=strtoupper($RandNum);
325         $oPhpCaptcha->SetOwnerText("Fake Code: ".$RandNum);
326         $oPhpCaptcha->UseColour(true);
327         $oPhpCaptcha->Create(); session_write_close(); die(); } }
328 if(!isset($_SESSION['CheckCookie'])) {
329 if(isset($_COOKIE['SessPass'])&&isset($_COOKIE['MemberName'])) {
330 require($SettDir['inc'].'prelogin.php'); } }
331 require($SettDir['inc'].'groupsetup.php');
332 if($Settings['board_offline']=="on"&&$GroupInfo['CanViewOffLine']!="yes") {
333 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);
334 ob_clean(); if(!isset($Settings['offline_text'])) {
335 echo "Sorry the board is off line.\nIf you are a admin you can login by the admin cp."; }
336 if(isset($Settings['offline_text'])) { echo $Settings['offline_text']; }
337 //echo "\n".sql_errorno($SQLStat);
338 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
339 $dayconv = array('second' => 1, 'minute' => 60, 'hour' => 3600, 'day' => 86400, 'week' => 604800, 'month' => 2630880, 'year' => 31570560, 'decade' => 15705600);
340 //Time Zone Set
341 if(!isset($_SESSION['UserTimeZone'])) { 
342         if(isset($Settings['DefaultTimeZone'])) { 
343         $_SESSION['UserTimeZone'] = $Settings['DefaultTimeZone'];
344         if(!isset($Settings['DefaultTimeZone'])) { 
345         $_SESSION['UserTimeZone'] = SeverOffSet().":00"; } } }
346 $checktime = explode(":",$_SESSION['UserTimeZone']);
347 if(count($checktime)!=2) {
348         if(!isset($checktime[0])) { $checktime[0] = "0"; }
349         if(!isset($checktime[1])) { $checktime[1] = "00"; }
350         $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
351 if(!is_numeric($checktime[0])) { $checktime[0] = "0"; }
352 if($checktime[0]>12) { $checktime[0] = "12"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
353 if($checktime[0]<-12) { $checktime[0] = "-12"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
354 if(!is_numeric($checktime[1])) { $checktime[1] = "00"; }
355 if($checktime[1]>59) { $checktime[1] = "59"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
356 if($checktime[1]<0) { $checktime[1] = "00"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
357 $checktimea = array("offset" => $_SESSION['UserTimeZone'], "hour" => $checktime[0], "minute" => $checktime[1]);
358 if(!isset($_SESSION['UserDST'])) { $_SESSION['UserDST'] = null; }
359 if($_SESSION['UserDST']==null) {
360 if($Settings['DefaultDST']=="off") { 
361         $_SESSION['UserDST'] = "off"; }
362 if($Settings['DefaultDST']=="on") { 
363         $_SESSION['UserDST'] = "on"; } }
364 // Guest Stuff
365 if(isset($_SESSION['MemberName'])||
366    isset($_COOKIE['MemberName'])) {
367         $_SESSION['GuestName'] = null;
368         $_COOKIE['GuestName'] = null; }
369 if(!isset($_SESSION['MemberName'])&&!isset($_COOKIE['MemberName'])) {
370 if(!isset($_SESSION['GuestName'])&&isset($_COOKIE['GuestName'])) {
371         $_SESSION['GuestName'] = $_COOKIE['GuestName']; } }
372 if(!isset($_SESSION['LastPostTime'])) { $_SESSION['LastPostTime'] = "0"; }
373 // Skin Stuff
374 if(!isset($_SESSION['Theme'])) { $_SESSION['Theme'] = null; }
375 if(!isset($_GET['theme'])) { $_GET['theme'] = null; }
376 if(!isset($_POST['theme'])) { $_POST['theme'] = null; }
377 if(!isset($_GET['skin'])) { $_GET['skin'] = null; }
378 if(!isset($_POST['skin'])) { $_POST['skin'] = null; }
379 if(!isset($_GET['style'])) { $_GET['style'] = null; }
380 if(!isset($_POST['style'])) { $_POST['style'] = null; }
381 if(!isset($_GET['css'])) { $_GET['css'] = null; }
382 if(!isset($_POST['css'])) { $_POST['css'] = null; }
383 if($_GET['theme']==null) {
384         if($_POST['theme']!=null) {
385                 $_GET['theme'] = $_POST['theme']; }
386         if($_POST['skin']!=null) {
387                 $_GET['theme'] = $_POST['skin']; }
388         if($_POST['style']!=null) {
389                 $_GET['theme'] = $_POST['style']; }
390         if($_POST['css']!=null) {
391                 $_GET['theme'] = $_POST['css']; }
392         if($_GET['skin']!=null) {
393                 $_GET['theme'] = $_GET['skin']; }
394         if($_GET['style']!=null) {
395                 $_GET['theme'] = $_GET['style']; }
396         if($_GET['css']!=null) {
397                 $_GET['theme'] = $_GET['css']; } }
398 if($_GET['theme']!=null) {
399 $_GET['theme'] = chack_themes($_GET['theme']);
400 if($_GET['theme']=="../"||$_GET['theme']=="./") {
401 $_GET['theme']="iDB"; $_SESSION['Theme']="iDB"; }
402 if (file_exists($SettDir['themes'].$_GET['theme']."/settings.php")) {
403 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
404 $NewDay=GMTimeStamp();
405 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_GET['theme'],$NewDay,$_SESSION['UserID']));
406 sql_query($qnewskin,$SQLStat); }
407 /* The file Theme Exists */ }
408 else { $_GET['theme'] = $Settings['DefaultTheme']; 
409 $_SESSION['Theme'] = $Settings['DefaultTheme'];
410 /* The file Theme Dose Not Exists */ } }
411 if($_GET['theme']==null) { 
412 if($_SESSION['Theme']!=null) {
413 $OldTheme = $_SESSION['Theme'];
414 $_SESSION['Theme'] = chack_themes($_SESSION['Theme']);
415 if($OldTheme!=$_SESSION['Theme']) { 
416 $NewDay=GMTimeStamp();
417 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_SESSION['Theme'],$NewDay,$_SESSION['UserID']));
418 sql_query($qnewskin,$SQLStat); }
419 $_GET['theme']=$_SESSION['Theme']; }
420 if($_SESSION['Theme']==null) {
421 $_SESSION['Theme']=$Settings['DefaultTheme'];
422 $_GET['theme']=$Settings['DefaultTheme']; } }
423 $PreSkin['skindir1'] = $_SESSION['Theme'];
424 $PreSkin['skindir2'] = $SettDir['themes'].$_SESSION['Theme'];
425 require($SettDir['themes'].$_GET['theme']."/settings.php");
426 $_SESSION['Theme'] = $_GET['theme'];
427 if(!isset($ThemeSet['TableStyle'])) {
428         $ThemeSet['TableStyle'] = "table"; }
429 if(isset($ThemeSet['TableStyle'])) {
430 if($ThemeSet['TableStyle']!="div"&&
431         $ThemeSet['TableStyle']!="table") {
432         $ThemeSet['TableStyle'] = "table"; } }
433 if(!isset($_SESSION['DBName'])) { $_SESSION['DBName'] = null; }
434 if($_SESSION['DBName']==null) {
435         $_SESSION['DBName'] = $Settings['sqldb']; }
436 if($_SESSION['DBName']!=null) {
437         if($_SESSION['DBName']!=$Settings['sqldb']) {
438 redirect("location",$basedir.url_maker($exfile['member'],$Settings['file_ext'],"act=logout",$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'],false)); } }
439 ?>