Subversion Repositories oidplus

Rev

Rev 251 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 251 Rev 261
Line 15... Line 15...
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
17
 * limitations under the License.
18
 */
18
 */
19
 
19
 
20
define('OUTPUT_FORMAT_SPACER', 2);
-
 
21
define('OUTPUT_FORMAT_MAX_LINE_LENGTH', 80);
-
 
22
 
-
 
23
# ---
-
 
24
 
-
 
25
require_once __DIR__ . '/../../../../includes/oidplus.inc.php';
20
require_once __DIR__ . '/../../../../includes/oidplus.inc.php';
26
 
21
 
27
OIDplus::init(true);
22
OIDplus::init(true);
28
 
23
 
29
originHeaders();
24
originHeaders();
Line 72... Line 67...
72
 
67
 
73
if (!$obj) {
68
if (!$obj) {
74
        $found = false;
69
        $found = false;
75
} else {
70
} else {
76
        $query = $obj->nodeId(); // this may sanitize/canonize identifiers
71
        $query = $obj->nodeId(); // this may sanitize/canonize identifiers
77
        $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where id = ?", array($obj->nodeId()));
72
        $res = OIDplus::db()->query("select * from ###objects where id = ?", array($obj->nodeId()));
78
        if ($res->num_rows() > 0) {
73
        if ($res->num_rows() > 0) {
79
                $found = true;
74
                $found = true;
80
                $distance = 0;
75
                $distance = 0;
81
        } else {
76
        } else {
82
                $found = false;
77
                $found = false;
83
                $objParent = OIDplusObject::parse($query)->getParent();
78
                $objParent = OIDplusObject::parse($query)->getParent();
84
                if ($objParent) {
79
                if ($objParent) {
85
                        $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where id = ?", array($objParent->nodeId()));
80
                        $res = OIDplus::db()->query("select * from ###objects where id = ?", array($objParent->nodeId()));
86
                        $distance = $objParent->distance($query);
81
                        $distance = $objParent->distance($query);
87
                        assert($res->num_rows() > 0);
82
                        assert($res->num_rows() > 0);
88
 
83
 
89
                        $query = $objParent->nodeId();
84
                        $query = $objParent->nodeId();
90
                        $obj = $objParent;
85
                        $obj = $objParent;
Line 126... Line 121...
126
                $cont = $row->description;
121
                $cont = $row->description;
127
                $cont = preg_replace('@<a[^>]+href\s*=\s*["\']([^\'"]+)["\'][^>]*>(.+)<\s*/\s*a\s*>@ismU', '\2 (\1)', $cont);
122
                $cont = preg_replace('@<a[^>]+href\s*=\s*["\']([^\'"]+)["\'][^>]*>(.+)<\s*/\s*a\s*>@ismU', '\2 (\1)', $cont);
128
                $out[] = 'description: ' . trim(html_entity_decode(strip_tags($cont)));
123
                $out[] = 'description: ' . trim(html_entity_decode(strip_tags($cont)));
129
 
124
 
130
                if (substr($query,0,4) === 'oid:') {
125
                if (substr($query,0,4) === 'oid:') {
131
                        $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."asn1id where oid = ?", array($row->id));
126
                        $res2 = OIDplus::db()->query("select * from ###asn1id where oid = ?", array($row->id));
132
                        while ($row2 = $res2->fetch_object()) {
127
                        while ($row2 = $res2->fetch_object()) {
133
                                $out[] = 'identifier: ' . $row2->name;
128
                                $out[] = 'identifier: ' . $row2->name;
134
                        }
129
                        }
135
 
130
 
136
                        $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."asn1id where standardized = ? and oid = ?", array(true, $row->id));
131
                        $res2 = OIDplus::db()->query("select * from ###asn1id where standardized = ? and oid = ?", array(true, $row->id));
137
                        while ($row2 = $res2->fetch_object()) {
132
                        while ($row2 = $res2->fetch_object()) {
138
                                $out[] = 'standardized-id: ' . $row2->name;
133
                                $out[] = 'standardized-id: ' . $row2->name;
139
                        }
134
                        }
140
 
135
 
141
                        $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."iri where oid = ?", array($row->id));
136
                        $res2 = OIDplus::db()->query("select * from ###iri where oid = ?", array($row->id));
142
                        while ($row2 = $res2->fetch_object()) {
137
                        while ($row2 = $res2->fetch_object()) {
143
                                $out[] = 'unicode-label: ' . $row2->name;
138
                                $out[] = 'unicode-label: ' . $row2->name;
144
                        }
139
                        }
145
 
140
 
146
                        $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."iri where longarc = ? and oid = ?", array(true, $row->id));
141
                        $res2 = OIDplus::db()->query("select * from ###iri where longarc = ? and oid = ?", array(true, $row->id));
147
                        while ($row2 = $res2->fetch_object()) {
142
                        while ($row2 = $res2->fetch_object()) {
148
                                $out[] = 'long-arc: ' . $row2->name;
143
                                $out[] = 'long-arc: ' . $row2->name;
149
                        }
144
                        }
150
                }
145
                }
151
 
146
 
152
                $out[] = 'created: ' . $row->created;
147
                $out[] = 'created: ' . $row->created;
153
                $out[] = 'updated: ' . $row->updated;
148
                $out[] = 'updated: ' . $row->updated;
154
 
149
 
155
                $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where parent = ? order by ".OIDplus::db()->natOrder('id'), array($row->id));
150
                $res2 = OIDplus::db()->query("select * from ###objects where parent = ? order by ".OIDplus::db()->natOrder('id'), array($row->id));
156
                if ($res2->num_rows() == 0) {
151
                if ($res2->num_rows() == 0) {
157
                        // $out[] = 'subordinate: (none)';
152
                        // $out[] = 'subordinate: (none)';
158
                }
153
                }
159
                while ($row2 = $res2->fetch_object()) {
154
                while ($row2 = $res2->fetch_object()) {
160
                        $out[] = 'subordinate: ' . $row2->id . show_asn1_appendix($row2->id);
155
                        $out[] = 'subordinate: ' . $row2->id . show_asn1_appendix($row2->id);
161
                }
156
                }
162
 
157
 
163
                $out[] = '';
158
                $out[] = '';
164
 
159
 
165
                $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."ra where email = ?", array($row->ra_email));
160
                $res2 = OIDplus::db()->query("select * from ###ra where email = ?", array($row->ra_email));
166
                if ($row2 = $res2->fetch_object()) {
161
                if ($row2 = $res2->fetch_object()) {
167
                        $out[] = 'ra: '.(!empty($row2->ra_name) ? $row2->ra_name : $row2->email);
162
                        $out[] = 'ra: '.(!empty($row2->ra_name) ? $row2->ra_name : $row2->email);
168
                        $out[] = 'ra-status: Information available';
163
                        $out[] = 'ra-status: Information available';
169
                        $out[] = 'ra-name: ' . $row2->ra_name;
164
                        $out[] = 'ra-name: ' . $row2->ra_name;
170
                        $out[] = 'ra-email: ' . $row->ra_email;
165
                        $out[] = 'ra-email: ' . $row->ra_email;
Line 207... Line 202...
207
        $longest_key = 0;
202
        $longest_key = 0;
208
        foreach ($out as $line) {
203
        foreach ($out as $line) {
209
                $longest_key = max($longest_key, strlen(trim(explode(':',$line,2)[0])));
204
                $longest_key = max($longest_key, strlen(trim(explode(':',$line,2)[0])));
210
        }
205
        }
211
 
206
 
212
        echo '% ' . str_repeat('*', OUTPUT_FORMAT_MAX_LINE_LENGTH-2)."\n";
207
        echo '% ' . str_repeat('*', OIDplus::config()->getValue('webwhois_output_format_max_line_length', 80)-2)."\n";
213
 
208
 
214
        foreach ($out as $line) {
209
        foreach ($out as $line) {
215
                if (trim($line) == '') {
210
                if (trim($line) == '') {
216
                        echo "\n";
211
                        echo "\n";
217
                        continue;
212
                        continue;
Line 220... Line 215...
220
                $ary = explode(':', $line, 2);
215
                $ary = explode(':', $line, 2);
221
 
216
 
222
                $key = trim($ary[0]);
217
                $key = trim($ary[0]);
223
 
218
 
224
                $value = trim($ary[1]);
219
                $value = trim($ary[1]);
225
                $value = wordwrap($value, OUTPUT_FORMAT_MAX_LINE_LENGTH - $longest_key - strlen(':') - OUTPUT_FORMAT_SPACER);
220
                $value = wordwrap($value, OIDplus::config()->getValue('webwhois_output_format_max_line_length', 80) - $longest_key - strlen(':') - OIDplus::config()->getValue('webwhois_output_format_spacer', 2));
226
                $value = str_replace("\n", "\n$key:".str_repeat(' ', $longest_key-strlen($key)) . str_repeat(' ', OUTPUT_FORMAT_SPACER), $value);
221
                $value = str_replace("\n", "\n$key:".str_repeat(' ', $longest_key-strlen($key)) . str_repeat(' ', OIDplus::config()->getValue('webwhois_output_format_spacer', 2)), $value);
227
 
222
 
228
                echo $key.':' . str_repeat(' ', $longest_key-strlen($key)) . str_repeat(' ', OUTPUT_FORMAT_SPACER) . (!empty($value) ? $value : '.') . "\n";
223
                echo $key.':' . str_repeat(' ', $longest_key-strlen($key)) . str_repeat(' ', OIDplus::config()->getValue('webwhois_output_format_spacer', 2)) . (!empty($value) ? $value : '.') . "\n";
229
        }
224
        }
230
 
225
 
231
        echo '% ' . str_repeat('*', OUTPUT_FORMAT_MAX_LINE_LENGTH-2)."\n";
226
        echo '% ' . str_repeat('*', OIDplus::config()->getValue('webwhois_output_format_max_line_length', 80)-2)."\n";
232
 
227
 
233
        $cont = ob_get_contents();
228
        $cont = ob_get_contents();
234
        ob_end_clean();
229
        ob_end_clean();
235
 
230
 
236
        echo $cont;
231
        echo $cont;
Line 316... Line 311...
316
# ---
311
# ---
317
 
312
 
318
function show_asn1_appendix($id) {
313
function show_asn1_appendix($id) {
319
        if (substr($id,0,4) === 'oid:') {
314
        if (substr($id,0,4) === 'oid:') {
320
                $appendix_asn1ids = array();
315
                $appendix_asn1ids = array();
321
                $res3 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."asn1id where oid = ?", array($id));
316
                $res3 = OIDplus::db()->query("select * from ###asn1id where oid = ?", array($id));
322
                while ($row3 = $res3->fetch_object()) {
317
                while ($row3 = $res3->fetch_object()) {
323
                        $appendix_asn1ids[] = $row3->name;
318
                        $appendix_asn1ids[] = $row3->name;
324
                }
319
                }
325
 
320
 
326
                $appendix = implode(', ', $appendix_asn1ids);
321
                $appendix = implode(', ', $appendix_asn1ids);