示例#1
0
 }
 // no that we have something - compule the data
 $nodeList = new nodeList();
 $communityName = str_replace(' ', '', $GLOBALS['community_name']);
 # use domain part of mail_sender_address
 $communityWebsite = 'http://www.' . substr(strrchr($GLOBALS['mail_sender_adress'], "@"), 1);
 $nodeList->setCommunityName($communityName);
 $nodeList->setWebsite($communityWebsite);
 $nodeList->setCommunityFile($GLOBALS['url_to_netmon'] . '/api/community.php');
 foreach ($result as $resultNode) {
     $node = new node($resultNode['id'], $resultNode['hostname']);
     $last_seen = $resultNode['last_update'];
     if (!empty($resultNode['last_seen']) && $resultNode['last_seen'] > $resultNode['last_update']) {
         $last_seen = $resultNode['last_seen'];
     }
     $node->setType('AccessPoint');
     $node->setHref($GLOBALS['url_to_netmon'] . 'router.php?router_id=' . $resultNode['id']);
     $node->setStatus($resultNode['status'] == 'online', $resultNode['client_count'], $last_seen);
     $node->setGeo($resultNode['latitude'], $resultNode['longitude']);
     $node->setUserId($resultNode['u_id']);
     $nodeList->addPerson($resultNode['u_id'], $resultNode['nickname'], $GLOBALS['url_to_netmon'] . 'user.php?user_id=' . $resultNode['u_id']);
     $nodeList->addNode($node->getNode());
 }
 try {
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 60 * 15));
     header('Content-type: application/json');
     echo json_encode($nodeList->getList(), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
 } catch (Exception $e) {
     echo 'Unable to create nodelist: ', $e->getMessage(), "\n";
 }