Exemple #1
0
    public function GetNode($id)
    {
        if ($result = $this->db->GetRow('SELECT n.*, rs.name AS linkradiosectorname,
		    inet_ntoa(n.ipaddr) AS ip, inet_ntoa(n.ipaddr_pub) AS ip_pub,
		    lc.name AS city_name,
				(CASE WHEN ls.name2 IS NOT NULL THEN ' . $this->db->Concat('ls.name2', "' '", 'ls.name') . ' ELSE ls.name END) AS street_name,
				lt.name AS street_type,
			lb.name AS borough_name, lb.type AS borough_type,
			ld.name AS district_name, lst.name AS state_name
			FROM vnodes n
			LEFT JOIN netradiosectors rs ON rs.id = n.linkradiosector
			LEFT JOIN location_cities lc ON (lc.id = n.location_city)
			LEFT JOIN location_streets ls ON (ls.id = n.location_street)
			LEFT JOIN location_street_types lt ON (lt.id = ls.typeid)
			LEFT JOIN location_boroughs lb ON (lb.id = lc.boroughid)
			LEFT JOIN location_districts ld ON (ld.id = lb.districtid)
			LEFT JOIN location_states lst ON (lst.id = ld.stateid)
			WHERE n.id = ?', array($id))) {
            $customer_manager = new LMSCustomerManager($this->db, $this->auth, $this->cache, $this->syslog);
            $user_manager = new LMSUserManager($this->db, $this->auth, $this->cache, $this->syslog);
            $result['radiosectors'] = $this->db->GetAll('SELECT * FROM netradiosectors WHERE netdev = ?', array($result['netdev']));
            $result['owner'] = $customer_manager->GetCustomerName($result['ownerid']);
            $result['createdby'] = $user_manager->GetUserName($result['creatorid']);
            $result['modifiedby'] = $user_manager->GetUserName($result['modid']);
            $result['creationdateh'] = date('Y/m/d, H:i', $result['creationdate']);
            $result['moddateh'] = date('Y/m/d, H:i', $result['moddate']);
            $result['lastonlinedate'] = lastonline_date($result['lastonline']);
            $result['mac'] = preg_split('/,/', $result['mac']);
            foreach ($result['mac'] as $mac) {
                $result['macs'][] = array('mac' => $mac, 'producer' => get_producer($mac));
            }
            unset($result['mac']);
            if ($netname = $this->db->GetOne('SELECT name FROM networks
				WHERE id = ?', array($result['netid']))) {
                $result['netname'] = $netname;
            }
            if ($result['ip_pub'] != '0.0.0.0') {
                $network_manager = new LMSNetworkManager($this->db, $this->auth, $this->cache, $this->syslog);
                $result['netpubid'] = $network_manager->GetNetIDByIP($result['ip_pub']);
                $result['netpubname'] = $this->db->GetOne('SELECT name FROM networks
					WHERE id = ?', array($result['netpubid']));
            }
            return $result;
        } else {
            return FALSE;
        }
    }
Exemple #2
0
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License Version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 *  USA.
 *
 *  $Id$
 */
$nodes = $DB->GetAll('SELECT n.id, n.name, n.mac,
        inet_ntoa(n.ipaddr) AS ip, inet_ntoa(n.ipaddr_pub) AS ip_pub,
        n.access, n.warning, n.info, n.lastonline
    FROM vnodes n
    JOIN ewx_stm_nodes s ON (s.nodeid = n.id)
    JOIN ewx_stm_channels c ON (s.channelid = c.id)
    WHERE c.cid = ?', array($_GET['id']));
if ($nodes) {
    foreach ($nodes as $idx => $row) {
        $nodes[$idx]['lastonlinedate'] = lastonline_date($row['lastonline']);
    }
}
$SMARTY->assign('customernodes', $nodes);
$SMARTY->display('nodelistshort.html');
    /**
     * Returns customer nodes
     * 
     * @param int $id Customer id
     * @param int $count Limit
     * @return array Nodes
     */
    public function getCustomerNodes($id, $count = null)
    {
        if ($result = $this->db->GetAll('SELECT n.id, n.name, mac, ipaddr,
				inet_ntoa(ipaddr) AS ip, ipaddr_pub,
				inet_ntoa(ipaddr_pub) AS ip_pub, passwd, access,
				warning, info, ownerid, lastonline, location,
				(SELECT COUNT(*) FROM nodegroupassignments
					WHERE nodeid = n.id) AS gcount,
				n.netid, net.name AS netname
				FROM vnodes n
				JOIN networks net ON net.id = n.netid
				WHERE ownerid = ?
				ORDER BY n.name ASC ' . ($count ? 'LIMIT ' . $count : ''), array($id))) {
            // assign network(s) to node record
            $network_manager = new LMSNetworkManager($this->db, $this->auth, $this->cache);
            $networks = (array) $network_manager->GetNetworks();
            foreach ($result as $idx => $node) {
                $ids[$node['id']] = $idx;
                $result[$idx]['lastonlinedate'] = lastonline_date($node['lastonline']);
                //foreach ($networks as $net)
                //	if (isipin($node['ip'], $net['address'], $net['mask'])) {
                //		$result[$idx]['network'] = $net;
                //		break;
                //	}
                if ($node['ipaddr_pub']) {
                    foreach ($networks as $net) {
                        if (isipin($node['ip_pub'], $net['address'], $net['mask'])) {
                            $result[$idx]['network_pub'] = $net;
                            break;
                        }
                    }
                }
            }
            // get EtherWerX channels
            if (ConfigHelper::checkValue(ConfigHelper::getConfig('phpui.ewx_support', false))) {
                $channels = $this->db->GetAllByKey('SELECT nodeid, channelid, c.name, c.id, cid,
				        nc.upceil, nc.downceil
					FROM ewx_stm_nodes
					JOIN ewx_stm_channels nc ON (channelid = nc.id)
					LEFT JOIN ewx_channels c ON (c.id = nc.cid)
					WHERE nodeid IN (' . implode(',', array_keys($ids)) . ')', 'nodeid');
                if ($channels) {
                    foreach ($channels as $channel) {
                        $idx = $ids[$channel['nodeid']];
                        $result[$idx]['channelid'] = $channel['id'] ? $channel['id'] : $channel['channelid'];
                        $result[$idx]['channelname'] = $channel['name'];
                        $result[$idx]['cid'] = $channel['cid'];
                        $result[$idx]['downceil'] = $channel['downceil'];
                        $result[$idx]['upceil'] = $channel['upceil'];
                    }
                }
            }
        }
        return $result;
    }
Exemple #4
0
    function GetNode($id)
    {
        if ($result = $this->DB->GetRow('SELECT n.*,
		    inet_ntoa(n.ipaddr) AS ip, inet_ntoa(n.ipaddr_pub) AS ip_pub,
		    lc.name AS city_name ' . ',(SELECT 1 FROM monitnodes WHERE monitnodes.id = n.id AND monitnodes.active = 1) AS monitoring ' . ',(SELECT 1 FROM monitnodes WHERE monitnodes.id = n.id AND monitnodes.active = 1 AND monitnodes.signaltest=1) AS monitoringsignal ' . ',(SELECT name FROM invprojects WHERE invprojects.id = n.invprojectid) AS projectname ' . ', (CASE WHEN ls.name2 IS NOT NULL THEN ' . $this->DB->Concat('ls.name2', "' '", 'ls.name') . ' ELSE ls.name END) AS street_name, lt.name AS street_type
			FROM vnodes n
			LEFT JOIN location_cities lc ON (lc.id = n.location_city)
			LEFT JOIN location_streets ls ON (ls.id = n.location_street)
			LEFT JOIN location_street_types lt ON (lt.id = ls.typeid)
			WHERE n.id = ?', array($id))) {
            $result['typeofdevicename'] = $this->DB->GetOne('SELECT type FROM dictionary_devices_client WHERE id = ? ' . $this->DB->Limit('1') . ' ;', array($result['typeofdevice']));
            $result['owner'] = $this->GetCustomerName($result['ownerid']);
            $result['createdby'] = $this->GetUserName($result['creatorid']);
            $result['modifiedby'] = $this->GetUserName($result['modid']);
            $result['creationdateh'] = date('Y/m/d, H:i', $result['creationdate']);
            $result['moddateh'] = date('Y/m/d, H:i', $result['moddate']);
            if ($result['access_from']) {
                $result['access_from'] = date('Y/m/d', $result['access_from']);
            } else {
                $result['access_from'] = '';
            }
            if ($result['access_to']) {
                $result['access_to'] = date('Y/m/d', $result['access_to']);
            } else {
                $result['acces_to'] = '';
            }
            $result['lastonlinedate'] = lastonline_date($result['lastonline']);
            if ($result['netid']) {
                $tmp = $this->DB->GetRow('SELECT n.name AS networkname, h.name AS hostname 
					FROM networks n 
					LEFT JOIN hosts h ON (h.id = n.hostid) 
					WHERE n.id = ? LIMIT 1;', array($result['netid']));
                $result['networkname'] = $tmp['networkname'];
                $result['hostname'] = $tmp['hostname'];
            }
            if ($result['netid_pub']) {
                $tmp = $this->DB->GetRow('SELECT n.name AS networkname, h.name AS hostname 
					FROM networks n 
					LEFT JOIN hosts h ON (h.id = n.hostid) 
					WHERE n.id = ? LIMIT 1;', array($result['netid_pub']));
                $result['networkname_pub'] = $tmp['networkname'];
                $result['hostname_pub'] = $tmp['hostname'];
            }
            if ($result['nasid'] && get_form('nodes.nas')) {
                $result['nasname'] = $this->DB->GetOne('SELECT name FROM nas WHERE id = ? LIMIT 1;', array($result['nasid']));
            }
            $result['mac'] = preg_split('/,/', $result['mac']);
            foreach ($result['mac'] as $mac) {
                $result['macs'][] = array('mac' => $mac, 'producer' => get_producer($mac));
            }
            unset($result['mac']);
            $result = $this->exechook('lms_getnode_after', $result);
            return $result;
        } else {
            return FALSE;
        }
    }
Exemple #5
0
    public function GetNode($id)
    {
        if ($result = $this->DB->GetRow('SELECT n.*,
		    inet_ntoa(n.ipaddr) AS ip, inet_ntoa(n.ipaddr_pub) AS ip_pub,
		    lc.name AS city_name,
				(CASE WHEN ls.name2 IS NOT NULL THEN ' . $this->DB->Concat('ls.name2', "' '", 'ls.name') . ' ELSE ls.name END) AS street_name, lt.name AS street_type
			FROM vnodes n
			LEFT JOIN location_cities lc ON (lc.id = n.location_city)
			LEFT JOIN location_streets ls ON (ls.id = n.location_street)
			LEFT JOIN location_street_types lt ON (lt.id = ls.typeid)
			WHERE n.id = ?', array($id))) {
            $result['owner'] = $this->GetCustomerName($result['ownerid']);
            $result['createdby'] = $this->GetUserName($result['creatorid']);
            $result['modifiedby'] = $this->GetUserName($result['modid']);
            $result['creationdateh'] = date('Y/m/d, H:i', $result['creationdate']);
            $result['moddateh'] = date('Y/m/d, H:i', $result['moddate']);
            $result['lastonlinedate'] = lastonline_date($result['lastonline']);
            $result['mac'] = preg_split('/,/', $result['mac']);
            foreach ($result['mac'] as $mac) {
                $result['macs'][] = array('mac' => $mac, 'producer' => get_producer($mac));
            }
            unset($result['mac']);
            if ($netname = $this->DB->GetOne('SELECT name FROM networks
				WHERE id = ?', array($result['netid']))) {
                $result['netname'] = $netname;
            }
            if ($result['ip_pub'] != '0.0.0.0') {
                $result['netpubid'] = $this->GetNetIDByIP($result['ip_pub']);
                $result['netpubname'] = $this->DB->GetOne('SELECT name FROM networks
					WHERE id = ?', array($result['netpubid']));
            }
            return $result;
        } else {
            return FALSE;
        }
    }
Exemple #6
0
    protected function customerNodesProvider($customer_id, $type = '', $count = null)
    {
        $type = strtolower($type);
        switch ($type) {
            case 'netdev':
                $type = 'nd.ownerid = ?';
                break;
            default:
                $type = 'n.ownerid = ?';
        }
        $result = $this->db->GetAll("SELECT\n                                        n.id, n.name, mac, ipaddr, inet_ntoa(ipaddr) AS ip, nd.name as netdev_name,\n                                        ipaddr_pub, n.authtype, inet_ntoa(ipaddr_pub) AS ip_pub,\n                                        passwd, access, warning, info, n.ownerid, lastonline, n.location,\n                                        (SELECT COUNT(*)\n                                        FROM nodegroupassignments\n                                        WHERE nodeid = n.id) AS gcount,\n                                        n.netid, net.name AS netname\n                                     FROM\n                                        vnodes n\n                                        JOIN networks net ON net.id = n.netid\n                                        LEFT JOIN netdevices nd ON n.netdev = nd.id\n                                     WHERE\n                                        " . $type . "\n                                     ORDER BY\n                                        n.name ASC " . ($count ? 'LIMIT ' . $count : ''), array($customer_id));
        if ($result) {
            // assign network(s) to node record
            $network_manager = new LMSNetworkManager($this->db, $this->auth, $this->cache);
            $networks = (array) $network_manager->GetNetworks();
            foreach ($result as $idx => $node) {
                $ids[$node['id']] = $idx;
                $result[$idx]['lastonlinedate'] = lastonline_date($node['lastonline']);
                if ($node['ipaddr_pub']) {
                    foreach ($networks as $net) {
                        if (isipin($node['ip_pub'], $net['address'], $net['mask'])) {
                            $result[$idx]['network_pub'] = $net;
                            break;
                        }
                    }
                }
            }
            // get EtherWerX channels
            if (ConfigHelper::checkValue(ConfigHelper::getConfig('phpui.ewx_support', false))) {
                $channels = $this->db->GetAllByKey('SELECT nodeid, channelid, c.name, c.id, cid,
				        nc.upceil, nc.downceil
			 		FROM ewx_stm_nodes
					JOIN ewx_stm_channels nc ON (channelid = nc.id)
					LEFT JOIN ewx_channels c ON (c.id = nc.cid)
					WHERE nodeid IN (' . implode(',', array_keys($ids)) . ')', 'nodeid');
                if ($channels) {
                    foreach ($channels as $channel) {
                        $idx = $ids[$channel['nodeid']];
                        $result[$idx]['channelid'] = $channel['id'] ? $channel['id'] : $channel['channelid'];
                        $result[$idx]['channelname'] = $channel['name'];
                        $result[$idx]['cid'] = $channel['cid'];
                        $result[$idx]['downceil'] = $channel['downceil'];
                        $result[$idx]['upceil'] = $channel['upceil'];
                    }
                }
            }
        }
        return $result;
    }