<?php  
function writeToLogDB($db,$text,$client){
	
	/*if(!isset($db)){
		$dbset = json_decode($_SESSION['settingsApp'],true);	
		$db = new mysqli ($dbset['DB']['DB_HOST'],$dbset['DB']['DB_USER'],$dbset['DB']['DB_PASS'],$dbset['DB']['DB_NAME']);
		$db->query("SET CHARSET SET utf8");
		$db->query("SET NAMES 'utf8'");
    }*/
	include "../settings.php";
	$db = new mysqli ($DB_HOST,$DB_USER,$DB_PASS,$DB_NAME,$DB_PORT);
    $db->query("SET CHARSET SET utf8");
    $db->query("SET NAMES 'utf8'");
	
	//$query = "INSERT INTO `es_logs` (`iduser`,`actionfunc`,`actiontext`,`ip`,`sysname`) VALUES (".$userid.", '".$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'].$_SERVER['REQUEST_METHOD'].$_SERVER['QUERY_STRING']."', '".addslashes($actiontext)."', '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER['HTTP_USER_AGENT']."')";
	$query = "INSERT INTO `clientapplogs` (`ip`,`value`,`clientid`) VALUES ('".$_SERVER['REMOTE_ADDR']."','".addslashes($actiontext)."',".$client.");";
	if($stmt = $db->prepare($query)){
    $stmt->execute();
    $stmt->close();
	}
	//$db->close();
	//return false;
  }

?>