Skip to content

Commit

Permalink
avoid duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-utkin committed Jan 13, 2024
1 parent 70306e8 commit 7336df7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion www/ajax/discoverCameras.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,17 @@ public function postData()
);

$tools = Array(
"/usr/lib/bluecherry/onvif/discovery_json/onvif_tool",
"/usr/lib/bluecherry/onvif/discovery_json/node-onvif.js",
"/usr/lib/bluecherry/onvif/discovery_json/onvif_tool",
);
foreach ($tools as $tool) {
$p = @popen($tool, "r");
if (!$p) { continue; }
while ($json_str = fgets($p)) {
$cam = json_decode($json_str);
$ip = $cam['ipv4'];
// append, unless already reported by earlier tools
if (in_array($ip, $ips)) { continue; }
$res[] = $cam;
$ips[] = $cam['ipv4'];
}
Expand Down

0 comments on commit 7336df7

Please sign in to comment.