-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_key_securities.php
101 lines (84 loc) · 3.46 KB
/
search_key_securities.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
require_once('inc/global.inc.php');
$smarty->assign("title","nSKM - Key Security Search");
if (isset($_GET["key"])) $id_key = $_GET["key"]; else $id_key = "";
if (isset($_POST["key"])) $id_key = $_POST["key"]; else $id_key = "";
if (isset($_POST["step"])) $step = $_POST["step"]; else $step = "";
$smarty->assign("id_key",$id_key);
$smarty->assign("step",$step);
if($step != '1')
{
// Afichage simple de la lis des clefs
$all_keys=get_available_keys();
$smarty->assign("allkeys",$all_keys);
$smarty->display('search_key_securities_first.tpl');
}
else
{
// We will seek all accounts of the servers...
$result = mysqli_query($mysql_link, "SELECT * FROM `hak` where `id_key`=$id_key ORDER BY `id_host`" )
or die (mysqli_error($mysql_link)."<br>Couldn't execute query: $query");
$id_lasthost="";
$id_lastaccount="";
$key_name = get_key_name($id_key);
$smarty->assign('key_name',$key_name);
while( $row = mysqli_fetch_array( $result ))
{
$line="";
// We start by seeing if the key exists
$id_currentkey = $row["id_key"];
if ( $id_currentkey == $id_key )
{
// HOST DISPLAY
$id_currenthost = $row["id_host"];
if ( $id_currenthost != $id_lasthost )
{
$hostname = get_host_name($id_currenthost);
$list[$id_currentkey][$id_currenthost]['hostname']= $hostname;
$id_lastaccount = "";
}
$id_lasthost = $id_currenthost;
// ACCOUNT DISPLAY
$id_currentaccount = $row["id_account"];
if ( $id_currentaccount != $id_lastaccount )
{
$accountname = get_account_name($id_currentaccount);
$list[$id_currentkey][$id_currenthost]['accounts'][]= $accountname;
}
$id_lastaccount = $id_currentaccount;
}
}
if (isset($list)) $smarty->assign('list',$list);
// We will seek all accounts of the Servers that contain the key application...
// ---------------------------------------------------------------------------------------
$resultkeyring = mysqli_query($mysql_link, "SELECT * FROM `keyrings-keys` where `id_key` = '$id_key' ORDER BY `id_keyring`" )
or die (mysqli_error($mysql_link)."<br>Couldn't execute query: $query");
while ( $rowkeyring = mysqli_fetch_array( $resultkeyring ))
{
$id_keyring = $rowkeyring["id_keyring"];
$result = mysqli_query($mysql_link, "SELECT * FROM `hak` where `id_keyring` = '$id_keyring' ORDER BY `id_host`" )
or die (mysqli_error($mysql_link)."<br>Couldn't execute query: $query");
$keyring_name = get_keyring_name($id_keyring);
$keyrings[$id_keyring]["keyring_name"]=get_keyring_name($id_keyring);
$nr = $result->num_rows;
$lasthostname="";
while( $row = mysqli_fetch_array( $result ))
{
// Afecting values
$id_host=$row["id_host"];
$id_account=$row["id_account"];
$keyrings[$id_keyring]["id_account"]=$row["id_account"];
$hostname = get_host_name($id_host);
if ( $hostname != $lasthostname )
{
$keyrings[$id_keyring]['hosts'][$id_host]['hostname']=$hostname;
$lasthostname = $hostname;
}
$account_name=get_account_name($id_account);
$keyrings[$id_keyring]['hosts'][$id_host]['accounts'][]=$account_name;
}
}
if (isset($list2)) $smarty->assign('list2',$keyrings);
$smarty->display('search_key_securities_list.tpl');
}
?>