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