/
hakk_setup.php
86 lines (70 loc) · 3.14 KB
/
hakk_setup.php
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
<?php include('MyFunctions.inc.php');
if (isset($_GET["id"])) $id = $_GET["id"]; else $id = "";
if (isset($_GET["host_name"])) $host_name = $_GET["host_name"]; else $host_name = "";
if (isset($_GET["id_account"])) $id_account = $_GET["id_account"]; else $id_account = "";
if (isset($_GET["account_name"])) $account_name = $_GET["account_name"]; else $account_name = "";
if (isset($_GET["hostgroup"])) $hostgroup = $_GET["hostgroup"]; else $hostgroup = "";
if (isset($_POST["step"])) $step = $_POST["step"]; else $step = "";
// We get the list of keyrings
/* $result = mysql_query( "SELECT * FROM `keyrings`" ); */
if($step != '1')
{
?>
<html>
<HEAD>
<TITLE>Hosts - accounts - Key Association</TITLE>
<LINK REL=STYLESHEET HREF="skm.css" TYPE="text/css">
</HEAD>
<BODY>
<?php
$name_account = get_account_name($id_account);
$name = get_host_name($id);
?>
<?php start_main_frame("<a href=\"show_all_hosts.php\"> SKM </a> > <a href=\"hosts-view.php?hostgroup=$hostgroup\">$hostgroup</a> > <a href=\"host-view.php?id=$id&hostgroup=$hostgroup\"> $name </a> > <a href=\"account-view.php?id=$id&hostgroup=$hostgroup&id_account=$id_account\">$name_account </a> > Add Key"); ?>
<?php start_left_pane(); ?>
<?php display_menu(); ?>
<?php end_left_pane(); ?>
<?php start_right_pane(); ?>
<center>
<form name="setup_hak" action="hakk_setup.php" method="post">
<fieldset><legend>Adding key(s) to account <?php echo("$account_name"); ?> on host <?php echo("$host_name");?></legend>
<table border='0' align='center' class="modif_contact">
<tr>
<td class="Type"><img src='images/key_little.gif'><?php display_availables_keys(); ?></td>
</td>
</tr>
</table>
</fieldset>
<center>
<input name="step" type="hidden" value="1">
<input name="id" type="hidden" value="<?php echo("$id");?>">
<input name="hostgroup" type="hidden" value="<?php echo("$hostgroup");?>">
<input name="id_account" type="hidden" value="<?php echo("$id_account");?>">
<input name="submit" type="submit" value="add">
</center>
</form>
</center>
<? end_right_pane(); ?>
<? end_main_frame(); ?>
</body>
</html>
<?php
}
else
{
if (isset($_POST["id"])) $host_id = $_POST["id"]; else $host_id = "";
if (isset($_POST["id_account"])) $account_id = $_POST["id_account"]; else $account_id = "";
if (isset($_POST["key"])) $key_id = $_POST["key"]; else $key_id = "";
if (isset($_POST["account_name"])) $account_name = $_POST["account_name"]; else $account_name = "";
if (isset($_POST["hostgroup"])) $hostgroup = $_POST["hostgroup"]; else $hostgroup = "";
/*
echo ("account_name = $account_name, account_id = $account_id, host_id = $host_id");
echo ("Keyring id = $keyring_id, key id = $key_id");
die ("We stop here");
*/
mysql_query( "INSERT INTO `hak` (`id_host`, `id_account`, `id_key`,`expand`) VALUES('$host_id','$account_id','$key_id','Y')" ) or die(mysql_error()."<br>Couldn't execute query: insert host_id=$host_id, account_id=$account_id, key_id=$key_id [$query]");
header("Location:account-view.php?id=$host_id&hostgroup=$hostgroup&id_account=$account_id");
echo ("key Added, redirecting...");
exit ();
}
?>