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