<commit_before><?php
/**
Centreon is developped with GPL Licence 2.0 :
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Developped by : <NAME> - <NAME>

The Software is provided to you AS IS and WITH ALL FAULTS.
OREON makes no representation and gives no warranty whatsoever,
whether express or implied, and without limitation, with regard to the quality,
safety, contents, performance, merchantability, non-infringement or suitability for
any particular or intended purpose of the Software found on the OREON web site.
In no event will OREON be liable for any direct, indirect, punitive, special,
incidental or consequential damages however they may arise and even if OREON has
been previously advised of the possibility of such damages.

For information : <EMAIL>
*/

	if (!isset($oreon))
		exit();
		
	if (!is_dir($nagiosCFGPath.$tab['id']."/")) {
		mkdir($nagiosCFGPath.$tab['id']."/");
	}

	$generatedSG = array();

	$handle = create_file($nagiosCFGPath.$tab['id']."/servicegroups.cfg", $oreon->user->get_name());
	$DBRESULT =& $pearDB->query("SELECT * FROM servicegroup ORDER BY `sg_name`");
	if (PEAR::isError($DBRESULT))
		print "DB Error : ".$DBRESULT->getDebugInfo()."<br>";
	
	$serviceGroup = array();
	$i = 1;
	$str = NULL;
	while($DBRESULT->fetchInto($serviceGroup))	{
		$BP = false;
		$generated = 0;
		$strDef = "";
		array_key_exists($serviceGroup["sg_id"], $gbArr[5]) ? $BP = true : NULL;
		
		if ($BP)	{
			$ret["comment"] ? ($strDef .= "# '" . $serviceGroup["sg_name"] . "' servicegroup definition " . $i . "\n") : NULL;
			if ($ret["comment"] && $serviceGroup["sg_comment"])	{
				$comment = array();
				$comment = explode("\n", $serviceGroup["sg_comment"]);
				foreach ($comment as $cmt)
					$strDef .= "# ".$cmt."\n";
			}
			$strDef .= "define servicegroup{\n";
			if ($serviceGroup["sg_name"])  $strDef .= print_line("servicegroup_name", $serviceGroup["sg_name"]);
			if ($serviceGroup["sg_alias"]) $strDef .= print_line("alias", $serviceGroup["sg_alias"]);
			// Service members
			$service = array();
			$strTemp = NULL;
			$DBRESULT2 =& $pearDB->query("SELECT service_description, service_id, host_name, host_id " .
									"FROM servicegroup_relation, service, host " .
									"WHERE servicegroup_sg_id = '".$serviceGroup["sg_id"]."' " .
									"AND service.service_id = servicegroup_relation.service_service_id " .
									"AND host.host_id = servicegroup_relation.host_host_id " .
									"AND service.service_activate = '1' " .
									"AND host.host_activate = '1' " .
									"AND  servicegroup_relation.host_host_id IS NOT NULL");
			if (PEAR::isError($DBRESULT2))
				print "DB Error : ".$DBRESULT2->getDebugInfo()."<br>";
			while($DBRESULT2->fetchInto($service)){
				isset($gbArr[4][$service["service_id"]]) ? $BP = true : NULL;
				
				if ($BP)	{				
					if ($service["host_id"])	{
						$BP = false;
						isset($gbArr[2][$service["host_id"]]) ? $BP = true : NULL;
						
						if ($BP && isHostOnThisInstance($service["host_id"], $tab['id'])){<commit_msg>remove special char in service group<commit_after><?php
/**
Centreon is developped with GPL Licence 2.0 :
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Developped by : <NAME> - <NAME>

The Software is provided to you AS IS and WITH ALL FAULTS.
OREON makes no representation and gives no warranty whatsoever,
whether express or implied, and without limitation, with regard to the quality,
safety, contents, performance, merchantability, non-infringement or suitability for
any particular or intended purpose of the Software found on the OREON web site.
In no event will OREON be liable for any direct, indirect, punitive, special,
incidental or consequential damages however they may arise and even if OREON has
been previously advised of the possibility of such damages.

For information : <EMAIL>
*/

	if (!isset($oreon))
		exit();
		
	if (!is_dir($nagiosCFGPath.$tab['id']."/")) {
		mkdir($nagiosCFGPath.$tab['id']."/");
	}

	$generatedSG = array();

	$handle = create_file($nagiosCFGPath.$tab['id']."/servicegroups.cfg", $oreon->user->get_name());
	$DBRESULT =& $pearDB->query("SELECT * FROM servicegroup ORDER BY `sg_name`");
	if (PEAR::isError($DBRESULT))
		print "DB Error : ".$DBRESULT->getDebugInfo()."<br>";
	
	$serviceGroup = array();
	$i = 1;
	$str = NULL;
	while($DBRESULT->fetchInto($serviceGroup))	{
		$BP = false;
		$generated = 0;
		$strDef = "";
		array_key_exists($serviceGroup["sg_id"], $gbArr[5]) ? $BP = true : NULL;
		
		if ($BP)	{
			$ret["comment"] ? ($strDef .= "# '" . $serviceGroup["sg_name"] . "' servicegroup definition " . $i . "\n") : NULL;
			if ($ret["comment"] && $serviceGroup["sg_comment"])	{
				$comment = array();
				$comment = explode("\n", $serviceGroup["sg_comment"]);
				foreach ($comment as $cmt)
					$strDef .= "# ".$cmt."\n";
			}
			$strDef .= "define servicegroup{\n";
			$serviceGroup["sg_name"] = str_replace("#S#", "/", $serviceGroup["sg_name"]);
			$serviceGroup["sg_name"] = str_replace("#BS#", "\\", $serviceGroup["sg_name"]);
			
			if ($serviceGroup["sg_name"])  $strDef .= print_line("servicegroup_name", $serviceGroup["sg_name"]);
			if ($serviceGroup["sg_alias"]) $strDef .= print_line("alias", $serviceGroup["sg_alias"]);
			// Service members
			$service = array();
			$strTemp = NULL;
			$DBRESULT2 =& $pearDB->query("SELECT service_description, service_id, host_name, host_id " .
									"FROM servicegroup_relation, service, host " .
									"WHERE servicegroup_sg_id = '".$serviceGroup["sg_id"]."' " .
									"AND service.service_id = servicegroup_relation.service_service_id " .
									"AND host.host_id = servicegroup_relation.host_host_id " .
									"AND service.service_activate = '1' " .
									"AND host.host_activate = '1' " .
									"AND  servicegroup_relation.host_host_id IS NOT NULL");
			if (PEAR::isError($DBRESULT2))
				print "DB Error : ".$DBRESULT2->getDebugInfo()."<br>";
			while($DBRESULT2->fetchInto($service)){
				isset($gbArr[4][$service["service_id"]]) ? $BP = true : NULL;
				
				if ($BP)	{				
					if ($service["host_id"])	{
						$BP = false;
						isset($gbArr[2][$service["host_id"]]) ? $BP = true : NULL;
						
						if ($BP && isHostOnThisInstance($service["host_id"], $tab['id'])){
							$service["service_description"] = str_replace("#S#", "/", $service["service_description"]);
							$service["service_description"] = str_replace("#BS#", "\\", $service["service_description"]);
			
{'fraction_non_alphanumeric': 0.1749961077378172, 'fraction_numerical': 0.004670714619336758, 'mean_word_length': 4.042386185243328, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '679974', 'n_tokens_mistral': 2450, 'n_tokens_neox': 2103, 'n_words': 506}