<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.
 * Centreon makes no representation and gives no warranty whatsoever,
 * whether express or implied, and without limitation, with regard to the quality,
 * any particular or intended purpose of the Software found on the Centreon web site.
 * In no event will Centreon be liable for any direct, indirect, punitive, special,
 * incidental or consequential damages however they may arise and even if Centreon has
 * been previously advised of the possibility of such damages.
 * 
 * For information : <EMAIL>
 */

aff_header("Oreon Setup Wizard", "Creating Database", 11);
?>
<table cellpadding="0" cellspacing="0" border="0" width="80%" class="StyleDottedHr" align="center">
  	<tr>
    	<th align="left">Component</th>
   	 	<th style="text-align: right;">Status</th>
  	</tr>
  	<tr>
		<td><b>Database : Connection</b></td>	<?php
	$res = connexion('root', (isset($_SESSION["pwdroot"]) ? $_SESSION["pwdroot"] : '' ) , $_SESSION["dbLocation"]) ;
	$mysql_msg = $res['1'];
	if ($mysql_msg == '') {
		print '<td align="right"><b><span class="go">OK</b></td></tr>';
	}	
	
	# Database creation 
	$usedb = mysql_select_db($_SESSION["nameOreonDB"], $res['0']) or ( $mysql_msg = mysql_error());
	if (!$usedb){
		print "<tr><td><b>Database &#146;".$_SESSION["nameOreonDB"]."&#146; : Creation</b></td>";
		$requete = "CREATE DATABASE ". $_SESSION["nameOreonDB"] . ";";
		if ($DEBUG) 
			print $requete . "<br />";
		@mysql_query($requete, $res['0']);
		if ($res['1'])
			print '<td align="right"><b><span class="go">CRITICAL</b></td></tr>';
		else
			print '<td align="right"><b><span class="go">OK</b></td></tr>';	
	}
	if (!$usedb){
		print "<tr><td><b>Database &#146;".$_SESSION["nameOdsDB"]."&#146; : Creation</b></td>";
		$requete = "CREATE DATABASE ". $_SESSION["nameOdsDB"] . ";";
		if ($DEBUG) 
			print $requete . "<br />";
		@mysql_query($requete, $res['0']);
		if ($res['1'])
			print '<td align="right"><b><span class="go">CRITICAL</b></td></tr>';
		else
			print '<td align="right"><b><span class="go">OK</b></td></tr>';	
	}
	
	# User management
	if (!$usedb){
		$mysql_msg = "";
		print "<tr><td><b>Database &#146;".$_SESSION["nameOreonDB"]."&#146; : Users Management</b></td>";
		$requete = "GRANT ALL PRIVILEGES ON `". $_SESSION["nameOreonDB"] . "` . * TO `". $_SESSION["nameOreonDB"] . "`@`". $_SESSION["nagiosLocation"] . "` IDENTIFIED BY '". $_SESSION["pwdOreonDB"] . "' WITH GRANT OPTION";
		if ($DEBUG) print $requete. "<br />";
		mysql_query($requete, $res['0']) or ( $mysql_msg= mysql_error());
		$mysql_msg = $res['1'];
		$requete = "GRANT ALL PRIVILEGES ON `". $_SESSION["nameOdsDB"] . "` . * TO `". $_SESSION["nameOreonDB"] . "`@`". $_SESSION["nagiosLocation"] . "` IDENTIFIED BY '". $_SESSION["pwdOreonDB"] . "' WITH GRANT OPTION";
		if ($DEBUG) print $requete. "<br />";
		mysql_query($requete, $res['0']) or ( $mysql_msg= mysql_error());
		$mysql_msg .= $res['1'];		
		if ($res['1'])
			print '<td align="right"><b><span class="go">CRITICAL</b><br />$mysql_msg<br /></td></tr>';
		else
			print '<td align="right"><b><span class="go">OK</b></td></tr>';	
	}	
	if ($_SESSION["mysqlVersion"] == "2")	{
        $requete = "UPDATE mysql.user SET Password = <PASSWORD>('". $_SESSION["<PASSWORD>"] ."') WHERE User = '". $_SESSION["nameOreonDB"] ."'";
        @mysql_query($requete, $res['0']) or ( $mysql_msg= mysql_error());
        $requete = "FLUSH PRIVILEGES";
        @mysql_query($requete, $res['0']) or ( $mysql_msg= mysql_error());
		$mysql_msg = $res['1'];
	}
	######################################################################################
	#  Oreon Database creation
	######################################################################################
	$usedb = mysql_select_db($_SESSION["nameOreonDB"], $res['0']) or ( $mysql_msg = mysql_error());
	if (!$usedb){
		$return_false = 0;
		@mysql_select_db($_SESSION["nameOreonDB"], $res['0']) or ( $mysql_msg= mysql_error());
		$mysql_msg = $res['1'];
		if ($mysql_msg == '') {
			echo '<td align="right"><b><span class="go">OK</b></td></tr>';
		} else {
			echo '<td align="right"><b><span class="stop">CRITICAL</span></b></td></tr>';
	    	$return_false = 1;
			print '<tr><td colspan="2" align="left"><span class="small">'.$mysql_msg.'</span></td></tr>';
		}
	} 
	if (!$return_false){
		print '<tr><td><b>Database &#146;'.$_SESSION["nameOreonDB"].'&#146; : Schema Creation</b></td>';
		$mysql_msg = '';
		$file_sql = file("./createTables.sql");
	    $str = NULL;
	    for ($i = 0; $i <= count($file_sql) - 1; $i++){
	        $line = $file_sql[$i];
	        if (($line[0] != '#' ) and ( $line[0] != '-' )  )    {
	            $pos = strrpos($line, ";");
	            if ($pos != false)      {
	                $str .= $line;
	                $str = chop ($str);
	  				if ($DEBUG) print $str . "<br />";
	                $result = @mysql_query($str, $res['0']) or ( $mysql_msg= $mysql_msg . "$str<br /><span class='warning'>->" . mysql_error() ."</span><br />");
	                $str = NULL;
	            } else
	            	$str .= $line;
	        }
	    }	
		if ($res[1] == '') {
			echo '<td align="right"><b><span class="go">OK</b></td></tr>';
		} else {
			echo '<td align="right"><b><span class="stop">CRITICAL</span></b><br />'.$res[1].'<br /></td></tr>';
		    $return_false = 1;
		}
	}
	
	$usedb = mysql_select_db($_SESSION["nameOreonDB"], $res['0']) or ( $mysql_msg = mysql_error());
	if (!$usedb){	
		$return_false = 0;
		print '<tr><td><b>Database &#146;'.$_SESSION["nameOdsDB"].'&#146; : Schema Creation</b></td>';
		$mysql_msg = $res['1'];
		if ($mysql_msg == '') {
			echo '<td align="right"><b><span class="go">OK</b></td></tr>';
		} else {
			echo '<td align="right"><b><span class="stop">CRITICAL</span></b></td></tr>';
	    	$return_false = 1;
			print '<tr><td colspan="2" align="left"><span class="small">'.$mysql_msg.'</span></td></tr>';
		}
	} 
	$usedb = mysql_select_db($_SESSION["nameOdsDB"], $res['0']) or ( $mysql_msg = mysql_error());
	if (!$return_false){
		print '<tr><td><b>Database &#146;'.$_SESSION["nameOdsDB"].'&#146; : Schema Creation</b></td>';
		$mysql_msg = '';
		$file_sql = file("./createTablesODS.sql");
	    $str = NULL;
	    for ($i = 0; $i <= count($file_sql) - 1; $i++){
	        $line = $file_sql[$i];
	        if (($line[0] != '#' ) and ( $line[0] != '-' )  )    {
	            $pos = strrpos($line, ";");
	            if ($pos != false)      {
	                $str .= $line;<commit_msg>rename centstorage sql file for first insert and database creation<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.
 * Centreon makes no representation and gives no warranty whatsoever,
 * whether express or implied, and without limitation, with regard to the quality,
 * any particular or intended purpose of the Software found on the Centreon web site.
 * In no event will Centreon be liable for any direct, indirect, punitive, special,
 * incidental or consequential damages however they may arise and even if Centreon has
 * been previously advised of the possibility of such damages.
 * 
 * For information : <EMAIL>
 */

aff_header("Oreon Setup Wizard", "Creating Database", 11);
?>
<table cellpadding="0" cellspacing="0" border="0" width="80%" class="StyleDottedHr" align="center">
  	<tr>
    	<th align="left">Component</th>
   	 	<th style="text-align: right;">Status</th>
  	</tr>
  	<tr>
		<td><b>Database : Connection</b></td>	<?php
	$res = connexion('root', (isset($_SESSION["pwdroot"]) ? $_SESSION["pwdroot"] : '' ) , $_SESSION["dbLocation"]) ;
	$mysql_msg = $res['1'];
	if ($mysql_msg == '') {
		print '<td align="right"><b><span class="go">OK</b></td></tr>';
	}	
	
	# Database creation 
	$usedb = mysql_select_db($_SESSION["nameOreonDB"], $res['0']) or ( $mysql_msg = mysql_error());
	if (!$usedb){
		print "<tr><td><b>Database &#146;".$_SESSION["nameOreonDB"]."&#146; : Creation</b></td>";
		$requete = "CREATE DATABASE ". $_SESSION["nameOreonDB"] . ";";
		if ($DEBUG) 
			print $requete . "<br />";
		@mysql_query($requete, $res['0']);
		if ($res['1'])
			print '<td align="right"><b><span class="go">CRITICAL</b></td></tr>';
		else
			print '<td align="right"><b><span class="go">OK</b></td></tr>';	
	}
	if (!$usedb){
		print "<tr><td><b>Database &#146;".$_SESSION["nameOdsDB"]."&#146; : Creation</b></td>";
		$requete = "CREATE DATABASE ". $_SESSION["nameOdsDB"] . ";";
		if ($DEBUG) 
			print $requete . "<br />";
		@mysql_query($requete, $res['0']);
		if ($res['1'])
			print '<td align="right"><b><span class="go">CRITICAL</b></td></tr>';
		else
			print '<td align="right"><b><span class="go">OK</b></td></tr>';	
	}
	
	# User management
	if (!$usedb){
		$mysql_msg = "";
		print "<tr><td><b>Database &#146;".$_SESSION["nameOreonDB"]."&#146; : Users Management</b></td>";
		$requete = "GRANT ALL PRIVILEGES ON `". $_SESSION["nameOreonDB"] . "` . * TO `". $_SESSION["nameOreonDB"] . "`@`". $_SESSION["nagiosLocation"] . "` IDENTIFIED BY '". $_SESSION["pwdOreonDB"] . "' WITH GRANT OPTION";
		if ($DEBUG) print $requete. "<br />";
		mysql_query($requete, $res['0']) or ( $mysql_msg= mysql_error());
		$mysql_msg = $res['1'];
		$requete = "GRANT ALL PRIVILEGES ON `". $_SESSION["nameOdsDB"] . "` . * TO `". $_SESSION["nameOreonDB"] . "`@`". $_SESSION["nagiosLocation"] . "` IDENTIFIED BY '". $_SESSION["pwdOreonDB"] . "' WITH GRANT OPTION";
		if ($DEBUG) print $requete. "<br />";
		mysql_query($requete, $res['0']) or ( $mysql_msg= mysql_error());
		$mysql_msg .= $res['1'];		
		if ($res['1'])
			print '<td align="right"><b><span class="go">CRITICAL</b><br />$mysql_msg<br /></td></tr>';
		else
			print '<td align="right"><b><span class="go">OK</b></td></tr>';	
	}	
	if ($_SESSION["mysqlVersion"] == "2")	{
        $requete = "UPDATE mysql.user SET Password = <PASSWORD>('". $_SESSION["<PASSWORD>"] ."') WHERE User = '". $_SESSION["nameOreonDB"] ."'";
        @mysql_query($requete, $res['0']) or ( $mysql_msg= mysql_error());
        $requete = "FLUSH PRIVILEGES";
        @mysql_query($requete, $res['0']) or ( $mysql_msg= mysql_error());
		$mysql_msg = $res['1'];
	}
	######################################################################################
	#  Oreon Database creation
	######################################################################################
	$usedb = mysql_select_db($_SESSION["nameOreonDB"], $res['0']) or ( $mysql_msg = mysql_error());
	if (!$usedb){
		$return_false = 0;
		@mysql_select_db($_SESSION["nameOreonDB"], $res['0']) or ( $mysql_msg= mysql_error());
		$mysql_msg = $res['1'];
		if ($mysql_msg == '') {
			echo '<td align="right"><b><span class="go">OK</b></td></tr>';
		} else {
			echo '<td align="right"><b><span class="stop">CRITICAL</span></b></td></tr>';
	    	$return_false = 1;
			print '<tr><td colspan="2" align="left"><span class="small">'.$mysql_msg.'</span></td></tr>';
		}
	} 
	if (!$return_false){
		print '<tr><td><b>Database &#146;'.$_SESSION["nameOreonDB"].'&#146; : Schema Creation</b></td>';
		$mysql_msg = '';
		$file_sql = file("./createTables.sql");
	    $str = NULL;
	    for ($i = 0; $i <= count($file_sql) - 1; $i++){
	        $line = $file_sql[$i];
	        if (($line[0] != '#' ) and ( $line[0] != '-' )  )    {
	            $pos = strrpos($line, ";");
	            if ($pos != false)      {
	                $str .= $line;
	                $str = chop ($str);
	  				if ($DEBUG) print $str . "<br />";
	                $result = @mysql_query($str, $res['0']) or ( $mysql_msg= $mysql_msg . "$str<br /><span class='warning'>->" . mysql_error() ."</span><br />");
	                $str = NULL;
	            } else
	            	$str .= $line;
	        }
	    }	
		if ($res[1] == '') {
			echo '<td align="right"><b><span class="go">OK</b></td></tr>';
		} else {
			echo '<td align="right"><b><span class="stop">CRITICAL</span></b><br />'.$res[1].'<br /></td></tr>';
		    $return_false = 1;
		}
	}
	
	$usedb = mysql_select_db($_SESSION["nameOreonDB"], $res['0']) or ( $mysql_msg = mysql_error());
	if (!$usedb){	
		$return_false = 0;
		print '<tr><td><b>Database &#146;'.$_SESSION["nameOdsDB"].'&#146; : Schema Creation</b></td>';
		$mysql_msg = $res['1'];
		if ($mysql_msg == '') {
			echo '<td align="right"><b><span class="go">OK</b></td></tr>';
		} else {
			echo '<td align="right"><b><span class="stop">CRITICAL</span></b></td></tr>';
	    	$return_false = 1;
			print '<tr><td colspan="2" align="left"><span class="small">'.$mysql_msg.'</span></td></tr>';
		}
	} 
	$usedb = mysql_select_db($_SESSION["nameOdsDB"], $res['0']) or ( $mysql_msg = mysql_error());
	if (!$return_false){
		print '<tr><td><b>Database &#146;'.$_SESSION["nameOdsDB"].'&#146; : Schema Creation</b></td>';
		$mysql_msg = '';
		$file_sql = file("./createTablesCentstorage.sql");
	    $str = NULL;
	    for ($i = 0; $i <= count($file_sql) - 1; $i++){
	        $line = $file_sql[$i];
	        if (($line[0] != '#' ) and ( $line[0] != '-' )  )    {
	            $pos = strrpos($line, ";");
	            if ($pos != false)      {
	                $str .= $line;
{'fraction_non_alphanumeric': 0.26543902986750506, 'fraction_numerical': 0.012875215210719364, 'mean_word_length': 3.7714285714285714, 'pattern_counts': {'":': 0, '<': 317, '<?xml version=': 0, '>': 313, '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': '4424271', 'n_tokens_mistral': 5085, 'n_tokens_neox': 4670, 'n_words': 980}