-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathha_setup.php
More file actions
47 lines (40 loc) · 1.41 KB
/
Copy pathha_setup.php
File metadata and controls
47 lines (40 loc) · 1.41 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
<?php
require_once('inc/global.inc.php');
$smarty->assign("title","Hosts - Accounts Association");
if (isset($_GET["id"])) $id_host = $_GET["id"]; else $id_host = "";
if (isset($_GET["host_name"])) $host_name = $_GET["host_name"]; else $host_name = "";
if (isset($_GET["id_hostgroup"])) $id_hostgroup = $_GET["id_hostgroup"]; else $id_hostgroup = "";
if (isset($_POST["account"])) $id_account = $_POST["account"]; else $id_account = "";
$smarty->assign("id_host",$id_host);
$smarty->assign("host_name",$host_name);
$smarty->assign("id_hostgroup",$id_hostgroup);
$smarty->assign("account",$id_account);
$mysql_link=$GLOBALS['mysql_link'];
// We get the list of accounts
$result = mysqli_query( $mysql_link,"SELECT * FROM `accounts`" );
if (isset($_POST["step"])) $step = $_POST["step"]; else $step = "";
if($step != '1')
{
$accounts=get_all_accounts();
$smarty->assign("accounts",$accounts);
$smarty->display('ha_setup.tpl');
}
else
{
$error_list = "";
if( empty( $error_list ) )
{
$id_host = $_POST['id'];
$id_hostgroup = $_POST['id_hostgroup'];
mysqli_query($mysql_link, "INSERT INTO `hosts-accounts` (`id_host`, `id_account`, `expand`) VALUES('$id_host','$id_account','Y')" )
or die(mysqli_error($mysql_link)."<br>Couldn't execute query");
header("Location:host-view.php?id_hostgroup=$id_hostgroup&id=$id_host");
echo ("account Added, redirecting...");
exit ();
}
else
{
echo( $error_list );
}
}
?>