MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Revised BSD License for more details.
- Copyright 2004-2010 iDB Support - http://idb.berlios.de/
- Copyright 2004-2010 Game Maker 2k - http://gamemaker2k.org/
+ Copyright 2004-2017 iDB Support - http://idb.berlios.de/
+ Copyright 2004-2017 Game Maker 2k - http://gamemaker2k.org/
- $FileInfo: function.php - Last Update: 06/13/2010 SVN 526 - Author: cooldude2k $
+ $FileInfo: function.php - Last Update: 06/23/2019 SVN 896 - Author: cooldude2k $
*/
$File3Name = basename($_SERVER['SCRIPT_NAME']);
if ($File3Name=="function.php"||$File3Name=="/function.php") {
require('index.php');
exit(); }
require_once($SettDir['misc'].'functions.php');
+require_once($SettDir['misc'].'ibbcode.php');
+require_once($SettDir['misc'].'iuntar.php');
+/* In php 6 and up the function get_magic_quotes_gpc dose not exist.
+ here we make a fake version that always sends false out. :P */
+if(!function_exists('get_magic_quotes_gpc')) {
+function get_magic_quotes_gpc() { return false; } }
+/**
+ * Undo the damage of magic_quotes_gpc if in effect
+ * @return bool
+ * @link http://www.charles-reace.com/blog/2010/07/13/undoing-magic-quotes/
+ */
+function fix_magic_quotes()
+{
+ if (get_magic_quotes_gpc()) {
+ $func = create_function(
+ '&$val, $key',
+ 'if(!is_numeric($val)) {$val = stripslashes($val);}'
+ );
+ array_walk_recursive($_GET, $func);
+ array_walk_recursive($_POST, $func);
+ array_walk_recursive($_COOKIE, $func);
+ }
+ return true;
+}
+fix_magic_quotes();
/* Change Some PHP Settings Fix the & to &
if($Settings['use_iniset']==true&&$Settings['qstr']!="/") {
ini_set("arg_separator.output",htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']));
function output_error($message, $level=E_USER_ERROR) {
$caller = next(debug_backtrace());
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); }
+ $Names['D'] = "Dagmara";
+define("_dagmara_", $Names['D']);
+// By s rotondo90 at gmail com at https://www.php.net/manual/en/function.random-int.php#119670
+if (!function_exists('random_int')) {
+ function random_int($min, $max) {
+ if (!function_exists('mcrypt_create_iv')) {
+ trigger_error(
+ 'mcrypt must be loaded for random_int to work',
+ E_USER_WARNING
+ );
+ return null;
+ }
+
+ if (!is_int($min) || !is_int($max)) {
+ trigger_error('$min and $max must be integer values', E_USER_NOTICE);
+ $min = (int)$min;
+ $max = (int)$max;
+ }
+
+ if ($min > $max) {
+ trigger_error('$max can\'t be lesser than $min', E_USER_WARNING);
+ return null;
+ }
+
+ $range = $counter = $max - $min;
+ $bits = 1;
+
+ while ($counter >>= 1) {
+ ++$bits;
+ }
+
+ $bytes = (int)max(ceil($bits/8), 1);
+ $bitmask = pow(2, $bits) - 1;
+
+ if ($bitmask >= PHP_INT_MAX) {
+ $bitmask = PHP_INT_MAX;
+ }
+
+ do {
+ $result = hexdec(
+ bin2hex(
+ mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
+ )
+ ) & $bitmask;
+ } while ($result > $range);
+
+ return $result + $min;
+ }
+}
// http://us.php.net/manual/en/function.uniqid.php#94959
/**
* Generates an UUID
(hexdec(substr($hash, 12, 4)) & 0x0fff) | $uuidverid,
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
substr($hash, 20, 12) ); } }
+// By info at raymondrodgers dot com at https://www.php.net/manual/en/function.random-int.php#118636
+function generateUUIDv4()
+{
+ if(version_compare(PHP_VERSION,'7.0.0', '<') )
+ {
+ return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
+
+ // 32 bits for "time_low"
+ mt_rand(0, 0xffff), mt_rand(0, 0xffff),
+
+ // 16 bits for "time_mid"
+ mt_rand(0, 0xffff),
+
+ // 16 bits for "time_hi_and_version",
+ // four most significant bits holds version number 4
+ mt_rand(0, 0x0fff) | 0x4000,
+
+ // 16 bits, 8 bits for "clk_seq_hi_res",
+ // 8 bits for "clk_seq_low",
+ // two most significant bits holds zero and one for variant DCE1.1
+ mt_rand(0, 0x3fff) | 0x8000,
+
+ // 48 bits for "node"
+ mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
+ );
+ }
+ else
+ {
+ return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
+
+ // 32 bits for "time_low"
+ random_int(0, 0xffff), random_int(0, 0xffff),
+
+ // 16 bits for "time_mid"
+ random_int(0, 0xffff),
+
+ // 16 bits for "time_hi_and_version",
+ // four most significant bits holds version number 4
+ random_int(0, 0x0fff) | 0x4000,
+
+ // 16 bits, 8 bits for "clk_seq_hi_res",
+ // 8 bits for "clk_seq_low",
+ // two most significant bits holds zero and one for variant DCE1.1
+ random_int(0, 0x3fff) | 0x8000,
+
+ // 48 bits for "node"
+ random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff)
+ );
+ }
+}
function rand_uuid($rndty = "rand", $namespace = null, $name = null) {
$rand_array = array(1 => "v3", 2 => "v4", 3 => "v5");
if($name===null) { $name = salt_hmac(); }
if($my_uuid=="v3"||$my_uuid=="v5") {
return uuid($my_uuid,$rndty,$name); } }
// unserialize sessions variables
-function unserialize_session($data) {
- $vars=preg_split('/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/',
- $data,-1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
- $i = 0;
- for($i=0; isset($vars[$i]); $i++) {
- $l = $i + 1;
- if(!isset($vars[$i])) { $vars[$i] = null; }
- if(!isset($vars[$l])) { $vars[$l] = null; }
- $result[$vars[$i]]=unserialize($vars[$l]);
- $i++; }
- if(!isset($result)) { $result = null; }
- return $result;
+// By: jason@joeymail.net
+// URL: http://us2.php.net/manual/en/function.session-decode.php#101687
+function unserialize_session($data)
+{
+ if( strlen( $data) == 0)
+ {
+ return array();
+ }
+ // match all the session keys and offsets
+ preg_match_all('/(^|;|\})([a-zA-Z0-9_]+)\|/i', $data, $matchesarray, PREG_OFFSET_CAPTURE);
+ $returnArray = array();
+ $lastOffset = null;
+ $currentKey = '';
+ foreach ( $matchesarray[2] as $value )
+ {
+ $offset = $value[1];
+ if(!is_null( $lastOffset))
+ {
+ $valueText = substr($data, $lastOffset, $offset - $lastOffset );
+ $returnArray[$currentKey] = unserialize($valueText);
+ }
+ $currentKey = $value[0];
+ $lastOffset = $offset + strlen( $currentKey )+1;
+ }
+ $valueText = substr($data, $lastOffset );
+ $returnArray[$currentKey] = unserialize($valueText);
+ return $returnArray;
}
-// User Agent Checker
-function user_agent_check($user_agent) {
-if (preg_match("/".preg_quote("ia_archiver")."/i", $user_agent)) {
- return "Alexa"; }
-if (preg_match("/".preg_quote("AltaVista")."/i", $user_agent)) {
- return "AltaVista"; }
-if (preg_match("/".preg_quote("Ask Jeeves")."/i", $user_agent)) {
- return "Ask Jeeves"; }
-if (preg_match("/".preg_quote("Baiduspider")."/i", $user_agent)) {
- return "Baidu"; }
-if (preg_match("/".preg_quote("msnbot")."/i", $user_agent)) {
- return "Bing"; }
-if (preg_match("/".preg_quote("CSE HTML Validator")."/i", $user_agent)) {
- return "CSE HTML Validator"; }
-if (preg_match("/".preg_quote("discobot")."/i", $user_agent)) {
- return "DiscoveryEngine"; }
-if (preg_match("/".preg_quote("Exabot")."/i", $user_agent)) {
- return "Exabot"; }
-if (preg_match("/".preg_quote("Googlebot")."/i", $user_agent)) {
- return "Google"; }
-if (preg_match("|".preg_quote("HTML/XML Validator","|")."|i", $user_agent)) {
- return "HTML/XML Validator"; }
-if (preg_match("/".preg_quote("Lycos")."/i", $user_agent)) {
- return "Lycos"; }
-if (preg_match("/".preg_quote("montastic-webmonitor")."/i", $user_agent)) {
- return "Montastic"; }
-if (preg_match("/".preg_quote("Sosospider")."/i", $user_agent)) {
- return "Soso"; }
-if (preg_match("/".preg_quote("Speedy Spider")."/i", $user_agent)) {
- return "Speedy"; }
-if (preg_match("/".preg_quote("TotalValidator")."/i", $user_agent)) {
- return "Total Validator"; }
-if (preg_match("/".preg_quote("Yahoo")."/i", $user_agent)) {
- return "Yahoo"; }
-if (preg_match("/".preg_quote("Yandex")."/i", $user_agent)) {
- return "Yandex"; }
-if (preg_match("/".preg_quote("FeedValidator")."/i", $user_agent)) {
- return "W3C Validator"; }
-if (preg_match("/".preg_quote("W3C_CSS_Validator")."/i", $user_agent)) {
- return "W3C Validator"; }
-if (preg_match("/".preg_quote("W3C_Validator")."/i", $user_agent)) {
- return "W3C Validator"; }
-if (preg_match("/".preg_quote("W3C-checklink")."/i", $user_agent)) {
- return "W3C Checklink"; }
-if (preg_match("/".preg_quote("WDG_SiteValidator")."/i", $user_agent)) {
- return "WDG Validator"; }
-if (preg_match("/".preg_quote("WDG_Validator")."/i", $user_agent)) {
- return "WDG Validator"; }
- return false; }
// Make the Query String if we are not useing &=
function qstring($qstr=";",$qsep="=")
{ $_GET = array(); $_GET = null;
if (!isset($_SERVER['QUERY_STRING'])) {
$_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); }
-ini_get("arg_separator.input", $qstr);
+ini_set("arg_separator.input", $qstr);
$_SERVER['QUERY_STRING'] = urldecode($_SERVER['QUERY_STRING']);
$preqs = explode($qstr,$_SERVER["QUERY_STRING"]);
$qsnum = count($preqs); $qsi = 0;
if($preqst[0]!=null) {
$_GET[$preqst[0]] = $preqst[1]; }
++$qsi; } return true; }
+if($Settings['qstr']!="&"&&
+ $Settings['qstr']!="/") {
+qstring($Settings['qstr'],$Settings['qsep']);
+if(!isset($_GET['page'])) { $_GET['page'] = null; }
+if(!isset($_GET['act'])) { $_GET['act'] = null; }
+if(!isset($_POST['act'])) { $_POST['act'] = null; }
+if(!isset($_GET['id'])) { $_GET['id'] = null; }
+if(!isset($_GET['debug'])) { $_GET['debug'] = "false"; }
+if(!isset($_GET['post'])) { $_GET['post'] = null; }
+if(!isset($_POST['License'])) { $_POST['License'] = null; } }
if($_SERVER['PATH_INFO']==null) {
if(getenv('PATH_INFO')!=null&&getenv('PATH_INFO')!="1") {
$_SERVER['PATH_INFO'] = getenv('PATH_INFO'); }
function redirects($type,$url,$time=0) {
if($type!="location"&&$type!="refresh") { $type=="location"; }
if($type=="refresh") { header("Refresh: ".$time."; URL=".$url); }
+if($type=="location") { idb_log_maker(302,"-"); }
if($type=="location") { header("Location: ".$url); } return true; }
// Make xhtml tags
function html_tag_make($name="br",$emptytag=true,$attbvar=null,$attbval=null,$extratest=null) {
return $mytag; }
// Start a xml document
function xml_tag_make($type,$attbs,$retval=false) {
- $renee1 = explode("&",$attbs);
- $reneenum=count($renee1);
- $reneei=0; $attblist = null;
- while ($reneei < $reneenum) {
- $renee2 = explode("=",$renee1[$reneei]);
- if($renee2[0]!=null||$renee2[1]!=null) {
- $attblist = $attblist.' '.$renee2[0].'="'.$renee2[1].'"'; }
- ++$reneei; }
+ $melanie1 = explode("&",$attbs);
+ $melanienum=count($melanie1);
+ $melaniei=0; $attblist = null;
+ while ($melaniei < $melanienum) {
+ $melanie2 = explode("=",$melanie1[$melaniei]);
+ if($melanie2[0]!=null||$melanie2[1]!=null) {
+ $attblist = $attblist.' '.$melanie2[0].'="'.$melanie2[1].'"'; }
+ ++$melaniei; }
if($retval!==false&&$retval!==true) { $retval=false; }
if($retval===false) {
echo '<?'.$type.$attblist.'?>'."\n"; }
$outlink = "<a href=\"".$outurl."\">".$outurl."</a>"; }
return $outlink; }
function url2link($string) {
-return preg_replace_callback("/([a-zA-Z]+)\:\/\/([a-z0-9\-\.]+)(\:[0-9]+)?\/([A-Za-z0-9\.\/%\?\-_;]+)?(\?)?([A-Za-z0-9\.\/%&=\?\-_;]+)?(\#)?([A-Za-z0-9\.\/%&=\?\-_;]+)?/is", "pre_url2link", $string); }
+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); }
function urlcheck($string) {
global $BoardURL;
-$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);
+$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);
if(isset($urlcheck[0][0])) { $url = $urlcheck[0][0]; }
if(!isset($urlcheck[0][0])) { $url = $BoardURL; }
return $url; }
if ($handle = opendir($ckskindir)) { $dirnum = null;
while (false !== ($ckfile = readdir($handle))) {
if ($dirnum==null) { $dirnum = 0; }
- if (file_exists($ckskindir.$ckfile."/info.php")) {
+ if (is_dir($ckskindir.$ckfile)&&file_exists($ckskindir.$ckfile."/info.php")) {
if ($ckfile != "." && $ckfile != "..") {
- //include($ckskindir.$ckfile."/info.php");
+ //require($ckskindir.$ckfile."/info.php");
$cktheme[$dirnum] = $ckfile;
++$dirnum; } } }
closedir($handle); asort($cktheme); }
$OldBoardQuery = preg_replace("/".$pregqstr."/isxS", $qstr, $_SERVER['QUERY_STRING']);
$BoardQuery = "?".$OldBoardQuery;
return $BoardQuery; }
+function log_fix_quotes($logtxt) {
+ $logtxt = str_replace("\"", "\\\"", $logtxt);
+ $logtxt = str_replace("'", "", $logtxt);
+ return $logtxt; }
+function get_server_values($matches) {
+ $return_text = "-";
+ if(isset($_SERVER[$matches[1]])) { $return_text = $_SERVER[$matches[1]]; }
+ if(!isset($_SERVER[$matches[1]])) { $return_text = "-"; }
+ return $return_text; }
+function get_cookie_values($matches) {
+ $return_text = null;
+ if(isset($_COOKIE[$matches[1]])) { $return_text = $_COOKIE[$matches[1]]; }
+ if(!isset($_COOKIE[$matches[1]])) { $return_text = null; }
+ return $return_text; }
+function get_env_values($matches) {
+ $return_text = getenv($matches[1]);
+ if(!isset($return_text)) { $return_text = "-"; }
+ return $return_text; }
+function get_setting_values($matches) {
+ global $Settings;
+ $return_text = null;
+ $matches[1] = str_replace("sqlpass", "sqluser", $matches[1]);
+ if(isset($Settings[$matches[1]])) { $return_text = $Settings[$matches[1]]; }
+ if(!isset($Settings[$matches[1]])) { $return_text = null; }
+ return $return_text; }
+function log_fix_get_server_values($matches) {
+ return log_fix_quotes(get_server_values($matches)); }
+function log_fix_get_cookie_values($matches) {
+ return log_fix_quotes(get_cookie_values($matches)); }
+function log_fix_get_env_values($matches) {
+ return log_fix_quotes(get_env_values($matches)); }
+function log_fix_get_setting_values($matches) {
+ return log_fix_quotes(get_setting_values($matches)); }
+function get_time($matches) {
+ return date(convert_strftime($matches[1])); }
+function convert_strftime($strftime) {
+$strftime = str_replace("%%", "{percent\}p", $strftime);
+$strftime = str_replace("%a", "D", $strftime);
+$strftime = str_replace("%A", "l", $strftime);
+$strftime = str_replace("%d", "d", $strftime);
+$strftime = str_replace("%e", "j", $strftime);
+$strftime = str_replace("%j", "z", $strftime);
+$strftime = str_replace("%u", "w", $strftime);
+$strftime = str_replace("%w", "w", $strftime);
+$strftime = str_replace("%U", "W", $strftime);
+$strftime = str_replace("%V", "W", $strftime);
+$strftime = str_replace("%W", "W", $strftime);
+$strftime = str_replace("%b", "M", $strftime);
+$strftime = str_replace("%B", "F", $strftime);
+$strftime = str_replace("%h", "M", $strftime);
+$strftime = str_replace("%m", "m", $strftime);
+$strftime = str_replace("%g", "y", $strftime);
+$strftime = str_replace("%G", "Y", $strftime);
+$strftime = str_replace("%y", "y", $strftime);
+$strftime = str_replace("%Y", "Y", $strftime);
+$strftime = str_replace("%H", "H", $strftime);
+$strftime = str_replace("%I", "h", $strftime);
+$strftime = str_replace("%l", "g", $strftime);
+$strftime = str_replace("%M", "i", $strftime);
+$strftime = str_replace("%p", "A", $strftime);
+$strftime = str_replace("%P", "a", $strftime);
+$strftime = str_replace("%r", "h:i:s A", $strftime);
+$strftime = str_replace("%R", "H:i", $strftime);
+$strftime = str_replace("%S", "s", $strftime);
+$strftime = str_replace("%T", "H:i:s", $strftime);
+$strftime = str_replace("%X", "H:i:s", $strftime);
+$strftime = str_replace("%z", "O", $strftime);
+$strftime = str_replace("%Z", "O", $strftime);
+$strftime = str_replace("%c", "D M j H:i:s Y", $strftime);
+$strftime = str_replace("%D", "m/d/y", $strftime);
+$strftime = str_replace("%F", "Y-m-d", $strftime);
+$strftime = str_replace("%x", "m/d/y", $strftime);
+$strftime = str_replace("%n", "\n", $strftime);
+$strftime = str_replace("%t", "\t", $strftime);
+$strftime = preg_replace("/\{percent\}p/s", "%", $strftime);
+return $strftime; }
+function apache_log_maker($logtxt,$logfile=null,$status=200,$contentsize="-",$headersize=0) {
+global $Settings;
+if(isset($Settings['DefaultTimeZone'])) {
+$servtz = new DateTimeZone($Settings['DefaultTimeZone']); }
+if(!isset($Settings['DefaultTimeZone'])) {
+$servtz = new DateTimeZone(date_default_timezone_get()); }
+$servcurtime = new DateTime();
+$servcurtime->setTimezone($servtz);
+if(!isset($_SERVER['HTTP_REFERER'])) { $LOG_URL_REFERER = "-"; }
+if(isset($_SERVER['HTTP_REFERER'])) { $LOG_URL_REFERER = $_SERVER['HTTP_REFERER']; }
+if($LOG_URL_REFERER==""||$LOG_URL_REFERER==null) { $LOG_URL_REFERER = "-"; }
+if(trim($LOG_URL_REFERER, "\x00..\x1F") == "") { $LOG_URL_REFERER = "-"; }
+$LOG_URL_REFERER = log_fix_quotes($LOG_URL_REFERER);
+if(!isset($_SERVER['PHP_AUTH_USER'])) { $LOG_AUTH_USER = "-"; }
+if(isset($_SERVER['PHP_AUTH_USER'])) { $LOG_AUTH_USER = $_SERVER['PHP_AUTH_USER']; }
+if($LOG_AUTH_USER==""||$LOG_AUTH_USER==null) { $LOG_AUTH_USER = "-"; }
+if(trim($LOG_AUTH_USER, "\x00..\x1F") == "") { $LOG_AUTH_USER = "-"; }
+$LOG_AUTH_USER = log_fix_quotes($LOG_AUTH_USER);
+if(!isset($_SERVER["HTTP_USER_AGENT"])) { $LOG_USER_AGENT = "-"; }
+if(isset($_SERVER["HTTP_USER_AGENT"])) { $LOG_USER_AGENT = $_SERVER["HTTP_USER_AGENT"]; }
+if($LOG_USER_AGENT==""||$LOG_USER_AGENT==null) { $LOG_USER_AGENT = "-"; }
+if(trim($LOG_USER_AGENT, "\x00..\x1F") == "") { $LOG_USER_AGENT = "-"; }
+$LOG_USER_AGENT = log_fix_quotes($LOG_USER_AGENT);
+$LogMemName = "-";
+if(!isset($_SESSION['MemberName'])) {
+ $_SESSION['MemberName'] = null; }
+if($_SESSION['MemberName']===null) {
+ $LogMemName = "-"; }
+if(isset($_SESSION['MemberName'])&&$_SESSION['MemberName']!==null) {
+ $LogMemName = $_SESSION['MemberName']; }
+if(trim($LogMemName, "\x00..\x1F") == "") { $LogMemName = "-"; }
+$LogMemName = log_fix_quotes($LogMemName);
+$LogMemID = "-";
+if(!isset($_SESSION['UserID'])) {
+ $_SESSION['UserID'] = 0; }
+if($_SESSION['UserID']===null||$_SESSION['UserID']===0) {
+ $LogMemID = "-"; }
+if(isset($_SESSION['UserID'])&&$_SESSION['UserID']!==null&&$_SESSION['UserID']!==0) {
+ $LogMemID = $_SESSION['UserID']; }
+if(trim($LogMemID, "\x00..\x1F") == "") { $LogMemID = "-"; }
+$LogMemID = log_fix_quotes($LogMemID);
+$LogGroupName = "-";
+if(!isset($_SESSION['UserGroup'])) {
+ $LogGroupName = "-"; }
+if(isset($_SESSION['UserGroup'])&&$_SESSION['UserGroup']===null) {
+ $LogGroupName = "-"; }
+if(isset($_SESSION['UserGroup'])&&$_SESSION['UserGroup']!==null) {
+ $LogGroupName = $_SESSION['UserGroup']; }
+if(trim($LogGroupName, "\x00..\x1F") == "") { $LogGroupName = "-"; }
+$LogGroupName = log_fix_quotes($LogGroupName);
+$LogGroupID = "-";
+if(!isset($_SESSION['UserGroupID'])) {
+ $LogGroupID = "-"; }
+if(isset($_SESSION['UserGroupID'])&&$_SESSION['UserGroupID']===null) {
+ $LogGroupID = "-"; }
+if(isset($_SESSION['UserGroupID'])&&$_SESSION['UserGroupID']!==null) {
+ $LogGroupID = $_SESSION['UserGroupID']; }
+if(trim($LogGroupID, "\x00..\x1F") == "") { $LogGroupID = "-"; }
+$LogGroupID = log_fix_quotes($LogGroupID);
+$LOG_QUERY_STRING = "";
+if($_SERVER["QUERY_STRING"]!=="") {
+$LOG_QUERY_STRING = "?".$_SERVER["QUERY_STRING"]; }
+if(trim($LOG_QUERY_STRING, "\x00..\x1F") == "") { $LOG_QUERY_STRING = ""; }
+$LOG_QUERY_STRING = log_fix_quotes($LOG_QUERY_STRING);
+$oldcontentsize = $contentsize;
+if($oldcontentsize=="-") { $oldcontentsize = 0; }
+if($contentsize===0) { $contentsize = "-"; }
+if($contentsize=="-"&&$headersize!==0) { $fullsitesize = $headersize; }
+if($contentsize!="-"&&$headersize!==0) { $fullsitesize = $contentsize + $headersize; }
+if($status=="302") { $contentsize = "-"; }
+$HTTP_REQUEST_LINE = $_SERVER["REQUEST_METHOD"]." ".$_SERVER["REQUEST_URI"]." ".$_SERVER["SERVER_PROTOCOL"];
+$HTTP_REQUEST_LINE = log_fix_quotes($HTTP_REQUEST_LINE);
+$logtxt = preg_replace("/%%/s", "{percent}p", $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)a/s", $_SERVER['REMOTE_ADDR'], $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)A/s", $_SERVER["SERVER_ADDR"], $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)B/s", $oldcontentsize, $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)b/s", $contentsize, $logtxt);
+$logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}C/s", "get_cookie_values", $logtxt);
+$logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}e/s", "get_env_values", $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)f/s", log_fix_quotes($_SERVER["SCRIPT_FILENAME"]), $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)h/s", $_SERVER['REMOTE_ADDR'], $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)H/s", $_SERVER["SERVER_PROTOCOL"], $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)\{Referer\}i/s", $LOG_URL_REFERER, $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)\{User-Agent\}i/s", $LOG_USER_AGENT, $logtxt);
+$logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}i/s", "get_server_values", $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)l/s", "-", $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)m/s", $_SERVER["REQUEST_METHOD"], $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)p/s", $_SERVER["SERVER_PORT"], $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)q/s", $LOG_QUERY_STRING, $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)r/s", $HTTP_REQUEST_LINE, $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)s/s", $status, $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)t/s", "[".$servcurtime->format("d/M/Y:H:i:s O")."]", $logtxt);
+$logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}t/s", "get_time", $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)u/s", $LOG_AUTH_USER, $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)U/s", log_fix_quotes($_SERVER["PHP_SELF"]), $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)v/s", $_SERVER["SERVER_NAME"], $logtxt);
+$logtxt = preg_replace("/%([\<\>]*?)V/s", $_SERVER["SERVER_NAME"], $logtxt);
+// Not what it should be but PHP dose not have variable to get Apache ServerName config value. :(
+$logtxt = preg_replace("/%([\<\>]*?)O/s", $fullsitesize, $logtxt);
+$logtxt = preg_replace_callback("/%([\<\>]*?)\{([^\}]*)\}s/s", "get_setting_values", $logtxt);
+$logtxt = preg_replace("/\%\{UserName\}m/s", $LogMemName, $logtxt);
+$logtxt = preg_replace("/\%\{MemberName\}m/s", $LogMemName, $logtxt);
+$logtxt = preg_replace("/\%\{UserID\}m/s", $LogMemID, $logtxt);
+$logtxt = preg_replace("/\%\{MemberID\}m/s", $LogMemID, $logtxt);
+$logtxt = preg_replace("/\%\{UserGroup\}m/s", $LogGroupName, $logtxt);
+$logtxt = preg_replace("/\%\{MemberGroup\}m/s", $LogGroupName, $logtxt);
+$logtxt = preg_replace("/\%\{UserGroupID\}m/s", $LogGroupID, $logtxt);
+$logtxt = preg_replace("/\%\{MemberGroupID\}m/s", $LogGroupID, $logtxt);
+$logtxt = preg_replace("/\{percent\}p/s", "%", $logtxt);
+if(isset($logfile)&&$logfile!==null) {
+ $fp = fopen($logfile, "a+");
+ if (flock($fp, LOCK_EX)) {
+ $logtxtnew = $logtxt."\r\n";
+ fwrite($fp, $logtxtnew, strlen($logtxtnew));
+ flock($fp, LOCK_UN); }
+ fclose($fp);
+ @chmod($logfile, 0666); }
+return $logtxt; }
+function idb_log_maker($status=200,$contentsize="-") {
+global $Settings,$SettDir;
+if(isset($Settings['DefaultTimeZone'])) {
+$servtz = new DateTimeZone($Settings['DefaultTimeZone']); }
+if(!isset($Settings['DefaultTimeZone'])) {
+$servtz = new DateTimeZone(date_default_timezone_get()); }
+$servcurtime = new DateTime();
+$servcurtime->setTimezone($servtz);
+if(!isset($Settings['log_http_request'])) {
+ $Settings['log_http_request'] = "off"; }
+if(!isset($Settings['log_config_format'])) {
+ $Settings['log_config_format'] = "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""; }
+if(isset($Settings['log_http_request'])&&$Settings['log_http_request']=="on"&&
+ $Settings['log_http_request']!==null&&$Settings['log_http_request']!="off") {
+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")); }
+if(isset($Settings['log_http_request'])&&$Settings['log_http_request']!="on"&&
+ $Settings['log_http_request']!==null&&$Settings['log_http_request']!="off") {
+$Settings['log_http_request'] = preg_replace_callback("/".preg_quote("%{", "/")."([^\}]*)".preg_quote("}t", "/")."/s", "get_time", $Settings['log_http_request']);
+$Settings['log_http_request'] = preg_replace_callback("/".preg_quote("%{", "/")."([^\}]*)".preg_quote("}s", "/")."/s", "get_setting_values", $Settings['log_http_request']);
+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")); } }
?>