fdbf9dd690626ae66f88e1782ab69d113f053d0a
[nodeconfig.git] / boot / getnodeid.php
1 <?php
2 //
3 // Returns node ID of requestor
4 //
5 // Mark Huang <mlhuang@cs.princeton.edu>
6 // Copyright (C) 2006 The Trustees of Princeton University
7 //
8 // $Id$ $
9 //
10
11 // Get admin API handle
12 require_once 'plc_api.php';
13 global $adm;
14
15 if (!empty($_REQUEST['mac_addr'])) {
16   $mac_lower = strtolower(trim($_REQUEST['mac_addr']));
17   $mac_upper = strtoupper(trim($_REQUEST['mac_addr']));
18   $interfaces = $adm->GetInterfaces(array('mac' => array($mac_lower, $mac_upper)));
19 } else {
20   $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
21 }
22
23 if (!empty($interfaces)) {
24   print $interfaces[0]['node_id'];
25 } else {
26   print "-1";
27 }
28
29 ?>