Rev 963 | Rev 991 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 963 | Rev 977 | ||
---|---|---|---|
Line 63... | Line 63... | ||
63 | $zip = new ZipArchive(); |
63 | $zip = new ZipArchive(); |
64 | if ($zip->open($tmp_file, ZipArchive::CREATE)!== true) { |
64 | if ($zip->open($tmp_file, ZipArchive::CREATE)!== true) { |
65 | throw new OIDplusException("cannot open <$tmp_file>"); |
65 | throw new OIDplusException("cannot open <$tmp_file>"); |
66 | } |
66 | } |
67 | 67 | ||
- | 68 | function make_line($command, $data) { |
|
- | 69 | return $command.$data."\r\n"; |
|
- | 70 | } |
|
- | 71 | ||
- | 72 | // https://github.com/danielmarschall/oidplus_dos/blob/master/OIDFILE.PAS |
|
- | 73 | define('CMD_VERSION', 'VERS'); |
|
- | 74 | define('CMD_OWN_ID', 'SELF'); |
|
- | 75 | define('CMD_PARENT', 'SUPR'); |
|
- | 76 | define('CMD_CHILD', 'CHLD'); |
|
- | 77 | define('CMD_ASN1_IDENTIFIER', 'ASN1'); |
|
- | 78 | define('CMD_UNICODE_LABEL', 'UNIL'); |
|
- | 79 | define('CMD_DESCRIPTION', 'DESC'); |
|
- | 80 | ||
68 | foreach ($dos_ids as $oid => $dos_id) { |
81 | foreach ($dos_ids as $oid => $dos_id) { |
69 | $cont = ''; |
82 | $cont = ''; |
70 | 83 | ||
71 | $cont .= "VERS2022\r\n"; |
84 | $cont .= make_line(CMD_VERSION, 2022); |
72 | 85 | ||
73 | $cont .= "SELF$dos_id$oid\r\n"; |
86 | $cont .= make_line(CMD_OWN_ID, $dos_id.$oid); |
74 | 87 | ||
75 | $parent_oid = $parent_oids[$oid]; |
88 | $parent_oid = $parent_oids[$oid]; |
76 | $parent_id = $dos_ids[$parent_oid]; |
89 | $parent_id = $dos_ids[$parent_oid]; |
77 | $cont .= "SUPR$parent_id$parent_oid\r\n"; |
90 | $cont .= make_line(CMD_PARENT, $parent_id.$parent_oid); |
78 | 91 | ||
79 | foreach ($parent_oids as $child_oid => $parent_oid) { |
92 | foreach ($parent_oids as $child_oid => $parent_oid) { |
80 | if ($child_oid == '') continue; |
93 | if ($child_oid == '') continue; |
81 | if ($parent_oid == $oid) { |
94 | if ($parent_oid == $oid) { |
82 | $child_id = $dos_ids[$child_oid]; |
95 | $child_id = $dos_ids[$child_oid]; |
83 | $cont .= "CHLD$child_id$child_oid\r\n"; |
96 | $cont .= make_line(CMD_CHILD, $child_id.$child_oid); |
84 | } |
97 | } |
85 | } |
98 | } |
86 | 99 | ||
87 | $res = OIDplus::db()->query("select * from ###asn1id where oid = 'oid:$oid'"); |
100 | $res = OIDplus::db()->query("select * from ###asn1id where oid = 'oid:$oid'"); |
88 | while ($row = $res->fetch_object()) { |
101 | while ($row = $res->fetch_object()) { |
89 | $asn1 = $row->name; |
102 | $asn1 = $row->name; |
90 | $cont .= "ASN1$asn1\r\n"; |
103 | $cont .= make_line(CMD_ASN1_IDENTIFIER, $asn1); |
91 | } |
104 | } |
92 | 105 | ||
93 | $res = OIDplus::db()->query("select * from ###iri where oid = 'oid:$oid'"); |
106 | $res = OIDplus::db()->query("select * from ###iri where oid = 'oid:$oid'"); |
94 | while ($row = $res->fetch_object()) { |
107 | while ($row = $res->fetch_object()) { |
95 | $iri = $row->name; |
108 | $iri = $row->name; |
96 | $cont .= "UNIL$iri\r\n"; |
109 | $cont .= make_line(CMD_UNICODE_LABEL, $iri); |
97 | } |
110 | } |
98 | 111 | ||
99 | if ($oid == '') { |
112 | if ($oid == '') { |
100 | // TODO: Split our OIDplus root OIDs into the real OID tree (1, 1.3, 1.3.6, ...) |
113 | // TODO: Split our OIDplus root OIDs into the real OID tree (1, 1.3, 1.3.6, ...) |
101 | $cont .= "DESCHere, you can find the root OIDs.\r\n"; |
114 | $cont .= make_line(CMD_DESCRIPTION, 'Here, you can find the root OIDs'); |
102 | } else { |
115 | } else { |
103 | $res = OIDplus::db()->query("select * from ###objects where id = 'oid:$oid';"); |
116 | $res = OIDplus::db()->query("select * from ###objects where id = 'oid:$oid';"); |
104 | $row = $res->fetch_object(); |
117 | $row = $res->fetch_object(); |
105 | $desc = trim(trim(strip_tags($row->description))); |
118 | $desc = trim(trim(strip_tags($row->description))); |
106 | $desc = str_replace("\r", "", $desc); |
119 | $desc = str_replace("\r", "", $desc); |
Line 110... | Line 123... | ||
110 | if (implode('',$desc_ary1) == '') $desc_ary1 = array(); |
123 | if (implode('',$desc_ary1) == '') $desc_ary1 = array(); |
111 | if (implode('',$desc_ary2) == '') $desc_ary2 = array(); |
124 | if (implode('',$desc_ary2) == '') $desc_ary2 = array(); |
112 | $desc_ary = array_merge($desc_ary1, $desc_ary2); |
125 | $desc_ary = array_merge($desc_ary1, $desc_ary2); |
113 | foreach ($desc_ary as $line_idx => $line) { |
126 | foreach ($desc_ary as $line_idx => $line) { |
114 | if ($line_idx >= 10/*DESCEDIT_LINES*/) break; |
127 | if ($line_idx >= 10/*DESCEDIT_LINES*/) break; |
115 | $cont .= "DESC$line\r\n"; |
128 | $cont .= make_line(CMD_DESCRIPTION, $line); |
116 | } |
129 | } |
117 | } |
130 | } |
118 | 131 | ||
119 | //echo "****$dos_id.OID\r\n"; |
132 | //echo "****$dos_id.OID\r\n"; |
120 | //echo "$cont\r\n"; |
133 | //echo "$cont\r\n"; |