[go: up one dir, main page]

Menu

[r81]: / edit.php  Maximize  Restore  History

Download this file

102 lines (98 with data), 3.2 kB

  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
<?
require_once 'config.php';
if(!$is_admin){
header("Location: ".$_SERVER['HTTP_REFERER']);
}
if(!isset($_GET['machine'])){
if(!isset($_POST)){
die();
}
else {
$mid=$_POST['mid'];
foreach($_POST['service'] as $service){
if(isset($service['id'])){
$temp= new MLService($service['id']);
if(isset($service['del'])){
$temp->delete();
}
else {
$temp->loadFromArray($service);
$temp->save();
}
}
}
}
}
else {
$mid=$_GET['machine'];
}
$machine=new MLMachine($mid);
if($_POST){
$news=$_POST['service']['new'];
if($news['display']!=""){
$temp=new MLService();
$temp->loadFromArray($news);
$machine->updateService($temp);
}
$machine=new MLMachine($mid);
}
//$services=getServicesOfMachine($mid);
$services=$machine->getServices();
?>
<html>
<body>
<form action='edit.php' method='post'>
<table align='center'>
<thead>
<tr>
<td colspan='7' style='text-align:center' >Services for <?php echo $machine->getDisplay()." ( ".$machine->getHost()." )"; ?></td>
</tr>
</thead>
<tr>
<td>Display</td>
<td>Protocol</td>
<td>Port</td>
<td>Interval</td>
<td>Count</td>
<td>Service Name</td>
<td>Del</td>
</tr>
<?php foreach($services as $service): ?>
<tr>
<td><input type='text' name='<?php echo "service[".$service->getID()."][display]"; ?>' value='<?php echo $service->getDisplay(); ?>' /> </td>
<td><?php echo MLService::getListOfProtocols($service->getID(),$service->getProtocol()) ?> </td>
<td><input type='text' name='<?php echo "service[".$service->getID()."][port]"; ?>' value='<?php echo $service->getPort(); ?>' /> </td>
<td><input type='text' name='<?php echo "service[".$service->getID()."][interval]"; ?>' value='<?php echo $service->getINterval(); ?>' /> </td>
<td>
<input type='text' name='<?php echo "service[".$service->getID()."][count]"; ?>' value='<?php echo $service->getCount(); ?>' />
<input type='hidden' name='<?php echo "service[".$service->getID()."][id]"; ?>' value='<?php echo $service->getID(); ?>' />
</td>
<td><input type='text' name='<?php echo "service[".$service->getID()."][service_name]"; ?>' value='<?php echo $service->getServiceName(); ?>' /> </td>
<td><input type='checkbox' name='<?php echo "service[".$service->getID()."][del]"; ?>' /> </td>
</tr>
<?php endforeach ?>
<tr>
<td colspan='7'><hr/></td>
</tr>
<tr>
<td><input type='text' name="service[new][display]"/> </td>
<td><?php echo MLService::getListOfProtocols('new','http') ?> </td>
<td><input type='text' name="service[new][port]"/> </td>
<td><input type='text' name="service[new][interval]"/> </td>
<td>
<input type='text' name='service[new][count]' />
<input type='hidden' name='service[new][mid]' value='<?php echo $mid?>' />
</td>
<td><input type='text' name='<?php echo "service[new][service_name]"; ?>' /> </td>
<td></td>
</tr>
<tfoot>
<tr>
<td colspan='4'><input type='submit' value="Update" /></td>
</tr>
</tfoot>
</table>
<input type='hidden' name='mid' value='<?php echo $mid?>' />
</form>
</body>
</html>