Subversion Repositories oidinfo_api

Compare Revisions

Ignore whitespace Rev 14 → Rev 15

/trunk/oid_utils.inc.phps
20,7 → 20,7
 
// All functions in this library are compatible with leading zeroes (not recommended) and leading dots
 
// TODO: change some function names, so that they have a uniform naming schema, and rename "oid identifier" into "asn.1 alphanumeric identifier"
// TODO: change some function names, so that they have a uniform naming schema, and rename "oid identifier" into "ASN.1 alphanumeric identifier"
// oid_id_is_valid() => asn1_alpha_id_valid()
 
define('OID_DOT_FORBIDDEN', 0);
341,7 → 341,7
function sanitizeOID($oid, $leading_dot=false) {
if ($leading_dot) $leading_dot = substr($oid,0,1) == '.';
 
// We are using a cache, since this function is used very often by OID+
// We are using a cache, since this function is used very often by OIDplus
global $oid_sanitize_cache;
$v = ($leading_dot ? 'T' : 'F').$oid;
if (isset($oid_sanitize_cache[$v])) return $oid_sanitize_cache[$v];
813,7 → 813,7
// Clean up
$count = -1;
$asn = preg_replace('@^\\{(.+)\\}$@', '\\1', $asn, -1, $count);
if ($count == 0) return false; // { and } are required. The asn.1 path will NOT be trimmed by this function
if ($count == 0) return false; // { and } are required. The ASN.1 path will NOT be trimmed by this function
 
// If identifier is set, apply it (no check if it overrides a standardized identifier)
$asn = preg_replace('|\s*([a-z][a-zA-Z0-9-]*)\s*\((\d+)\)|', ' \\2', $asn);
/trunk/oidinfo_api.inc.phps
606,7 → 606,7
$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
// Do not allow Numeric-only. It would only be valid in an IRI path, but not in a single identifier
if (!iri_arc_valid($iri, false)) $iri = null;
}
}
988,7 → 988,7
protected $connected = false;
protected $socket = null;
 
const SPP_MAX_CONNECTION_ATTEMPTS = 3; // TODO: Auslagern in OIDInfoAPI Klasse...?
const SPP_MAX_CONNECTION_ATTEMPTS = 3; // TODO: Put into an OIDInfoAPI class...?
 
const DEFAULT_PORT = 49500;
 
1000,7 → 1000,7
$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)
echo "gethostbyname() failed.\n"; // TODO: exceptions? (also all "echos" below)
return false;
}
$this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
/trunk/xml_utils.inc.phps
3,7 → 3,7
/*
* XML Encoding Utilities
* Copyright 2011-2020 Daniel Marschall, ViaThinkSoft
* Version 1.7.1
* Version 1.7.2 (2020-12-06)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
33,8 → 33,8
}
 
// get rid of existing entities else double-escape
// DM 24.08.2016 Auskommentiert wegen oid+ xml export
// $str = html_entity_decode(stripslashes($str),ENT_QUOTES,'UTF-8');
// DM 24.08.2016 Removed because of OIDplus 1.0 XML export
//$str = html_entity_decode(stripslashes($str),ENT_QUOTES,'UTF-8');
 
$ar = preg_split('/(?<!^)(?!$)/u', $str); // return array of every multi-byte character
$str2 = '';
55,7 → 55,7
if ($c == '&#61;') $c = '=';
if ($c == '&#34;') $c = '"';
if ($c == '&#39;') $c = '\'';
if ($c == '&#38;') $c = '&'; // DM 24.08.2016 Re-Aktiviert wegen oid+ xml export
if ($c == '&#38;') $c = '&'; // DM 24.08.2016 Re-added because OIDplus 1.0 XML export
}
 
if (!$encode_linebreaks) {
141,50 → 141,50
}
 
function html_named_to_numeric_entities($str) {
if (!function_exists('decodeNamedEntities')) {
function decodeNamedEntities($string) {
// https://stackoverflow.com/questions/20406599/how-to-encode-for-entity-igrave-not-defined-error-in-xml-feed
static $entities = NULL;
if (NULL === $entities) {
$entities = array_flip(
array_diff(
get_html_translation_table(HTML_ENTITIES, ENT_COMPAT | ENT_HTML401, 'UTF-8'),
get_html_translation_table(HTML_ENTITIES, ENT_COMPAT | ENT_XML1, 'UTF-8')
)
);
}
return str_replace(array_keys($entities), $entities, $string);
if (!mb_detect_encoding($str, 'UTF-8', true)) $str = utf8_encode($str);
return mb_htmlentities(decodeNamedEntities($str));
}
 
if (!function_exists('decodeNamedEntities')) {
function decodeNamedEntities($string) {
// https://stackoverflow.com/questions/20406599/how-to-encode-for-entity-igrave-not-defined-error-in-xml-feed
static $entities = NULL;
if (NULL === $entities) {
$entities = array_flip(
array_diff(
get_html_translation_table(HTML_ENTITIES, ENT_COMPAT | ENT_HTML401, 'UTF-8'),
get_html_translation_table(HTML_ENTITIES, ENT_COMPAT | ENT_XML1, 'UTF-8')
)
);
}
return str_replace(array_keys($entities), $entities, $string);
}
}
 
if (!function_exists('mb_convert_encoding')) {
// https://riptutorial.com/php/example/15633/converting-unicode-characters-to-their-numeric-value-and-or-html-entities-using-php
function mb_convert_encoding($str, $to_encoding, $from_encoding = NULL) {
return iconv(($from_encoding === NULL) ? mb_internal_encoding() : $from_encoding, $to_encoding, $str);
}
if (!function_exists('mb_convert_encoding')) {
// https://riptutorial.com/php/example/15633/converting-unicode-characters-to-their-numeric-value-and-or-html-entities-using-php
function mb_convert_encoding($str, $to_encoding, $from_encoding = NULL) {
return iconv(($from_encoding === NULL) ? mb_internal_encoding() : $from_encoding, $to_encoding, $str);
}
}
 
if (!function_exists('mb_ord')) {
// https://riptutorial.com/php/example/15633/converting-unicode-characters-to-their-numeric-value-and-or-html-entities-using-php
function mb_ord($char, $encoding = 'UTF-8') {
if ($encoding === 'UCS-4BE') {
list(, $ord) = (strlen($char) === 4) ? @unpack('N', $char) : @unpack('n', $char);
return $ord;
} else {
return mb_ord(mb_convert_encoding($char, 'UCS-4BE', $encoding), 'UCS-4BE');
}
if (!function_exists('mb_ord')) {
// https://riptutorial.com/php/example/15633/converting-unicode-characters-to-their-numeric-value-and-or-html-entities-using-php
function mb_ord($char, $encoding = 'UTF-8') {
if ($encoding === 'UCS-4BE') {
list(, $ord) = (strlen($char) === 4) ? @unpack('N', $char) : @unpack('n', $char);
return $ord;
} else {
return mb_ord(mb_convert_encoding($char, 'UCS-4BE', $encoding), 'UCS-4BE');
}
}
}
 
if (!function_exists('mb_htmlentities')) {
// https://riptutorial.com/php/example/15633/converting-unicode-characters-to-their-numeric-value-and-or-html-entities-using-php
function mb_htmlentities($string, $hex = true, $encoding = 'UTF-8') {
return preg_replace_callback('/[\x{80}-\x{10FFFF}]/u', function ($match) use ($hex) {
return sprintf($hex ? '&#x%X;' : '&#%d;', mb_ord($match[0]));
}, $string);
}
if (!function_exists('mb_htmlentities')) {
// https://riptutorial.com/php/example/15633/converting-unicode-characters-to-their-numeric-value-and-or-html-entities-using-php
function mb_htmlentities($string, $hex = true, $encoding = 'UTF-8') {
return preg_replace_callback('/[\x{80}-\x{10FFFF}]/u', function ($match) use ($hex) {
return sprintf($hex ? '&#x%X;' : '&#%d;', mb_ord($match[0]));
}, $string);
}
 
if (!mb_detect_encoding($str, 'UTF-8', true)) $str = utf8_encode($str);
return mb_htmlentities(decodeNamedEntities($str));
}