Rev 261 | Rev 557 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/php
<?php
/*
* OIDplus 2.0
* Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once __DIR__ . '/../includes/oidplus.inc.php';
OIDplus::init(false);
if (!OIDplus::baseConfig()->exists('OIDINFO_API_URL')) {
die("OIDINFO_API_URL not available (API is currently not public)\n");
}
define('VERBOSE', false);
define('DEFAULT_EMAIL', 'oidra@viathinksoft.de');
define('ALL_OID_LIST', '/home/oidplus/all_oids.txt'); // contains all OIDs (non-public file)
define('DESIRED_ROOT', '1.3.6.1.4.1.37476');
# ---
exec("cat ".escapeshellarg(ALL_OID_LIST)." | sort | grep '^".DESIRED_ROOT."'", $out, $ec);
foreach ($out as $oid) {
$oid = trim($oid);
if ($oid == '') continue;
check_oid($oid);
}
function check_oid($oid, $root=DESIRED_ROOT) {
$data = ft_get_oid_data($oid);
// ASN.1 IDs
if (!isset($data['oid']['identifier'])) $data['oid']['identifier'] = array();
if (is_array($data['oid']['identifier'])) {
asort($data['oid']['identifier']);
$oidinfo = implode('|',$data['oid']['identifier']);
} else {
$oidinfo = $data['oid']['identifier'];
}
$oidplus = array();
$resx = OIDplus::db()->query("select name from ###asn1id where oid = ?", array("oid:$oid"));
while ($rowx = $resx->fetch_array()) {
$oidplus[] = $rowx['name'];
}
asort($oidplus);
$oidplus = implode('|',$oidplus);
if ($oidinfo != $oidplus) {
echo "ASN.1 : $oid (oidinfo '$oidinfo' vs oidplus '$oidplus')\n";
}
// Unicode Labels
if (!isset($data['oid']['unicode-label'])) $data['oid']['unicode-label'] = array();
if (is_array($data['oid']['unicode-label'])) {
asort($data['oid']['unicode-label']);
$oidinfo = implode('|',$data['oid']['unicode-label']);
} else {
$oidinfo = $data['oid']['unicode-label'];
}
$oidplus = array();
$resx = OIDplus::db()->query("select name from ###iri where oid = ?", array("oid:$oid"));
while ($rowx = $resx->fetch_array()) {
$oidplus[] = $rowx['name'];
}
asort($oidplus);
$oidplus = implode('|',$oidplus);
if ($oidinfo != $oidplus) {
echo "IRI : $oid (oidinfo '$oidinfo' vs oidplus '$oidplus')\n";
}
}
echo "OK\n";
# ---
function ft_get_oid_data($oid) {
$url = OIDplus::baseConfig()->getValue('OIDINFO_API_URL') . '&oid='.urlencode($oid);
$cont_json = @file_get_contents($url);
if (!$cont_json) {
sleep(5);
$cont_json = @file_get_contents($url);
if (!$cont_json) return false;
}
$data = json_decode($cont_json,true);
return $data;
}