public function __construct($router_id = false, $crawl_cycle_id = false, $offset = false, $limit = false, $sort_by = false, $order = false)
 {
     $result = array();
     if ($offset !== false) {
         $this->setOffset((int) $offset);
     }
     if ($limit !== false) {
         $this->setLimit((int) $limit);
     }
     if ($sort_by !== false) {
         $this->setSortBy($sort_by);
     }
     if ($order !== false) {
         $this->SetOrder($order);
     }
     // initialize $total_count with the total number of objects in the list (over all pages)
     try {
         $stmt = DB::getInstance()->prepare("SELECT COUNT(*) as total_count\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM crawl_batman_advanced_originators\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(crawl_batman_advanced_originators.router_id = :router_id OR :router_id=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(crawl_batman_advanced_originators.crawl_cycle_id = :crawl_cycle_id OR :crawl_cycle_id=0)");
         $stmt->bindParam(':router_id', $router_id, PDO::PARAM_INT);
         $stmt->bindParam(':crawl_cycle_id', $crawl_cycle_id ? $crawl_cycle_id : (int) crawling::getLastEndedCrawlCycle()['id'], PDO::PARAM_INT);
         $stmt->execute();
         $total_count = $stmt->fetch(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     $this->setTotalCount((int) $total_count['total_count']);
     //if limit -1 then get all ressource records
     if ($this->getLimit() == -1) {
         $this->setLimit($this->getTotalCount());
     }
     try {
         $stmt = DB::getInstance()->prepare("SELECT  crawl_batman_advanced_originators.id as status_id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcrawl_batman_advanced_originators.*\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM crawl_batman_advanced_originators\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(crawl_batman_advanced_originators.router_id = :router_id OR :router_id=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(crawl_batman_advanced_originators.crawl_cycle_id = :crawl_cycle_id OR :crawl_cycle_id=0)\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase :sort_by\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'status_id' then crawl_batman_advanced_originators.id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'router_id' then crawl_batman_advanced_originators.router_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'crawl_cycle_id' then crawl_batman_advanced_originators.crawl_cycle_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $this->getOrder() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT :offset, :limit");
         $stmt->bindParam(':router_id', $router_id, PDO::PARAM_INT);
         $stmt->bindParam(':crawl_cycle_id', $crawl_cycle_id ? $crawl_cycle_id : (int) crawling::getLastEndedCrawlCycle()['id'], PDO::PARAM_INT);
         $stmt->bindParam(':offset', $this->getOffset(), PDO::PARAM_INT);
         $stmt->bindParam(':limit', $this->getLimit(), PDO::PARAM_INT);
         $stmt->bindParam(':sort_by', $this->getSortBy(), PDO::PARAM_STR);
         $stmt->execute();
         $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     foreach ($result as $res) {
         $originator_status = new OriginatorStatus((int) $res['status_id'], (int) $res['crawl_cycle_id'], (int) $res['router_id'], $res['originator'], (int) $res['link_quality'], $res['nexthop'], $res['outgoing_interface'], $res['last_seen'], $res['crawl_date']);
         $this->originator_status_list[] = $originator_status;
     }
 }
 public function __construct($status_id = false, $router_id = false, $offset = false, $limit = false, $sort_by = false, $order = false)
 {
     $result = array();
     if ($offset !== false) {
         $this->setOffset((int) $offset);
     }
     if ($limit !== false) {
         $this->setLimit((int) $limit);
     }
     if ($sort_by !== false) {
         $this->setSortBy($sort_by);
     }
     if ($order !== false) {
         $this->SetOrder($order);
     }
     // initialize $total_count with the total number of objects in the list (over all pages)
     try {
         $stmt = DB::getInstance()->prepare("SELECT COUNT(*) as total_count\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM interfaces\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(interfaces.router_id = :router_id OR :router_id=0)");
         $stmt->bindParam(':router_id', $router_id, PDO::PARAM_INT);
         $stmt->execute();
         $total_count = $stmt->fetch(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     $this->setTotalCount((int) $total_count['total_count']);
     //if limit -1 then get all ressource records
     if ($this->getLimit() == -1) {
         $this->setLimit($this->getTotalCount());
     }
     try {
         $stmt = DB::getInstance()->prepare("SELECT i.id as i_id, i.router_id as i_router_id, i.name as i_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\ti.create_date as i_create_date, i.update_date as i_update_date,\n\t\t\t\t\t\t\t\t\t\t\t\t\tci.id as ci_id, ci.router_id as ci_router_id, ci.crawl_cycle_id as ci_crawl_cycle_id,\n\t\t\t\t\t\t\t\t\t\t\t\t\tci.interface_id ci_interface_id, ci.crawl_date as ci_crawl_date, ci.name as ci_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\tci.mac_addr as ci_mac_addr, ci.traffic_rx ci_traffic_rx, ci.traffic_rx_avg ci_traffic_rx_avg,\n\t\t\t\t\t\t\t\t\t\t\t\t\tci.traffic_tx ci_traffic_tx, ci.traffic_tx_avg ci_traffic_tx_avg, ci.wlan_mode ci_wlan_mode,\n\t\t\t\t\t\t\t\t\t\t\t\t\tci.wlan_frequency ci_wlan_frequency, ci.wlan_essid ci_wlan_essid, ci.wlan_bssid ci_wlan_bssid,\n\t\t\t\t\t\t\t\t\t\t\t\t\tci.wlan_tx_power ci_wlan_tx_power, ci.mtu ci_mtu\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM interfaces i, crawl_interfaces ci\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(i.router_id = :router_id OR :router_id=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tci.interface_id = i.id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tci.crawl_cycle_id = :status_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase :sort_by\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'name' then i.name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $this->getOrder() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT :offset, :limit");
         $stmt->bindParam(':status_id', $status_id ? $status_id : (int) crawling::getLastEndedCrawlCycle()['id'], PDO::PARAM_INT);
         $stmt->bindParam(':router_id', $router_id, PDO::PARAM_INT);
         $stmt->bindParam(':offset', $this->getOffset(), PDO::PARAM_INT);
         $stmt->bindParam(':limit', $this->getLimit(), PDO::PARAM_INT);
         $stmt->bindParam(':sort_by', $this->getSortBy(), PDO::PARAM_STR);
         $stmt->execute();
         $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     foreach ($result as $networkinterface) {
         $new_networkinterface = new Networkinterface((int) $networkinterface['i_id'], (int) $networkinterface['i_router_id'], $networkinterface['i_name'], $networkinterface['i_create_date'], $networkinterface['i_update_date']);
         $new_networkinterface->setStatusdata(new NetworkinterfaceStatus((int) $networkinterface['ci_id'], (int) $networkinterface['ci_crawl_cycle_id'], (int) $networkinterface['ci_interface_id'], (int) $networkinterface['ci_router_id'], $networkinterface['ci_name'], $networkinterface['ci_mac_addr'], (int) $networkinterface['ci_mtu'], (int) $networkinterface['ci_traffic_rx'], (int) $networkinterface['ci_traffic_rx_avg'], (int) $networkinterface['ci_traffic_tx'], (int) $networkinterface['ci_traffic_tx_avg'], $networkinterface['ci_wlan_mode'], $networkinterface['ci_wlan_frequency'], $networkinterface['ci_wlan_essid'], $networkinterface['ci_wlan_bssid'], (int) $networkinterface['ci_wlan_tx_power'], $networkinterface['ci_crawl_date']));
         $this->networkinterfacelist[] = $new_networkinterface;
     }
 }
示例#3
0
 public function store()
 {
     if ($this->crawl_cycle_id == 0) {
         $this->setCrawlCycleId((int) crawling::getLastEndedCrawlCycle()['id']);
     }
     if ($this->crawl_cycle_id != 0 and $this->object != "" and $this->object_id != 0 and $this->action != "" and $this->data != null) {
         try {
             $stmt = DB::getInstance()->prepare("INSERT INTO events (crawl_cycle_id, object, object_id, action, create_date, update_date, data)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES (?, ?, ?, ?, NOW(), NOW(), ?)");
             $stmt->execute(array($this->crawl_cycle_id, $this->object, $this->object_id, $this->action, $this->data));
             return DB::getInstance()->lastInsertId();
         } catch (PDOException $e) {
             echo $e->getMessage();
             echo $e->getTraceAsString();
         }
     }
     return false;
 }
示例#4
0
 /**
  * Initialize the routerlist with routers
  * @param $user_id	possible values:
  *							int: >0, initialize the routerlist with the routers of the user
  *							boolean: false, initialize the routerlist with routers of all users
  * @param $offset	possible values:
  *							int: >=0, controll the position from where the first router in the list ist fetched from db
  *							boolean: false, initialize offset with 0
  * @param $limit	possible values:
  *							int: >=0, controll the maximum numbers of routers in the list
  *							int: -1, set limit to maximum
  * @param $sort_by	possible values:
  *							string: hostname, 
  *							boolean: false, sort default by router_id
  * @param $order	possible values:
  *							string: asc, desc
  *							boolean: false, order default asc
  */
 public function __construct($crawl_cycle_id = false, $user_id = false, $crawl_method = false, $status = false, $hardware_name = false, $firmware_version = false, $batman_advanced_version = false, $kernel_version = false, $offset = false, $limit = false, $sort_by = false, $order = false)
 {
     $result = array();
     if ($offset !== false) {
         $this->setOffset((int) $offset);
     }
     if ($limit !== false) {
         $this->setLimit((int) $limit);
     }
     if ($sort_by !== false) {
         $this->setSortBy($sort_by);
     }
     if ($order !== false) {
         $this->SetOrder($order);
     }
     // initialize $total_count with the total number of objects in the list (over all pages)
     try {
         $stmt = DB::getInstance()->prepare("SELECT COUNT(*) as total_count\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM routers r, users u, chipsets c, crawl_routers s\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(r.user_id = :user_id OR :user_id=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(r.crawl_method = :crawl_method OR :crawl_method='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(s.status = :status OR :status='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(c.hardware_name = :hardware_name OR :hardware_name='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(s.firmware_version = :firmware_version OR :firmware_version='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(s.batman_advanced_version = :batman_advanced_version OR :batman_advanced_version='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(s.kernel_version = :kernel_version OR :kernel_version='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tr.user_id = u.id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tr.chipset_id= c.id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tr.id = s.router_id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ts.crawl_cycle_id = :crawl_cycle_id");
         $stmt->bindParam(':crawl_cycle_id', $crawl_cycle_id ? $crawl_cycle_id : (int) crawling::getLastEndedCrawlCycle()['id'], PDO::PARAM_INT);
         $stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
         $stmt->bindParam(':crawl_method', $crawl_method, PDO::PARAM_STR);
         $stmt->bindParam(':status', $status, PDO::PARAM_STR);
         $stmt->bindParam(':hardware_name', $hardware_name, PDO::PARAM_STR);
         $stmt->bindParam(':firmware_version', $firmware_version, PDO::PARAM_STR);
         $stmt->bindParam(':batman_advanced_version', $batman_advanced_version, PDO::PARAM_STR);
         $stmt->bindParam(':kernel_version', $kernel_version, PDO::PARAM_STR);
         $stmt->execute();
         $total_count = $stmt->fetch(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     $this->setTotalCount((int) $total_count['total_count']);
     //if limit -1 then get all ressource records
     if ($this->getLimit() == -1) {
         $this->setLimit($this->getTotalCount());
     }
     try {
         $stmt = DB::getInstance()->prepare("SELECT r.id as r_id, r.user_id as r_user_id, r.create_date as r_create_date, r.update_date as r_update_date, r.crawl_method as r_crawl_method, r.hostname as r_hostname, r.allow_router_auto_assign as r_allow_router_auto_assign, r.router_auto_assign_login_string as r_allow_router_auto_assign, r.router_auto_assign_hash as r_router_auto_assign_hash, r.description as r_description, r.location as r_location, r.latitude as r_latitude, r.longitude as r_longitude, r.chipset_id as r_chipset_id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   u.id as u_id, u.session_id as u_session_id, u.nickname as u_nickname, u.password as u_password, u.openid as u_openid, u.api_key as u_api_key, u.vorname as u_vorname, u.nachname as u_nachname, u.strasse as u_strasse, u.plz as u_plz, u.ort as u_ort, u.telefon as u_telefon, u.email as u_email, u.jabber as u_jabber, u.icq as u_icq, u.website as u_website, u.about as u_about, u.allow_node_delegation as u_allow_node_delegation, u.notification_method as u_notification_method, u.permission as u_permission, u.create_date as u_create_date, u.update_date as u_update_date, u.activated as u_activated,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   c.id as c_id, c.create_date as c_create_date, c.update_date as c_update_date, c.name as c_name, c.hardware_name as c_hardware_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   s.id as s_id, s.router_id as s_router_id, s.crawl_cycle_id as s_crawl_cycle_id, s.crawl_date as s_crawl_date, s.status as s_status, s.hostname as s_hostname, s.description as s_description, s.location as s_location, s.latitude as s_latitude, s.longitude as s_longitude, s.luciname as s_luciname, s.luciversion as s_luciversion, s.distname as s_distname, s.distversion as s_distversion, s.chipset as s_chipset, s.cpu as s_cpu, s.memory_total as s_memory_total, s.memory_caching as s_memory_caching, s.memory_buffering as s_memory_buffering, s.memory_free as s_memory_free, s.loadavg as s_loadavg, s.processes as s_processes, s.uptime as s_uptime, s.idletime as s_idletime, s.local_time as s_local_time, s.community_essid as s_community_essid, s.community_nickname as s_community_nickname, s.community_email as s_community_email, s.community_prefix as s_community_prefix, s.batman_advanced_version as s_batman_advanced_version, s.fastd_version as s_fastd_version, s.kernel_version as s_kernel_version, s.configurator_version as s_configurator_version, s.nodewatcher_version as s_nodewatches_version, s.firmware_version as s_firmware_version, s.firmware_revision as s_firmware_revision, s.openwrt_core_revision as s_openwrt_core_revision, s.openwrt_feeds_packages_revision as s_openwrt_feeds_packages_revision, s.client_count as s_client_count,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   max(cr.crawl_date) as last_seen\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tusers u,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tchipsets c,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcrawl_routers s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN routers AS r ON r.id = s.router_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN crawl_routers AS cr ON cr.router_id = r.id AND cr.status = 'online'\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(r.user_id = :user_id OR :user_id=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(r.crawl_method = :crawl_method OR :crawl_method='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(s.status = :status OR :status='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(c.hardware_name = :hardware_name OR :hardware_name='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(s.firmware_version = :firmware_version OR :firmware_version='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(s.batman_advanced_version = :batman_advanced_version OR :batman_advanced_version='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(s.kernel_version = :kernel_version OR :kernel_version='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tr.user_id = u.id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tr.chipset_id= c.id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tr.id = s.router_id AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ts.crawl_cycle_id = :crawl_cycle_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tGROUP BY r.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase :sort_by\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'router_id' then r.id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'user_id' then u.id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'crawl_cycle_id' then s.crawl_cycle_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $this->getOrder() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT :offset, :limit");
         $stmt->bindParam(':crawl_cycle_id', $crawl_cycle_id ? $crawl_cycle_id : (int) crawling::getLastEndedCrawlCycle()['id'], PDO::PARAM_INT);
         $stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
         $stmt->bindParam(':crawl_method', $crawl_method, PDO::PARAM_STR);
         $stmt->bindParam(':status', $status, PDO::PARAM_STR);
         $stmt->bindParam(':hardware_name', $hardware_name, PDO::PARAM_STR);
         $stmt->bindParam(':firmware_version', $firmware_version, PDO::PARAM_STR);
         $stmt->bindParam(':batman_advanced_version', $batman_advanced_version, PDO::PARAM_STR);
         $stmt->bindParam(':kernel_version', $kernel_version, PDO::PARAM_STR);
         $stmt->bindParam(':offset', $this->getOffset(), PDO::PARAM_INT);
         $stmt->bindParam(':limit', $this->getLimit(), PDO::PARAM_INT);
         $stmt->bindParam(':sort_by', $this->getSortBy(), PDO::PARAM_STR);
         $stmt->execute();
         $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     foreach ($result as $router) {
         $new_router = new Router((int) $router['r_id'], (int) $router['r_user_id'], $router['r_hostname'], $router['r_description'], $router['r_location'], $router['r_latitude'], $router['r_longitude'], (int) $router['r_chipset_id'], $router['r_crawl_method'], $router['r_create_date'], $router['r_update_date']);
         $new_router->setUser(new User((int) $router['u_id'], $router['u_session_id'], $router['u_nickname'], $router['u_password'], $router['u_openid'], $router['u_api_key'], $router['u_vorname'], $router['u_nachname'], $router['u_strasse'], (int) $router['u_plz'], $router['u_ort'], $router['u_telefon'], $router['u_email'], $router['u_jabber'], $router['u_website'], $router['u_about'], $router['u_notification_method'], (int) $router['u_permission'], (int) $router['u_activated'], $router['u_create_date'], $router['u_update_date']));
         $new_router->setChipset(new Chipset((int) $router['c_id'], $router['c_name'], $router['c_hardware_name'], $router['c_create_date'], $router['c_update_date']));
         $new_router->setStatusdata(new RouterStatus((int) $router['s_id'], (int) $router['s_crawl_cycle_id'], (int) $router['s_router_id'], $router['s_status'], $router['s_crawl_date'], $router['s_hostname'], (int) $router['s_client_count'], $router['s_chipset'], $router['s_cpu'], (int) $router['s_memory_total'], (int) $router['s_memory_caching'], (int) $router['s_memory_buffering'], (int) $router['s_memory_free'], $router['s_loadavg'], $router['s_processes'], $router['s_uptime'], $router['s_idletime'], $router['s_local_time'], $router['s_distname'], $router['s_distversion'], $router['s_openwrt_core_revision'], $router['s_openwrt_feeds_packages_revision'], $router['s_firmware_version'], $router['s_firmware_revision'], $router['s_kernel_version'], $router['s_configurator_version'], $router['s_nodewatches_version'], $router['s_fastd_version'], $router['s_batman_advanced_version'], $router['last_seen']));
         $this->routerlist[] = $new_router;
     }
 }
示例#5
0
<?php

try {
    require_once "../runtime.php";
    require_once ROOT_DIR . '/config/config.local.inc.php';
    require_once ROOT_DIR . '/lib/core/db.class.php';
    require_once ROOT_DIR . '/lib/core/crawling.class.php';
    require_once ROOT_DIR . '/lib/extern/node_list.php';
    require_once ROOT_DIR . '/lib/extern/node.php';
    try {
        $query = "SELECT r.id,\n\t\t\t\tr.hostname,\n\t\t\t\tr.latitude,\n\t\t\t\tr.longitude,\n\t\t\t\tu.id as u_id,\n\t\t\t\tu.nickname,\n\t\t\t\ts.status,\n\t\t\t\ts.client_count,\n\t\t\t\tUNIX_TIMESTAMP(r.update_date) as last_update,\n\t\t\t\tUNIX_TIMESTAMP(max(cr.crawl_date)) as last_seen\n\t\t\t\tFROM\n\t\t\t\t\trouters AS r\n\t\t\t\t\tJOIN crawl_routers AS s ON r.id = s.router_id\n\t\t\t\t\tJOIN users AS u ON r.user_id = u.id\n\t\t\t\t\tLEFT JOIN crawl_routers AS cr ON cr.router_id = r.id AND cr.status = 'online'\n\t\t\t\tWHERE\n\t\t\t\t\ts.crawl_cycle_id = :crawl_cycle_id\n\t\t\t\tGROUP BY r.id";
        $stmt = DB::getInstance()->prepare($query);
        $lastCycleID = (int) crawling::getLastEndedCrawlCycle()['id'];
        $stmt->bindParam(':crawl_cycle_id', $lastCycleID, PDO::PARAM_INT);
        $stmt->execute();
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    } catch (PDOException $e) {
        echo $e->getMessage();
        echo $e->getTraceAsString();
    }
    // 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'];