Small update
[iDB.git] / inc / function.php
blob303a0bf2a3822b91d7658519ed8d9eae87940ebd
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-2019 iDB Support - https://idb.osdn.jp/support/category.php?act=view&id=1
12 Copyright 2004-2019 Game Maker 2k - https://idb.osdn.jp/support/category.php?act=view&id=2
14 $FileInfo: function.php - Last Update: 08/02/2019 SVN 905 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="function.php"||$File3Name=="/function.php") {
18 require('index.php');
19 exit(); }
20 require_once($SettDir['misc'].'functions.php');
21 require_once($SettDir['misc'].'ibbcode.php');
22 require_once($SettDir['misc'].'iuntar.php');
23 /* In php 6 and up the function get_magic_quotes_gpc dose not exist.
24 here we make a fake version that always sends false out. :P */
25 if(!function_exists('get_magic_quotes_gpc')) {
26 function get_magic_quotes_gpc() { return false; } }
27 /**
28 * Undo the damage of magic_quotes_gpc if in effect
29 * @return bool
30 * @link http://www.charles-reace.com/blog/2010/07/13/undoing-magic-quotes/
32 function fix_magic_quotes()
34 if (get_magic_quotes_gpc()) {
35 $func = create_function(
36 '&$val, $key',
37 'if(!is_numeric($val)) {$val = stripslashes($val);}'
39 array_walk_recursive($_GET, $func);
40 array_walk_recursive($_POST, $func);
41 array_walk_recursive($_COOKIE, $func);
43 return true;
45 fix_magic_quotes();
46 /* Change Some PHP Settings Fix the & to &amp;
47 if($Settings['use_iniset']==true&&$Settings['qstr']!="/") {
48 ini_set("arg_separator.output",htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']));
49 ini_set("arg_separator.input",$Settings['qstr']);
50 ini_set("arg_separator",htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset'])); }
51 //$basepath = pathinfo($_SERVER['REQUEST_URI']);
52 if(dirname($_SERVER['REQUEST_URI'])!="."||
53 dirname($_SERVER['REQUEST_URI'])!=null) {
54 $basedir = dirname($_SERVER['REQUEST_URI'])."/"; }*/
55 // Get the base dir name
56 /*if(dirname($_SERVER['SCRIPT_NAME'])!="."||
57 dirname($_SERVER['SCRIPT_NAME'])!=null) {
58 $basedir = dirname($_SERVER['SCRIPT_NAME'])."/"; }
59 if($basedir==null||$basedir==".") {
60 if(dirname($_SERVER['SCRIPT_NAME'])=="."||
61 dirname($_SERVER['SCRIPT_NAME'])==null) {
62 $basedir = dirname($_SERVER['PHP_SELF'])."/"; } }
63 if($basedir=="\/") { $basedir="/"; }
64 $basedir = str_replace("//", "/", $basedir);*/
65 if($Settings['qstr']!="/") {
66 $iDBURLCHK = $Settings['idburl']; }
67 if($Settings['qstr']=="/") {
68 $iDBURLCHK = preg_replace("/\/$/","",$Settings['idburl']); }
69 $basecheck = parse_url($iDBURLCHK);
70 $basedir = $basecheck['path'];
71 $cbasedir = $basedir;
72 $rbasedir = $basedir;
73 if($Settings['fixbasedir']!=null&&$Settings['fixbasedir']!="off") {
74 $basedir = $Settings['fixbasedir']; }
75 if($Settings['fixcookiedir']!=null&&$Settings['fixcookiedir']!="") {
76 $cbasedir = $Settings['fixcookiedir']; }
77 if($Settings['fixredirectdir']!=null) {
78 $rbasedir = $Settings['fixredirectdir']; }
79 $BaseURL = $basedir;
80 // Get our Host Name and Referer URL's Host Name
81 if(!isset($_SERVER['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = null; }
82 $REFERERurl = parse_url($_SERVER['HTTP_REFERER']);
83 if(!isset($REFERERurl['host'])) { $REFERERurl['host'] = null; }
84 $URL['REFERER'] = $REFERERurl['host'];
85 $URL['HOST'] = $basecheck['host'];
86 $REFERERurl = null;
87 // Function made by Howard Yeend
88 // http://php.net/manual/en/function.trigger-error.php#92016
89 // http://www.puremango.co.uk/
90 function output_error($message, $level=E_USER_ERROR) {
91 $caller = next(debug_backtrace());
92 trigger_error($message.' in <strong>'.$caller['function'].'</strong> called from <strong>'.$caller['file'].'</strong> on line <strong>'.$caller['line'].'</strong>'."\n<br />error handler", $level); }
93 $Names['D'] = "Dagmara";
94 define("_dagmara_", $Names['D']);
95 // By s rotondo90 at gmail com at https://www.php.net/manual/en/function.random-int.php#119670
96 if (!function_exists('random_int')) {
97 function random_int($min, $max) {
98 if (!function_exists('mcrypt_create_iv')) {
99 trigger_error(
100 'mcrypt must be loaded for random_int to work',
101 E_USER_WARNING
103 return null;
106 if (!is_int($min) || !is_int($max)) {
107 trigger_error('$min and $max must be integer values', E_USER_NOTICE);
108 $min = (int)$min;
109 $max = (int)$max;
112 if ($min > $max) {
113 trigger_error('$max can\'t be lesser than $min', E_USER_WARNING);
114 return null;
117 $range = $counter = $max - $min;
118 $bits = 1;
120 while ($counter >>= 1) {
121 ++$bits;
124 $bytes = (int)max(ceil($bits/8), 1);
125 $bitmask = pow(2, $bits) - 1;
127 if ($bitmask >= PHP_INT_MAX) {
128 $bitmask = PHP_INT_MAX;
131 do {
132 $result = hexdec(
133 bin2hex(
134 mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
136 ) & $bitmask;
137 } while ($result > $range);
139 return $result + $min;
142 // http://us.php.net/manual/en/function.uniqid.php#94959
144 * Generates an UUID
146 * @author Andrew Moore
147 * @url http://us.php.net/manual/en/function.uniqid.php#94959
149 function uuid_old($uuidver = "v4", $rndty = "rand", $namespace = null, $name = null) {
150 if($uuidver!="v3"&&$uuidver!="v4"&&$uuidver!="v5") { $uuidver = "v4"; }
151 if($uuidver=="v4") {
152 return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
153 $rndty(0, 0xffff), $rndty(0, 0xffff),
154 $rndty(0, 0xffff),
155 $rndty(0, 0x0fff) | 0x4000,
156 $rndty(0, 0x3fff) | 0x8000,
157 $rndty(0, 0xffff), $rndty(0, 0xffff), $rndty(0, 0xffff) ); }
158 if($uuidver=="v3"||$uuidver=="v5") {
159 if($namespace===null) {
160 $namespace = uuid_old("v4",$rndty); }
161 $nhex = str_replace(array('-','{','}'), '', $namespace);
162 $nstr = '';
163 for($i = 0; $i < strlen($nhex); $i+=2) {
164 if(isset($nhex[$i+1])) {
165 $nstr .= chr(hexdec($nhex[$i].$nhex[$i+1])); }
166 if(!isset($nhex[$i+1])) {
167 $nstr .= chr(hexdec($nhex[$i])); }
169 if($name===null) { $name = salt_hmac(); }
170 // Calculate hash value
171 if($uuidver=="v3") {
172 $uuidverid = 0x3000;
173 if (function_exists('hash')) {
174 $hash = hash("md5", $nstr . $name); }
175 if (!function_exists('hash')) {
176 $hash = md5($nstr . $name); } }
177 if($uuidver=="v5") {
178 $uuidverid = 0x5000;
179 if (function_exists('hash')) {
180 $hash = hash("sha1", $nstr . $name); }
181 if (!function_exists('hash')) {
182 $hash = sha1($nstr . $name); } }
183 return sprintf('%08s-%04s-%04x-%04x-%12s',
184 substr($hash, 0, 8),
185 substr($hash, 8, 4),
186 (hexdec(substr($hash, 12, 4)) & 0x0fff) | $uuidverid,
187 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
188 substr($hash, 20, 12) ); } }
189 class UUID {
190 public static function v3($namespace, $name) {
191 if(!self::is_valid($namespace)) return false;
193 // Get hexadecimal components of namespace
194 $nhex = str_replace(array('-','{','}'), '', $namespace);
196 // Binary Value
197 $nstr = '';
199 // Convert Namespace UUID to bits
200 for($i = 0; $i < strlen($nhex); $i+=2) {
201 $nstr .= chr(hexdec($nhex[$i].$nhex[$i+1]));
204 // Calculate hash value
205 $hash = md5($nstr . $name);
207 return sprintf('%08s-%04s-%04x-%04x-%12s',
209 // 32 bits for "time_low"
210 substr($hash, 0, 8),
212 // 16 bits for "time_mid"
213 substr($hash, 8, 4),
215 // 16 bits for "time_hi_and_version",
216 // four most significant bits holds version number 3
217 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
219 // 16 bits, 8 bits for "clk_seq_hi_res",
220 // 8 bits for "clk_seq_low",
221 // two most significant bits holds zero and one for variant DCE1.1
222 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
224 // 48 bits for "node"
225 substr($hash, 20, 12)
229 public static function v4() {
230 return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
232 // 32 bits for "time_low"
233 mt_rand(0, 0xffff), mt_rand(0, 0xffff),
235 // 16 bits for "time_mid"
236 mt_rand(0, 0xffff),
238 // 16 bits for "time_hi_and_version",
239 // four most significant bits holds version number 4
240 mt_rand(0, 0x0fff) | 0x4000,
242 // 16 bits, 8 bits for "clk_seq_hi_res",
243 // 8 bits for "clk_seq_low",
244 // two most significant bits holds zero and one for variant DCE1.1
245 mt_rand(0, 0x3fff) | 0x8000,
247 // 48 bits for "node"
248 mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
252 public static function v5($namespace, $name) {
253 if(!self::is_valid($namespace)) return false;
255 // Get hexadecimal components of namespace
256 $nhex = str_replace(array('-','{','}'), '', $namespace);
258 // Binary Value
259 $nstr = '';
261 // Convert Namespace UUID to bits
262 for($i = 0; $i < strlen($nhex); $i+=2) {
263 $nstr .= chr(hexdec($nhex[$i].$nhex[$i+1]));
266 // Calculate hash value
267 $hash = sha1($nstr . $name);
269 return sprintf('%08s-%04s-%04x-%04x-%12s',
271 // 32 bits for "time_low"
272 substr($hash, 0, 8),
274 // 16 bits for "time_mid"
275 substr($hash, 8, 4),
277 // 16 bits for "time_hi_and_version",
278 // four most significant bits holds version number 5
279 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
281 // 16 bits, 8 bits for "clk_seq_hi_res",
282 // 8 bits for "clk_seq_low",
283 // two most significant bits holds zero and one for variant DCE1.1
284 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
286 // 48 bits for "node"
287 substr($hash, 20, 12)
291 public static function is_valid($uuid) {
292 return preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?'.
293 '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/i', $uuid) === 1;
296 function uuid($uuidver = "v4", $rndty = "rand", $namespace = null, $name = null) {
297 if($uuidver!="v3"&&$uuidver!="v4"&&$uuidver!="v5") { $uuidver = "v4"; }
298 if($uuidver=="v3") { return UUID::v3(UUID::v4(), salt_hmac()); }
299 if($uuidver=="v3") { return UUID::v4(); }
300 if($uuidver=="v3") { return UUID::v5(UUID::v4(), salt_hmac()); }
301 return false; }
302 // By info at raymondrodgers dot com at https://www.php.net/manual/en/function.random-int.php#118636
303 function generateUUIDv4()
305 if(version_compare(PHP_VERSION,'7.0.0', '<') )
307 return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
309 // 32 bits for "time_low"
310 mt_rand(0, 0xffff), mt_rand(0, 0xffff),
312 // 16 bits for "time_mid"
313 mt_rand(0, 0xffff),
315 // 16 bits for "time_hi_and_version",
316 // four most significant bits holds version number 4
317 mt_rand(0, 0x0fff) | 0x4000,
319 // 16 bits, 8 bits for "clk_seq_hi_res",
320 // 8 bits for "clk_seq_low",
321 // two most significant bits holds zero and one for variant DCE1.1
322 mt_rand(0, 0x3fff) | 0x8000,
324 // 48 bits for "node"
325 mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
328 else
330 return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
332 // 32 bits for "time_low"
333 random_int(0, 0xffff), random_int(0, 0xffff),
335 // 16 bits for "time_mid"
336 random_int(0, 0xffff),
338 // 16 bits for "time_hi_and_version",
339 // four most significant bits holds version number 4
340 random_int(0, 0x0fff) | 0x4000,
342 // 16 bits, 8 bits for "clk_seq_hi_res",
343 // 8 bits for "clk_seq_low",
344 // two most significant bits holds zero and one for variant DCE1.1
345 random_int(0, 0x3fff) | 0x8000,
347 // 48 bits for "node"
348 random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff)
352 function rand_uuid_old($rndty = "rand", $namespace = null, $name = null) {
353 $rand_array = array(1 => "v3", 2 => "v4", 3 => "v5");
354 if($name===null) { $name = salt_hmac(); }
355 $my_uuid = $rand_array[$rndty(1,3)];
356 if($my_uuid=="v4") { return uuid_old("v4",$rndty); }
357 if($my_uuid=="v3"||$my_uuid=="v5") {
358 return uuid_old($my_uuid,$rndty,$name); } }
359 function rand_uuid($rndty = "rand", $namespace = null, $name = null) {
360 $rand_array = array(1 => "v3", 2 => "v4", 3 => "v5");
361 if($name===null) { $name = salt_hmac(); }
362 $my_uuid = $rand_array[$rndty(1,3)];
363 if($my_uuid=="v4") { return uuid("v4",$rndty); }
364 if($my_uuid=="v3"||$my_uuid=="v5") {
365 return uuid($my_uuid,$rndty,$name); } }
366 // unserialize sessions variables
367 // By: jason@joeymail.net
368 // URL: http://us2.php.net/manual/en/function.session-decode.php#101687
369 function unserialize_session($data)
371 if( strlen( $data) == 0)
373 return array();
375 // match all the session keys and offsets
376 preg_match_all('/(^|;|\})([a-zA-Z0-9_]+)\|/i', $data, $matchesarray, PREG_OFFSET_CAPTURE);
377 $returnArray = array();
378 $lastOffset = null;
379 $currentKey = '';
380 foreach ( $matchesarray[2] as $value )
382 $offset = $value[1];
383 if(!is_null( $lastOffset))
385 $valueText = substr($data, $lastOffset, $offset - $lastOffset );
386 $returnArray[$currentKey] = unserialize($valueText);
388 $currentKey = $value[0];
389 $lastOffset = $offset + strlen( $currentKey )+1;
391 $valueText = substr($data, $lastOffset );
392 $returnArray[$currentKey] = unserialize($valueText);
393 return $returnArray;
395 // Make the Query String if we are not useing &=
396 function qstring($qstr=";",$qsep="=")
397 { $_GET = array(); $_GET = null;
398 if (!isset($_SERVER['QUERY_STRING'])) {
399 $_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); }
400 ini_set("arg_separator.input", $qstr);
401 $_SERVER['QUERY_STRING'] = urldecode($_SERVER['QUERY_STRING']);
402 $preqs = explode($qstr,$_SERVER["QUERY_STRING"]);
403 $qsnum = count($preqs); $qsi = 0;
404 while ($qsi < $qsnum) {
405 $preqst = explode($qsep,$preqs[$qsi],2);
406 $fix1 = array(" ",'$'); $fix2 = array("_","_");
407 $preqst[0] = str_replace($fix1, $fix2, $preqst[0]);
408 $preqst[0] = killbadvars($preqst[0]);
409 if($preqst[0]!=null) {
410 $_GET[$preqst[0]] = $preqst[1]; }
411 ++$qsi; } return true; }
412 if($Settings['qstr']!="&"&&
413 $Settings['qstr']!="/") {
414 qstring($Settings['qstr'],$Settings['qsep']);
415 if(!isset($_GET['page'])) { $_GET['page'] = null; }
416 if(!isset($_GET['act'])) { $_GET['act'] = null; }
417 if(!isset($_POST['act'])) { $_POST['act'] = null; }
418 if(!isset($_GET['id'])) { $_GET['id'] = null; }
419 if(!isset($_GET['debug'])) { $_GET['debug'] = "false"; }
420 if(!isset($_GET['post'])) { $_GET['post'] = null; }
421 if(!isset($_POST['License'])) { $_POST['License'] = null; } }
422 if($_SERVER['PATH_INFO']==null) {
423 if(getenv('PATH_INFO')!=null&&getenv('PATH_INFO')!="1") {
424 $_SERVER['PATH_INFO'] = getenv('PATH_INFO'); }
425 if(getenv('PATH_INFO')==null) {
426 $myscript = $_SERVER["SCRIPT_NAME"];
427 $myphpath = $_SERVER["PHP_SELF"];
428 $mypathinfo = str_replace($myscript, "", $myphpath);
429 @putenv("PATH_INFO=".$mypathinfo); } }
430 // Change raw post data to POST array
431 // Not sure why I made but alwell. :P
432 function parse_post_data()
433 { $_POST = array(); $_POST = null;
434 $postdata = file_get_contents("php://input");
435 if (!isset($postdata)) { $postdata = null; }
436 $postdata = urldecode($postdata);
437 $preqs = explode("&",$postdata);
438 $qsnum = count($preqs); $qsi = 0;
439 while ($qsi < $qsnum) {
440 $preqst = explode("=",$preqs[$qsi],2);
441 $fix1 = array(" ",'$'); $fix2 = array("_","_");
442 $preqst[0] = str_replace($fix1, $fix2, $preqst[0]);
443 $preqst[0] = killbadvars($preqst[0]);
444 if($preqst[0]!=null) {
445 $_POST[$preqst[0]] = $preqst[1]; }
446 ++$qsi; } return true; }
447 // Change Path info to Get Vars :
448 function mrstring() {
449 $urlvar = explode('/',$_SERVER['PATH_INFO']);
450 $num=count($urlvar); $i=1;
451 while ($i < $num) {
452 //$urlvar[$i] = urldecode($urlvar[$i]);
453 if(!isset($_GET[$urlvar[$i]])) { $_GET[$urlvar[$i]] = null; }
454 if(!isset($urlvar[$i])) { $urlvar[$i] = null; }
455 if($_GET[$urlvar[$i]]==null&&$urlvar[$i]!=null) {
456 $fix1 = array(" ",'$'); $fix2 = array("_","_");
457 $urlvar[$i] = str_replace($fix1, $fix2, $urlvar[$i]);
458 $urlvar[$i] = killbadvars($urlvar[$i]);
459 $_GET[$urlvar[$i]] = $urlvar[$i+1]; }
460 ++$i; ++$i; } return true; }
461 // Redirect to another file with ether timed or nontimed redirect
462 function redirect($type,$file,$time=0,$url=null,$dbsr=true) {
463 if($type!="location"&&$type!="refresh") { $type=="location"; }
464 if($url!=null) { $file = $url.$file; }
465 if($dbsr===true) { $file = str_replace("//", "/", $file); }
466 if($type=="refresh") { header("Refresh: ".$time."; URL=".$file); }
467 if($type=="location") { session_write_close();
468 header("Location: ".$file); } return true; }
469 function redirects($type,$url,$time=0) {
470 if($type!="location"&&$type!="refresh") { $type=="location"; }
471 if($type=="refresh") { header("Refresh: ".$time."; URL=".$url); }
472 if($type=="location") { idb_log_maker(302,"-"); }
473 if($type=="location") { header("Location: ".$url); } return true; }
474 // Make xhtml tags
475 function html_tag_make($name="br",$emptytag=true,$attbvar=null,$attbval=null,$extratest=null) {
476 $var_num = count($attbvar); $value_num = count($attbval);
477 if($var_num!=$value_num) {
478 output_error("Erorr Number of Var and Values dont match!",E_USER_ERROR);
479 return false; } $i = 0;
480 while ($i < $var_num) {
481 if($i==0) { $mytag = "<".$name." ".$attbvar[$i]."=\"".$attbval[$i]."\""; }
482 if($i>=1) { $mytag = $mytag." ".$attbvar[$i]."=\"".$attbval[$i]."\""; }
483 if($i==$var_num-1) {
484 if($emptytag===false) { $mytag = $mytag.">"; }
485 if($emptytag===true) { $mytag = $mytag." />"; } } ++$i; }
486 if($attbvar==null&&$attbval==null) { $mytag = "<".$name;
487 if($emptytag===true) { $mytag = $mytag." />"; }
488 if($emptytag===false) { $mytag = $mytag.">"; } }
489 if($emptytag===false&&$extratest!=null) {
490 $mytag = $mytag.$extratest; $mytag = $mytag."</".$name.">"; }
491 return $mytag; }
492 // Start a xml document
493 function xml_tag_make($type,$attbs,$retval=false) {
494 $melanie1 = explode("&",$attbs);
495 $melanienum=count($melanie1);
496 $melaniei=0; $attblist = null;
497 while ($melaniei < $melanienum) {
498 $melanie2 = explode("=",$melanie1[$melaniei]);
499 if($melanie2[0]!=null||$melanie2[1]!=null) {
500 $attblist = $attblist.' '.$melanie2[0].'="'.$melanie2[1].'"'; }
501 ++$melaniei; }
502 if($retval!==false&&$retval!==true) { $retval=false; }
503 if($retval===false) {
504 echo '<?'.$type.$attblist.'?>'."\n"; }
505 if($retval===true) {
506 return '<?'.$type.$attblist.'?>'."\n"; } }
507 // Start a xml document (old version)
508 function xml_doc_start($ver,$encode,$retval=false) {
509 if($retval===false) {
510 echo xml_tag_make('xml','version='.$ver.'&encoding='.$encode,true); }
511 if($retval===true) {
512 return xml_tag_make('xml','version='.$ver.'&encoding='.$encode,true); } }
513 $icharset = $Settings['charset'];
514 $debug_on = false;
515 if(isset($_GET['debug'])) {
516 if($_GET['debug']=="true"||
517 $_GET['debug']=="on") {
518 $debug_on = true; } }
519 $BoardURL = $Settings['idburl'];
520 // Change URLs to Links
521 function pre_url2link($matches) {
522 global $BoardURL; $opennew = true;
523 $burlCHCK = parse_url($BoardURL);
524 $urlCHCK = parse_url($matches[0]);
525 if($urlCHCK['host']==$burlCHCK['host']) {
526 $opennew = false; }
527 $outurl = $urlCHCK['scheme']."://";
528 if(isset($urlCHCK['user'])) {
529 $outurl = $outurl.$urlCHCK['user'];
530 if(isset($urlCHCK['pass'])) {
531 $outurl = $outurl.":".$urlCHCK['pass']; }
532 $outurl = $outurl."@"; }
533 $outurl = $outurl.$urlCHCK['host'];
534 if(isset($urlCHCK['path'])) {
535 $outurl = $outurl.$urlCHCK['path']; }
536 if(!isset($urlCHCK['path'])) {
537 $outurl = $outurl."/"; }
538 if(isset($urlCHCK['query'])) {
539 $urlCHCK['query'] = str_replace(" ", "+", $urlCHCK['query']);
540 $outurl = $outurl."?".$urlCHCK['query']; }
541 if(isset($urlCHCK['fragment'])) {
542 $urlCHCK['fragment'] = str_replace(" ", "+", $urlCHCK['fragment']);
543 $outurl = $outurl."#".$urlCHCK['fragment']; }
544 if($opennew===true) {
545 $outlink = "<a onclick=\"window.open(this.href); return false;\" href=\"".$outurl."\">".$outurl."</a>"; }
546 if($opennew===false) {
547 $outlink = "<a href=\"".$outurl."\">".$outurl."</a>"; }
548 return $outlink; }
549 function url2link($string) {
550 return preg_replace_callback("/(?<![\">])\b([a-zA-Z]+)\:\/\/([a-z0-9\-\.@\:]+)(\:[0-9]+)?\/([A-Za-z0-9\.\/%\?\!\$\(\)\*\-_\:;,\+\@~]+)?(\?)?([A-Za-z0-9\.\/%&\=\?\!\$\(\)\*\-_\:;,\+\@~]+)?(\#)?([A-Za-z0-9\.\/%&\=\?\!\$\(\)\*\-_\:;,\+\@~]+)?/is", "pre_url2link", $string); }
551 function urlcheck($string) {
552 global $BoardURL;
553 $retnum = preg_match_all("/([a-zA-Z]+)\:\/\/([a-z0-9\-\.@\:]+)(\:[0-9]+)?\/([A-Za-z0-9\.\/%\?\!\$\(\)\*\-_\:;,\+\@~]+)?(\?)?([A-Za-z0-9\.\/%&\=\?\!\$\(\)\*\-_\:;,\+\@~]+)?(\#)?([A-Za-z0-9\.\/%&\=\?\!\$\(\)\*\-_\:;,\+\@~]+)?/is", $string, $urlcheck);
554 if(isset($urlcheck[0][0])) { $url = $urlcheck[0][0]; }
555 if(!isset($urlcheck[0][0])) { $url = $BoardURL; }
556 return $url; }
557 //Check to make sure theme exists
558 $BoardTheme = $Settings['DefaultTheme'];
559 $ThemeDir = $SettDir['themes'];
560 function chack_themes($theme) {
561 global $BoardTheme,$ThemeDir;
562 if(!isset($theme)) { $theme = null; }
563 if(preg_match("/([a-zA-Z]+)\:/isU",$theme)) {
564 $theme = $BoardTheme; }
565 if(!preg_match("/^[a-z0-9]+$/isU",$theme)) {
566 $theme = $BoardTheme; }
567 require('settings.php');
568 $ckskindir = dirname(realpath("settings.php"))."/".$ThemeDir;
569 if ($handle = opendir($ckskindir)) { $dirnum = null;
570 while (false !== ($ckfile = readdir($handle))) {
571 if ($dirnum==null) { $dirnum = 0; }
572 if (is_dir($ckskindir.$ckfile)&&file_exists($ckskindir.$ckfile."/info.php")) {
573 if ($ckfile != "." && $ckfile != "..") {
574 //require($ckskindir.$ckfile."/info.php");
575 $cktheme[$dirnum] = $ckfile;
576 ++$dirnum; } } }
577 closedir($handle); asort($cktheme); }
578 $theme=preg_replace("/(.*?)\.\/(.*?)/", $BoardTheme, $theme);
579 if(!in_array($theme,$cktheme)||strlen($theme)>26) {
580 $theme = $BoardTheme; } return $theme; }
581 // Make a url with query string
582 function url_maker($file="index",$ext=".php",$qvarstr=null,$qstr=";",$qsep="=",$prexqstr=null,$exqstr=null,$fixhtml=true) {
583 global $sidurls, $icharset, $debug_on;
584 $fileurl = null; if(!isset($ext)) { $ext = null; }
585 if($ext==null) { $ext = ".php"; }
586 if($ext=="noext"||$ext=="no ext"||$ext=="no+ext") { $ext = null; }
587 $file = $file.$ext;
588 if($sidurls=="on"&&$qstr!="/") {
589 if(defined('SID')) {
590 if($qvarstr==null) { $qvarstr = SID; }
591 if($qvarstr!=null) { $qvarstr = SID."&".$qvarstr; } } }
592 if($debug_on===true) {
593 if($qvarstr==null) { $qvarstr = "debug=on"; }
594 if($qvarstr!=null) { $qvarstr = $qvarstr."&debug=on"; } }
595 if($qvarstr==null) { $fileurl = $file; }
596 if($fixhtml===true) {
597 $qstr = htmlentities($qstr, ENT_QUOTES, $icharset);
598 $qsep = htmlentities($qsep, ENT_QUOTES, $icharset); }
599 if($prexqstr!=null) {
600 $rene1 = explode("&",$prexqstr);
601 $renenum=count($rene1);
602 $renei=0;
603 $reneqstr = "index.php?";
604 if($qstr!="/") { $fileurl = $file."?"; }
605 if($qstr=="/") { $fileurl = $file."/"; }
606 while ($renei < $renenum) {
607 $rene2 = explode("=",$rene1[$renei]);
608 if(!isset($rene2[0])) { $rene2[0] = null; }
609 $rene2[1] = urlencode($rene2[1]);
610 if(!isset($rene2[0])) { $rene2[0] = null; }
611 $rene2[1] = urlencode($rene2[1]);
612 if($qstr!="/") {
613 $fileurl = $fileurl.$rene2[0].$qsep.$rene2[1]; }
614 if($qstr=="/") {
615 $fileurl = $fileurl.$rene2[0]."/".$rene2[1]."/"; }
616 $reneis = $renei + 1;
617 if($qstr!="/") {
618 if($reneis < $renenum) { $fileurl = $fileurl.$qstr; } }
619 ++$renei; } }
620 if($qvarstr!=null&&$qstr!="/") { $fileurl = $fileurl.$qstr; }
621 if($qvarstr!=null) {
622 if($prexqstr==null) {
623 if($qstr!="/") { $fileurl = $file."?"; }
624 if($qstr=="/") { $fileurl = $file."/"; } }
625 $cind1 = explode("&",$qvarstr);
626 $cindnum=count($cind1);
627 $cindi=0;
628 $cindqstr = "index.php?";
629 while ($cindi < $cindnum) {
630 $cind2 = explode("=",$cind1[$cindi]);
631 if(!isset($cind2[0])) { $cind2[0] = null; }
632 $cind2[0] = urlencode($cind2[0]);
633 if(!isset($cind2[1])) { $cind2[1] = null; }
634 $cind2[1] = urlencode($cind2[1]);
635 if($qstr!="/") {
636 $fileurl = $fileurl.$cind2[0].$qsep.$cind2[1]; }
637 if($qstr=="/") {
638 $fileurl = $fileurl.$cind2[0]."/".$cind2[1]."/"; }
639 $cindis = $cindi + 1;
640 if($qstr!="/") {
641 if($cindis < $cindnum) { $fileurl = $fileurl.$qstr; } }
642 ++$cindi; } }
643 if($exqstr!=null&&$qstr!="/") { $fileurl = $fileurl.$qstr; }
644 if($exqstr!=null) {
645 if($qvarstr==null&&$prexqstr==null) {
646 if($qstr!="/") { $fileurl = $file."?"; }
647 if($qstr=="/") { $fileurl = $file."/"; } }
648 $sand1 = explode("&",$exqstr);
649 $sanum=count($sand1);
650 $sandi=0;
651 $sandqstr = "index.php?";
652 while ($sandi < $sanum) {
653 $sand2 = explode("=",$sand1[$sandi]);
654 if(!isset($sand2[0])) { $sand2[0] = null; }
655 $sand2[0] = urlencode($sand2[0]);
656 if(!isset($sand2[1])) { $sand2[1] = null; }
657 $sand2[1] = urlencode($sand2[1]);
658 if($qstr!="/") {
659 $fileurl = $fileurl.$sand2[0].$qsep.$sand2[1]; }
660 if($qstr=="/") {
661 $fileurl = $fileurl.$sand2[0]."/".$sand2[1]."/"; }
662 $sandis = $sandi + 1;
663 if($qstr!="/") {
664 if($sandis < $sanum) { $fileurl = $fileurl.$qstr; } }
665 ++$sandi; } }
666 return $fileurl; }
667 $thisdir = dirname(realpath("Preindex.php"))."/";
668 // Get the Query String
669 function GetQueryStr($qstr=";",$qsep="=",$fixhtml=true)
670 { $pregqstr = preg_quote($qstr,"/");
671 $pregqsep = preg_quote($qsep,"/");
672 $oqstr = $qstr; $oqsep = $qsep;
673 if($fixhtml===true||$fixhtml==null) {
674 $qstr = htmlentities($qstr, ENT_QUOTES, $icharset);
675 $qsep = htmlentities($qsep, ENT_QUOTES, $icharset); }
676 $OldBoardQuery = preg_replace("/".$pregqstr."/isxS", $qstr, $_SERVER['QUERY_STRING']);
677 $BoardQuery = "?".$OldBoardQuery;
678 return $BoardQuery; }
679 function log_fix_quotes($logtxt) {
680 $logtxt = str_replace("\"", "\\\"", $logtxt);
681 $logtxt = str_replace("'", "", $logtxt);
682 return $logtxt; }
683 function get_server_values($matches) {
684 $return_text = "-";
685 if(isset($_SERVER[$matches[1]])) { $return_text = $_SERVER[$matches[1]]; }
686 if(!isset($_SERVER[$matches[1]])) { $return_text = "-"; }
687 return $return_text; }
688 function get_cookie_values($matches) {
689 $return_text = null;
690 if(isset($_COOKIE[$matches[1]])) { $return_text = $_COOKIE[$matches[1]]; }
691 if(!isset($_COOKIE[$matches[1]])) { $return_text = null; }
692 return $return_text; }
693 function get_env_values($matches) {
694 $return_text = getenv($matches[1]);
695 if(!isset($return_text)) { $return_text = "-"; }
696 return $return_text; }
697 function get_setting_values($matches) {
698 global $Settings;
699 $return_text = null;
700 $matches[1] = str_replace("sqlpass", "sqluser", $matches[1]);
701 if(isset($Settings[$matches[1]])) { $return_text = $Settings[$matches[1]]; }
702 if(!isset($Settings[$matches[1]])) { $return_text = null; }
703 return $return_text; }
704 function log_fix_get_server_values($matches) {
705 return log_fix_quotes(get_server_values($matches)); }
706 function log_fix_get_cookie_values($matches) {
707 return log_fix_quotes(get_cookie_values($matches)); }
708 function log_fix_get_env_values($matches) {
709 return log_fix_quotes(get_env_values($matches)); }
710 function log_fix_get_setting_values($matches) {
711 return log_fix_quotes(get_setting_values($matches)); }
712 function get_time($matches) {
713 return date(convert_strftime($matches[1])); }
714 function convert_strftime($strftime) {
715 $strftime = str_replace("%%", "{percent\}p", $strftime);
716 $strftime = str_replace("%a", "D", $strftime);
717 $strftime = str_replace("%A", "l", $strftime);
718 $strftime = str_replace("%d", "d", $strftime);
719 $strftime = str_replace("%e", "j", $strftime);
720 $strftime = str_replace("%j", "z", $strftime);
721 $strftime = str_replace("%u", "w", $strftime);
722 $strftime = str_replace("%w", "w", $strftime);
723 $strftime = str_replace("%U", "W", $strftime);
724 $strftime = str_replace("%V", "W", $strftime);
725 $strftime = str_replace("%W", "W", $strftime);
726 $strftime = str_replace("%b", "M", $strftime);
727 $strftime = str_replace("%B", "F", $strftime);
728 $strftime = str_replace("%h", "M", $strftime);
729 $strftime = str_replace("%m", "m", $strftime);
730 $strftime = str_replace("%g", "y", $strftime);
731 $strftime = str_replace("%G", "Y", $strftime);
732 $strftime = str_replace("%y", "y", $strftime);
733 $strftime = str_replace("%Y", "Y", $strftime);
734 $strftime = str_replace("%H", "H", $strftime);
735 $strftime = str_replace("%I", "h", $strftime);
736 $strftime = str_replace("%l", "g", $strftime);
737 $strftime = str_replace("%M", "i", $strftime);
738 $strftime = str_replace("%p", "A", $strftime);
739 $strftime = str_replace("%P", "a", $strftime);
740 $strftime = str_replace("%r", "h:i:s A", $strftime);
741 $strftime = str_replace("%R", "H:i", $strftime);
742 $strftime = str_replace("%S", "s", $strftime);
743 $strftime = str_replace("%T", "H:i:s", $strftime);
744 $strftime = str_replace("%X", "H:i:s", $strftime);
745 $strftime = str_replace("%z", "O", $strftime);
746 $strftime = str_replace("%Z", "O", $strftime);
747 $strftime = str_replace("%c", "D M j H:i:s Y", $strftime);
748 $strftime = str_replace("%D", "m/d/y", $strftime);
749 $strftime = str_replace("%F", "Y-m-d", $strftime);
750 $strftime = str_replace("%x", "m/d/y", $strftime);
751 $strftime = str_replace("%n", "\n", $strftime);
752 $strftime = str_replace("%t", "\t", $strftime);
753 $strftime = preg_replace("/\{percent\}p/s", "%", $strftime);
754 return $strftime; }
755 function apache_log_maker($logtxt,$logfile=null,$status=200,$contentsize="-",$headersize=0) {
756 global $Settings;
757 if(isset($Settings['DefaultTimeZone'])) {
758 $servtz = new DateTimeZone($Settings['DefaultTimeZone']); }
759 if(!isset($Settings['DefaultTimeZone'])) {
760 $servtz = new DateTimeZone(date_default_timezone_get()); }
761 $servcurtime = new DateTime();
762 $servcurtime->setTimezone($servtz);
763 if(!isset($_SERVER['HTTP_REFERER'])) { $LOG_URL_REFERER = "-"; }
764 if(isset($_SERVER['HTTP_REFERER'])) { $LOG_URL_REFERER = $_SERVER['HTTP_REFERER']; }
765 if($LOG_URL_REFERER==""||$LOG_URL_REFERER==null) { $LOG_URL_REFERER = "-"; }
766 if(trim($LOG_URL_REFERER, "\x00..\x1F") == "") { $LOG_URL_REFERER = "-"; }
767 $LOG_URL_REFERER = log_fix_quotes($LOG_URL_REFERER);
768 if(!isset($_SERVER['PHP_AUTH_USER'])) { $LOG_AUTH_USER = "-"; }
769 if(isset($_SERVER['PHP_AUTH_USER'])) { $LOG_AUTH_USER = $_SERVER['PHP_AUTH_USER']; }
770 if($LOG_AUTH_USER==""||$LOG_AUTH_USER==null) { $LOG_AUTH_USER = "-"; }
771 if(trim($LOG_AUTH_USER, "\x00..\x1F") == "") { $LOG_AUTH_USER = "-"; }
772 $LOG_AUTH_USER = log_fix_quotes($LOG_AUTH_USER);
773 if(!isset($_SERVER["HTTP_USER_AGENT"])) { $LOG_USER_AGENT = "-"; }
774 if(isset($_SERVER["HTTP_USER_AGENT"])) { $LOG_USER_AGENT = $_SERVER["HTTP_USER_AGENT"]; }
775 if($LOG_USER_AGENT==""||$LOG_USER_AGENT==null) { $LOG_USER_AGENT = "-"; }
776 if(trim($LOG_USER_AGENT, "\x00..\x1F") == "") { $LOG_USER_AGENT = "-"; }
777 $LOG_USER_AGENT = log_fix_quotes($LOG_USER_AGENT);
778 $LogMemName = "-";
779 if(!isset($_SESSION['MemberName'])) {
780 $_SESSION['MemberName'] = null; }
781 if($_SESSION['MemberName']===null) {
782 $LogMemName = "-"; }
783 if(isset($_SESSION['MemberName'])&&$_SESSION['MemberName']!==null) {
784 $LogMemName = $_SESSION['MemberName']; }
785 if(trim($LogMemName, "\x00..\x1F") == "") { $LogMemName = "-"; }
786 $LogMemName = log_fix_quotes($LogMemName);
787 $LogMemID = "-";
788 if(!isset($_SESSION['UserID'])) {
789 $_SESSION['UserID'] = 0; }
790 if($_SESSION['UserID']===null||$_SESSION['UserID']===0) {
791 $LogMemID = "-"; }
792 if(isset($_SESSION['UserID'])&&$_SESSION['UserID']!==null&&$_SESSION['UserID']!==0) {
793 $LogMemID = $_SESSION['UserID']; }
794 if(trim($LogMemID, "\x00..\x1F") == "") { $LogMemID = "-"; }
795 $LogMemID = log_fix_quotes($LogMemID);
796 $LogGroupName = "-";
797 if(!isset($_SESSION['UserGroup'])) {
798 $LogGroupName = "-"; }
799 if(isset($_SESSION['UserGroup'])&&$_SESSION['UserGroup']===null) {
800 $LogGroupName = "-"; }
801 if(isset($_SESSION['UserGroup'])&&$_SESSION['UserGroup']!==null) {
802 $LogGroupName = $_SESSION['UserGroup']; }
803 if(trim($LogGroupName, "\x00..\x1F") == "") { $LogGroupName = "-"; }
804 $LogGroupName = log_fix_quotes($LogGroupName);
805 $LogGroupID = "-";
806 if(!isset($_SESSION['UserGroupID'])) {
807 $LogGroupID = "-"; }
808 if(isset($_SESSION['UserGroupID'])&&$_SESSION['UserGroupID']===null) {
809 $LogGroupID = "-"; }
810 if(isset($_SESSION['UserGroupID'])&&$_SESSION['UserGroupID']!==null) {
811 $LogGroupID = $_SESSION['UserGroupID']; }
812 if(trim($LogGroupID, "\x00..\x1F") == "") { $LogGroupID = "-"; }
813 $LogGroupID = log_fix_quotes($LogGroupID);
814 $LOG_QUERY_STRING = "";
815 if($_SERVER["QUERY_STRING"]!=="") {
816 $LOG_QUERY_STRING = "?".$_SERVER["QUERY_STRING"]; }
817 if(trim($LOG_QUERY_STRING, "\x00..\x1F") == "") { $LOG_QUERY_STRING = ""; }
818 $LOG_QUERY_STRING = log_fix_quotes($LOG_QUERY_STRING);
819 $oldcontentsize = $contentsize;
820 if($oldcontentsize=="-") { $oldcontentsize = 0; }
821 if($contentsize===0) { $contentsize = "-"; }
822 if($contentsize=="-"&&$headersize!==0) { $fullsitesize = $headersize; }
823 if($contentsize!="-"&&$headersize!==0) { $fullsitesize = $contentsize + $headersize; }
824 if($status=="302") { $contentsize = "-"; }
825 $HTTP_REQUEST_LINE = $_SERVER["REQUEST_METHOD"]." ".$_SERVER["REQUEST_URI"]." ".$_SERVER["SERVER_PROTOCOL"];
826 $HTTP_REQUEST_LINE = log_fix_quotes($HTTP_REQUEST_LINE);
827 $logtxt = preg_replace("/%%/s", "{percent}p", $logtxt);
828 $logtxt = preg_replace("/%([\<\>]*?)a/s", $_SERVER['REMOTE_ADDR'], $logtxt);
829 $logtxt = preg_replace("/%([\<\>]*?)A/s", $_SERVER["SERVER_ADDR"], $logtxt);
830 $logtxt = preg_replace("/%([\<\>]*?)B/s", $oldcontentsize, $logtxt);
831 $logtxt = preg_replace("/%([\<\>]*?)b/s", $contentsize, $logtxt);
832 $logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}C/s", "get_cookie_values", $logtxt);
833 $logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}e/s", "get_env_values", $logtxt);
834 $logtxt = preg_replace("/%([\<\>]*?)f/s", log_fix_quotes($_SERVER["SCRIPT_FILENAME"]), $logtxt);
835 $logtxt = preg_replace("/%([\<\>]*?)h/s", $_SERVER['REMOTE_ADDR'], $logtxt);
836 $logtxt = preg_replace("/%([\<\>]*?)H/s", $_SERVER["SERVER_PROTOCOL"], $logtxt);
837 $logtxt = preg_replace("/%([\<\>]*?)\{Referer\}i/s", $LOG_URL_REFERER, $logtxt);
838 $logtxt = preg_replace("/%([\<\>]*?)\{User-Agent\}i/s", $LOG_USER_AGENT, $logtxt);
839 $logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}i/s", "get_server_values", $logtxt);
840 $logtxt = preg_replace("/%([\<\>]*?)l/s", "-", $logtxt);
841 $logtxt = preg_replace("/%([\<\>]*?)m/s", $_SERVER["REQUEST_METHOD"], $logtxt);
842 $logtxt = preg_replace("/%([\<\>]*?)p/s", $_SERVER["SERVER_PORT"], $logtxt);
843 $logtxt = preg_replace("/%([\<\>]*?)q/s", $LOG_QUERY_STRING, $logtxt);
844 $logtxt = preg_replace("/%([\<\>]*?)r/s", $HTTP_REQUEST_LINE, $logtxt);
845 $logtxt = preg_replace("/%([\<\>]*?)s/s", $status, $logtxt);
846 $logtxt = preg_replace("/%([\<\>]*?)t/s", "[".$servcurtime->format("d/M/Y:H:i:s O")."]", $logtxt);
847 $logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}t/s", "get_time", $logtxt);
848 $logtxt = preg_replace("/%([\<\>]*?)u/s", $LOG_AUTH_USER, $logtxt);
849 $logtxt = preg_replace("/%([\<\>]*?)U/s", log_fix_quotes($_SERVER["PHP_SELF"]), $logtxt);
850 $logtxt = preg_replace("/%([\<\>]*?)v/s", $_SERVER["SERVER_NAME"], $logtxt);
851 $logtxt = preg_replace("/%([\<\>]*?)V/s", $_SERVER["SERVER_NAME"], $logtxt);
852 // Not what it should be but PHP dose not have variable to get Apache ServerName config value. :(
853 $logtxt = preg_replace("/%([\<\>]*?)O/s", $fullsitesize, $logtxt);
854 $logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}s/s", "get_setting_values", $logtxt);
855 $logtxt = preg_replace("/\%\{UserName\}m/s", $LogMemName, $logtxt);
856 $logtxt = preg_replace("/\%\{MemberName\}m/s", $LogMemName, $logtxt);
857 $logtxt = preg_replace("/\%\{UserID\}m/s", $LogMemID, $logtxt);
858 $logtxt = preg_replace("/\%\{MemberID\}m/s", $LogMemID, $logtxt);
859 $logtxt = preg_replace("/\%\{UserGroup\}m/s", $LogGroupName, $logtxt);
860 $logtxt = preg_replace("/\%\{MemberGroup\}m/s", $LogGroupName, $logtxt);
861 $logtxt = preg_replace("/\%\{UserGroupID\}m/s", $LogGroupID, $logtxt);
862 $logtxt = preg_replace("/\%\{MemberGroupID\}m/s", $LogGroupID, $logtxt);
863 $logtxt = preg_replace("/\{percent\}p/s", "%", $logtxt);
864 if(isset($logfile)&&$logfile!==null) {
865 $fp = fopen($logfile, "a+");
866 if (flock($fp, LOCK_EX)) {
867 $logtxtnew = $logtxt."\r\n";
868 fwrite($fp, $logtxtnew, strlen($logtxtnew));
869 flock($fp, LOCK_UN); }
870 fclose($fp);
871 @chmod($logfile, 0666); }
872 return $logtxt; }
873 function idb_log_maker($status=200,$contentsize="-") {
874 global $Settings,$SettDir;
875 if(isset($Settings['DefaultTimeZone'])) {
876 $servtz = new DateTimeZone($Settings['DefaultTimeZone']); }
877 if(!isset($Settings['DefaultTimeZone'])) {
878 $servtz = new DateTimeZone(date_default_timezone_get()); }
879 $servcurtime = new DateTime();
880 $servcurtime->setTimezone($servtz);
881 if(!isset($Settings['log_http_request'])) {
882 $Settings['log_http_request'] = "off"; }
883 if(!isset($Settings['log_config_format'])) {
884 $Settings['log_config_format'] = "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""; }
885 if(isset($Settings['log_http_request'])&&$Settings['log_http_request']=="on"&&
886 $Settings['log_http_request']!==null&&$Settings['log_http_request']!="off") {
887 return apache_log_maker($Settings['log_config_format'], $SettDir['logs'].$Settings['sqltable'].$servcurtime->format("Ym").".log", $status, $contentsize, strlen(implode("\r\n",headers_list())."\r\n\r\n")); }
888 if(isset($Settings['log_http_request'])&&$Settings['log_http_request']!="on"&&
889 $Settings['log_http_request']!==null&&$Settings['log_http_request']!="off") {
890 $Settings['log_http_request'] = preg_replace_callback("/".preg_quote("%{", "/")."([^\}]*)".preg_quote("}t", "/")."/s", "get_time", $Settings['log_http_request']);
891 $Settings['log_http_request'] = preg_replace_callback("/".preg_quote("%{", "/")."([^\}]*)".preg_quote("}s", "/")."/s", "get_setting_values", $Settings['log_http_request']);
892 return apache_log_maker($Settings['log_config_format'], $SettDir['logs'].$Settings['log_http_request'], $status, $contentsize, strlen(implode("\r\n",headers_list())."\r\n\r\n")); } }