3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the Revised BSD License.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 Revised BSD License for more details.
11 Copyright 2004-2011 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
14 $FileInfo: sql.php - Last Update: 07/01/2011 SVN 690 - Author: cooldude2k $
16 /* Some ini setting changes uncomment if you need them.
18 $disfunc = @ini_get
("disable_functions");
19 $disfunc = @trim
($disfunc);
20 $disfunc = @preg_replace
("/([\\s+|\\t+|\\n+|\\r+|\\0+|\\x0B+])/i", "", $disfunc);
21 if($disfunc!="ini_set") { $disfunc = explode(",",$disfunc); }
22 if($disfunc=="ini_set") { $disfunc = array("ini_set"); }
23 if(!in_array("ini_set", $disfunc)) {
24 @ini_set
("html_errors", false);
25 @ini_set
("track_errors", false);
26 @ini_set
("display_errors", false);
27 @ini_set
("report_memleaks", false);
28 @ini_set
("display_startup_errors", false);
29 //@ini_set("error_log","logs/error.log");
30 @ini_set
("docref_ext", "");
31 @ini_set
("docref_root", "http://php.net/"); }
32 @error_reporting
(E_ALL ^ E_NOTICE
);
33 /* Get rid of session id in urls */
34 if(!in_array("ini_set", $disfunc)) {
35 @ini_set
("date.timezone","UTC");
36 @ini_set
("default_mimetype","text/html");
37 @ini_set
("zlib.output_compression", false);
38 @ini_set
("zlib.output_compression_level", -1);
39 @ini_set
("session.use_trans_sid", false);
40 @ini_set
("session.use_cookies", true);
41 @ini_set
("session.use_only_cookies", true);
42 @ini_set
("url_rewriter.tags","");
43 @ini_set
('zend.ze1_compatibility_mode', 0);
44 @ini_set
("ignore_user_abort", 1); }
45 @set_time_limit
(30); @ignore_user_abort
(true);
46 /* Change session garbage collection settings */
47 if(!in_array("ini_set", $disfunc)) {
48 @ini_set
("session.gc_probability", 1);
49 @ini_set
("session.gc_divisor", 100);
50 @ini_set
("session.gc_maxlifetime", 1440);
51 /* Change session hash type here */
52 @ini_set
("session.hash_function", 1);
53 @ini_set
("session.hash_bits_per_character", 6); }
54 /* Do not change anything below this line unless you know what you are doing */
55 $File3Name = basename($_SERVER['SCRIPT_NAME']);
56 if ($File3Name=="sql.php"||
$File3Name=="/sql.php") {
57 header('Location: index.php');
59 if(file_exists('settings.php')) {
60 require_once('settings.php');
61 if(file_exists('extrasettings.php')) {
62 require_once('extrasettings.php'); }
63 if(file_exists('extendsettings.php')) {
64 require_once('extendsettings.php'); }
65 if(!in_array("ini_set", $disfunc)&&$Settings['qstr']!="/"&&$Settings['qstr']!="&") {
66 ini_set("arg_separator.output",htmlentities($Settings['qstr'], ENT_QUOTES
, $Settings['charset']));
67 ini_set("arg_separator.input",$Settings['qstr']); } }
68 if(!isset($Settings['idburl'])) { $Settings['idburl'] = null; }
69 if(!isset($Settings['fixbasedir'])) { $Settings['fixbasedir'] = null; }
70 if(!isset($Settings['fixpathinfo'])) { $Settings['fixpathinfo'] = null; }
71 if(!isset($Settings['fixcookiedir'])) { $Settings['fixcookiedir'] = null; }
72 if(!isset($Settings['fixredirectdir'])) { $Settings['fixcookiedir'] = null; }
73 $Settings['bid'] = base64_encode(urlencode($Settings['idburl']));
74 if(!isset($Settings['showverinfo'])) {
75 $Settings['showverinfo'] = "on"; }
76 if($Settings['fixpathinfo']=="off") {
77 $Settings['fixpathinfo'] = null; }
78 if($Settings['fixbasedir']=="off") {
79 $Settings['fixbasedir'] = null; }
80 if($Settings['fixcookiedir']=="off") {
81 $Settings['fixcookiedir'] = null; }
82 if($Settings['fixredirectdir']=="off") {
83 $Settings['fixredirectdir'] = null; }
84 $OldSettings['fixpathinfo'] = $Settings['fixpathinfo'];
85 $OldSettings['fixbasedir'] = $Settings['fixbasedir'];
86 $OldSettings['fixcookiedir'] = $Settings['fixcookiedir'];
87 $OldSettings['fixredirectdir'] = $Settings['fixredirectdir'];
88 if($Settings['idburl']=="localhost") {
89 header("Content-Type: text/plain; charset=UTF-8");
90 echo "500 Error: URL is malformed. Try reinstalling iDB."; die(); }
91 if($Settings['fixbasedir']=="on") {
92 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
93 $PathsTest = parse_url($Settings['idburl']);
94 $Settings['fixbasedir'] = $PathsTest['path']."/";
95 $Settings['fixbasedir'] = str_replace("//", "/", $Settings['fixbasedir']); } }
96 if($Settings['fixcookiedir']=="on") {
97 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
98 $PathsTest = parse_url($Settings['idburl']);
99 $Settings['fixcookiedir'] = $PathsTest['path']."/";
100 $Settings['fixcookiedir'] = str_replace("//", "/", $Settings['fixcookiedir']); } }
101 if($Settings['fixredirectdir']=="on") {
102 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
103 $PathsTest = parse_url($Settings['idburl']);
104 $Settings['fixredirectdir'] = $PathsTest['path']."/";
105 $Settings['fixredirectdir'] = str_replace("//", "/", $Settings['fixredirectdir']); } }
106 if(!isset($Settings['charset'])) {
107 $Settings['charset'] = "ISO-8859-15"; }
108 if(isset($Settings['charset'])) {
109 if($Settings['charset']!="ISO-8859-15"&&$Settings['charset']!="ISO-8859-1"&&
110 $Settings['charset']!="UTF-8"&&$Settings['charset']!="CP866"&&
111 $Settings['charset']!="Windows-1251"&&$Settings['charset']!="Windows-1252"&&
112 $Settings['charset']!="KOI8-R"&&$Settings['charset']!="BIG5"&&
113 $Settings['charset']!="GB2312"&&$Settings['charset']!="BIG5-HKSCS"&&
114 $Settings['charset']!="Shift_JIS"&&$Settings['charset']!="EUC-JP") {
115 $Settings['charset'] = "ISO-8859-15"; } }
116 $chkcharset = $Settings['charset'];
117 if(!in_array("ini_set", $disfunc)) {
118 @ini_set
('default_charset', $Settings['charset']); }
119 //session_save_path($SettDir['inc']."temp/");
120 if(!isset($Settings['sqldb'])) {
121 if(file_exists("install.php")) { header('Location: install.php'); die(); }
122 if(!file_exists("install.php")) { header("Content-Type: text/plain; charset=UTF-8");
123 echo "403 Error: Sorry could not find install.php\nTry uploading files again and if that dose not work try download iDB again."; die(); } }
124 if(isset($Settings['sqldb'])&&
125 function_exists("date_default_timezone_set")) {
126 @date_default_timezone_set
("UTC"); }
127 if(!isset($Settings['sqlhost'])) { $Settings['sqlhost'] = "localhost"; }
128 if($Settings['fixpathinfo']=="on") {
129 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
130 putenv("PATH_INFO=".$_SERVER['ORIG_PATH_INFO']); }
131 // Check to see if variables are set
132 if(!isset($SettDir['inc'])) { $SettDir['inc'] = "inc/"; }
133 if(!isset($SettDir['archive'])) { $SettDir['archive'] = "archive/"; }
134 if(!isset($SettDir['misc'])) { $SettDir['misc'] = "inc/misc/"; }
135 if(!isset($SettDir['sql'])) { $SettDir['sql'] = "inc/misc/sql/"; }
136 if(!isset($SettDir['admin'])) { $SettDir['admin'] = "inc/admin/"; }
137 if(!isset($SettDir['sqldumper'])) { $SettDir['sqldumper'] = "inc/admin/sqldumper/"; }
138 if(!isset($SettDir['mod'])) { $SettDir['mod'] = "inc/mod/"; }
139 if(!isset($SettDir['themes'])) { $SettDir['themes'] = "themes/"; }
140 if(!isset($Settings['use_iniset'])) { $Settings['use_iniset'] = null; }
141 if(!isset($Settings['clean_ob'])) { $Settings['clean_ob'] = "off"; }
142 if(!isset($_SERVER['PATH_INFO'])) { $_SERVER['PATH_INFO'] = null; }
143 if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
144 $_SERVER['HTTP_ACCEPT_ENCODING'] = null; }
145 if(!isset($_SERVER["HTTP_ACCEPT"])) { $_SERVER["HTTP_ACCEPT"] = null; }
146 if(!isset($_SERVER['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = null; }
147 if(!isset($_GET['page'])) { $_GET['page'] = null; }
148 if(!isset($_GET['act'])) { $_GET['act'] = null; }
149 if(!isset($_POST['act'])) { $_POST['act'] = null; }
150 if(!isset($_GET['modact'])) { $_GET['modact'] = null; }
151 if(!isset($_POST['modact'])) { $_POST['modact'] = null; }
152 if(!isset($_GET['id'])) { $_GET['id'] = null; }
153 if(!isset($_GET['debug'])) { $_GET['debug'] = "off"; }
154 if(!isset($_GET['post'])) { $_GET['post'] = null; }
155 if(!isset($_POST['License'])) { $_POST['License'] = null; }
156 if(!isset($_SERVER['HTTPS'])) { $_SERVER['HTTPS'] = "off"; }
157 if(!isset($Settings['SQLThemes'])) { $Settings['SQLThemes'] = "off"; }
158 if($Settings['SQLThemes']!="on"&&$Settings['SQLThemes']!="off") {
159 $Settings['SQLThemes'] = "off"; }
160 require_once($SettDir['misc'].'utf8.php');
161 require_once($SettDir['inc'].'filename.php');
162 if(!isset($Settings['use_hashtype'])) {
163 $Settings['use_hashtype'] = "sha1"; }
164 if(!function_exists('hash')||
!function_exists('hash_algos')) {
165 if($Settings['use_hashtype']!="md5"&&
166 $Settings['use_hashtype']!="sha1") {
167 $Settings['use_hashtype'] = "sha1"; } }
168 if(function_exists('hash')&&function_exists('hash_algos')) {
169 if(!in_array($Settings['use_hashtype'],hash_algos())) {
170 $Settings['use_hashtype'] = "sha1"; }
171 if($Settings['use_hashtype']!="md2"&&
172 $Settings['use_hashtype']!="md4"&&
173 $Settings['use_hashtype']!="md5"&&
174 $Settings['use_hashtype']!="sha1"&&
175 $Settings['use_hashtype']!="sha224"&&
176 $Settings['use_hashtype']!="sha256"&&
177 $Settings['use_hashtype']!="sha384"&&
178 $Settings['use_hashtype']!="sha512"&&
179 $Settings['use_hashtype']!="ripemd128"&&
180 $Settings['use_hashtype']!="ripemd160"&&
181 $Settings['use_hashtype']!="ripemd256"&&
182 $Settings['use_hashtype']!="ripemd320"&&
183 $Settings['use_hashtype']!="salsa10"&&
184 $Settings['use_hashtype']!="salsa20"&&
185 $Settings['use_hashtype']!="snefru"&&
186 $Settings['use_hashtype']!="snefru256"&&
187 $Settings['use_hashtype']!="gost") {
188 $Settings['use_hashtype'] = "sha1"; } }
189 // Check to see if variables are set
190 require_once($SettDir['misc'].'setcheck.php');
191 $dayconv = array('second' => 1, 'minute' => 60, 'hour' => 3600, 'day' => 86400, 'week' => 604800, 'month' => 2630880, 'year' => 31570560, 'decade' => 315705600);
192 require_once($SettDir['inc'].'function.php');
193 if(!in_array("ini_set", $disfunc)) {
194 // Set user agent if we can use ini_set and have to do any http requests. :P
195 $iverstring = "FR 0.0.0 ".$VER2[2]." 0";
196 if($Settings['hideverinfohttp']=="off") {
197 $iverstring = $VER2[1]." ".$VER1[0].".".$VER1[1].".".$VER1[2]." ".$VER2[2]." ".$SubVerN; }
198 if($Settings['hideverinfohttp']=="on") {
199 $iverstring = "FR 0.0.0 ".$VER2[2]." 0"; }
200 $qstrtest = htmlentities($Settings['qstr'], ENT_QUOTES
, $Settings['charset']);
201 $qseptest = htmlentities($Settings['qsep'], ENT_QUOTES
, $Settings['charset']);
202 $isiteurl = $Settings['idburl']."?act".$qseptest."view";
203 @ini_set
("user_agent", "Mozilla/5.0 (compatible; ".$VerCheckName."/".$iverstring."; +".$isiteurl.")"); }
204 $iDBVerName = $VerCheckName."|".$VER2[1]."|".$VER1[0].".".$VER1[1].".".$VER1[2]."|".$VER2[2]."|".$SubVerN;
206 This way checks iDB version by sending the iDBVerName to the iDB Version Checker.
207 $Settings['vercheck'] = 1;
208 This way checks iDB version by sending the board url to the iDB Version Checker.
209 $Settings['vercheck'] = 2;
211 if(!isset($Settings['vercheck'])) {
212 $Settings['vercheck'] = 2; }
213 if($Settings['vercheck']!=1&&
214 $Settings['vercheck']!=2) {
215 $Settings['vercheck'] = 2; }
216 if($Settings['vercheck']===2) {
217 if($_GET['act']=="vercheckxsl") {
218 if(stristr($_SERVER["HTTP_ACCEPT"],"application/xml") ) {
219 header("Content-Type: application/xml; charset=".$Settings['charset']); }
220 else { header("Content-Type: text/xml; charset=".$Settings['charset']); }
221 xml_doc_start("1.0",$Settings['charset']);
223 <xsl
:stylesheet version
="1.0" xmlns
:xsl
="http://www.w3.org/1999/XSL/Transform">
225 <xsl
:template match
="/">
226 <html xsl
:version
="1.0" xmlns
:xsl
="http://www.w3.org/1999/XSL/Transform" xmlns
="http://www.w3.org/1999/xhtml">
227 <body style
="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
228 <xsl
:for-each select
="versioninfo/version">
229 <div style
="background-color:teal;color:white;padding:4px">
230 <span style
="font-weight:bold"><xsl
:value
-of select
="vname"/></span
>
232 <div style
="margin-left:20px;margin-bottom:1em;font-size:10pt">
233 <span style
="font-style:italic">
234 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
>
242 <?php
gzip_page("off",$GZipEncode['Type']); session_write_close(); die(); }
243 if($_GET['act']=="versioninfo") {
244 if(stristr($_SERVER["HTTP_ACCEPT"],"application/xml") ) {
245 header("Content-Type: application/xml; charset=".$Settings['charset']); }
246 else { header("Content-Type: text/xml; charset=".$Settings['charset']); }
247 xml_doc_start("1.0",$Settings['charset']);
248 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"; ?
>
250 <!DOCTYPE versioninfo
[
251 <!ELEMENT
versioninfo (version
*)>
252 <!ELEMENT
version (charset
,title
,name
,vname
)>
253 <!ELEMENT
charset (#PCDATA)>
254 <!ELEMENT
title (#PCDATA)>
255 <!ELEMENT
name (#PCDATA)>
256 <!ELEMENT
vname (#PCDATA)>
262 <charset
><?php
echo $Settings['charset']; ?
></charset
>
263 <title
><?php
echo $Settings['board_name']; ?
></title
>
264 <?php
echo "<name>".$iDBVerName."</name>\n"; ?
>
265 <vname
><?php
echo $VerCheckName; ?
> Version Checker
</vname
>
269 <?php
gzip_page("off",$GZipEncode['Type']); session_write_close(); die(); } }
270 if($Settings['vercheck']===1) {
271 if($_GET['act']=="versioninfo") { header("Content-Type: text/plain; charset=UTF-8");
272 header("Location: ".$VerCheckURL."&name=".urlencode($iDBVerName)); $urlstatus = 302;
273 gzip_page("off",$GZipEncode['Type']); session_write_close(); die(); } }
274 if($_GET['act']=="homepage") { header("Content-Type: text/plain; charset=UTF-8");
275 header("Location: ".$Settings['weburl']); $urlstatus = 302;
276 gzip_page("off",$GZipEncode['Type']); session_write_close(); die(); }
277 if($Settings['enable_pathinfo']=="on") {
278 mrstring(); /* Change Path info to Get Vars :P */ }
279 // Check to see if variables are set
280 $qstrhtml = htmlentities($Settings['qstr'], ENT_QUOTES
, $Settings['charset']);
281 if($Settings['enable_https']=="on"&&$_SERVER['HTTPS']=="on") {
282 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
283 $HTTPsTest = parse_url($Settings['idburl']); if($HTTPsTest['scheme']=="http") {
284 $Settings['idburl'] = preg_replace("/http\:\/\//i", "https://", $Settings['idburl']); } } }
285 $cookieDomain = null; $cookieSecure = false;
286 if($Settings['idburl']!=null&&$Settings['idburl']!="localhost") {
287 $URLsTest = parse_url($Settings['idburl']);
288 $cookieDomain = $URLsTest['host'];
289 if($cookieDomain=="localhost") { $cookieDomain = false; }
290 if($Settings['enable_https']=="on") {
291 if($URLsTest['scheme']=="https") { $cookieSecure = true; }
292 if($URLsTest['scheme']!="https") { $cookieSecure = false; } } }
293 if(!in_array("ini_set", $disfunc)) {
294 @ini_set
('default_charset', $Settings['charset']); }
295 $File1Name = dirname($_SERVER['SCRIPT_NAME'])."/";
296 $File2Name = $_SERVER['SCRIPT_NAME'];
297 $File3Name=str_replace($File1Name, null, $File2Name);
298 if ($File3Name=="sql.php"||
$File3Name=="/sql.php") {
299 header('Location: index.php');
301 //error_reporting(E_ERROR);
302 // Check if gzip is on and if user's browser can accept gzip pages
303 if($_GET['act']=="MkCaptcha"||
$_GET['act']=="Captcha") {
304 $Settings['use_gzip'] = 'off'; }
305 if($Settings['use_gzip']=="on") {
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']=="gzip") {
312 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) { $Settings['use_gzip'] = "on";
313 $GZipEncode['Type'] = "gzip"; } else { $Settings['use_gzip'] = "off"; } }
314 if($Settings['use_gzip']=="deflate") {
315 if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], "deflate")) { $Settings['use_gzip'] = "on";
316 $GZipEncode['Type'] = "deflate"; } else { $Settings['use_gzip'] = "off"; } }
317 function idb_output_handler($buffer) { return $buffer; }
318 if($Settings['clean_ob']=="on") {
319 /* Check for other output handlers/buffers are open
320 and close and get the contents in an array */
321 $numob = count(ob_list_handlers()); $iob = 0;
322 while ($iob < $numob) {
323 $old_ob_var[$iob] = ob_get_clean();
324 ++
$iob; } } ob_start("idb_output_handler");
325 if($Settings['use_gzip']=="on") {
326 if($GZipEncode['Type']!="gzip") { if($GZipEncode['Type']!="deflate") { $GZipEncode['Type'] = "gzip"; } }
327 if($GZipEncode['Type']=="gzip") {
328 header("Content-Encoding: gzip"); }
329 if($GZipEncode['Type']=="deflate") {
330 header("Content-Encoding: deflate"); } }
331 /* if(eregi("msie",$browser) && !eregi("opera",$browser)){
332 header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); } */
334 $SQLStat = sql_connect_db($Settings['sqlhost'],$Settings['sqluser'],$Settings['sqlpass'],$Settings['sqldb']);
335 if(isset($Settings['sql_collate'])&&!isset($Settings['sql_charset'])) {
336 if($Settings['sql_collate']=="ascii_bin"||
337 $Settings['sql_collate']=="ascii_generel_ci") {
338 $Settings['sql_charset'] = "ascii"; }
339 if($Settings['sql_collate']=="latin1_bin"||
340 $Settings['sql_collate']=="latin1_general_ci"||
341 $Settings['sql_collate']=="latin1_general_cs") {
342 $Settings['sql_charset'] = "latin1"; }
343 if($Settings['sql_collate']=="utf8_bin"||
344 $Settings['sql_collate']=="utf8_general_ci"||
345 $Settings['sql_collate']=="utf8_unicode_ci") {
346 $Settings['sql_charset'] = "utf8"; } }
347 if(isset($Settings['sql_collate'])&&isset($Settings['sql_charset'])) {
348 if($Settings['sql_charset']=="ascii") {
349 if($Settings['sql_collate']!="ascii_bin"&&
350 $Settings['sql_collate']!="ascii_generel_ci") {
351 $Settings['sql_collate'] = "ascii_generel_ci"; } }
352 if($Settings['sql_charset']=="latin1") {
353 if($Settings['sql_collate']!="latin1_bin"&&
354 $Settings['sql_collate']!="latin1_general_ci"&&
355 $Settings['sql_collate']!="latin1_general_cs") {
356 $Settings['sql_collate'] = "latin1_general_ci"; } }
357 if($Settings['sql_charset']=="utf8") {
358 if($Settings['sql_collate']!="utf8_bin"&&
359 $Settings['sql_collate']!="utf8_general_ci"&&
360 $Settings['sql_collate']!="utf8_unicode_ci") {
361 $Settings['sql_collate'] = "utf8_unicode_ci"; } }
362 $SQLCollate = $Settings['sql_collate'];
363 $SQLCharset = $Settings['sql_charset']; }
364 if(!isset($Settings['sql_collate'])||
!isset($Settings['sql_charset'])) {
365 $SQLCollate = "latin1_general_ci";
366 $SQLCharset = "latin1";
367 if($Settings['charset']=="ISO-8859-1") {
368 $SQLCollate = "latin1_general_ci";
369 $SQLCharset = "latin1"; }
370 if($Settings['charset']=="ISO-8859-15") {
371 $SQLCollate = "latin1_general_ci";
372 $SQLCharset = "latin1"; }
373 if($Settings['charset']=="UTF-8") {
374 $SQLCollate = "utf8_unicode_ci";
375 $SQLCharset = "utf8"; }
376 $Settings['sql_collate'] = $SQLCollate;
377 $Settings['sql_charset'] = $SQLCharset; }
378 sql_set_charset($SQLCharset,$SQLStat);
379 if($SQLStat===false) {
380 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);
381 ob_clean(); echo "Sorry could not connect to sql database.\nContact the board admin about error. Error log below.";
382 echo "\n".sql_errorno($SQLStat); $urlstatus = 503;
383 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
384 $sqltable = $Settings['sqltable'];
385 $temp_user_ip = $_SERVER['REMOTE_ADDR'];
386 if(!isset($_SERVER['HTTP_USER_AGENT'])) {
387 $_SERVER['HTTP_USER_AGENT'] = ""; }
388 if(strpos($_SERVER['HTTP_USER_AGENT'], "msie") &&
389 !strpos($_SERVER['HTTP_USER_AGENT'], "opera")){
390 header("X-UA-Compatible: IE=Edge"); }
391 if(strpos($_SERVER['HTTP_USER_AGENT'], "chromeframe")) {
392 header("X-UA-Compatible: IE=Edge,chrome=1"); }
393 $temp_user_agent = $_SERVER['HTTP_USER_AGENT'];
394 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
395 $MkIndexFile = $exfile['index'].$Settings['file_ext']; }
396 if($Settings['file_ext']=="no+ext"||
$Settings['file_ext']=="no ext") {
397 $MkIndexFile = $exfile['index']; }
398 $temp_session_data = "ViewingPage|s:9:\"?act=view\";ViewingFile|s:".strlen($MkIndexFile).":\"".$MkIndexFile."\";PreViewingTitle|s:7:\"Viewing\";ViewingTitle|s:11:\"Board index\";UserID|s:1:\"0\";UserIP|s:".strlen($_SERVER['REMOTE_ADDR']).":\"".$_SERVER['REMOTE_ADDR']."\";UserGroup|s:".strlen($Settings['GuestGroup']).":\"".$Settings['GuestGroup']."\";UserGroupID|s:1:\"4\";UserTimeZone|s:".strlen($Settings['DefaultTimeZone']).":\"".$Settings['DefaultTimeZone']."\";UserDST|s:".strlen($Settings['DefaultDST']).":\"".$Settings['DefaultDST']."\";";
399 $SQLSType = $Settings['sqltype'];
400 //Session Open Function
401 function sql_session_open($save_path, $session_name ) {
402 global $sess_save_path;
403 $sess_save_path = $save_path;
405 //Session Close Function
406 function sql_session_close() {
408 //Session Read Function
409 function sql_session_read($id) {
410 global $sqltable,$SQLStat,$SQLSType,$temp_user_ip,$temp_user_agent,$temp_session_data;
411 $result = sql_query(sql_pre_query("SELECT * FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '%s'", array($id)),$SQLStat);
412 if (!sql_num_rows($result)) {
413 sql_query(sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"session_id\"<>'%s' AND \"ip_address\"='%s'", array($id,$temp_user_ip)),$SQLStat);
414 $time = GMTimeStamp();
415 sql_query(sql_pre_query("INSERT INTO \"".$sqltable."sessions\" (\"session_id\", \"session_data\", \"user_agent\", \"ip_address\", \"expires\") VALUES\n".
416 "('%s', '%s', '%s', '%s', %i)", array($id,$temp_session_data,$temp_user_agent,$temp_user_ip,$time)),$SQLStat);
419 $time = GMTimeStamp();
420 $predata = sql_num_rows($result);
423 $row = sql_fetch_assoc($result);
424 $data = $row['session_data']; }
425 /*sql_query(sql_pre_query("UPDATE \"".$sqltable."sessions\" SET \"session_data\"='%s',\"expires\"=%i WHERE \"session_id\"='%s'", array($data,$time,$id)),$SQLStat);*/
427 //Session Write Function
428 function sql_session_write($id,$data) {
429 global $sqltable,$SQLStat,$SQLSType,$temp_user_ip,$temp_user_agent;
430 $time = GMTimeStamp();
431 $rs = sql_query(sql_pre_query("UPDATE \"".$sqltable."sessions\" SET \"session_data\"='%s',\"user_agent\"='%s',\"ip_address\"='%s',\"expires\"=%i WHERE \"session_id\"='%s'", array($data,$temp_user_agent,$temp_user_ip,$time,$id)),$SQLStat);
433 //Session Destroy Function
434 function sql_session_destroy($id) {
435 global $sqltable,$SQLStat;
436 sql_query(sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"session_id\" = '$id'", array($id)),$SQLStat);
438 //Session Garbage Collection Function
439 function sql_session_gc($maxlifetime) {
440 global $sqltable,$SQLStat;
441 $time = GMTimeStamp() - $maxlifetime;
442 //sql_query(sql_pre_query('DELETE FROM \"'.$sqltable.'sessions\" WHERE \"expires\" < UNIX_TIMESTAMP();', array(null)),$SQLStat);
443 sql_query(sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"expires\" < %i", array($time)),$SQLStat);
445 session_set_save_handler("sql_session_open", "sql_session_close", "sql_session_read", "sql_session_write", "sql_session_destroy", "sql_session_gc");
446 if($cookieDomain==null) {
447 session_set_cookie_params(0, $cbasedir); }
448 if($cookieDomain!=null) {
449 if($cookieSecure===true) {
450 session_set_cookie_params(0, $cbasedir, $cookieDomain, 1); }
451 if($cookieSecure===false) {
452 session_set_cookie_params(0, $cbasedir, $cookieDomain); } }
453 session_cache_limiter("private, no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0");
454 header("Cache-Control: private, no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0");
455 header("Pragma: private, no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0");
456 header("P3P: CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");
457 header("Date: ".gmdate("D, d M Y H:i:s")." GMT");
458 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
459 header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
460 if(!isset($_COOKIE[$Settings['sqltable']."sess"])) {
461 $exptime = GMTimeStamp() - ini_get("session.gc_maxlifetime");
462 sql_query(sql_pre_query("DELETE FROM \"".$Settings['sqltable']."sessions\" WHERE \"expires\" < %i OR \"ip_address\"='%s'", array($exptime,$temp_user_ip)),$SQLStat); }
463 session_name($Settings['sqltable']."sess");
465 //header("Set-Cookie: PHPSESSID=" . session_id() . "; path=".$cbasedir);
466 output_reset_rewrite_vars();
467 if($_GET['act']=="bsdl"||
$_GET['act']=="BSDL"||
$_GET['act']=="license"||
468 $_GET['act']=="LICENSE"||
$_GET['act']=="License") { $_GET['act']="bsd"; }
469 if($_GET['act']=="bsd") {
470 header("Content-Type: text/plain; charset=".$Settings['charset']);
471 require("LICENSE"); gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
472 if($_GET['act']=="README"||
$_GET['act']=="ReadME") { $_GET['act']="readme"; }
473 if($_GET['act']=="readme"||
$_GET['act']=="ReadMe") {
474 header("Content-Type: text/plain; charset=".$Settings['charset']);
475 require("README"); gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
476 if($_GET['act']=="js"||
$_GET['act']=="javascript") {
477 header("Content-Script-Type: text/javascript");
478 if(stristr($_SERVER["HTTP_ACCEPT"],"application/x-javascript") ) {
479 header("Content-Type: application/x-javascript; charset=".$Settings['charset']); } else {
480 if(stristr($_SERVER["HTTP_ACCEPT"],"application/javascript") ) {
481 header("Content-Type: application/javascript; charset=".$Settings['charset']); } else {
482 header("Content-Type: text/javascript; charset=".$Settings['charset']); } }
483 require($SettDir['inc'].'javascript.php');
484 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); die(); }
485 if($Settings['use_captcha']=="on") {
486 if($_GET['act']=="MkCaptcha"||
$_GET['act']=="Captcha") {
487 if($Settings['captcha_clean']=="on") { ob_clean(); }
488 require($SettDir['inc']."captcha.php");
489 $aFonts = array('inc/fonts/VeraBd.ttf', 'inc/fonts/VeraBI.ttf', 'inc/fonts/VeraIt.ttf', 'inc/fonts/Vera.ttf');
490 $oPhpCaptcha = new PhpCaptcha($aFonts, 200, 60);
491 $RNumSize = rand(7,17); $i=0; $RandNum = null;
492 while ($i <= $RNumSize) {
493 $RandNum=$RandNum.dechex(rand(1,15)); ++
$i; }
494 $RandNum=strtoupper($RandNum);
495 $oPhpCaptcha->SetOwnerText("Fake Code: ".$RandNum);
496 $oPhpCaptcha->UseColour(true);
497 $oPhpCaptcha->Create(); session_write_close(); die(); } }
498 if(!isset($_SESSION['CheckCookie'])) {
499 if(isset($_COOKIE['SessPass'])&&isset($_COOKIE['MemberName'])) {
500 require($SettDir['inc'].'prelogin.php'); } }
501 require($SettDir['inc'].'groupsetup.php');
502 if($Settings['board_offline']=="on"&&$GroupInfo['CanViewOffLine']!="yes") {
503 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);
504 ob_clean(); if(!isset($Settings['offline_text'])) {
505 echo "Sorry the board is off line.\nIf you are a admin you can login by the admin cp."; }
506 if(isset($Settings['offline_text'])) { echo $Settings['offline_text']; } $urlstatus = 503;
507 //echo "\n".sql_errorno($SQLStat);
508 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
510 if(!isset($_SESSION['UserTimeZone'])) {
511 if(isset($Settings['DefaultTimeZone'])) {
512 $_SESSION['UserTimeZone'] = $Settings['DefaultTimeZone'];
513 if(!isset($Settings['DefaultTimeZone'])) {
514 $_SESSION['UserTimeZone'] = SeverOffSet().":00"; } } }
515 $checktime = explode(":",$_SESSION['UserTimeZone']);
516 if(count($checktime)!=2) {
517 if(!isset($checktime[0])) { $checktime[0] = "0"; }
518 if(!isset($checktime[1])) { $checktime[1] = "00"; }
519 $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
520 if(!is_numeric($checktime[0])) { $checktime[0] = "0"; }
521 if(!is_numeric($checktime[1])) { $checktime[1] = "00"; }
522 if($checktime[1]<0) { $checktime[1] = "00"; $_SESSION['UserTimeZone'] = $checktime[0].":".$checktime[1]; }
523 $checktimea = array("offset" => $_SESSION['UserTimeZone'], "hour" => $checktime[0], "minute" => $checktime[1]);
524 if(!isset($_SESSION['UserDST'])) { $_SESSION['UserDST'] = null; }
525 if($_SESSION['UserDST']==null) {
526 if($Settings['DefaultDST']=="off") {
527 $_SESSION['UserDST'] = "off"; }
528 if($Settings['DefaultDST']=="on") {
529 $_SESSION['UserDST'] = "on"; } }
531 if(isset($_SESSION['MemberName'])||
532 isset($_COOKIE['MemberName'])) {
533 $_SESSION['GuestName'] = null;
534 $_COOKIE['GuestName'] = null; }
535 if(!isset($_SESSION['MemberName'])&&!isset($_COOKIE['MemberName'])) {
536 if(!isset($_SESSION['GuestName'])&&isset($_COOKIE['GuestName'])) {
537 $_SESSION['GuestName'] = $_COOKIE['GuestName']; } }
538 if(!isset($_SESSION['LastPostTime'])) { $_SESSION['LastPostTime'] = "0"; }
540 if(!isset($_SESSION['Theme'])) { $_SESSION['Theme'] = null; }
541 if(!isset($_GET['theme'])) { $_GET['theme'] = null; }
542 if(!isset($_POST['theme'])) { $_POST['theme'] = null; }
543 if(!isset($_GET['skin'])) { $_GET['skin'] = null; }
544 if(!isset($_POST['skin'])) { $_POST['skin'] = null; }
545 if(!isset($_GET['style'])) { $_GET['style'] = null; }
546 if(!isset($_POST['style'])) { $_POST['style'] = null; }
547 if(!isset($_GET['css'])) { $_GET['css'] = null; }
548 if(!isset($_POST['css'])) { $_POST['css'] = null; }
549 if($_GET['theme']==null) {
550 if($_POST['theme']!=null) {
551 $_GET['theme'] = $_POST['theme']; }
552 if($_POST['skin']!=null) {
553 $_GET['theme'] = $_POST['skin']; }
554 if($_POST['style']!=null) {
555 $_GET['theme'] = $_POST['style']; }
556 if($_POST['css']!=null) {
557 $_GET['theme'] = $_POST['css']; }
558 if($_GET['skin']!=null) {
559 $_GET['theme'] = $_GET['skin']; }
560 if($_GET['style']!=null) {
561 $_GET['theme'] = $_GET['style']; }
562 if($_GET['css']!=null) {
563 $_GET['theme'] = $_GET['css']; } }
564 if($Settings['SQLThemes']=="off") {
565 if($_GET['theme']!=null) {
566 $_GET['theme'] = chack_themes($_GET['theme']);
567 if($_GET['theme']=="../"||
$_GET['theme']=="./") {
568 $_GET['theme']="iDB"; $_SESSION['Theme']="iDB"; }
569 if (file_exists($SettDir['themes'].$_GET['theme']."/settings.php")) {
570 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
571 $NewDay=GMTimeStamp();
572 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_GET['theme'],$NewDay,$_SESSION['UserID']));
573 sql_query($qnewskin,$SQLStat); }
574 /* The file Theme Exists */ }
575 else { $_GET['theme'] = $Settings['DefaultTheme'];
576 $_SESSION['Theme'] = $Settings['DefaultTheme'];
577 /* The file Theme Dose Not Exists */ } }
578 if($_GET['theme']==null) {
579 if($_SESSION['Theme']!=null) {
580 $OldTheme = $_SESSION['Theme'];
581 $_SESSION['Theme'] = chack_themes($_SESSION['Theme']);
582 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
583 if($OldTheme!=$_SESSION['Theme']) {
584 $NewDay=GMTimeStamp();
585 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_SESSION['Theme'],$NewDay,$_SESSION['UserID']));
586 sql_query($qnewskin,$SQLStat); } }
587 $_GET['theme']=$_SESSION['Theme']; }
588 if($_SESSION['Theme']==null) {
589 $_SESSION['Theme']=$Settings['DefaultTheme'];
590 $_GET['theme']=$Settings['DefaultTheme']; } }
591 $PreSkin['skindir1'] = $_SESSION['Theme'];
592 $PreSkin['skindir2'] = $SettDir['themes'].$_SESSION['Theme'];
593 require($SettDir['themes'].$_GET['theme']."/settings.php"); }
594 if($Settings['SQLThemes']=="on") {
595 if($_GET['theme']==null&&$_SESSION['Theme']==null) {
596 $_GET['theme'] = $Settings['DefaultTheme'];
597 $_SESSION['Theme'] = $Settings['DefaultTheme']; }
598 if($_GET['theme']!=null) {
599 $themequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."themes\" WHERE \"Name\"='%s'", array($_GET['theme'])); }
600 if($_GET['theme']==null) {
601 if($_SESSION['Theme']!=null) {
602 $themequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."themes\" WHERE \"Name\"='%s'", array($_SESSION['Theme'])); } }
603 $themeresult=sql_query($themequery,$SQLStat);
604 $themenum=sql_num_rows($themeresult);
606 $_GET['theme'] = $Settings['DefaultTheme'];
607 $_SESSION['Theme'] = $Settings['DefaultTheme'];
608 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
609 $NewDay=GMTimeStamp();
610 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_SESSION['Theme'],$NewDay,$_SESSION['UserID']));
611 sql_query($qnewskin,$SQLStat); }
612 $themequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."themes\" WHERE \"Name\"='%s'", array($_GET['theme']));
613 $themeresult=sql_query($themequery,$SQLStat);
614 $themenum=sql_num_rows($themeresult); }
616 if($_GET['theme']==null) {
617 if($_SESSION['Theme']!=null) {
618 $_GET['theme'] = $_SESSION['Theme']; } }
619 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
620 $NewDay=GMTimeStamp();
621 $qnewskin = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"UseTheme\"='%s',\"LastActive\"='%s' WHERE \"id\"=%i", array($_GET['theme'],$NewDay,$_SESSION['UserID']));
622 sql_query($qnewskin,$SQLStat); } }
623 require($SettDir['inc'].'sqlthemes.php');
624 sql_free_result($themeresult); }
625 $_SESSION['Theme'] = $_GET['theme'];
626 function get_theme_values($matches) {
629 if(isset($ThemeSet[$matches[1]])) { $return_text = $ThemeSet[$matches[1]]; }
630 if(!isset($ThemeSet[$matches[1]])) { $return_text = null; }
631 return $return_text; }
632 foreach($ThemeSet AS $key => $value) {
633 $ThemeSet[$key] = preg_replace("/%%/s", "{percent}p", $ThemeSet[$key]);
634 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}T/s", "get_theme_values", $ThemeSet[$key]);
635 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}e/s", "get_env_values", $ThemeSet[$key]);
636 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}i/s", "get_server_values", $ThemeSet[$key]);
637 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}s/s", "get_setting_values", $ThemeSet[$key]);
638 $ThemeSet[$key] = preg_replace_callback("/%\{([^\}]*)\}t/s", "get_time", $ThemeSet[$key]);
639 $ThemeSet[$key] = preg_replace("/\{percent\}p/s", "%", $ThemeSet[$key]); }
640 if(!isset($ThemeSet['TableStyle'])) {
641 $ThemeSet['TableStyle'] = "table"; }
642 if(isset($ThemeSet['TableStyle'])) {
643 if($ThemeSet['TableStyle']!="div"&&
644 $ThemeSet['TableStyle']!="table") {
645 $ThemeSet['TableStyle'] = "table"; } }
646 if(!isset($_SESSION['DBName'])) { $_SESSION['DBName'] = null; }
647 if($_SESSION['DBName']==null) {
648 $_SESSION['DBName'] = $Settings['sqldb']; }
649 if($_SESSION['DBName']!=null) {
650 if($_SESSION['DBName']!=$Settings['sqldb']) {
651 redirect("location",$rbasedir.url_maker($exfile['member'],$Settings['file_ext'],"act=logout",$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'],false)); } }