1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
require_once ('classes/Session.inc');
Session::logcheck("MenuPolicy", "PolicyServers"); // Who manage server can reload server conf
require_once ("classes/Session.inc");
require_once ("classes/Security.inc");
$what = GET('what');
$back = GET('back');
ossim_valid($what, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("What"));
ossim_valid($back, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("back"));
if (ossim_error()) {
die(ossim_error());
}
/* what to reload... */
if (empty($what)) $what = 'all';
require_once ('ossim_conf.inc');
$ossim_conf = $GLOBALS["CONF"];
/* get the port and IP address of the server */
$address = '127.0.0.1';
$port = '40001';
$address = $ossim_conf->get_conf("server_address");
$port = $ossim_conf->get_conf("server_port");
/* create socket */
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
printf(gettext("socket_create() failed: reason: %s\n") , socket_strerror($socket));
}
/* connect */
$result = socket_connect($socket, $address, $port);
echo "<b> socket_connect() reussie : \$result = $result</b>";//Aro
if ($result < 0) {
printf(gettext("socket_connect() failed: reason: %s %s\n") , $result, socket_strerror($result));
}
$in = 'connect id="1" type="web"' . "\n";
$out = '';
socket_write($socket, $in, strlen($in));
$out = socket_read($socket, 2048);
//echo "<p/><b> \$out = $out </b>";// Aro
if (strncmp($out, 'ok id="1"', 9) != 0) {
// If the server is down / unavailable, clear the need to reload
// Switch off web indicator
require_once ('classes/WebIndicator.inc');
if ($what == "all") {
WebIndicator::set_off("Reload_policies");
WebIndicator::set_off("Reload_hosts");
WebIndicator::set_off("Reload_nets");
WebIndicator::set_off("Reload_sensors");
WebIndicator::set_off("Reload_plugins");
WebIndicator::set_off("Reload_directives");
WebIndicator::set_off("Reload_servers");
} else {
WebIndicator::set_off("Reload_" . $what);
}
// Reset main indicator if no more policy reload need
if (!WebIndicator::is_on("Reload_policies") && !WebIndicator::is_on("Reload_hosts") && !WebIndicator::is_on("Reload_nets") && !WebIndicator::is_on("Reload_sensors") && !WebIndicator::is_on("Reload_plugins") && !WebIndicator::is_on("Reload_directives") && !WebIndicator::is_on("Reload_servers")) {
WebIndicator::set_off("ReloadPolicy");
}
// update indicators on top frame
$OssimWebIndicator->update_display();
echo gettext("Error connecting to server-----") . " ...\n";
exit;
}
$in = 'reload-' . $what . ' id="2"' . "\n";
$out = '';
socket_write($socket, $in, strlen($in));
$out = socket_read($socket, 2048);
if (strncmp($out, 'ok id="2"', 9) != 0) {
echo gettext("Bad response from server") . " ...\n";
exit;
}
socket_close($socket);
// Switch off web indicator
require_once ('classes/WebIndicator.inc');
if ($what == "all") {
WebIndicator::set_off("Reload_policies");
WebIndicator::set_off("Reload_hosts");
WebIndicator::set_off("Reload_nets");
WebIndicator::set_off("Reload_sensors");
WebIndicator::set_off("Reload_plugins");
WebIndicator::set_off("Reload_directives");
WebIndicator::set_off("Reload_servers");
} else {
WebIndicator::set_off("Reload_" . $what);
}
// Reset main indicator if no more policy reload need
if (!WebIndicator::is_on("Reload_policies") && !WebIndicator::is_on("Reload_hosts") && !WebIndicator::is_on("Reload_nets") && !WebIndicator::is_on("Reload_sensors") && !WebIndicator::is_on("Reload_plugins") && !WebIndicator::is_on("Reload_directives") && !WebIndicator::is_on("Reload_servers")) {
WebIndicator::set_off("ReloadPolicy");
}
// update indicators on top frame
$OssimWebIndicator->update_display();
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style/style.css"/>
</head>
<body>
<p> <?php
echo gettext("---------------------------Reload completed successfully----------------------------------------------"); ?> </p>
<?php
$location = urldecode($back);
sleep(2);
echo "<script>
///history.go(-1);
window.location='$location';
</script>
";
?>
</body>
</html> |
Partager