Ejemplo n.º 1
0
 public function userNetworkStatus($userid)
 {
     $result = array();
     if ($userid > 0) {
         $srvrs = $this->client_serversIds($userid);
         if ($srvrs && $srvrs["status"] == 'ok' && count($srvrs["data"]) > 0) {
             $all_srvrs = $srvrs["data"];
             $serdersIds = $this->_idsList($all_srvrs, 'serverid');
             //$serdersIds = array_unique($serdersIds);
             $srvrsIds = implode(',', $serdersIds);
             $ext = $this->servers_ext($srvrsIds, 1);
             // 1 - availble
             $int = $this->servers_int($srvrsIds, 1);
             if ($ext && count($ext) > 0 || $int && count($int) > 0) {
                 $this->pubKeys = MonitisApi::getPublicKeys();
                 for ($s = 0; $s < count($all_srvrs); $s++) {
                     $serverid = $all_srvrs[$s]['serverid'];
                     if ($ext && count($ext) > 0) {
                         $extMon = $this->getServerMonitors($serverid, $ext);
                         $all_srvrs[$s]['external'] = $extMon;
                     }
                     if ($int && count($int) > 0) {
                         $intMon = $this->getServerMonitors($serverid, $int);
                         $all_srvrs[$s]['internal'] = $intMon;
                     }
                 }
                 $result["status"] = 'ok';
                 $result["data"] = $all_srvrs;
             } else {
                 $result["status"] = 'error';
                 $result["msg"] = 'No monitors for the active products, or they are not available';
             }
         } else {
             $result["status"] = 'error';
             $result["msg"] = $srvrs["msg"];
         }
     } else {
         $result["status"] = 'error';
         $result["msg"] = 'User login error';
     }
     return $result;
 }