Subversion Repositories oidplus

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. require_once __DIR__ . '/../../../includes/oidplus.inc.php';
  21. require_once __DIR__ . '/../../../includes/oidinfo_api.inc.php';
  22.  
  23. header('Content-Type:text/html; charset=UTF-8');
  24.  
  25. OIDplus::init(true);
  26.  
  27. OIDplus::db()->set_charset("UTF8");
  28. OIDplus::db()->query("SET NAMES 'utf8'");
  29.  
  30. # ---
  31.  
  32. if (OIDplus::config()->oidinfoExportProtected() && !OIDplus::authUtils()::isAdminLoggedIn()) {
  33.         echo '<p>You need to <a href="./?goto=oidplus:login">log in</a> as administrator.</p>';
  34.         die();
  35. }
  36.  
  37. header('Content-Type:text/xml');
  38.  
  39. $oa = new OIDInfoAPI();
  40. $oa->addSimplePingProvider('viathinksoft.de:49500');
  41.  
  42. echo $oa->xmlAddHeader(OIDplus::config()->systemTitle(), isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'Export interface', OIDPLUS_ADMIN_EMAIL);
  43.  
  44. $params['allow_html'] = true;
  45. $params['allow_illegal_email'] = true; // It should be enabled, because the creator could have used some kind of human-readable anti-spam technique
  46. $params['soft_correct_behavior'] = OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE;
  47. $params['do_online_check'] = false; // Flag to disable this online check, because it generates a lot of traffic and runtime.
  48. $params['do_illegality_check'] = true;
  49. $params['do_simpleping_check'] = true;
  50. $params['auto_extract_name'] = '';
  51. $params['auto_extract_url'] = '';
  52. $params['always_output_comment'] = false;
  53. $params['creation_allowed_check'] = isset($_GET['online']) && $_GET['online'];
  54. $params['tolerant_htmlentities'] = true;
  55. $params['ignore_xhtml_light'] = false;
  56.  
  57. $nonConfidential = OIDplusObject::getAllNonConfidential();
  58.  
  59. foreach ($nonConfidential as $id) {
  60.  
  61.         if (substr($id,0,4) != 'oid:') continue;
  62.  
  63.         $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where id = '".OIDplus::db()->real_escape_string($id)."'");
  64.         if ($row = OIDplus::db()->fetch_object($res)) {
  65.                 $elements['identifier'] = array();
  66.                 $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."asn1id where oid = '".OIDplus::db()->real_escape_string($row->id)."'");
  67.                 while ($row2 = OIDplus::db()->fetch_object($res2)) {
  68.                         $elements['identifier'][] = $row2->name; // 'unicode-label' is currently not in the standard format (oid.xsd)
  69.                 }
  70.  
  71.                 $elements['unicode-label'] = array();
  72.                 $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."iri where oid = '".OIDplus::db()->real_escape_string($row->id)."'");
  73.                 while ($row2 = OIDplus::db()->fetch_object($res2)) {
  74.                         $elements['unicode-label'][] = $row2->name;
  75.                 }
  76.  
  77.                 $res2 = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."ra where email = '".OIDplus::db()->real_escape_string($row->ra_email)."'");
  78.                 $row2 = OIDplus::db()->fetch_object($res2);
  79.  
  80.                 $elements['description'] = $row->title;
  81.                 $elements['information'] = $row->description;
  82.  
  83.                 $elements['first-registrant']['first-name'] = '';
  84.                 $elements['first-registrant']['last-name'] = '';
  85.                 $elements['first-registrant']['address'] = '';
  86.                 $elements['first-registrant']['email'] = '';
  87.                 $elements['first-registrant']['phone'] = '';
  88.                 $elements['first-registrant']['fax'] = '';
  89.                 $elements['first-registrant']['creation-date'] = _formatdate($row->created);
  90.  
  91.                 $elements['current-registrant']['first-name'] = $row2 ? $row2->ra_name : '';
  92.                 $elements['current-registrant']['last-name'] = '';
  93.                 $elements['current-registrant']['email'] = $row->ra_email;
  94.  
  95.                 $elements['current-registrant']['phone'] = '';
  96.                 $elements['current-registrant']['fax'] = '';
  97.                 $elements['current-registrant']['address'] = '';
  98.                 if ($row2) {
  99.                         $tmp = array();
  100.                         if (!empty($row2->organization))  $tmp[] = $row2->organization;
  101.                         if (!empty($row2->office))        $tmp[] = $row2->office;
  102.                         if (!empty($row2->personal_name)) $tmp[] = $row2->personal_name;
  103.                         if (!$row2->privacy) {
  104.                                 if (!empty($row2->street))   $tmp[] = $row2->street;
  105.                                 if (!empty($row2->zip_town)) $tmp[] = $row2->zip_town;
  106.                                 if (!empty($row2->country))  $tmp[] = $row2->country;
  107.                                 $elements['current-registrant']['phone'] = !empty($row2->phone) ? $row2->phone : $row2->mobile;
  108.                                 $elements['current-registrant']['fax'] = $row2->fax;
  109.                         }
  110.                         $elements['current-registrant']['address'] = implode("<br/>\n", $tmp);
  111.                 }
  112.                 $elements['current-registrant']['modification-date'] = _formatdate($row->updated);
  113.  
  114.                 $oid = OIDplusObject::parse($row->id)->getDotNotation();
  115.                 echo $oa->createXMLEntry($oid, $elements, $params, $comment='');
  116.         }
  117.  
  118.         flush();
  119. }
  120.  
  121. echo $oa->xmlAddFooter();
  122.  
  123. # ---
  124.  
  125. function _formatdate($str) {
  126.         $str = explode(' ',$str)[0];
  127.         if ($str == '0000-00-00') $str = '';
  128.         return $str;
  129. }
  130.