public function get_default_value()
 {
     if ($this->type == 6) {
         return parameter_actions::human_filesize_formatted($this->default_value, 1);
     } else {
         return $this->default_value;
     }
 }
 public function get_fra_reclaimable()
 {
     $fra_reclaimable = 0;
     foreach ($this->instances as $instance) {
         $fra_reclaimable = parameter_actions::get_parameter_by_id(9004, $instance->db_id);
         $fra_reclaimable = $fra_reclaimable + $fra_reclaimable->current_value;
     }
     return round($fra_reclaimable / 1024 / 1024 / 1024, 0);
 }
session_start();
if ($_SESSION['login'] != true) {
    header("Location: login.php");
    exit;
}
include_once "../classes/class_parameter.php";
include_once "../classes/class_parameter_actions.php";
include_once "../classes/class_instance.php";
include_once "../classes/class_instance_actions.php";
$instances_arr = instance_actions::get_instance_by_server($_POST['hostname']);
foreach ($instances_arr as $instance) {
    $fra_space_obj = parameter_actions::get_parameter_by_id(1089, $instance->db_id);
    $fra_data[$instance->db_id]['fra_space'] = $fra_space_obj->get_current_value();
    $fra_used_space_obj = parameter_actions::get_parameter_by_id(9003, $instance->db_id);
    $fra_data[$instance->db_id]['used_fra_space'] = $fra_used_space_obj->get_current_value();
    $fra_reclaimable_space_obj = parameter_actions::get_parameter_by_id(9004, $instance->db_id);
    $fra_data[$instance->db_id]['reclaimable_fra_space'] = $fra_reclaimable_space_obj->get_current_value();
    $fra_data[$instance->db_id]['used_fra_percentage'] = round($fra_used_space_obj->current_value / $fra_space_obj->current_value * 100, 0);
    $fra_data[$instance->db_id]['reclaimable_fra_percentage'] = round(($fra_used_space_obj->current_value - $fra_reclaimable_space_obj->current_value) / $fra_space_obj->current_value * 100, 0);
}
?>
<script>
	<?php 
foreach ($instances_arr as $instance) {
    ?>
		  $(function() {
			var instance_fra_usage = <?php 
    echo $fra_data[$instance->db_id]['used_fra_percentage'];
    ?>
;
			var instance_fra_reclaimable = <?php 
include_once "./includes/classes/class_parameter_actions.php";
include_once "./includes/classes/class_instance.php";
include_once "./includes/classes/class_instance_actions.php";
# Generating instance objects
$arr_instance_objs = instance_actions::get_all_instances();
# Generating the content of the dialog box for selection a parameter
$dialog_parameter_arr = parameter_actions::get_all_parameter_array();
$dialog_parameter_html = "";
?>
<script type="text/javascript">
	var instance_search_objs = <?php 
echo instance_actions::get_all_instance_search_json();
?>
; 
	var parameter_search_objs = <?php 
echo parameter_actions::get_all_parameter_search_json();
?>
;
</script>
<div id="bottom-header">
	<div class="container clearfix">
		<h1 id="bh_h1">Database Overview</h1>
		<div id="target_menu_div">
			<ul id="target_menu">
			</ul>
		</div>
		<input onkeyup="instant_search_instances(this.value);" class="prod_db_search" type="text" placeholder="Search all databases ...">
	</div>
	<div style="clear: both;"></div>
</div>
<?php

#error_reporting(E_ALL); ini_set('display_errors', '1');
include "./includes/templates/header.php";
include "./includes/templates/top_header.php";
include_once "./includes/classes/class_parameter_actions.php";
include_once "./includes/classes/class_instance.php";
include_once "./includes/classes/class_instance_actions.php";
$so_data_arr = parameter_actions::get_all_switchover_as_array();
?>
<div id="bottom-header">
	<div class="container clearfix">
		<h1 id="bh_h1">Switchover Monitor</h1>
		<div id="target_menu_div">
			<ul id="target_menu">
			</ul>
		</div>
	</div>
	<div style="clear: both;"></div>
</div>

<div id="content-area">
	<div id="top-shadow">
		<div class="container">
			<div class="table_header prod-db-item">
				<div class="dummy" style="width: 28px;"></div>
				<div class="attribute time">switchover time</div>
				<div class="attribute extended_sid">database RZ1</div>
				<div class="attribute so_arrow">direction</div>
				<div class="attribute extended_sid" style="border: 0;">database RZ2</div>
			</div>
						  </td>
						</tr>
					  </thead>
					</table>
				<?php 
} else {
    ?>
					<table class="progress_string">
						<thead>
							<tr><th colspan="2"><?php 
    echo $parameter_obj->name;
    ?>
</th></tr>
						</thead><tbody>
						  	<?php 
    $arr_parameter_changes = parameter_actions::get_all_parameter_changes_as_array($parameter_obj->parameter_id, $_POST['instance_id']);
    foreach ($arr_parameter_changes as $change) {
        echo '<tr><td class="time">' . $change['time'] . '</td><td>' . $change['value'] . '</td></tr>';
    }
    ?>
					  	</tbody>
					</table>
				<?php 
}
?>
	  
				</div>
				<div class="summary">
					<table>
						<thead><tr><th colspan="2">Summary</th></tr></thead>
						<tbody>
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
if ($_SESSION['login'] != true) {
    header("Location: login.php");
    exit;
}
include_once "../classes/class_parameter_actions.php";
include_once "../classes/class_instance.php";
include_once "../classes/class_instance_actions.php";
# Generating the content of the dialog box for selection a parameter
$dialog_parameter_arr = parameter_actions::get_all_parameter_array();
?>

<input onsubmit="return false;" onkeyup="dialog_search_parameter(this.value);" class="oracle_parameter_search" type="text" placeholder="Search all parameter ...">
<div class="mCustomScrollbar" data-mcs-theme="dark" style="float: left; max-height: 359px;">
	<?php 
foreach ($dialog_parameter_arr as $parameter_id => $attribute) {
    echo '<div onclick="load_parameter_widget (' . $_POST['instance_id'] . ', ' . $parameter_id . ', ' . $attribute['type'] . ');" id="ora_parameter_item_' . $parameter_id . '" class="ora_parameter_item">
					<img class="parameter_icon_flat" src="images/icon_parameter.png">
					<div class="attribute name">' . $attribute['name'] . '</div>
					<div class="attribute description">' . $attribute['description'] . '</div>
				  </div>';
}
?>
</div>
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
if ($_SESSION['login'] != true) {
    header("Location: login.php");
    exit;
}
include_once "../classes/class_parameter_actions.php";
include_once "../classes/class_parameter.php";
echo json_encode(parameter_actions::get_chart_data($_POST["parameter_id"], $_POST["instance_id"], $_POST["max_time"], $_POST["step"]));
 static function get_chart_data($parameter_id, $instance_id, $max_time, $step)
 {
     $db = mysqli_connect($_SESSION['db_host'], $_SESSION['db_user'], $_SESSION['db_password'], $_SESSION['db_database']);
     $labels = "";
     $data = "";
     # If value is always the same the chart will not be shown, this is changed here
     $return_label[] = '';
     # Get inital value (first older then max time)
     $query = "SELECT * FROM `values` where time < DATE_FORMAT(now(), '%Y-%m-%d') - INTERVAL " . $max_time . " HOUR and `parameter_id` = " . $parameter_id . " and `db_id` = " . $instance_id . " ORDER BY time asc limit 1";
     $result = mysqli_query($db, $query);
     while ($row = mysqli_fetch_object($result)) {
         $result_value = $row->value_string;
     }
     if ($max_time < 25) {
         $query = "SELECT DATE_FORMAT(NOW() - INTERVAL " . $max_time . " HOUR, '%H:%i') as time from dual";
     } else {
         $query = "SELECT DATE_FORMAT(NOW() - INTERVAL " . $max_time . " HOUR, '%d.%m') as time from dual";
     }
     $result = mysqli_query($db, $query);
     while ($row = mysqli_fetch_object($result)) {
         $result_label = $row->time;
     }
     # If there is no value older then max_time 0 will be assigned
     if (isset($result_value) == false) {
         $result_value = 0;
     }
     # Get values
     for ($x = $max_time; $x >= 0; $x = $x - $step) {
         if ($max_time < 25) {
             $query = "SELECT `ID`, `value_string`, DATE_FORMAT(time, '%H.%i') AS 'time', time as time_raw FROM `values` where time <=  DATE_FORMAT(now(), '%Y-%m-%d') - INTERVAL " . ($x - $step) . " HOUR and time > DATE_FORMAT(now(), '%Y-%m-%d') - INTERVAL " . $x . " HOUR and `parameter_id` = " . $parameter_id . " and `db_id` = " . $instance_id . " ORDER BY time_raw asc limit 1";
         } else {
             $query = "SELECT `ID`, `value_string`, DATE_FORMAT(time, '%d.%m') AS 'time', time as time_raw FROM `values` where time <=  DATE_FORMAT(now(), '%Y-%m-%d') - INTERVAL " . ($x - $step) . " HOUR and time > DATE_FORMAT(now(), '%Y-%m-%d') - INTERVAL " . $x . " HOUR and `parameter_id` = " . $parameter_id . " and `db_id` = " . $instance_id . " ORDER BY time_raw asc limit 1";
         }
         #echo $query.'\n';
         $result = mysqli_query($db, $query);
         while ($row = mysqli_fetch_object($result)) {
             $result_value = $row->value_string;
             $result_label = $row->time;
         }
         # If values returned, then use them, if not use the last values
         if (isset($result_label)) {
             $return_label[] = $result_label;
             $data[$x] = $result_value;
         } else {
             if ($max_time < 25) {
                 $query = "SELECT DATE_FORMAT(NOW() - INTERVAL " . $x . " HOUR, '%H.%i') as time from dual";
             } else {
                 $query = "SELECT DATE_FORMAT(NOW() - INTERVAL " . $x . " HOUR, '%d.%m') as time from dual";
             }
             #echo $query.'\n';
             $result = mysqli_query($db, $query);
             while ($row = mysqli_fetch_object($result)) {
                 $last_x = $x + $step;
                 $return_label[] = $row->time;
                 $data[$x] = $data[$last_x];
             }
         }
         unset($result_label);
         unset($result_value);
     }
     # If type is 6 (byte) then convert human readable
     $query = "SELECT type FROM `parameter` WHERE `parameter_id` = " . $parameter_id;
     $result = mysqli_query($db, $query);
     while ($row = mysqli_fetch_object($result)) {
         if ($row->type == 6) {
             # If value is always the same the chart will not be shown, this is changed here
             $return_data[] = '0';
             foreach ($data as $value) {
                 $return_data[] = parameter_actions::human_filesize($value, 1);
             }
         } else {
             # Cleant result from indexes, because they are not needed
             if ($row->type == 1) {
                 # If value is always the same the chart will not be shown, this is changed here
                 $return_data[] = '-5';
                 foreach ($data as $value) {
                     $value = strtoupper($value);
                     switch ($value) {
                         case 'TRUE':
                             $return_data[] = 1;
                             break;
                         case 'FALSE':
                             $return_data[] = 0;
                             break;
                         case 0:
                             $return_data[] = -5;
                             break;
                         default:
                             $return_data[] = -1;
                     }
                 }
             } else {
                 # If value is always the same the chart will not be shown, this is changed here
                 $return_data[] = '0';
                 foreach ($data as $value) {
                     $return_data[] = $value;
                 }
             }
         }
     }
     $arr_return['data'] = $return_data;
     $arr_return['label'] = $return_label;
     return $arr_return;
 }
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
if ($_SESSION['login'] != true) {
    header("Location: login.php");
    exit;
}
include_once "../classes/class_parameter.php";
include_once "../classes/class_parameter_actions.php";
$value_id = filter_var($_POST['value_id'], FILTER_VALIDATE_INT);
$dba_notice = filter_var($_POST['dba_notice'], FILTER_SANITIZE_STRING);
$publish_range = filter_var($_POST['publish_range'], FILTER_SANITIZE_STRING);
parameter_actions::save_parameter_notice($value_id, $dba_notice, $publish_range);
    static function send_fra_notification($server_obj, $email_address)
    {
        ############################################
        # Server Overview
        ############################################
        if ($server_obj->get_fra_used_percentage() < 70) {
            $fra_server_used_color = 'green';
        } elseif ($server_obj->get_fra_used_percentage() < 90) {
            $fra_server_used_color = 'orange';
        } else {
            $fra_server_used_color = 'red';
        }
        $mail_text = '<h2>Server Overview</h2>
			<table>
				<tr>
					<td style="border: 1px dotted; padding: 5px; width: 200px;"><b>Hostname</b></td>
					<td style="border: 1px dotted; padding: 5px; width: 300px;">' . $server_obj->hostname . '</td>
				</tr>
				<tr>
					<td style="border: 1px dotted; padding: 5px; width: 200px;"><b>FRA Space (u30)</b></td>
					<td style="border: 1px dotted; padding: 5px; width: 300px;">' . $server_obj->get_fra_space() . 'GB</td>
				</tr>
				<tr>
					<td style="border: 1px dotted; padding: 5px; width: 200px;"><b>Assigned FRA Space</b></td>
					<td style="border: 1px dotted; padding: 5px; width: 300px; background: red; color: #fff;">' . $server_obj->get_fra_assigned() . 'GB (' . round($server_obj->get_fra_assigned() / $server_obj->get_fra_space() * 100, 0) . '% assigned)</td>
				</tr>
				<tr>
					<td style="border: 1px dotted; padding: 5px; width: 200px;"><b>FRA Space used</b></td>
					<td style="border: 1px dotted; padding: 5px; width: 300px; background: ' . $fra_server_used_color . '; color: #fff;">' . $server_obj->get_fra_used_space() . 'GB</td>
				</tr>
			</table>		
			';
        ############################################
        # Database Overview
        ############################################
        foreach ($server_obj->instances as $instance) {
            $fra_space_obj = parameter_actions::get_parameter_by_id(1089, $instance->db_id);
            $fra_data[$instance->db_id]['fra_space'] = $fra_space_obj->get_current_value();
            $fra_used_space_obj = parameter_actions::get_parameter_by_id(9003, $instance->db_id);
            $fra_data[$instance->db_id]['used_fra_space'] = $fra_used_space_obj->get_current_value();
            $fra_reclaimable_space_obj = parameter_actions::get_parameter_by_id(9004, $instance->db_id);
            $fra_data[$instance->db_id]['reclaimable_fra_space'] = $fra_reclaimable_space_obj->get_current_value();
            $fra_data[$instance->db_id]['used_fra_percentage'] = round($fra_used_space_obj->current_value / $fra_space_obj->current_value * 100, 0);
            $fra_data[$instance->db_id]['reclaimable_fra_percentage'] = round(($fra_used_space_obj->current_value - $fra_reclaimable_space_obj->current_value) / $fra_space_obj->current_value * 100, 0);
        }
        $mail_text = $mail_text . '<h2>Databases</h2><table>';
        foreach ($server_obj->instances as $instance) {
            if ($fra_data[$instance->db_id]['used_fra_percentage'] < 70) {
                $fra_db_used_color = 'green';
            } elseif ($fra_data[$instance->db_id]['used_fra_percentage'] < 90) {
                $fra_db_used_color = 'orange';
            } else {
                $fra_db_used_color = 'red';
            }
            $mail_text = $mail_text . '
					<tr>
						<td style="border: 1px dotted; padding: 5px; width: 75px;"><b>' . $instance->sid . '</b></td>
						<td style="border: 1px dotted; padding: 5px; width: 447px; background: ' . $fra_db_used_color . '; color: #fff;">' . $fra_data[$instance->db_id]['used_fra_space'] . ' ' . '/ ' . $fra_data[$instance->db_id]['fra_space'] . ' used (' . $fra_data[$instance->db_id]['reclaimable_fra_space'] . ' reclaimable)</td>
					</tr>
				';
        }
        $mail_text = $mail_text . '</table>';
        ############################################
        # Send E-Mail
        ############################################
        $subject = '[FRA-Monitor Alert] FRA over assigned on ' . $server_obj->get_hostname() . ' noapplix';
        $headers = "From: FRA-Monitor\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        mail($email_address, $subject, $mail_text, $headers);
        echo $mail_text . '<br>';
        echo "Mail has been sent!<br>";
    }
<?php

#error_reporting(E_ALL); ini_set('display_errors', '1');
include "./includes/templates/header.php";
include "./includes/templates/top_header.php";
include_once "./includes/classes/class_parameter_actions.php";
include_once "./includes/classes/class_instance.php";
include_once "./includes/classes/class_instance_actions.php";
# Get last parameter changes
$arr_last_parameter_changes = parameter_actions::get_last_parameter_chagnes_as_array();
?>
<div id="bottom-header">
	<div class="container clearfix">
		<h1 id="bh_h1">Last parameter changes</h1>
		<div id="target_menu_div">
			<ul id="target_menu">
			</ul>
		</div>
	</div>
	<div style="clear: both;"></div>
</div>

<div id="content-area">
	<div id="top-shadow">
		<div class="container" style="height: 1371px; padding-left: 19px; padding-top: 17px">
		<div class="table_header ora_parameter_item">
			<div class="dummy" style="width: 28px;"></div>
			<div class="attribute time">time</div>
			<div class="attribute sid">SID</div>
			<div class="attribute hostname">hostname</div>
			<div class="attribute parameter_value">parameter name</div>