r2709 - adjust context to the current navigation and split it for two helpers
[racktables] / popup.php
1 <?php
2 require 'inc/init.php';
3 ?>
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" style="height: 100%;">
6 <head>
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
8 <?php
9 echo "<title>RackTables pop-up</title>\n";
10 echo "<link rel=stylesheet type='text/css' href=pi.css />\n";
11 echo "<link rel=icon href='" . getFaviconURL() . "' type='image/x-icon' />";
12 echo '</head><body style="height: 100%;">';
13 assertStringArg ('helper', __FILE__);
14 switch ($_REQUEST['helper'])
15 {
16 case 'portlist':
17 // FIXME: shouldn't this be derived from the URL?
18 $pageno = 'object';
19 $tabno = 'ports';
20 fixContext();
21 if (!permitted())
22 {
23 renderAccessDenied();
24 die;
25 }
26 assertUIntArg ('type', __FILE__);
27 assertUIntArg ('port', __FILE__);
28 assertUIntArg ('object_id', __FILE__);
29 assertStringArg ('port_name', __FILE__);
30 echo '<div style="background-color: #f0f0f0; border: 1px solid #3c78b5; padding: 10px; height: 100%; text-align: center; margin: 5px;">';
31 echo '<h2>Choose a port:</h2><br><br>';
32 echo '<form action="javascript:;">';
33 echo '<input type=hidden id=remote_port_name>';
34 echo '<input type=hidden id=remote_object_name>';
35 echo '<select size=' . getConfigVar ('MAXSELSIZE') . ' id=ports>';
36 $type_id = $_REQUEST['type'];
37 $port_id = $_REQUEST['port'];
38 $object_id = $_REQUEST['object_id'];
39 $port_name = $_REQUEST['port_name'];
40 renderEmptyPortsSelect ($port_id, $type_id);
41 echo '</select><br><br>';
42 echo "<input type='submit' value='Proceed' onclick='".
43 "if (getElementById(\"ports\").value != \"\") {".
44 " opener.location=\"${root}process.php?page=object&tab=ports&op=linkPort&object_id=$object_id&port_id=$port_id&port_name=$port_name&remote_port_name=\"+getElementById(\"remote_port_name\").value+\"&remote_object_name=\"+getElementById(\"remote_object_name\").value+\"&remote_port_id=\"+getElementById(\"ports\").value; ".
45 " window.close();}'>";
46 echo '</form></div>';
47 break;
48 case 'inet4list':
49 $pageno = 'ipv4space';
50 $tabno = 'default';
51 fixContext();
52 if (!permitted())
53 {
54 renderAccessDenied();
55 die;
56 }
57 echo '<div style="background-color: #f0f0f0; border: 1px solid #3c78b5; padding: 10px; height: 100%; text-align: center; margin: 5px;">';
58 echo '<h2>Choose a port:</h2><br><br>';
59 echo '<form action="javascript:;">';
60 echo '<input type=hidden id=ip>';
61 echo '<select size=' . getConfigVar ('MAXSELSIZE') . ' id=addresses>';
62 renderAllIPv4Allocations();
63 $addresses = getAllIPv4Allocations();
64 usort ($addresses, 'sortObjectAddressesAndNames');
65 foreach ($addresses as $address)
66 echo "<option value='${address['ip']}' onclick='getElementById(\"ip\").value=\"${address['ip']}\";'>" .
67 "${address['object_name']} ${address['name']} ${address['ip']}</option>\n";
68 echo '</select><br><br>';
69 echo "<input type=submit value='Proceed' onclick='".
70 "if (getElementById(\"ip\")!=\"\") {".
71 " opener.document.getElementById(\"remoteip\").value=getElementById(\"ip\").value;".
72 " window.close();}'>";
73 echo '</form></div>';
74 break;
75 default:
76 showError ('Invalid parameter or internal error', __FILE__);
77 break;
78 }
79 ?>
80 </body>
81 </html>