Subversion Repositories oidinfo_api

Compare Revisions

No changes between revisions

Regard whitespace Rev 1 → Rev 2

/trunk/2016-09-02_old_oidinfo_api_with_csv_reader.zip
Cannot display: file marked as a binary type.
svn:mime-type = application/zip
Property changes:
Added: svn:mime-type
+application/zip
\ No newline at end of property
/trunk/LICENSE
0,0 → 1,202
 
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
 
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 
1. Definitions.
 
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
 
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
 
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
 
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
 
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
 
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
 
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
 
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
 
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
 
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
 
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
 
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
 
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
 
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
 
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
 
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
 
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
 
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
 
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
 
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
 
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
 
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
 
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
 
END OF TERMS AND CONDITIONS
 
APPENDIX: How to apply the Apache License to your work.
 
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
 
Copyright 2018 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.
/trunk/csv_lookup_server_example/Makefile
0,0 → 1,0
link ../../confidential/jobs/0077_csv_lookup_server/v2/Makefile
Property changes:
Added: svn:special
+*
\ No newline at end of property
/trunk/csv_lookup_server_example/oid_lookup_srv
0,0 → 1,0
link ../../confidential/jobs/0077_csv_lookup_server/v2/oid_lookup_srv
Property changes:
Added: svn:special
+*
\ No newline at end of property
/trunk/csv_lookup_server_example/oid_lookup_srv.cpp
0,0 → 1,0
link ../../confidential/jobs/0077_csv_lookup_server/v2/oid_lookup_srv.cpp
Property changes:
Added: svn:special
+*
\ No newline at end of property
/trunk/csv_lookup_server_example/oid_lookup_srv.h
0,0 → 1,0
link ../../confidential/jobs/0077_csv_lookup_server/v2/oid_lookup_srv.h
Property changes:
Added: svn:special
+*
\ No newline at end of property
/trunk/csv_lookup_server_example/oid_table.csv
0,0 → 1,4
2.999
2.999.1
2.999.2
 
Property changes:
Added: svn:mime-type
+text/csv
\ No newline at end of property
/trunk/index.html
0,0 → 1,364
<html>
 
<head>
<title>oid-info.com API for PHP</title>
<style>
code, pre {
color:blue;
}
pre.cmd {
background-color:#BBBBBB;
}
.attention {
color:red;
}
</style>
</head>
 
<body>
 
<h1>oid-info.com API for PHP</h1>
 
<p><i>12 March 2019</i></p>
 
<h2>Introduction</h2>
 
<p><a href="http://oid-info.com/">oid-info.com</a> is a public repository for Object Identifiers (OIDs). This API is available in PHP and can be used in web-interfaces (Apache module, cgi-bin, etc.) but can also be used in command line tools written in PHP (on Linux with shebang <code>#!/usr/bin/php</code>) .</p>
 
<p>The majority of the functions provided by this API helps developers in creating XML files which can be uploaded to the OID repository to add multiple OIDs, but the API also contains other helpful utilities related to OIDs, UUIDs and the OID repository in general. The XML generation can be useful for Registration Authorities (RAs) that want to deliver their assignments to oid-info.com , but also for people who want to support the OID repository by adding OIDs from public sources. The XML files generated by these API functions are conform with the <a href="http://www.oid-info.com/oid.xsd">XML schema of oid-info.com</a> and can be uploaded <a href="http://www.oid-info.com/submit.htm">here</a> - you will also find more information about the XML submission at these pages.</p>
 
<p>An example of a XML generation code can be found here: <a href="oidinfo_example.phps">oidinfo_example.phps</a></p>
 
<p>The API is licensed under the terms of the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 License</a> and was written by <a href="http://www.daniel-marschall.de/">Daniel Marschall</a>.</p>
 
<h2>Download</h2>
 
<p><a href="https://www.viathinksoft.com/projects/oidinfo_api">Download the current version of the API here</a> / <a href="https://svn.viathinksoft.com/cgi-bin/viewvc.cgi/oidinfo_api/">Browse SVN repository</a></p>
 
<p>Browse the source code online:</p>
 
<ul>
<li><a href="oid_illegality_rules">oid_illegality_rules</a></li>
<li><a href="oidinfo_api.inc.phps">oidinfo_api.inc.phps</a></li>
<li><a href="oidinfo_test.phps">oidinfo_test.phps</a> (optional)</li>
<li><a href="oidinfo_example.phps">oidinfo_example.phps</a> (optional)</li>
<li><a href="oid_utils.inc.phps">oid_utils.inc.phps</a> (dependent unit)</li>
<li><a href="uuid_utils.inc.phps">uuid_utils.inc.phps</a> (dependent unit)</li>
<li><a href="xml_utils.inc.phps">xml_utils.inc.phps</a> (dependent unit)</li>
<li>Example for a simple ping provider (<a href="#part6">see part 6</a>): <a href="csv_lookup_server_example/">CSV Lookup Server</a></li>
</ul>
 
<h2>Table of Contents</h1>
 
<ul>
<li><a href="#part1">Part 1: "Ping API" / "Verbose Ping Provider" for checking if OIDs are available or allowed to create</a></li>
<li><a href="#part2">Part 2: Syntax checking</a></li>
<li><a href="#part3">Part 3: XML file creation</a></li>
<li><a href="#part4">Part 4: Offline check if OIDs are illegal</a></li>
<li><a href="#part5">Part 5: Misc functions</a></li>
<li><a href="#part6">Part 6: Simple Ping Providers</a></li>
</ul>
 
<h2>Class <code>OIDInfoAPI</code></h2>
 
<p><i>Note: Not every throwable Exception (they are all of type <code>OIDInfoException</code>) is described in the method descriptions.</i></p>
 
<h3><a name="part1">Part 1: "Ping API" / "Verbose Ping Provider" for checking if OIDs are available or allowed to create</h3>
 
<h4>Online check functions</h4>
 
<p><i>Note: These 4 functions include the <code>strictCheckSyntax()</code> check (see <a href="#part2">Part 2: Syntax checking</a>).</i></p>
 
<pre class="cmd">public function checkOnlineExists($oid)</pre>
<p>An online check will be performed, to check if <code>$oid</code> <i>exists</i>. "Exist" means, the OID was added to the repository. Exist does not mean that the OID is also validated by the OID repository admin (i.e. available through the web interface).</p>
<p>You can use the function <code>oidExisting</code> which uses the online-check (verbose ping provider) and the simple-ping-provider, if available, in combination.</p>
<pre class="cmd">public function checkOnlineAvailable($oid)</pre>
<p>An online check will be performed, to check if <code>$oid</code> is <i>available</i>. "Available" means, the OID was added to the repository and is validated by the OID repository admin.</p>
<pre class="cmd">public function checkOnlineAllowed($oid)</pre>
<p>An online check will be performed, to check if <code>$oid</code> is <i>allowed</i>. "Allowed" means, that the OID repository allows the creation of this OID. This is the case for OIDs which are not created in a frozen or leaf arc of the OID tree and are not known as illegal.</p>
<p><font class="attention">Attention!</font> "Allowed" will also be <code>true</code> if the OID already exists in the OID repository.</p>
<p><font class="attention">Attention!</font> Before using this function, you should verify that <code>$oid</code> is not listed in the local blacklist (please see <a href="#part4">Part 4: Offline check if OIDs are illegal</a>), by using <code>illegalOID($oid)</code>, because this low level function does not include this check by design.</p>
<pre class="cmd">public function checkOnlineMayCreate($oid)</pre>
<p>An online check will be performed, to check if <code>$oid</code> may be <i>created</i>. This means that the OID is <i>allowed</i> (<code>checkOnlineAllowed</code>) and does not <i>exist</i> (<code>!checkOnlineExists</code>).</p>
<!-- <p><font class="attention">Attention!</font> This check will NOT include a check against the local blacklist of illegal OIDs (please see <a href="#part4">Part 4: Offline check if OIDs are illegal</a>). This step needs to be done separately.</p> -->
<p><font class="attention">Attention!</font> Before using this function, you should verify that <code>$oid</code> is not listed in the local blacklist (please see <a href="#part4">Part 4: Offline check if OIDs are illegal</a>), by using <code>illegalOID($oid)</code>, because this low level function does not include this check by design. It is recommended to use <code>oidMayCreate()</code> instead.</p>
 
<h4>Caching</h4>
<pre class="cmd">pingCacheMaxAge = 3600</pre>
<p>The results of <code>checkOnlineExists</code>, <code>checkOnlineAvailable</code>, <code>checkOnlineAllowed</code> and <code>checkOnlineMayCreate</code> are cached to reduce the amount of web traffic, which also increases the performance. The variable <code>pingCacheMaxAge</code> contains the maxiumum amount of seconds before the cache entry will be renewed.
The cache will be automatically cleared if the function <code>clearPingCache</code> is called, or if the PHP script session terminates.</p>
<p>The default value is 3600 seconds, which is 1 hour. If you are using the OIDInfo-API in a long-term process (e.g. a daemon or crawler service), you should probably modify the <code>pingCacheMaxAge</code> setting.
<p>If you want to make sure that the cache is never used, please set <code>pingCacheMaxAge = -1</code>. Please note, that the cache is still maintained (extended and updated).</p>
<p>If you do not want that the cache entries expire, you can use the <a href="http://php.net/manual/en/math.constants.php">PHP constant</a> INF: <code>pingCacheMaxAge = INF</code>.</p>
<pre class="cmd">public function clearPingCache()</pre>
<p>This function clears the ping cache. This will also reduce the amount of currently used memory.</p>
 
<h4>Configuration of the verbose ping provider</h4>
 
<p><i>The "Verbose Ping Provider" is a HTTP(S) webservice which tells wheather an OID exists at oid-info.com, and if it may be created.</i></p>
 
<p>The webservice must return following content:</p>
 
<pre>
First digit of the ping result
"-" = error
"0" = OID does not exist
"1" = OID does exist, but is not approved yet
"2" = OID does exist and is accessible
 
Second digit of the ping result
"-" = error
"0" = The OID may not be created
"1" = OID is not an illegal OID, and none of its ascendant is a leaf and its parent OID is not frozen
</pre>
 
<pre class="cmd">$verbosePingProviders = array('https://misc.daniel-marschall.de/oid-repository/ping_oid.php?oid={OID}');</pre>
<p>The URL(s) of the verbose ping provider(s). The string <code>{OID}</code> will be replaced by the OID in dot-notation. Usually, you do not need to edit this configuration.</p>
 
<h3><a name="part2">Part 2: Syntax checking</h3>
 
<pre class="cmd">public static function strictCheckSyntax($oid)</pre>
<p>Returns <code>true</code>, if the <code>$oid</code> has the correct syntax for usage in the XML files for the OID repository. This means:</p>
<ul>
<li>The syntax is a valid dot-notation</li>
<li>The OID does not begin with a dot (this notation can be found in SNMP and OID+ systems)</li>
<li>No arc contains a leading zero</li>
</ul>
<pre class="cmd">public static function trySanitizeOID($oid)</pre>
<p>Tries to repair <code>$oid</code> to make it comply with <code>strictCheckSyntax</code>. A leading dot as well as leading zeros will be removed. If the OID is still invalid, the function will return <code>false</code>, otherwise the sanitized OID as string.</p>
 
<h3><a name="part3">Part 3: XML file creation</h3>
 
<pre class="cmd">public function softCorrectEMail($email, $params)</pre>
<p>This function tries to correct an invalid eMail address (probably obfuscated for anti spam purposes), e.g. "john[at]example[dot]com" will be corrected into "john@example.com" .</p>
<p>If <code>$params['allow_illegal_email']</code> is <code>true</code>, and the email address is still invalid, an empty string will be returned.</p>
<p>Otherwise, the function will return the email address which was fully, partially or not corrected.</p>
<p><font class="attention">Attention!</font> You don't need to use this function if you create an XML file using <code>createXMLEntry</code>, since this step will be done automatically.</p>
<pre class="cmd">public function softCorrectPhone($phone, $params)</pre>
<p>This function tries to corrects a phone number and remove invalid characters, like dashes or brackets.</p>
<p><font class="attention">Attention!</font> You don't need to use this function if you create an XML file using <code>createXMLEntry</code>, since this step will be done automatically.</p>
<pre class="cmd">public function correctDesc($desc, $params, $ending_dot_policy=OIDInfoAPI::OIDINFO_CORRECT_DESC_OPTIONAL_ENDING_DOT, $enforce_xhtml_light=false)</pre>
<p>This function tries to change the description to make it comply with the XML file.</p>
<p>If <code>$params['allow_html']</code> is <code>true</code>, HTML tags will be allowed, otherwise they will be encoded.</p>
<p>If <code>$params['tolerant_htmlentities']</code> is <code>true</code>, double encoded HTML entities like <code>&amp;amp;amp;</code> will be corrected.</p>
<p>Also, this function will remove unnecessary phrasings like "OID for " at the beginning or ending of the description.</p>
<p>Following constants are valid values for <code>$ending_dot_policy</code>:</p>
<ul>
<li><code>OIDInfoAPI::OIDINFO_CORRECT_DESC_OPTIONAL_ENDING_DOT = 0</code></li>
<li><code>OIDInfoAPI::OIDINFO_CORRECT_DESC_ENFORCE_ENDING_DOT = 1</code> (A leading dot will be created if it is not available)</li>
<li><code>OIDInfoAPI::OIDINFO_CORRECT_DESC_DISALLOW_ENDING_DOT = 2</code> (A leading dot will be removed from the text)</li>
</ul>
<p>If <code>$enforce_xhtml_light</code> is set to <code>true</code>, then tags which are not included in the <a href="http://www.oid-info.com/xhtml-light.xsd">XHTML Light specification</a> are removed, except if <code>$params['ignore_xhtml_light']</code> is <code>true</code>.</p>
<p><font class="attention">Attention!</font> You don't need to use this function if you create an XML file using <code>createXMLEntry</code>, since this step will be done automatically.</p>
<pre class="cmd">public function xmlAddHeader($firstName, $lastName, $email)</pre>
<p>Outputs the beginning of a XML file which can be created and submitted to oid-info.com</p>
<pre class="cmd">public function xmlAddFooter()</pre>
<p>Returns the footer of the XML file.</p>
<pre class="cmd">public function createXMLEntry($oid, $elements, $params, $comment='')</pre>
<p>Returns a <code>&lt;oid&gt;</code> entry for the XML file, with an optional comment <code>$comment</code> above the entry.</p>
<p>Valid values of <code>$elements</code> and <code>$params</code> will be explained in the following sections.</p>
 
<h4>Valid values for <code>$params</code></h4>
<pre class="cmd">$params['allow_html']</pre>
<p>Allows HTML in <code>&lt;description&gt;</code> and <code>&lt;information&gt;</code></p>
<p>Default: <code>false</code></p>
<pre class="cmd">$params['allow_illegal_email']</pre>
<p>Does not delete email addresses which could not be repaired with <code>softCorrectEMail</code>.</p>
<p>This should stay enabled, because we don't know if the source used some kind of human-readable anti-spam technique instead of an actual wrong address.</p>
<p>Default: <code>true</code></p>
<pre class="cmd">$params['soft_correct_behavior']</pre>
<p>This defines the way ASN.1 identifiers (<code>$elements['synonymous-identifier']</code>) will be corrected in case they are illegal. Following modes are available:</p>
<ul>
<li><code>OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE</code> : The illegal identifier will be deleted.</li>
<li><code>OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_LOWERCASE_BEGINNING</code> : The beginning will be enforced to be lowercase.</li>
<li><code>OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_ALL_POSSIBLE</code> : All invalid characters will be removed, and the beginning will be enforced to be lowercase.</li>
</ul>
<p>Default: <code>OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE</code></p>
<pre class="cmd">$params['do_online_check']</pre>
<p>Flag to disable this online check (<code>checkOnlineMayCreate($oid)</code>) to save traffic and runtime.</p>
<p>Default: <code>false</code></p>
<pre class="cmd">$params['do_illegality_check']</pre>
<p>Checks if the OID is illegal (<code>illegalOID($oid)</code>) before adding it to the XML</p>
<p>Default: <code>true</code></p>
<pre class="cmd">$params['do_simpleping_check']</pre>
<p>When a simple ping provider defined, the XML entry will not be added when one of the simple ping providers reports the OID as existing.</p>
<p>Default: <code>true</code></p>
<pre class="cmd">$params['auto_extract_name']</pre>
<p>If this is set, the <code>&lt;information&gt;</code> field will end with "Automatically extracted from ..."</p>
<p>Default: ''</p>
<pre class="cmd">$params['auto_extract_url']</pre>
<p>If this is set, the <code>&lt;information&gt;</code> field will end with "Automatically extracted from ..."</p>
<p>Default: ''</p>
<pre class="cmd">$params['always_output_comment']</pre>
<p>Also output comment if there was an error (e.g. OID already existing)</p>
<p>Default: <code>false</code></p>
<pre class="cmd">$params['ignore_xhtml_light']</pre>
<p>If set to <code>true</code>, tags which are not allowed in the <a href="http://www.oid-info.com/xhtml-light.xsd">XHTML Light specification</a> won't be excluded (fields: address, description and information).</p>
 
<h4>Valid values for <code>$elements</code></h4>
 
<pre>
$elements['synonymous-identifier'] = ''; // string or array
$elements['description'] = '';
$elements['information'] = '';
 
$elements['first-registrant']['first-name'] = '';
$elements['first-registrant']['last-name'] = '';
$elements['first-registrant']['address'] = '';
$elements['first-registrant']['email'] = '';
$elements['first-registrant']['phone'] = '';
$elements['first-registrant']['fax'] = '';
$elements['first-registrant']['creation-date'] = '';
 
$elements['current-registrant']['first-name'] = '';
$elements['current-registrant']['last-name'] = '';
$elements['current-registrant']['address'] = '';
$elements['current-registrant']['email'] = '';
$elements['current-registrant']['phone'] = '';
$elements['current-registrant']['fax'] = '';
$elements['current-registrant']['modification-date'] = '';
</pre>
 
<h3><a name="part4">Part 4: Offline check if OIDs are illegal</h3>
 
<p>With these functions, you can query if OIDs are listed in a blacklist, which is stored locally. The download package contains a default
<a href="oid_illegality_rules">illegality rule file</a> which contains known illegal OID arcs.</p>
 
</p>
 
<pre class="cmd">public function clearIllegalityRules()</pre>
<p>Clears all illegality rules (please see below).</p>
<pre class="cmd">public function loadIllegalityRuleFile($file)</pre>
<p>Loads a file which contains illegality rules (please see below).</p>
<pre class="cmd">public function addIllegalityRule($rule)</pre>
<p>Adds an illegality rule (please see below).</p>
<pre class="cmd">public function illegalOID($oid, &$illegal_root='')</pre>
<p>Returns <code>true</code>, if <code>$oid</code> is marked as illegal OID according to the illegality rules.</p>
<p><code>$illegal_root</code> will contain the illegal beginning of the OID.</p>
<p>Example: If 2.999.1 would be marked as illegal, and if <code>$oid</code> is 2.999.1.55, then <code>$illegal_root</code> will be 2.999.1</p>
 
<h4>Illegality rules</h4>
 
<p>Illegality rules define arcs or OIDs which are considered as illegal.</p>
 
<p>An illegality rule file has following syntax:</p>
 
<pre>[1.3.6.1.4.1.37476.3.1.5.1]
 
-- <i>comment</i>
<i>rule</i> --</i>comment</i>
<i>rule</i>
<i>rule</i></pre>
 
<p>where <a href="http://www.viathinksoft.de/documents/oid/oidplus/?action=show_oid&oid=.1.3.6.1.4.1.37476.3.1.5.1">1.3.6.1.4.1.37476.3.1.5.1</a> is the file format definition, and <i>rule</i> is an illegality rule (which can also be manually defined via <code>addIllegalityRule($rule)</code>) with following syntax:
 
<p><code>2.999.(11-).0</code> : the arc values 11 and below are illegal</p>
<p><code>2.999.(11+).0</code> : the arc values 11 and above are illegal</p>
<p><code>2.999.(1-5).0</code> : the arc values 1 to 5 are illegal</p>
<p><code>2.999.*.0</code> : * is equal to (0+)</p>
 
<h3><a name="part5">Part 5: Misc functions</h3>
 
<pre class="cmd">function __construct()</pre>
<p>When the class is created and a file with the name "oid_illegality_rules" exist, this file will be processed with <code>loadIllegalityRuleFile</code>.</p>
<pre class="cmd">public static function getPublicURL($oid)</pre>
<p>Returns the public URL to the OID registry, pointing to the information about <code>$oid</code>.</p>
<pre class="cmd">public function oidExisting($oid, $onlineCheck=true, $useSimplePingProvider=true)</pre>
<p>Returns <code>true</code> if <code>$oid</code> is existing.</p>
<p>If <code>$useSimplePingProvider</code> is <code>true</code>, the simple ping provider will be checked first.</p>
<p>If the OID does not exist in the cache, or if no simple ping provider is loaded, or if <code>$useSimplePingProvider</code> is <code>false</code>, then an online check (<code>checkOnlineExists</code>) will be done if <code>$onlineCheck</code> is <code>true</code>.</p>
<p>An Exception of type <code>OIDInfoException</code> will be thrown, if none of the both checks could be performed (e.g. no simple ping provider is defined and online check disabled).</p>
<p>An Exception of type <code>OIDInfoException</code> will be thrown in case that <code>$oid</code> cannot be repaired with <code>trySanitizeOID($oid)</code></p>
<pre class="cmd">public function oidMayCreate($oid, $onlineCheck=true, $useSimplePingProvider=true, $illegalityCheck=true)</pre>
<p>Returns <code>true</code> if <code>$oid</code> may be created.</p>
<p>If <code>$illegalityCheck</code> is <code>true</code> and <code>illegalOID($oid)</code> results is <code>true</code>, then the function will immediately result in <code>false</code>.</p>
<p>If <code>$useSimplePingProvider</code> is <code>true</code>, the simple ping provider will be checked first if the OID is already existing (which would result in <code>false</code>).</p>
<p>If the OID does not exist in the cache, or if no simple ping provider is loaded, or if <code>$useSimplePingProvider</code> is <code>false</code>, then an online check (<code>checkOnlineMayCreate</code>) will be done if <code>$onlineCheck</code> is <code>true</code>.</p>
<p>An Exception of type <code>OIDInfoException</code> will be thrown, if none of the both checks could be performed (e.g. no simple ping provider defined and online check disabled).</p>
<p>An Exception of type <code>OIDInfoException</code> will be thrown in case that <code>$oid</code> cannot be repaired with <code>trySanitizeOID($oid)</code></p>
 
<h3><a name="part6">Part 6: Simple Ping Providers</h3>
 
<p><i>Following table shows the differnce between the Simple Ping Providers and the Verbose Ping Providers.</i></p>
 
<table border="1" width="60%" cellpadding="5" cellspacing="5">
<tr>
<td width="50%"><b>Simple Ping Provider (<a href="#part6">Part 6</a>)</b></td>
<td width="50%"><b>Verbose Ping Provider (<a href="#part1">Part 1</a>)</b></td>
</tr>
 
<tr>
<td>Uses Telnet protocol (usually port 49500)</td>
<td>Uses HTTP(s) protocol</td>
</tr>
 
<tr>
<td>Multiple queries per session/connection</td>
<td>Only 1 query per session (HTTP(s) request)</td>
</tr>
 
<tr>
<td>Multiple simple ping providers can be defined and hosted anywhere</td>
<td>Only the official ViaThinkSoft service can be used</td>
</tr>
 
<tr>
<td>Can provide any OID tree (e.g. your own RA's OIDs)</td>
<td>Provides information on all OIDs in oid-info.com</td>
</tr>
 
<tr>
<td>Only provides information if the OID exists at the given local database.</td>
<td>Provides information if the OID exists at oid-info.com, and if it may be created. Additionally, the information provided will make clear if the OID is active (i.e. activated by the verified by the administrator after submitting).</td>
</tr>
 
<tr>
<td>Very fast, especially if the service is located at the local host.</td>
<td>Rather slow</td>
</tr>
 
<tr>
<td>Usual scenario: You have an OID tree of your RA, and want to quickly check if a given OID is in that tree.</td>
<td>Usual scenario: You want to check if you may create an OID at oid-info.com, or if it is available there.</td>
</tr>
 
</table>
 
<pre class="cmd">public function addSimplePingProvider($addr)</pre>
<p>Adds a simple ping provider.</p>
<p>Possibility 1 (<code>OIDSimplePingProvider</code>): <code>$addr</code> is a hostname without protocol specification. The port is optional. If no port is specified, the port 49500 will be used. The connection will be only built up while the first query is sent!</p>
<p>Possibility 2 (<code>CSVSimplePingProvider</code>):: <code>$addr</code> is a filename of a CSV file. A "virtual" simple ping provider will be created. The CSV will be read immediately, and will be re-read in every query, after the modification timestamp had changed.</p>
<pre class="cmd">public function removeSimplePingProvider($addr)</pre>
<p>Removed a simple ping provider.</p>
<pre class="cmd">public function removeAllSimplePingProviders()</pre>
<p>Removes all simple ping providers.</p>
<pre class="cmd">public function listSimplePingProviders()</pre>
<p>List all simple ping providers.</p>
<pre class="cmd">public function simplePingProviderCheckOID($oid)</pre>
<p>Checks if an OID is existing.</p>
<p>The result is <code>true</code> when one of the providers returns "1".</p>
<p>The result is <code>false</code> if all providers returned "0".</p>
<p>The result is <code>null</code> no providers returned "1", and at least one provider failed to connect or returned something unexpected.</p>
<p>Throws an Exception of type <code>OIDInfoException</code>, if no providers are in the list.</p>
<pre class="cmd">public function simplePingProviderAvailable()</pre>
<p>Returns true, if at least one ping provider is added to the list.</p>
 
 
 
<!--
<h3><a name="part6">Part 6: CSV functions</h3>
 
<p>These functions are intended for special cooperations with oid-info.com, and are therefore not documented.</p>
 
<pre class="cmd">public function unloadCSVs()</pre>
<pre class="cmd">public function addCSVDump($file)</pre>
<pre class="cmd">public function defineLearningCSV($file)</pre>
<pre class="cmd">public function undefineLearningCSV($file)</pre>
<pre class="cmd">public function existsInCSV($oid)</pre>
<pre class="cmd">public function useSingleCSV($file, $mayModify=true, $create_cache=true)</pre>
-->
 
</body>
 
</html>
 
Property changes:
Added: svn:mime-type
+text/html
\ No newline at end of property
/trunk/oid_illegality_rules
0,0 → 1,248
[1.3.6.1.4.1.37476.3.1.5.2]
 
-- Standard OID Illegality Rule Definition File
-- by Daniel Marschall and Olivier Dubuisson
-- Revision: 8 April 2019
-- This file contains all oid-info.com rules as of 2018_09_18_illegal_oid_table.csv
 
-- SYNTAX:
-- -- comment : comments are also allowed after a rule definition
-- 2.999.(11-).0 : the arc values 11 and below are illegal
-- 2.999.(11+).0 : the arc values 11 and above are illegal
-- 2.999.(1-5).0 : the arc values 1 to 5 are illegal
-- 2.999.(!3).0 : only arc 3 is valid, all others are invalid (added in version 2)
-- 2.999.*.0 : * is equal to (0+)
 
 
-- TODO: Add more constraints according to http://www.iana.org/assignments/smi-numbers/smi-numbers.xml
-- IANA REGISTRIES
-- 1.3.6.1 http://www.iana.org/assignments/smi-numbers/smi-numbers.xml
-- 1.3.6.1.1 http://www.iana.org/assignments/ldap-parameters/ldap-parameters-1.csv
-- 1.3.6.1.2 http://www.iana.org/assignments/smi-numbers/smi-numbers-2.csv
-- 1.3.6.1.2.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-3.csv
-- 1.3.6.1.2.1.2.2.1.3 http://www.iana.org/assignments/smi-numbers/smi-numbers-5.csv
-- 1.3.6.1.2.1.2.2.1.3.131 http://www.iana.org/assignments/smi-numbers/smi-numbers-6.csv
-- 1.3.6.1.2.1.10 http://www.iana.org/assignments/smi-numbers/smi-numbers-7.csv
-- 1.3.6.1.2.1.10.23 http://www.iana.org/assignments/smi-numbers/smi-numbers-8.csv
-- 1.3.6.1.2.1.10.166 http://www.iana.org/assignments/smi-numbers/smi-numbers-9.csv
-- 1.3.6.1.2.1.16 http://www.iana.org/assignments/smi-numbers/smi-numbers-10.csv
-- 1.3.6.1.2.1.16.20 http://www.iana.org/assignments/smi-numbers/smi-numbers-11.csv
-- 1.3.6.1.2.1.27 http://www.iana.org/assignments/smi-numbers/smi-numbers-13.csv
-- 1.3.6.1.2.1.27.4 (Registry is empty.)
-- 1.3.6.1.2.1.27.5 (Registry is empty.)
-- 1.3.6.1.2.1.28 ??????????????????????????????????
-- 1.3.6.1.2.1.28.2.1.24 http://www.iana.org/assignments/smi-numbers/smi-numbers-17.csv
-- 1.3.6.1.2.1.34 http://www.iana.org/assignments/smi-numbers/smi-numbers-18.csv
-- 1.3.6.1.2.1.153.4 (Registry is empty.)
-- 1.3.6.1.2.1.194.1.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-20.csv
-- 1.3.6.1.2.2 http://www.iana.org/assignments/smi-numbers/smi-numbers-21.csv
-- 1.3.6.1.3 http://www.iana.org/assignments/smi-numbers/smi-numbers-22.csv
-- 1.3.6.1.3.116 http://www.iana.org/assignments/smi-numbers/smi-numbers-23.csv
-- 1.3.6.1.4 http://www.iana.org/assignments/smi-numbers/smi-numbers-24.csv
-- 1.3.6.1.4.1 http://www.iana.org/assignments/enterprise-numbers
-- 1.3.6.1.5 http://www.iana.org/assignments/smi-numbers/smi-numbers-26.csv
-- 1.3.6.1.5.3 http://www.iana.org/assignments/smi-numbers/smi-numbers-27.csv
-- 1.3.6.1.5.4 http://www.iana.org/assignments/smi-numbers/smi-numbers-28.csv
-- 1.3.6.1.5.5 http://www.iana.org/assignments/smi-numbers/smi-numbers-29.csv
-- 1.3.6.1.5.5.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-30.csv
-- 1.3.6.1.5.5.4 http://www.iana.org/assignments/smi-numbers/smi-numbers-31.csv
-- 1.3.6.1.5.5.8 http://www.iana.org/assignments/smi-numbers/smi-numbers-32.csv
-- 1.3.6.1.5.5.8.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-33.csv
-- 1.3.6.1.5.5.8.2 http://www.iana.org/assignments/smi-numbers/smi-numbers-34.csv
-- 1.3.6.1.5.5.8.3 http://www.iana.org/assignments/smi-numbers/smi-numbers-35.csv
-- 1.3.6.1.5.5.10 http://www.iana.org/assignments/smi-numbers/smi-numbers-36.csv
-- 1.3.6.1.5.5.11 http://www.iana.org/assignments/smi-numbers/ltans.csv
-- 1.3.6.1.5.5.11.0 http://www.iana.org/assignments/smi-numbers/ltans-module-identifiers.csv
-- 1.3.6.1.5.5.11.1 http://www.iana.org/assignments/smi-numbers/ltans-cms-content-types.csv
-- 1.3.6.1.5.5.11.2 http://www.iana.org/assignments/smi-numbers/ltans-ers-encryption-methods.csv
-- 1.3.6.1.5.5.12 http://www.iana.org/assignments/smi-numbers/smi-numbers-37.csv
-- 1.3.6.1.5.5.12.0 http://www.iana.org/assignments/smi-numbers/smi-numbers-38.csv
-- 1.3.6.1.5.5.12.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-39.csv
-- 1.3.6.1.5.5.12.2 http://www.iana.org/assignments/smi-numbers/smi-numbers-40.csv
-- 1.3.6.1.5.5.12.3 http://www.iana.org/assignments/smi-numbers/smi-numbers-41.csv
-- 1.3.6.1.5.5.12.4 http://www.iana.org/assignments/smi-numbers/smi-numbers-42.csv
-- 1.3.6.1.5.5.12.5 http://www.iana.org/assignments/smi-numbers/smi-numbers-43.csv
-- 1.3.6.1.5.5.12.6 http://www.iana.org/assignments/smi-numbers/smi-numbers-44.csv
-- 1.3.6.1.5.5.12.7 http://www.iana.org/assignments/smi-numbers/smi-numbers-45.csv
-- 1.3.6.1.5.5.13 http://www.iana.org/assignments/smi-numbers/smi-numbers-46.csv
-- 1.3.6.1.5.5.15 http://www.iana.org/assignments/smi-numbers/smi-numbers-47.csv
-- 1.3.6.1.5.5.15.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-48.csv
-- 1.3.6.1.5.5.15.2 http://www.iana.org/assignments/smi-numbers/smi-numbers-49.csv
-- 1.3.6.1.5.6 http://www.iana.org/assignments/smi-numbers/smi-numbers-50.csv
-- 1.3.6.1.5.7 http://www.iana.org/assignments/smi-numbers/smi-numbers-51.csv
-- 1.3.6.1.5.7.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-52.csv
-- 1.3.6.1.5.7.2 http://www.iana.org/assignments/smi-numbers/smi-numbers-53.csv
-- 1.3.6.1.5.7.3 http://www.iana.org/assignments/smi-numbers/smi-numbers-54.csv
-- 1.3.6.1.5.7.4 http://www.iana.org/assignments/smi-numbers/smi-numbers-55.csv
-- 1.3.6.1.5.7.5 http://www.iana.org/assignments/smi-numbers/smi-numbers-56.csv
-- 1.3.6.1.5.7.6 http://www.iana.org/assignments/smi-numbers/smi-numbers-57.csv
-- 1.3.6.1.5.7.7 http://www.iana.org/assignments/smi-numbers/smi-numbers-58.csv
-- 1.3.6.1.6 http://www.iana.org/assignments/smi-numbers/smi-numbers-59.csv
-- 1.3.6.1.6.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-60.csv
-- 1.3.6.1.6.2 ??? Not listed in http://www.iana.org/assignments/smi-numbers/smi-numbers.xml
-- 1.3.6.1.6.3 http://www.iana.org/assignments/smi-numbers/smi-numbers-61.csv
-- 1.3.6.1.7 http://www.iana.org/assignments/smi-numbers/smi-numbers-64.csv
-- 1.3.6.1.7.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-65.csv
-- 1.3.6.1.7.1.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-66.csv
-- 1.3.6.1.7.1.2 http://www.iana.org/assignments/smi-numbers/smi-numbers-67.csv
-- 1.3.6.1.7.1.2.1 http://www.iana.org/assignments/smi-numbers/smi-numbers-68.csv
-- 1.3.6.1.7.1.2.2 http://www.iana.org/assignments/smi-numbers/smi-numbers-69.csv
-- 1.3.6.1.7.1.3 http://www.iana.org/assignments/smi-numbers/smi-numbers-70.csv
-- 1.3.6.1.8 http://www.iana.org/assignments/media-feature-tags/media-feature-tags.xhtml
-- 1.3.6.1.8.1 http://www.iana.org/assignments/media-feature-tags/media-feature-tags-1.csv
-- 1.3.6.1.8.2 (No registrations at this time.)
-- 1.3.6.1.8.3 http://www.iana.org/assignments/media-feature-tags/media-feature-tags-3.csv
-- 1.3.6.1.8.4 http://www.iana.org/assignments/media-feature-tags/media-feature-tags-4.csv
 
 
-- CATEGORY: Currently "not expected" OID arc values - once the RAs are reaching a specific arc value, these limits have to be increased
0.(10+) -- itu, currently max 9
1.(4+) -- iso, currently max 3
1.3.6.(2+) -- dod
1.3.6.1.(9+) -- internet
1.3.6.1.2.(3+) -- mgmt
1.3.6.1.2.1.(301+) -- mib-2 (Sep 2015: max 233)
1.3.6.1.2.1.0.* -- reserved
1.3.6.1.2.1.1.(10+) -- system (Sep 2015: max 9)
1.3.6.1.4.(2+) -- private (Sep 2015: max 1)
2.(1000+) -- joint-iso-itu-t (Sep 2015: max 51 & 999)
2.1.(124+) -- asn1 (Sep 2015: max 10 & 123)
2.5.29.(71+) -- OIDs underneath {joint-iso-itu-t(2) ds(5) certificateExtension(29)} have a number less or equal to 70 in the current edition of Rec. ITU-T X.509 | ISO/IEC 9594-8
2.16.840.1.113883.3.(10000+) -- externalUseRoots (Dec 2017: upper bound set to 10,000)
1.3.6.1.3.(147+) -- The highest experiment number is currently (Sep 2015): 126 , see http://www.iana.org/assignments/smi-numbers/smi-numbers.xml
-- Various vendors claim to have arcs higher than the current number: hippisw(147), ipsecSaMonModule(500), ipsecMIB(503), host(999), ppvpnTcMIB(1111), nhrpMIB(9999)
1.3.6.1.5.(8+) -- OIDs underneath 1.3.6.1.5 are not expected (at this point in time) to have a number greater than 7 ( http://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-26 )
1.3.6.1.5.2.(6+) -- At this point in time (Apr 2019) OIDs allocated by Kerberos version 2 underneath 1.3.6.1.5.2 are not expected to have a number greater than 5.
-- see https://web.mit.edu/kerberos/krb5-oids/krb5-oids.asn
1.3.6.1.5.7.1.(5+) -- OIDs underneath 1.3.6.1.5.7.1 are not expected (at this point in time) to have a number greater than 4 ( https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-52 )
 
-- CATEGORY: Reserved
1.1.3.* -- Reserved for ISO/IEC 9834-3
 
-- CATEGORY: Unassigned country codes
1.2.1
1.2.2
1.2.6 -- was 1.3.6 meant?
1.2.10
1.2.16
1.2.39
1.2.110 -- According to the secretary of the ISO 3166 maintenance Agency (16 June 2003), country code 110 is un-assigned in ISO 3166-1; it does not represent any country
1.2.158 -- This OID is not used since Taiwan is not an ISO National Body. All OIDs for Taiwan are registered under {joint-iso-itu-t(2) country(16) taiwan(158)}
1.2.886 -- Country code 886 has been abused in 1998 because someone at Taiwan Chungwa Telecom originally believed 886 was an ITU assignment for Taiwan Numeric Code, but the 886 country code ( http://unstats.un.org/unsd/methods/m49/m49chang.htm#ftni ) was assigned to Yemen before that country merged with Democratic Yemen. Taiwan has NO RIGHT to use this arc. The Statistic Division of the United Nations may assign this arc to any country without any notice, so keep using this arc will be a big trouble. Note that the use of this illegal OID should be avoided in any new document and/or standard. All existing OID should be transfered to the 2.16.158 arc which is assigned to Taiwan. Also read Conflicts over Taiwan OIDs: http://www.alvestrand.no/objectid/taiwan.html
1.2.3166
1.2.57958
 
-- CATEGORY: Example OIDS
2.999.* -- OID 2.999 is only used for creating (informal) examples, hence child OIDs do not need to be described in the OID repository, as the same child OID can be reused by someone else for a different purpose
1.3.6.1.4.1.37476.9999.* -- ViaThinkSoft example OID (obsolete in favor of 2.999)
 
-- CATEGORY: Illegal usage (hijacking / collission)
1.3.6.1.2.1.1.7.* -- Illegal redefintion of 1.3.6.1.2.1.1.7 (defined in IETF RFC 1213 without child nodes) by agilent-wanstats.mib as "sysServices"
2.16.158.3 -- Institute for Information Industry claims to have this OID but the Registration Authority for the superior OID confirmed that this OID was never assigned to III
2.16.158.5 -- Taiwan-CA.com, Inc. (TaiCA) claims to have this OID but the Registration Authority for the superior OID confirmed that this OID was never assigned to them
2.16.158.6 -- CHIEF Telecom Inc. (www.chief.com.tw) claims to use this OID but it is illegal because Taiwan non-government organizations are registered under {joint-iso-itu-t(2) country(16) tw(158) organization(1)}
2.16.158.7 -- Organizations have OIDs under {joint-iso-itu-t(2) country(16) tw(158) organization(1)}
1.3.6.1.4.1.(65665+) -- There are illegal definitions of the arcs 65665, 76561 and 123456 found on the internet.
 
-- CATEGORY: Definitions
2.27.(128+) -- Child OIDs are limited to 127 so that the OID can encode in 2 octets.
0.(40+) -- According to Rec. ITU-T X.660 | ISO/IEC 9834-1, "the arcs beneath root arcs 0 and 1 are restricted to forty arcs numbered 0 to 39"
1.(40+) -- According to Rec. ITU-T X.660 | ISO/IEC 9834-1, "the arcs beneath root arcs 0 and 1 are restricted to forty arcs numbered 0 to 39"
1.0.1 -- International Standard ISO 1:2002 is about "Geometrical Product Specifications (GPS) -- Standard reference temperature for geometrical product specification and verification", hence does not define OIDs
1.0.16 -- International Standard ISO 16:1975 is about "Acoustics -- Standard tuning frequency (Standard musical pitch)", hence does not define OIDs
 
-- CATEGORY: Cancelled, withdrawn and rejected OIDs
1.0.29192.2.2.3 -- This OID was allocated to the "Speck" family of block ciphers in ISO/IEC 29192-2 PDAM1 in 2017 but this proposed amendment has been cancelled
1.3.6.1.4.1.37476.9000.36 -- Withdrawn FreeOID by ViaThinkSoft (spam), https://www.viathinksoft.de/freeoid/display_oid.php?oid=36
2.16.840.1.113883.3.20 -- Rejected in the HL7 OID Registry
2.16.840.1.113883.13.(223-225) -- Entered in error in HL7 OID Registry
2.16.840.1.113883.3.24.6.1 -- Entered in error in HL7 OID Registry; The correct OID is 2.16.840.1.113883.4.344
2.16.840.1.113883.3.24.6.2 -- Entered in error in HL7 OID Registry; The correct OID is 2.16.840.1.113883.4.345
2.16.840.1.113883.3.41 -- Rejected by HL7 because it is a duplicate of 2.16.840.1.113883.6.14
2.16.840.1.113883.3.4831.3 -- rejected by HL7: http://www.hl7.org/oid/index.cfm?Comp_OID=2.16.840.1.113883.3.4831.3
 
-- CATEGORY: Misdefined in specifications
1.2.840.113549.1.9.16.0.999 -- According to IETF RFC Errata 3866 ( https://www.rfc-editor.org/errata_search.php?eid=3866 ), the correct number is 49 and not 999 as wrongly specified in IETF RFC 6210
1.0.10118.3.0.61 -- The correct OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2) 7} (the mistake was found when proofreading ISO/IEC 10118-3:2018 for publication, so it will be corrected in a technical corrigendum or amendment)
1.0.10118.3.0.62 -- The correct OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2) 8} (the mistake was found when proofreading ISO/IEC 10118-3:2018 for publication, so it will be corrected in a technical corrigendum or amendment)
1.0.10118.3.0.63 -- The correct OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2) 9} (the mistake was found when proofreading ISO/IEC 10118-3:2018 for publication, so it will be corrected in a technical corrigendum or amendment)
1.0.10118.3.0.64 -- The correct OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2) 10} (the mistake was found when proofreading ISO/IEC 10118-3:2018 for publication, so it will be corrected in a technical corrigendum or amendment)
1.0.10118.3.0.66 -- The correct OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2) 11} (the mistake was found when proofreading ISO/IEC 10118-3:2018 for publication, so it will be corrected in a technical corrigendum or amendment)
1.0.10118.3.0.67 -- The correct OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2) 12} (the mistake was found when proofreading ISO/IEC 10118-3:2018 for publication, so it will be corrected in a technical corrigendum or amendment)
0.0.24.752 -- There is a mistake in Rec. ITU-T X.792 (http://www.itu.int/ITU-T/formal-language/itu-t/x/x792/1999/AuditASN1Module.html) where number 752 is used instead of 792.
 
-- CATEGORY: Not assigned by IANA (probably mistyped)
1.3.6.1.5.5.7.3.0 -- OID 1.3.6.1.5.5.7.3.0 has not been assigned by IANA ( https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-1.3.6.1.5.5.7.3 )
1.3.6.1.5.5.1.4 -- Not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-30
1.3.6.1.5.5.1.5 -- Not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-30
1.3.6.1.5.5.1.6 -- Not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-30
1.3.6.1.5.5.1.7 -- Not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-30
1.3.6.1.5.5.1.8 -- Not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-30
1.3.6.1.2.1.10.10 -- OID not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-7
1.3.6.1.2.1.10.1 -- OID not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-7
1.3.6.1.2.1.10.2 -- OID not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-7
1.3.6.1.5.4.(1+) -- The only child OID defined in the SMI Security for Confidentiality Codes ( https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-28 ) is reserved(0)
1.3.6.1.2.1.10.9999 -- OID not allocated at https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-7
1.3.0 -- OID not defined at http://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml
1.3.6.1.1.2.0 -- OID not defined at http://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml
1.3.6.1.2.2.1.17 -- OID not defined at http://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml
1.3.6.1.2.2.1.22 -- OID not defined at http://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml
 
-- CATEGORY: Not defined by IETF (probably mistyped)
1.3.6.1.6.3.1.2.2.6.1000 -- Not defined in IETF RFC 3418
1.3.6.1.2.1.10.18.6.1.(24+) -- IETF RFC 4805 ( https://tools.ietf.org/html/rfc4805 ) only defines 23 child OIDs of 1.3.6.1.2.1.10.18.6.1
1.3.6.1.2.1.10.18.8.1.(14+) -- IETF RFC 4805 ( https://tools.ietf.org/html/rfc4805 ) only defines 13 child OIDs of 1.3.6.1.2.1.10.18.8.1
1.3.6.1.2.1.3.1.(2+) -- According to IETF RFC 1213 ( https://tools.ietf.org/html/rfc1213 ), there is only one child OID underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) at(3) atTable(1)}
1.3.6.1.2.1.39.1.2.(2+) -- According to IETF RFC 1697 ( https://tools.ietf.org/html/rfc1697 ), there is only one child OID underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) rdbmsMIB(39) rdbmsObjects(1) rdbmsDbInfoTable(2)}
1.3.6.1.2.1.39.1.3.(2+) -- According to IETF RFC 1697 ( https://tools.ietf.org/html/rfc1697 ), there is only one child OID underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) rdbmsMIB(39) rdbmsObjects(1) rdbmsDbParamTable(3)}
1.3.6.1.2.1.39.3.1.(2+) -- According to IETF RFC 1697 ( https://tools.ietf.org/html/rfc1697 ), there is only one child OID underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) rdbmsMIB(39) rdbmsConformance(3) rdbmsCompliances(1)}
1.3.6.1.2.1.39.3.2.(2+) -- According to IETF RFC 1697 ( https://tools.ietf.org/html/rfc1697 ), there is only one child OID underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) rdbmsMIB(39) rdbmsConformance(3) rdbmsGroups(2)}
1.3.6.1.2.1.39.(4+) -- According to IETF RFC 1697 ( https://tools.ietf.org/html/rfc1697 ), there are only three child OIDs underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) rdbmsMIB(39)}
1.3.6.1.2.1.4.21.1.(14+) -- IETF RFC 1213 ( http://www.ietf.org/rfc/rfc1213.txt ) defines child OIDs up to number 13 underneath OID 1.3.6.1.2.1.4.21.1
1.3.6.1.1.1.3 -- OID 1.3.6.1.1.1.3 is not defined in IETF RFC 2307 ( https://tools.ietf.org/html/rfc2307.html ). directoryOperTable OBJECT-TYPE is identified by OID 1.3.6.1.4.1.358.4.6.1.3
1.3.6.1.2.1.99.1.1.(2+) -- IETF RFC 3433 ( https://tools.ietf.org/html/rfc3433.html ) defines only one child OID underneath OID 1.3.6.1.2.1.99.1.1
1.3.6.1.2.1.25.1.(8+) -- OIDs underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) host(25) hrSystem(1)} do not have a number greater than 7 in IETF RFC 2790 ( https://tools.ietf.org/html/rfc2790.html )
1.3.6.1.2.1.10.23.(5+) -- OIDs underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) transmission(10) ppp(23)} are not expected to have a number greater than 4 ( https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-8 )
1.3.6.1.2.1.4.(40+) -- Child OIDs of 1.3.6.1.2.1.4 do not have a number greater to 39 in IETF RFC 4293 ( https://datatracker.ietf.org/doc/rfc4293/ )
1.3.6.1.2.1.69.10 -- Not assigned in IETF RFC 4639 ( https://tools.ietf.org/html/rfc4639 )
1.3.6.1.2.1.69.4 -- Not assigned in IETF RFC 4639 ( https://tools.ietf.org/html/rfc4639 ), use {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) docsSubMgt(125)} instead
 
-- CATEGORY: Not assigned (probably mistyped)
2.16.840.1.113883.3.44.21 -- The correct OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) hl7(113883) externalUseRoots(3) stmarys(4421)}
2.16.840.1.11422 -- The correct OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) 114222}
2.16.840.1.(113526-) -- Childs OIDs of 2.16.840.1 have a number greater than or equal to 113,527
1.3.6.1.2.1.10.10.1.1.2 -- This OID is not defined in ACC-MIB (v1) ( http://www.mibdepot.com/cgi-bin/getmib3.cgi?win=mib_a&i=1&n=ACC-MIB&r=ericsson&f=mib_txt_12_3_1_5&v=v1&t=tree#dot5Group )
1.3.6.1.2.1.10.7.20 -- The correct OID is {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) powerEthernetMIB(105)}
1.3.6.1.2.1.10.7.300 -- The correct OID is {iso(1) member-body(2) us(840) ieee802dot3(10006) snmpmibs(300)}
1.3.6.1.2.1.39.1.4.2 -- The correct OID is {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) transmission(10) sonetMIB(39) sonetObjects(1) sonetFarEndLine(4) sonetFarEndLineIntervalTable(2)}
1.3.6.1.2.2.2.1.(7+) -- OIDs underneath {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) pib(2) frameworkPib(2) frwkBasePibClasses(1)} cannot be greater than 6 because there are only 6 OBJECT-TYPEs defined in IETF RFC 3318 ( https://tools.ietf.org/html/rfc3318.html )
1.3.6.1.4.1.1226.685 -- The correct OID is 1.3.6.1.4.1.1226.1.685
1.3.6.1.4.1.23.2.8889 -- No such OID underneath {iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 23 mibDoc(2)}
1.3.12.999 -- Not assigned by Ecma International
0.0.0 -- Not a series of ITU-T Recommendations
0.3.18 -- Not an assigned DNIC
0.0.8.0 -- Not an H-series ITU-T Recommendation
0.0.23 -- The W-series of ITU-T Recommendations does not exist
2.16.840.1.113883.3.3724.1 -- The correct OID is 2.16.840.1.113883.3.3724
2.49.0.0.174.24900174 -- Invalid WMO OID, see http://alerting.worldweather.org/authorities.php , correct is 2.49.0.0.174.0
2.49.0.0.768.249007680 -- Invalid WMO OID, see http://alerting.worldweather.org/authorities.php , correct is 2.49.0.0.768.0
2.49.0.2.0.0 -- Invalid WMO OID, see http://alerting.worldweather.org/authorities.php , correct is 2.49.0.2.0
0.1.* -- There is no OID underneath OID 0.1
1.2.826.1004 -- The correct OID is 1.2.826.0.1004
1.2.826.1147 -- The correct OID is 1.2.826.0.1147
1.2.826.1296 -- The correct OID is 1.2.826.0.1296
1.2.840.63
1.2.840.802 -- The right OID for IEEE 802.3ad is 1.2.840.10006
1.2.840.1006
1.2.840.10008.421292 -- not assigned by DICOM
1.2.840.11789
2.2.840 -- was 1.2.840 meant?
2.16.840.1.113883.3.0 -- Not assigned by HL7
2.16.840.101 -- The right OID is {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101)}
1.3.6.1.1.250
1.3.6.1.5.2.(0-1) -- kerberosV5
1.3.6.1.5.2.3.0 -- Not allocated by Kerberos version 2
1.3.6.1.5.2.4.0 -- Not allocated by Kerberos version 2
0.0.17.3303.(!127) -- The only child OID underneath 0.0.17.3303 is 127
 
-- END OF FILE --
/trunk/oid_utils.inc.phps
0,0 → 1,0
link ../../code/php/oid_utils.inc.phps
Property changes:
Added: svn:special
+*
\ No newline at end of property
/trunk/oidinfo_api.inc.phps
0,0 → 1,1008
<?php
 
/**
* OID-Info.com API by Daniel Marschall, ViaThinkSoft
* License terms: Apache 2.0
* Revision: 2019-04-01
*/
 
error_reporting(E_ALL | E_NOTICE | E_STRICT | E_DEPRECATED);
 
if (file_exists(__DIR__ . '/oid_utils.inc.phps')) require_once __DIR__ . '/oid_utils.inc.phps';
if (file_exists(__DIR__ . '/oid_utils.inc.php')) require_once __DIR__ . '/oid_utils.inc.php';
if (file_exists(__DIR__ . '/xml_utils.inc.phps')) require_once __DIR__ . '/xml_utils.inc.phps';
if (file_exists(__DIR__ . '/xml_utils.inc.php')) require_once __DIR__ . '/xml_utils.inc.php';
 
class OIDInfoException extends Exception {
}
 
class OIDInfoAPI {
 
# --- PART 0: Constants
 
// First digit of the ping result
// "-" = error
// "0" = OID does not exist
// "1" = OID does exist, but is not approved yet
// "2" = OID does exist and is accessible
/*private*/ const PING_IDX_EXISTS = 0;
 
// Second digit of the ping result
// "-" = error
// "0" = The OID may not be created
// "1" = OID is not an illegal OID, and none of its ascendant is a leaf and its parent OID is not frozen
/*private*/ const PING_IDX_MAY_CREATE = 1;
 
/*private*/ const SOFT_CORRECT_BEHAVIOR_NONE = 0;
/*private*/ const SOFT_CORRECT_BEHAVIOR_LOWERCASE_BEGINNING = 1;
/*private*/ const SOFT_CORRECT_BEHAVIOR_ALL_POSSIBLE = 2;
 
/*public*/ const DEFAULT_ILLEGALITY_RULE_FILE = __DIR__ . '/oid_illegality_rules';
 
# --- Part 1: "Ping API" for checking if OIDs are available or allowed to create
 
public $verbosePingProviders = array('https://misc.daniel-marschall.de/oid-repository/ping_oid.php?oid={OID}');
 
private $pingCache = array();
 
public $pingCacheMaxAge = 3600;
 
public function clearPingCache() {
$this->pingCache = array();
}
 
public function checkOnlineExists($oid) {
if (!self::strictCheckSyntax($oid)) return false;
 
$pingResult = $this->pingOID($oid);
$ret = $pingResult[self::PING_IDX_EXISTS] >= 1;
return $ret;
}
 
public function checkOnlineAvailable($oid) {
if (!self::strictCheckSyntax($oid)) return false;
 
$pingResult = $this->pingOID($oid);
$ret = $pingResult[self::PING_IDX_EXISTS] == 2;
return $ret;
}
 
public function checkOnlineAllowed($oid) {
if (!self::strictCheckSyntax($oid)) return false;
 
$pingResult = $this->pingOID($oid);
return $pingResult[self::PING_IDX_MAY_CREATE] == 1;
}
 
public function checkOnlineMayCreate($oid) {
if (!self::strictCheckSyntax($oid)) return false;
 
$pingResult = $this->pingOID($oid);
 
// OID is either illegal, or one of their parents are leaf or frozen
# if (!checkOnlineAllowed($oid)) return false;
if ($pingResult[self::PING_IDX_MAY_CREATE] == 0) return false;
 
// The OID exists already, so we don't need to create it again
# if ($this->checkOnlineExists($oid)) return false;
if ($pingResult[self::PING_IDX_EXISTS] >= 1) return false;
 
return true;
}
 
protected function pingOID($oid) {
if (isset($this->pingCache[$oid])) {
$cacheAge = $this->pingCache[$oid][0] - time();
if ($cacheAge <= $this->pingCacheMaxAge) {
return $this->pingCache[$oid][1];
}
}
 
if (count($this->verbosePingProviders) == 0) {
throw new OIDInfoException("No verbose ping provider available!");
}
 
$res = false;
foreach ($this->verbosePingProviders as $url) {
$url = str_replace('{OID}', $oid, $url);
$cn = @file_get_contents($url);
if ($cn === false) continue;
$loc_res = trim($cn);
if (strpos($loc_res, '-') === false) {
$res = $loc_res;
break;
}
}
if ($res === false) {
throw new OIDInfoException("Could not ping OID $oid status!");
}
 
// if ($this->pingCacheMaxAge >= 0) {
$this->pingCache[$oid] = array(time(), $res);
//}
 
return $res;
}
 
# --- PART 2: Syntax checking
 
public static function strictCheckSyntax($oid) {
return oid_valid_dotnotation($oid, false, false, 1);
}
 
// Returns false if $oid has wrong syntax
// Return an OID without leading dot or zeroes, if the syntax is acceptable
public static function trySanitizeOID($oid) {
// Allow leading dots and leading zeroes, but remove then afterwards
$ok = oid_valid_dotnotation($oid, true, true, 1);
if ($ok === false) return false;
 
return sanitizeOID($oid, $oid[0] == '.');
}
 
# --- PART 3: XML file creation
 
protected static function eMailValid($email) {
# TODO: use isemail project
 
if (empty($email)) return false;
 
if (strpos($email, '@') === false) return false;
 
$ary = explode('@', $email, 2);
if (!isset($ary[1])) return false;
if (strpos($ary[1], '.') === false) return false;
 
return true;
}
 
public function softCorrectEMail($email, $params) {
$email = str_replace(' ', '', $email);
$email = str_replace('&', '@', $email);
$email = str_replace('(at)', '@', $email);
$email = str_replace('[at]', '@', $email);
$email = str_replace('(dot)', '.', $email);
$email = str_replace('[dot]', '.', $email);
$email = trim($email);
 
if (!$params['allow_illegal_email'] && !self::eMailValid($email)) {
return '';
}
 
return $email;
}
 
public function softCorrectPhone($phone, $params) {
// TODO: if no "+", add "+1" , but only if address is in USA
// TODO: or use param to fixate country if it is not known
/*
NOTE: with german phone numbers, this will cause trouble, even if we assume "+49"
06223 / 1234
shall be
+49 6223 1234
and not
+49 06223 1234
*/
 
$phone = str_replace('-', ' ', $phone);
$phone = str_replace('.', ' ', $phone);
$phone = str_replace('/', ' ', $phone);
$phone = str_replace('(', ' ', $phone);
$phone = str_replace(')', ' ', $phone);
 
// HL7 registry has included this accidently
$phone = str_replace('&quot;', '', $phone);
 
$phone = trim($phone);
 
return $phone;
}
 
private static function strip_to_xhtml_light($str){
$str = str_ireplace('<b>', '<strong>', $str);
$str = str_ireplace('</b>', '</strong>', $str);
 
$str = preg_replace('@<\s*script.+<\s*/script.*>@isU', '', $str);
$str = preg_replace('@<\s*style.+<\s*/style.*>@isU', '', $str);
 
$str = preg_replace_callback(
'@<(\s*/{0,1}\d*)([^\s/>]+)(\s*[^>]*)>@i',
function ($treffer) {
// see http://oid-info.com/xhtml-light.xsd
$whitelist = array('a', 'br', 'code', 'em', 'font', 'img', 'li', 'strong', 'sub', 'sup', 'ul');
 
$pre = $treffer[1];
$tag = $treffer[2];
$attrib = $treffer[3];
if (in_array($tag, $whitelist)) {
return '<'.$pre.$tag.$attrib.'>';
} else {
return '';
}
}, $str);
 
return $str;
}
 
const OIDINFO_CORRECT_DESC_OPTIONAL_ENDING_DOT = 0;
const OIDINFO_CORRECT_DESC_ENFORCE_ENDING_DOT = 1;
const OIDINFO_CORRECT_DESC_DISALLOW_ENDING_DOT = 2;
 
public function correctDesc($desc, $params, $ending_dot_policy=self::OIDINFO_CORRECT_DESC_OPTIONAL_ENDING_DOT, $enforce_xhtml_light=false) {
$desc = trim($desc);
 
$desc = preg_replace('@<!\\[CDATA\\[(.+)\\]\\]>@ismU', '\\1', $desc);
 
if (substr_count($desc, '>') != substr_count($desc, '<')) {
$params['allow_html'] = false;
}
 
$desc = str_replace("\r", '', $desc);
 
if (!$params['allow_html']) {
// htmlentities_numeric() does this for us
/*
$desc = str_replace('&', '&amp;', $desc);
$desc = str_replace('<', '&lt;', $desc);
$desc = str_replace('>', '&gt;', $desc);
$desc = str_replace('"', '&quot;', $desc);
$desc = str_replace("'", '&#39;', $desc); // &apos; is not HTML. It is XML
*/
 
$desc = str_replace("\n", '<br />', $desc);
} else {
// Some problems we had with HL7 registry
$desc = preg_replace('@&lt;(/{0,1}(p|i|b|u|ul|li))&gt;@ismU', '<\\1>', $desc);
# preg_match_all('@&lt;[^ :\\@]+&gt;@ismU', $desc, $m);
# if (count($m[0]) > 0) print_r($m);
 
$desc = preg_replace('@<i>(.+)&lt;i/&gt;@ismU', '<i>\\1</i>', $desc);
$desc = str_replace('<p><p>', '</p><p>', $desc);
 
// <p> are not supported by oid-info.com
$desc = str_replace('<p>', '<br /><br />', $desc);
$desc = str_replace('</p>', '', $desc);
}
 
// Escape unicode characters as numeric &#...;
// The XML 1.0 standard does only has a few entities, but nothing like e.g. &euro; , so we prefer numeric
 
//$desc = htmlentities_numeric($desc, $params['allow_html']);
if (!$params['allow_html']) $desc = htmlentities($desc);
$desc = html_named_to_numeric_entities($desc);
 
// Remove HTML tags which are not allowed
if ($params['allow_html'] && (!$params['ignore_xhtml_light']) && $enforce_xhtml_light) {
// oid-info.com does only allow a few HTML tags
// see http://oid-info.com/xhtml-light.xsd
$desc = self::strip_to_xhtml_light($desc);
}
 
// Solve some XML problems...
$desc = preg_replace('@<\s*br\s*>@ismU', '<br/>', $desc); // auto close <br>
$desc = preg_replace('@(href\s*=\s*)(["\'])(.*)&([^#].*)(\2)@ismU', '\1\2\3&amp;\4\5', $desc); // fix "&" inside href-URLs to &amp;
// TODO: what do we do if there are more XHTML errors (e.g. additional open tags) which would make the XML invalid?
 
// "Trim" <br/>
do { $desc = preg_replace('@^\s*<\s*br\s*/{0,1}\s*>@isU', '', $desc, -1, $count); } while ($count > 0); // left trim
do { $desc = preg_replace('@<\s*br\s*/{0,1}\s*>\s*$@isU', '', $desc, -1, $count); } while ($count > 0); // right trim
 
// Correct double-encoded stuff
if (!isset($params['tolerant_htmlentities']) || $params['tolerant_htmlentities']) {
do {
$old_desc = $desc;
# Full list of entities: https://www.freeformatter.com/html-entities.html
# Max: 8 chars ( &thetasym; )
# Min: 2 chars ( lt,gt,ni,or,ne,le,ge,Mu,Nu,Xi,Pi,mu,nu,xi,pi )
$desc = preg_replace('@(&|&amp;)(#|&#35;)(\d+);@ismU', '&#\3;', $desc);
$desc = preg_replace('@(&|&amp;)([a-zA-Z0-9]{2,8});@ismU', '&\2;', $desc);
} while ($old_desc != $desc);
}
 
// TODO: use the complete list of oid-info.com
// TODO: Make this step optional using $params
/*
Array
(
[0] => Root OID for
[1] => OID for
[2] => OID identifying
[3] => Top arc for
[4] => Arc for
[5] => arc root
[6] => Node for
[7] => Leaf node for
[8] => This OID describes
[9] => [tT]his oid
[10] => This arc describes
[11] => This identifies
[12] => Identifies a
[13] => [Oo]bject [Ii]dentifier
[14] => Identifier for
[15] => This [Ii]dentifier is for
[16] => Identifiers used by
[17] => identifier$
[18] => This branch
[19] => Branch for
[20] => Child tree for
[21] => Child for
[22] => Subtree for
[23] => Sub-OID
[24] => Tree for
[25] => Child object
[26] => Parent OID
[27] => root for
[28] => Assigned for
[29] => Used to identify
[30] => Used in
[31] => Used for
[32] => For use by
[33] => Entry for
[34] => This is for
[35] => ["]?OID["]?
[36] => ^OID
[37] => OID$
[38] => oid
[39] => oid$
[40] => OIDs
)
$x = 'Root OID for ; OID for ; OID identifying ; Top arc for ; Arc for ; arc root; Node for ; Leaf node for ; This OID describes ; [tT]his oid ; This arc describes ; This identifies ; Identifies a ; [Oo]bject [Ii]dentifier; Identifier for ; This [Ii]dentifier is for ; Identifiers used by ; identifier$; This branch ; Branch for ; Child tree for ; Child for ; Subtree for ; Sub-OID; Tree for ; Child object; Parent OID; root for ; Assigned for ; Used to identify ; Used in ; Used for ; For use by ; Entry for ; This is for ; ["]?OID["]? ; ^OID ; OID$; oid ; oid$; OIDs';
$ary = explode('; ', $x);
print_r($ary);
*/
$desc = preg_replace("@^Root OID for the @i", '', $desc);
$desc = preg_replace("@^Root OID for @i", '', $desc);
$desc = preg_replace("@^OID root for the @i", '', $desc);
$desc = preg_replace("@^OID root for @i", '', $desc);
$desc = preg_replace("@^This OID will be used for @i", '', $desc);
$desc = preg_replace("@^This will be a generic OID for the @i", '', $desc);
$desc = preg_replace("@^OID for @i", '', $desc);
$desc = preg_replace("@ Root OID$@i", '', $desc);
$desc = preg_replace("@ OID$@i", '', $desc);
$desc = preg_replace("@ OID Namespace$@i", '', $desc);
$desc = preg_replace("@^OID for @i", '', $desc);
 
$desc = rtrim($desc);
if ($ending_dot_policy == self::OIDINFO_CORRECT_DESC_ENFORCE_ENDING_DOT) {
if (($desc != '') && (substr($desc, -1)) != '.') $desc .= '.';
} else if ($ending_dot_policy == self::OIDINFO_CORRECT_DESC_DISALLOW_ENDING_DOT) {
$desc = preg_replace('@\\.$@', '', $desc);
}
 
return $desc;
}
 
public function xmlAddHeader($firstName, $lastName, $email) {
// TODO: encode
 
$firstName = htmlentities_numeric($firstName);
if (empty($firstName)) {
throw new OIDInfoException("Please supply a first name");
}
 
$lastName = htmlentities_numeric($lastName);
if (empty($lastName)) {
throw new OIDInfoException("Please supply a last name");
}
 
$email = htmlentities_numeric($email);
if (empty($email)) {
throw new OIDInfoException("Please supply an email address");
}
 
// $out = "<!DOCTYPE oid-database>\n\n";
$out = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
$out .= '<oid-database xmlns="http://oid-info.com"'."\n";
$out .= ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'."\n";
$out .= ' xsi:schemaLocation="http://oid-info.com '."\n";
$out .= ' http://oid-info.com/oid.xsd">'."\n";
$out .= "\t<submitter>\n";
$out .= "\t\t<first-name>$firstName</first-name>\n";
$out .= "\t\t<last-name>$lastName</last-name>\n";
$out .= "\t\t<email>$email</email>\n";
$out .= "\t</submitter>\n";
 
if (!self::eMailValid($email)) {
throw new OIDInfoException("eMail address '$email' is invalid");
}
 
return $out;
}
 
public function xmlAddFooter() {
return "</oid-database>\n";
}
 
/*
-- CODE TEMPLATE --
 
$params['allow_html'] = false; // Allow HTML in <description> and <information>
$params['allow_illegal_email'] = true; // We should allow it, because we don't know if the user has some kind of human-readable anti-spam technique
$params['soft_correct_behavior'] = OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE;
$params['do_online_check'] = false; // Flag to disable this online check, because it generates a lot of traffic and runtime.
$params['do_illegality_check'] = true;
$params['do_simpleping_check'] = true;
$params['auto_extract_name'] = '';
$params['auto_extract_url'] = '';
$params['always_output_comment'] = false; // Also output comment if there was an error (e.g. OID already existing)
$params['creation_allowed_check'] = true;
$params['tolerant_htmlentities'] = true;
$params['ignore_xhtml_light'] = false;
 
$elements['synonymous-identifier'] = ''; // string or array
$elements['description'] = '';
$elements['information'] = '';
 
$elements['first-registrant']['first-name'] = '';
$elements['first-registrant']['last-name'] = '';
$elements['first-registrant']['address'] = '';
$elements['first-registrant']['email'] = '';
$elements['first-registrant']['phone'] = '';
$elements['first-registrant']['fax'] = '';
$elements['first-registrant']['creation-date'] = '';
 
$elements['current-registrant']['first-name'] = '';
$elements['current-registrant']['last-name'] = '';
$elements['current-registrant']['address'] = '';
$elements['current-registrant']['email'] = '';
$elements['current-registrant']['phone'] = '';
$elements['current-registrant']['fax'] = '';
$elements['current-registrant']['modification-date'] = '';
 
$oid = '1.2.3';
 
$comment = 'test';
 
echo $oa->createXMLEntry($oid, $elements, $params, $comment);
*/
public function createXMLEntry($oid, $elements, $params, $comment='') {
// Backward compatibility
if (!isset($params['do_csv_check'])) $params['do_simpleping_check'] = true;
 
// Set default behavior
if (!isset($params['allow_html'])) $params['allow_html'] = false; // Allow HTML in <description> and <information>
if (!isset($params['allow_illegal_email'])) $params['allow_illegal_email'] = true; // We should allow it, because we don't know if the user has some kind of human-readable anti-spam technique
if (!isset($params['soft_correct_behavior'])) $params['soft_correct_behavior'] = self::SOFT_CORRECT_BEHAVIOR_NONE;
if (!isset($params['do_online_check'])) $params['do_online_check'] = false; // Flag to disable this online check, because it generates a lot of traffic and runtime.
if (!isset($params['do_illegality_check'])) $params['do_illegality_check'] = true;
if (!isset($params['do_simpleping_check'])) $params['do_simpleping_check'] = true;
if (!isset($params['auto_extract_name'])) $params['auto_extract_name'] = '';
if (!isset($params['auto_extract_url'])) $params['auto_extract_url'] = '';
if (!isset($params['always_output_comment'])) $params['always_output_comment'] = false; // Also output comment if there was an error (e.g. OID already existing)
if (!isset($params['creation_allowed_check'])) $params['creation_allowed_check'] = true;
if (!isset($params['tolerant_htmlentities'])) $params['tolerant_htmlentities'] = true;
if (!isset($params['ignore_xhtml_light'])) $params['ignore_xhtml_light'] = false;
 
$out = '';
if (!empty($comment)) $out .= "\t\t<!-- $comment -->\n";
 
if ($params['always_output_comment']) {
$err = $out;
} else {
$err = false;
}
 
if (isset($elements['dotted_oid'])) {
throw new OIDInfoException("'dotted_oid' in the \$elements array is not supported. Please use the \$oid argument.");
}
if (isset($elements['value'])) {
// TODO: WHAT SHOULD WE DO WITH THAT?
throw new OIDInfoException("'value' in the \$elements array is currently not supported.");
}
 
$bak_oid = $oid;
$oid = self::trySanitizeOID($oid);
if ($oid === false) {
$out .= "\t\t<!-- Ignored '$bak_oid', because it is not a valid OID -->\n";
return false;
}
 
if ($params['creation_allowed_check']) {
if (!$this->oidMayCreate($oid, $params['do_online_check'], $params['do_simpleping_check'], $params['do_illegality_check'])) return $err;
}
 
$elements['description'] = $this->correctDesc($elements['description'], $params, self::OIDINFO_CORRECT_DESC_DISALLOW_ENDING_DOT, true);
$elements['information'] = $this->correctDesc($elements['information'], $params, self::OIDINFO_CORRECT_DESC_ENFORCE_ENDING_DOT, true);
 
if ($params['auto_extract_name'] || $params['auto_extract_url']) {
if (!empty($elements['information'])) $elements['information'] .= '<br /><br />';
if ($params['auto_extract_name'] || $params['auto_extract_url']) {
$elements['information'] .= 'Automatically extracted from <a href="'.$params['auto_extract_url'].'">'.$params['auto_extract_name'].'</a>.';
} else if ($params['auto_extract_name']) {
$elements['information'] .= 'Automatically extracted from '.$params['auto_extract_name'];
} else if ($params['auto_extract_url']) {
$hr_url = $params['auto_extract_url'];
// $hr_url = preg_replace('@^https{0,1}://@ismU', '', $hr_url);
$hr_url = preg_replace('@^http://@ismU', '', $hr_url);
$elements['information'] .= 'Automatically extracted from <a href="'.$params['auto_extract_url'].'">'.$hr_url.'</a>.';
}
}
 
// Validate ASN.1 ID
if (isset($elements['synonymous-identifier'])) {
if (!is_array($elements['synonymous-identifier'])) {
$elements['synonymous-identifier'] = array($elements['synonymous-identifier']);
}
foreach ($elements['synonymous-identifier'] as &$synid) {
if ($synid == '') {
$synid = null;
continue;
}
 
$behavior = $params['soft_correct_behavior'];
 
if ($behavior == self::SOFT_CORRECT_BEHAVIOR_NONE) {
if (!oid_id_is_valid($synid)) $synid = null;
} else if ($behavior == self::SOFT_CORRECT_BEHAVIOR_LOWERCASE_BEGINNING) {
$synid[0] = strtolower($synid[0]);
if (!oid_id_is_valid($synid)) $synid = null;
} else if ($behavior == self::SOFT_CORRECT_BEHAVIOR_ALL_POSSIBLE) {
$synid = oid_soft_correct_id($synid);
// if (!oid_id_is_valid($synid)) $synid = null;
} else {
throw new OIDInfoException("Unexpected soft-correction behavior for ASN.1 IDs");
}
}
}
 
// ATTENTION: the XML-generator will always add <dotted-oid> , but what will happen if additionally an
// asn1-path (<value>) is given? (the resulting OIDs might be inconsistent/mismatch)
if (isset($elements['value']) && (!asn1_path_valid($elements['value']))) {
unset($elements['value']);
}
 
// Validate IRI (currently not supported by oid-info.com, but the tag name is reserved)
if (isset($elements['iri'])) {
if (!is_array($elements['iri'])) {
$elements['iri'] = array($elements['iri']);
}
foreach ($elements['iri'] as &$iri) {
// Numeric-only nicht erlauben. Das wäre ja nur in einem IRI-Pfad gültig, aber nicht als einzelner Identifier
if (!iri_arc_valid($iri, false)) $iri = null;
}
}
 
if (isset($elements['first-registrant']['phone']))
$elements['first-registrant']['phone'] = $this->softCorrectPhone($elements['first-registrant']['phone'], $params);
 
if (isset($elements['current-registrant']['phone']))
$elements['current-registrant']['phone'] = $this->softCorrectPhone($elements['current-registrant']['phone'], $params);
 
if (isset($elements['first-registrant']['fax']))
$elements['first-registrant']['fax'] = $this->softCorrectPhone($elements['first-registrant']['fax'], $params);
 
if (isset($elements['current-registrant']['fax']))
$elements['current-registrant']['fax'] = $this->softCorrectPhone($elements['current-registrant']['fax'], $params);
 
if (isset($elements['first-registrant']['email']))
$elements['first-registrant']['email'] = $this->softCorrectEMail($elements['first-registrant']['email'], $params);
 
if (isset($elements['current-registrant']['email']))
$elements['current-registrant']['email'] = $this->softCorrectEMail($elements['current-registrant']['email'], $params);
 
// TODO: if name is empty, but address has 1 line, take it as firstname (but remove hyperlink)
 
$out_loc = '';
foreach ($elements as $name => $val) {
if (($name == 'first-registrant') || ($name == 'current-registrant')) {
$out_loc2 = '';
foreach ($val as $name2 => $val2) {
if (is_null($val2)) continue;
if (empty($val2)) continue;
 
if (!is_array($val2)) $val2 = array($val2);
 
foreach ($val2 as $val3) {
// if (is_null($val3)) continue;
if (empty($val3)) continue;
 
if ($name2 == 'address') {
// $val3 = htmlentities_numeric($val3);
$val3 = $this->correctDesc($val3, $params, self::OIDINFO_CORRECT_DESC_DISALLOW_ENDING_DOT, true);
} else {
// $val3 = htmlentities_numeric($val3);
$val3 = $this->correctDesc($val3, $params, self::OIDINFO_CORRECT_DESC_DISALLOW_ENDING_DOT, false);
}
$out_loc2 .= "\t\t\t<$name2>".$val3."</$name2>\n";
}
}
 
if (!empty($out_loc2)) {
$out_loc .= "\t\t<$name>\n";
$out_loc .= $out_loc2;
$out_loc .= "\t\t</$name>\n";
}
} else {
// if (is_null($val)) continue;
if (empty($val) && ($name != 'description')) continue; // description is mandatory, according to http://oid-info.com/oid.xsd
 
if (!is_array($val)) $val = array($val);
 
foreach ($val as $val2) {
// if (is_null($val2)) continue;
if (empty($val2) && ($name != 'description')) continue; // description is mandatory, according to http://oid-info.com/oid.xsd
 
if (($name != 'description') && ($name != 'information')) { // don't correctDesc description/information, because we already did it above.
// $val2 = htmlentities_numeric($val2);
$val2 = $this->correctDesc($val2, $params, self::OIDINFO_CORRECT_DESC_OPTIONAL_ENDING_DOT, false);
}
$out_loc .= "\t\t<$name>".$val2."</$name>\n";
}
}
}
 
if (!empty($out)) {
$out = "\t<oid>\n"."\t\t".trim($out)."\n";
} else {
$out = "\t<oid>\n";
}
$out .= "\t\t<dot-notation>$oid</dot-notation>\n";
$out .= $out_loc;
$out .= "\t</oid>\n";
 
return $out;
}
 
# --- PART 4: Offline check if OIDs are illegal
 
protected $illegality_rules = array();
 
public function clearIllegalityRules() {
$this->illegality_rules = array();
}
 
public function loadIllegalityRuleFile($file) {
if (!file_exists($file)) {
throw new OIDInfoException("Error: File '$file' does not exist");
}
 
$lines = file($file);
 
if ($lines === false) {
throw new OIDInfoException("Error: Could not load '$file'");
}
 
$signature = trim(array_shift($lines));
if (($signature != '[1.3.6.1.4.1.37476.3.1.5.1]') && ($signature != '[1.3.6.1.4.1.37476.3.1.5.2]')) {
throw new OIDInfoException("'$file' does not seem to a valid illegality rule file (file format OID does not match. Signature $signature unexpected)");
}
 
foreach ($lines as $line) {
// Remove comments
$ary = explode('--', $line);
$rule = trim($ary[0]);
 
if ($rule !== '') $this->addIllegalityRule($rule);
}
}
 
public function addIllegalityRule($rule) {
$test = $rule;
$test = preg_replace('@\\.\\(!\\d+\\)@ismU', '.0', $test); // added in ver 2
$test = preg_replace('@\\.\\(\\d+\\+\\)@ismU', '.0', $test);
$test = preg_replace('@\\.\\(\\d+\\-\\)@ismU', '.0', $test);
$test = preg_replace('@\\.\\(\\d+\\-\\d+\\)@ismU', '.0', $test);
$test = preg_replace('@\\.\\*@ismU', '.0', $test);
 
if (!oid_valid_dotnotation($test, false, false, 1)) {
throw new OIDInfoException("Illegal illegality rule '$rule'.");
}
 
$this->illegality_rules[] = $rule;
}
 
public function illegalOID($oid, &$illegal_root='') {
$bak = $oid;
$oid = self::trySanitizeOID($oid);
if ($oid === false) {
$illegal_root = $bak;
return true; // is illegal
}
 
$rules = $this->illegality_rules;
 
foreach ($rules as $rule) {
$rule = str_replace(array('(', ')'), '', $rule);
 
$oarr = explode('.', $oid);
$rarr = explode('.', $rule);
 
if (count($oarr) < count($rarr)) continue;
 
$rulefit = true;
 
$illrootary = array();
 
$vararcs = 0;
$varsfit = 0;
for ($i=0; $i<count($rarr); $i++) {
$oelem = $oarr[$i];
$relem = $rarr[$i];
 
$illrootary[] = $oelem;
 
if ($relem == '*') $relem = '0+';
 
$startchar = substr($relem, 0, 1);
$endchar = substr($relem, -1, 1);
if ($startchar == '!') { // added in ver 2
$vararcs++;
$relem = substr($relem, 1, strlen($relem)-1); // cut away first char
if ($oelem != $relem) $varsfit++;
} else if ($endchar == '+') {
$vararcs++;
$relem = substr($relem, 0, strlen($relem)-1); // cut away last char
if ($oelem >= $relem) $varsfit++;
} else if ($endchar == '-') {
$vararcs++;
$relem = substr($relem, 0, strlen($relem)-1); // cut away last char
if ($oelem <= $relem) $varsfit++;
} else if (strpos($relem, '-') !== false) {
$vararcs++;
$limarr = explode('-', $relem);
$limmin = $limarr[0];
$limmax = $limarr[1];
if (($oelem >= $limmin) && ($oelem <= $limmax)) $varsfit++;
} else {
if ($relem != $oelem) {
$rulefit = false;
break;
}
}
}
 
if ($rulefit && ($vararcs == $varsfit)) {
$illegal_root = implode('.', $illrootary);
return true; // is illegal
}
}
 
$illegal_root = '';
return false; // not illegal
}
 
# --- PART 5: Misc functions
 
function __construct() {
if (file_exists(self::DEFAULT_ILLEGALITY_RULE_FILE)) {
$this->loadIllegalityRuleFile(self::DEFAULT_ILLEGALITY_RULE_FILE);
}
}
 
public static function getPublicURL($oid) {
return "http://oid-info.com/get/$oid";
}
 
public function oidExisting($oid, $onlineCheck=true, $useSimplePingProvider=true) {
$bak_oid = $oid;
$oid = self::trySanitizeOID($oid);
if ($oid === false) {
throw new OIDInfoException("'$bak_oid' is not a valid OID");
}
 
$canuseSimplePingProvider = $useSimplePingProvider && $this->simplePingProviderAvailable();
if ($canuseSimplePingProvider) {
if ($this->simplePingProviderCheckOID($oid)) return true;
}
if ($onlineCheck) {
return $this->checkOnlineExists($oid);
}
if ((!$canuseSimplePingProvider) && (!$onlineCheck)) {
throw new OIDInfoException("No simple or verbose checking method chosen/available");
}
return false;
}
 
public function oidMayCreate($oid, $onlineCheck=true, $useSimplePingProvider=true, $illegalityCheck=true) {
$bak_oid = $oid;
$oid = self::trySanitizeOID($oid);
if ($oid === false) {
throw new OIDInfoException("'$bak_oid' is not a valid OID");
}
 
if ($illegalityCheck && $this->illegalOID($oid)) return false;
 
$canuseSimplePingProvider = $useSimplePingProvider && $this->simplePingProviderAvailable();
if ($canuseSimplePingProvider) {
if ($this->simplePingProviderCheckOID($oid)) return false;
}
if ($onlineCheck) {
return $this->checkOnlineMayCreate($oid);
}
if ((!$canuseSimplePingProvider) && (!$onlineCheck)) {
throw new OIDInfoException("No simple or verbose checking method chosen/available");
}
return true;
}
 
# --- PART 6: Simple Ping Providers
# TODO: Question ... can't these provider concepts (SPP and VPP) not somehow be combined?
 
protected $simplePingProviders = array();
 
public function addSimplePingProvider($addr) {
if (!isset($this->simplePingProviders[$addr])) {
if (strtolower(substr($addr, -4, 4)) == '.csv') {
$this->simplePingProviders[$addr] = new CSVSimplePingProvider($addr);
} else {
$this->simplePingProviders[$addr] = new OIDSimplePingProvider($addr);
// $this->simplePingProviders[$addr]->connect();
}
}
return $this->simplePingProviders[$addr];
}
 
public function removeSimplePingProvider($addr) {
$this->simplePingProviders[$addr]->disconnect();
unset($this->simplePingProviders[$addr]);
}
 
public function removeAllSimplePingProviders() {
foreach ($this->simplePingProviders as $addr => $obj) {
$this->removeSimplePingProvider($addr);
}
}
 
public function listSimplePingProviders() {
$out = array();
foreach ($this->simplePingProviders as $addr => $obj) {
$out[] = $addr;
}
return $out;
}
 
public function simplePingProviderCheckOID($oid) {
if (!$this->simplePingProviderAvailable()) {
throw new OIDInfoException("No simple ping providers available.");
}
 
$one_null = false;
foreach ($this->simplePingProviders as $addr => $obj) {
$res = $obj->queryOID($oid);
if ($res) return true;
if ($res !== false) $one_null = true;
}
 
return $one_null ? null : false;
}
 
public function simplePingProviderAvailable() {
return count($this->simplePingProviders) >= 1;
}
 
}
 
interface IOIDSimplePingProvider {
public function queryOID($oid);
public function disconnect();
public function connect();
}
 
class CSVSimplePingProvider implements IOIDSimplePingProvider {
protected $csvfile = '';
protected $lines = array();
protected $filemtime = 0;
 
public function queryOID($oid) {
$this->reloadCSV();
return in_array($oid, $this->lines);
}
 
public function disconnect() {
// Nothing
}
 
public function connect() {
// Nothing
}
 
// TODO: This cannot handle big CSVs. We need to introduce the old code of "2016-09-02_old_oidinfo_api_with_csv_reader.zip" here.
protected function reloadCSV() {
if (!file_exists($this->csvfile)) {
throw new OIDInfoException("File '".$this->csvfile."' does not exist");
}
$filemtime = filemtime($this->csvfile);
if ($filemtime != $this->filemtime) {
$this->lines = file($csvfile);
$this->filemtime = $filemtime;
}
}
 
function __construct($csvfile) {
$this->csvfile = $csvfile;
$this->reloadCSV();
}
}
 
 
class OIDSimplePingProvider implements IOIDSimplePingProvider {
protected $addr = '';
protected $connected = false;
protected $socket = null;
 
const SPP_MAX_CONNECTION_ATTEMPTS = 3; // TODO: Auslagern in OIDInfoAPI Klasse...?
 
const DEFAULT_PORT = 49500;
 
protected function spp_reader_init() {
$this->spp_reader_uninit();
 
$ary = explode(':', $this->addr);
$host = $ary[0];
$service_port = isset($ary[1]) ? $ary[1] : self::DEFAULT_PORT;
$address = @gethostbyname($host);
if ($address === false) {
echo "gethostbyname() failed.\n"; // TODO: exceptions? (Auch alle "echos" darunter)
return false;
}
$this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($this->socket === false) {
echo "socket_create() failed: " . socket_strerror(socket_last_error()) . "\n";
return false;
}
$result = @socket_connect($this->socket, $address, $service_port);
if ($result === false) {
echo "socket_connect() failed: " . socket_strerror(socket_last_error($this->socket)) . "\n";
return false;
}
 
$this->connected = true;
}
 
protected function spp_reader_avail($oid, $failcount=0) {
$in = "${oid}\n\0"; // PHP's socket_send() does not send a trailing \n . There needs to be something after the \n ... :(
 
if ($failcount >= self::SPP_MAX_CONNECTION_ATTEMPTS) {
echo "Query $oid: CONNECTION FAILED!\n";
return null;
}
 
if (!$this->connected) {
$this->spp_reader_init();
}
 
$s = @socket_send($this->socket, $in, strlen($in), 0);
if ($s != strlen($in)) {
// echo "Query $oid: Sending failed\n";
$this->spp_reader_init();
if (!$this->socket) return null;
return $this->spp_reader_avail($oid, $failcount+1);
}
 
$out = @socket_read($this->socket, 2048);
if (trim($out) == '1') {
return true;
} else if (trim($out) == '0') {
return false;
} else {
// echo "Query $oid: Receiving failed\n";
$this->spp_reader_init();
if (!$this->socket) return null;
return $this->spp_reader_avail($oid, $failcount+1);
}
}
 
protected function spp_reader_uninit() {
if (!$this->connected) return;
@socket_close($this->socket);
$this->connected = false;
}
 
public function queryOID($oid) {
if (trim($oid) === 'bye') return null;
return $this->spp_reader_avail($oid);
}
 
public function disconnect() {
return $this->spp_reader_uninit();
}
 
public function connect() {
return $this->spp_reader_init();
}
 
function __construct($addr='localhost:49500') {
$this->addr = $addr;
}
 
}
/trunk/oidinfo_example.phps
0,0 → 1,49
<?php
 
require_once __DIR__ . '/oidinfo_api.inc.phps';
 
$oa = new OIDInfoAPI();
$oa->addSimplePingProvider('viathinksoft.de:49500');
 
echo $oa->xmlAddHeader('hello', 'world', 'test@example.com');
 
$params['allow_html'] = true; // Allow HTML in <description> and <information>
$params['allow_illegal_email'] = true; // It should be enabled, because the creator could have used some kind of human-readable anti-spam technique
$params['soft_correct_behavior'] = OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE;
$params['do_online_check'] = false; // Flag to disable this online check, because it generates a lot of traffic and runtime.
$params['do_illegality_check'] = false;
$params['do_simpleping_check'] = false;
$params['auto_extract_name'] = '';
$params['auto_extract_url'] = '';
$params['always_output_comment'] = false; // Do not output comment if there was an error (e.g. OID already existing)
$params['creation_allowed_check'] = false;
$params['tolerant_htmlentities'] = true;
$params['ignore_xhtml_light'] = false;
 
$elements['synonymous-identifier'] = ''; // string or array
$elements['description'] = '';
$elements['information'] = '';
 
$elements['first-registrant']['first-name'] = '';
$elements['first-registrant']['last-name'] = '';
$elements['first-registrant']['address'] = '';
$elements['first-registrant']['email'] = '';
$elements['first-registrant']['phone'] = '';
$elements['first-registrant']['fax'] = '';
$elements['first-registrant']['creation-date'] = '';
 
$elements['current-registrant']['first-name'] = '';
$elements['current-registrant']['last-name'] = '';
$elements['current-registrant']['address'] = '';
$elements['current-registrant']['email'] = '';
$elements['current-registrant']['phone'] = '';
$elements['current-registrant']['fax'] = '';
$elements['current-registrant']['modification-date'] = '';
 
$oid = '2.999';
echo $oa->createXMLEntry($oid, $elements, $params, $comment='hello');
 
$oid = '2.999.1';
echo $oa->createXMLEntry($oid, $elements, $params, $comment='hello');
 
echo $oa->xmlAddFooter();
/trunk/oidinfo_test.phps
0,0 → 1,19
<?php
 
require_once __DIR__ . '/oidinfo_api.inc.phps';
 
$oa = new OIDInfoAPI();
 
$oa->loadIllegalityRuleFile('oid_illegality_rules');
 
assert($oa->illegalOID('1.3.6.1.2.1.9999') === true);
assert($oa->illegalOID('1.3.6.1.2.1.9999.123') === true);
assert($oa->illegalOID('2.999') === false);
assert($oa->illegalOID('3') === true);
assert($oa->illegalOID('1') === false);
assert($oa->illegalOID('1.0.16') === true);
assert($oa->illegalOID('1.2.6.0') === true); // 1.2.6 is illegal -> 1.2.6.0 too
 
assert($oa->strictCheckSyntax('0', false, true) === true);
assert($oa->strictCheckSyntax('1', false, true) === true);
assert($oa->strictCheckSyntax('(requesting)', false, true) === false);
/trunk/uuid_utils.inc.phps
0,0 → 1,0
link /home/daniel-marschall/public_html/tools/uuid_mac_decoder/includes/uuid_utils.inc.phps
Property changes:
Added: svn:special
+*
\ No newline at end of property
/trunk/xml_utils.inc.phps
0,0 → 1,0
link ../../code/php/xml_utils.inc.phps
Property changes:
Added: svn:special
+*
\ No newline at end of property