Rev 237 | Rev 511 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 237 | Rev 261 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | <?php |
2 | <?php |
3 | 3 | ||
4 | require_once __DIR__ . '/../includes/oidplus.inc.php'; |
4 | require_once __DIR__ . '/../includes/oidplus.inc.php'; |
5 | 5 | ||
6 | OIDplus::init(false); |
6 | OIDplus::init(false); |
7 | if (!defined('OIDINFO_API_URL')) { |
7 | if (!OIDplus::baseConfig()->exists('OIDINFO_API_URL')) { |
8 | die("OIDINFO_API_URL not available (API is currently not public)\n"); |
8 | die("OIDINFO_API_URL not available (API is currently not public)\n"); |
9 | } |
9 | } |
10 | 10 | ||
11 | define('VERBOSE', false); |
11 | define('VERBOSE', false); |
12 | define('DEFAULT_EMAIL', 'oidra@viathinksoft.de'); |
12 | define('DEFAULT_EMAIL', 'oidra@viathinksoft.de'); |
Line 24... | Line 24... | ||
24 | check_oid($oid); |
24 | check_oid($oid); |
25 | } |
25 | } |
26 | 26 | ||
27 | function check_oid($oid) { |
27 | function check_oid($oid) { |
28 | 28 | ||
29 | $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where id = ?", array("oid:$oid")); |
29 | $res = OIDplus::db()->query("select * from ###objects where id = ?", array("oid:$oid")); |
30 | $ok = $res->num_rows() > 0; |
30 | $ok = $res->num_rows() > 0; |
31 | 31 | ||
32 | if (!$ok) { |
32 | if (!$ok) { |
33 | echo "Not existing: $oid : Adding!\n"; |
33 | echo "Not existing: $oid : Adding!\n"; |
34 | add_oid($oid); |
34 | add_oid($oid); |
Line 50... | Line 50... | ||
50 | $title = '(tbd)'; |
50 | $title = '(tbd)'; |
51 | $description = '(tbd)'; |
51 | $description = '(tbd)'; |
52 | $ra_email = ''; |
52 | $ra_email = ''; |
53 | if ((DEFAULT_EMAIL != '') && ($ra_email == '')) $ra_email = DEFAULT_EMAIL; |
53 | if ((DEFAULT_EMAIL != '') && ($ra_email == '')) $ra_email = DEFAULT_EMAIL; |
54 | 54 | ||
55 | sql_execute("insert into ".OIDPLUS_TABLENAME_PREFIX."objects (id, parent, title, description, ra_email) values (?, ?, ?, ?, ?)", array("oid:$oid", "oid:$parent", $title, $description, $ra_email)); |
55 | sql_execute("insert into ###objects (id, parent, title, description, ra_email) values (?, ?, ?, ?, ?)", array("oid:$oid", "oid:$parent", $title, $description, $ra_email)); |
56 | 56 | ||
57 | return; |
57 | return; |
58 | } |
58 | } |
59 | 59 | ||
60 | if (!isset($data['oid']['identifier'])) $data['oid']['identifier'] = array(); |
60 | if (!isset($data['oid']['identifier'])) $data['oid']['identifier'] = array(); |
61 | foreach ($data['oid']['identifier'] as $identifier) { |
61 | foreach ($data['oid']['identifier'] as $identifier) { |
62 | sql_execute("insert into ".OIDPLUS_TABLENAME_PREFIX."asn1id (oid, name) values (?, ?)", array("oid:$oid", $identifier)); |
62 | sql_execute("insert into ###asn1id (oid, name) values (?, ?)", array("oid:$oid", $identifier)); |
63 | } |
63 | } |
64 | 64 | ||
65 | if (!isset($data['oid']['unicode-label'])) $data['oid']['unicode-label'] = array(); |
65 | if (!isset($data['oid']['unicode-label'])) $data['oid']['unicode-label'] = array(); |
66 | foreach ($data['oid']['unicode-label'] as $identifier) { |
66 | foreach ($data['oid']['unicode-label'] as $identifier) { |
67 | sql_execute("insert into ".OIDPLUS_TABLENAME_PREFIX."iri (oid, name) values (?, ?)", array("oid:$oid", $identifier)); |
67 | sql_execute("insert into ###iri (oid, name) values (?, ?)", array("oid:$oid", $identifier)); |
68 | } |
68 | } |
69 | 69 | ||
70 | $parent = ($oid == $root) ? '' : oid_up($oid); |
70 | $parent = ($oid == $root) ? '' : oid_up($oid); |
71 | 71 | ||
72 | $title = strip_tags(@$data['oid']['description']); |
72 | $title = strip_tags(@$data['oid']['description']); |
Line 79... | Line 79... | ||
79 | $description = '<p>' . str_ireplace('<br><br>', '</p><p>', $description) . '</p>'; |
79 | $description = '<p>' . str_ireplace('<br><br>', '</p><p>', $description) . '</p>'; |
80 | 80 | ||
81 | $ra_email = @$data['oid']['current_registrant']['email']; |
81 | $ra_email = @$data['oid']['current_registrant']['email']; |
82 | if ($ra_email == '') $ra_email = @$data['oid']['first_registrant']['email']; |
82 | if ($ra_email == '') $ra_email = @$data['oid']['first_registrant']['email']; |
83 | 83 | ||
84 | $resx = OIDplus::db()->query("select ra_email from ".OIDPLUS_TABLENAME_PREFIX."objects where id = ?", array("oid:$parent")); |
84 | $resx = OIDplus::db()->query("select ra_email from ###objects where id = ?", array("oid:$parent")); |
85 | if ($rowx = $resx->fetch_array()) $ra_email = $rowx['ra_email']; |
85 | if ($rowx = $resx->fetch_array()) $ra_email = $rowx['ra_email']; |
86 | 86 | ||
87 | $created = @$data['oid']['first_registrant']['creation-date']; |
87 | $created = @$data['oid']['first_registrant']['creation-date']; |
88 | $updated = @$data['oid']['last-modification']; |
88 | $updated = @$data['oid']['last-modification']; |
89 | 89 | ||
90 | sql_execute("insert into ".OIDPLUS_TABLENAME_PREFIX."objects (id, parent, title, description, ra_email, created, updated) values (?, ?, ?, ?, ?, ?, ?)", |
90 | sql_execute("insert into ###objects (id, parent, title, description, ra_email, created, updated) values (?, ?, ?, ?, ?, ?, ?)", |
91 | array("oid:$oid", "oid:$parent", $title, $description, $ra_email, $created, $updated)); |
91 | array("oid:$oid", "oid:$parent", $title, $description, $ra_email, $created, $updated)); |
92 | } |
92 | } |
93 | 93 | ||
94 | function ft_get_oid_data($oid) { |
94 | function ft_get_oid_data($oid) { |
95 | $url = OIDINFO_API_URL . '&oid='.urlencode($oid); |
95 | $url = OIDplus::baseConfig()->getValue('OIDINFO_API_URL') . '&oid='.urlencode($oid); |
96 | $cont_json = @file_get_contents($url); |
96 | $cont_json = @file_get_contents($url); |
97 | if (!$cont_json) { |
97 | if (!$cont_json) { |
98 | sleep(5); |
98 | sleep(5); |
99 | $cont_json = @file_get_contents($url); |
99 | $cont_json = @file_get_contents($url); |
100 | if (!$cont_json) return false; |
100 | if (!$cont_json) return false; |