$login = isauth(); if (is_admin("system_is_admin", $login) != "Y" && ldap_get_right("parc_can_clone", $login) != "Y") { echo "<p style='color:red'>Action non autorisee.</p>"; die; } $restriction_parcs = "n"; if (is_admin("system_is_admin", $login) != "Y") { $restriction_parcs = "y"; $tab_delegated_parcs = list_delegated_parcs($login); if (count($tab_delegated_parcs) == 0) { echo "<p style='color:red'>Aucun parc ne vous a ete delegue.</p>\n"; die; } } if ($_GET['mode'] == 'ping_ip') { $resultat = fping($_GET['ip']); if ($resultat) { //echo "<img type=\"image\" src=\"../elements/images/enabled.gif\" border='0' alt='".$_GET['ip']."' title='".$_GET['ip']."' />"; echo "<img type=\"image\" src=\"../elements/images/enabled.gif\" border=\"0\" alt=\"" . $_GET['ip'] . "\" title=\"" . $_GET['ip'] . "\" />"; } else { //echo "<img type=\"image\" src=\"../elements/images/disabled.gif\" border='0' alt='".$_GET['ip']."' title='".$_GET['ip']."' />"; echo "<img type=\"image\" src=\"../elements/images/disabled.gif\" border=\"0\" alt=\"" . $_GET['ip'] . "\" title=\"" . $_GET['ip'] . "\" />"; } } elseif ($_GET['mode'] == 'session') { $res = get_smbsess($_GET['nom_machine']); echo $res['html']; } elseif ($_GET['mode'] == 'wake_shutdown_or_reboot') { wake_shutdown_or_reboot($_GET['ip'], $_GET['nom'], $_GET['wake'], $_GET['shutdown_reboot']); } elseif ($_GET['mode'] == 'check_versions_sysresccd') { $resultat2 = exec("/usr/bin/sudo /usr/share/se3/scripts/se3_get_sysresccd.sh 'check_version'", $retour); foreach ($retour as $key => $value) {
function isPingable($hostname, $device_id = FALSE) { global $config; $fping_params = ''; if (is_numeric($config['fping_options']['retries']) || $config['fping_options']['retries'] > 1) { $fping_params .= ' -r ' . $config['fping_options']['retries']; } if (is_numeric($config['fping_options']['timeout']) || $config['fping_options']['timeout'] > 1) { $fping_params .= ' -t ' . $config['fping_options']['timeout']; } if (is_numeric($config['fping_options']['count']) || $config['fping_options']['count'] > 0) { $fping_params .= ' -c ' . $config['fping_options']['count']; } if (is_numeric($config['fping_options']['millisec']) || $config['fping_options']['millisec'] > 0) { $fping_params .= ' -p ' . $config['fping_options']['millisec']; } $response = array(); $status = fping($hostname, $fping_params); if ($status['loss'] == 100) { $response['result'] = FALSE; } else { $response['result'] = TRUE; } if (is_numeric($status['avg'])) { $response['last_ping_timetaken'] = $status['avg']; } $response['db'] = $status; return $response; }
/** * Check if the given host responds to ICMP echo requests ("pings"). * * @param string $hostname The hostname or IP address to send ping requests to. * @param int $address_family The address family (AF_INET for IPv4 or AF_INET6 for IPv6) to use. Defaults to IPv4. Will *not* be autodetected for IP addresses, so it has to be set to AF_INET6 when pinging an IPv6 address or an IPv6-only host. * @param array $attribs The device attributes * * @return bool TRUE if the host responded to at least one ping request, FALSE otherwise. */ function isPingable($hostname, $address_family = AF_INET, $attribs = array()) { global $config; $response = array(); if (can_ping_device($attribs) === true) { $fping_params = ''; if (is_numeric($config['fping_options']['retries']) || $config['fping_options']['retries'] > 1) { $fping_params .= ' -r ' . $config['fping_options']['retries']; } if (is_numeric($config['fping_options']['timeout']) || $config['fping_options']['timeout'] > 1) { $fping_params .= ' -t ' . $config['fping_options']['timeout']; } if (is_numeric($config['fping_options']['count']) || $config['fping_options']['count'] > 0) { $fping_params .= ' -c ' . $config['fping_options']['count']; } if (is_numeric($config['fping_options']['millisec']) || $config['fping_options']['millisec'] > 0) { $fping_params .= ' -p ' . $config['fping_options']['millisec']; } $status = fping($hostname, $fping_params, $address_family); if ($status['loss'] == 100) { $response['result'] = FALSE; } else { $response['result'] = TRUE; } if (is_numeric($status['avg'])) { $response['last_ping_timetaken'] = $status['avg']; } $response['db'] = $status; } else { $response['result'] = true; $response['last_ping_timetaken'] = 0; } return $response; }