Exemplo n.º 1
0
 private function getAssociation(P2000 $p2000, News $news)
 {
     $p2000id = $p2000->getId();
     $newsid = $news->getId();
     $leftLabels = array();
     $rightLabels = array();
     if (strtolower($p2000->getLocation()) !== strtolower($news->getLocation())) {
         return false;
     }
     foreach ($p2000->getLabels() as $pLabel) {
         $date = null;
         $match = false;
         foreach ($news->getLabels() as $nLabel) {
             if (strtolower($nLabel) === "overig") {
                 continue;
             }
             if (Util::labelsMatch($pLabel, $nLabel)) {
                 if (!$match) {
                     $match = true;
                 }
                 if (!in_array($pLabel, $leftLabels, true)) {
                     array_push($leftLabels, $pLabel);
                 }
                 if (!in_array($nLabel, $rightLabels, true)) {
                     array_push($rightLabels, $nLabel);
                 }
             }
         }
         if ($match) {
             $p2000date = $p2000->getDate()->format('d-m-Y');
             $newsDate = $news->getDate()->format('d-m-Y');
             if ($p2000date === $newsDate && !in_array($p2000date, $leftLabels, true)) {
                 array_push($leftLabels, $p2000->getDate()->format('d-m-Y'));
                 $date = $p2000->getDate();
             }
         }
     }
     if (count($leftLabels) < 1) {
         return false;
     }
     return new AssocRule($p2000id, $newsid, $leftLabels, $rightLabels, $date);
 }
Exemplo n.º 2
0
        die("-s parameter (select on this field) missing\n");
    }
    if (!($What = @$Options['w'])) {
        die("-w parameter (select on this field value) missing\n");
    }
}
if (@$Options['m'] == 'zbxsender') {
    if (!($ZabbixHost = @$Options['z'])) {
        die("-z parameter (zabbix host) missing\n");
    }
}
reset($Hosts);
$connected = false;
while (($host = current($Hosts)) !== false) {
    try {
        $P2000 = new P2000($host, $User, $Password);
        $P2000->Login();
        $connected = true;
    } catch (\Exception $ex) {
    }
    next($Hosts);
}
if (!$connected) {
    exitWithError($ex->getMessage());
}
if (@$Options['m'] == 'discovery') {
    echo $P2000->Discovery($Class);
} elseif (@$Options['m'] == 'query') {
    echo $P2000->SingleValue($Class, $Select, $What, $Field);
} elseif (@$Options['m'] == 'zbxsender') {
    $data = $P2000->dataToZbxSender($Class);