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
102
103
104
105
106
107
108
109
110
111
112
|
<?php require_once('basic_info.php');
global $dbh;
if ($_GET["for"] == "get_selected_data_center_info") { if(!empty($_POST["selected_item_list"])){
$fields = array("Host Name" => "hostname", "Device Type" => "device_type", "Company" => "company", "OS" => "os", "VM Host" => "vm_host", "Admin Login" => "admin_login", "URL" => "url", "S/N" => "sn", "Model" => "model", "Remarks" => "remark");
$user_permission = get_user_permission_by_cmsloginid($_SESSION["cmsloginid"]);
$result = "<table id='selected_data_center_info'> <tr> <th style='width: 50px;'>Modify</th> <th style='width: 150px;'>Data Center</th> <th style='width: 120px;'>Public IP</th> <th style='width: 120px;'>Internal IP</th>";
foreach($fields as $key => $field){ if($user_permission[$field] == 1){ $result .= "<th>".$key."</th>"; } }
$result .= "</tr>";
$selected_item = explode(",", $_POST["selected_item_list"]);
foreach($selected_item as $item){ //$data_center_detail_info = get_data_center_detail($item);
$sql = "select dcd.*,dc.id as data_center_id, dc.id as data_center_id, dc.name as dc_name from data_center_detail dcd INNER JOIN data_center dc ON dcd.data_center_id = dc.id where dcd.id = ? and dcd.status = ? and dcd.deleted = ? and dc.status = ? and dc.deleted = ? order by dc.name ASC, dcd.internal_ip ASC"; $parameters = array($item, 1, 0 ,1, 0); $data_center_detail = bind_pdo($sql, $parameters, "selectone");
if(!empty($data_center_detail)){ $result .= "<tr>";
$result .= "<td><a href='data_center_detail_modifyform.php?id=".(int)$item."' target='_blank'><button type='button'>Modify</button></a></td>";
if($_SESSION["role"] == "super_admin"){ $result .= "<td><a href='data_center_modifyform.php?id=".$data_center_detail["data_center_id"]."' target='_blank' style='text-decoration: underline;'>".$data_center_detail["dc_name"]."</a></td>"; }else{ $result .= "<td>".$data_center_detail["dc_name"]."</td>"; }
$public_ip_info = get_public_ip_by_data_center_detail_id($item);
$result .= "<td>";
foreach($public_ip_info as $public_ip){ $result .= $public_ip["public_ip"]."<br>"; }
$result .= "</td>"; $result .= "<td>".$data_center_detail["internal_ip"]."</td>";
foreach($fields as $key => $field){ $permission = explode(",", $user_permission[$field]);
$read = $permission[0]; $modify = $permission[1];
if($read == 1){ if($field == "device_type" || $field == "os"){ $data_center_detail[$field] = "";
if($data_center_detail[$field."_id"] > 0){ $master_type_code_info = get_master_type_code_by_id($data_center_detail[$field."_id"]); if(!empty($master_type_code_info)){ $data_center_detail[$field] = $master_type_code_info["name_en"]; } } }
if($field == "admin_login"){ $data_center_detail[$field] = ""; $admin_login_info = get_admin_login_by_data_center_detail_id($item); foreach($admin_login_info as $admin_login){ $data_center_detail[$field] .= "Name: ".$admin_login["login_name"]."<br>Password: ".aes_crypt($admin_login["login_pw"], 2)."<hr>"; }
$data_center_detail[$field] = substr_replace($data_center_detail[$field], "", -4); }
if($field == "url") $data_center_detail[$field] = "<a href='".$data_center_detail[$field]."' target='_blank' style='text-decoration:underline; color: blue;'>".$data_center_detail[$field]."</a>";
$wrap = ""; if($field == "remark") $wrap = "style='white-space: normal;'";
$result .= "<td ".$wrap.">".$data_center_detail[$field]."</td>"; } }
$result .= "</tr>"; } }
$result .= "</table>";
echo $result; }else{ echo "No records."; } }
|