Source for file verify.php

Documentation is available at verify.php

  1. <?php
  2. /**
  3. * Getting data from original specimen data provider
  4. * <br/><br/>
  5. * @author Gabriele Droege, DNA Bank Network <contact@dnabank-network.org>
  6. * @version 2.0
  7. * @package Input
  8. * @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org<br>The contents of this file are subject to the Mozilla Public License Version 1.1
  9. * @filesource
  10. * @license http://www.mozilla.org/MPL/ MPL
  11. */
  12.  
  13.     /********************************************************************************************
  14.     * increasing time for trying to connect to provider                                         *
  15.     *********************************************************************************************/
  16.     set_time_limit(1000);
  17.  
  18.  
  19.     $processor = new XSLTProcessor; 
  20.     $xsl = new DOMDocument;
  21.  
  22.     /********************************************************************************************
  23.     * loading xstl stylesheet, depending on required schema                                     *
  24.     *********************************************************************************************/
  25. if($ID_Schema == 1) {
  26.  $xsl->load('../input/XSLT/en_ABCD1.2_Summary.xslt');
  27.  }
  28. if($ID_Schema == 2) {
  29.  $xsl->load('../input/XSLT/en_ABCD2.0_Summary.xslt');
  30. }
  31. if($ID_Schema == 3 OR $ID_Schema == 6) {
  32.  $xsl->load('../input/XSLT/en_DarwinCore_UnitDetail.xslt');
  33. }
  34. if($ID_Schema == 4) {
  35.  $xsl->load('../input/XSLT/en_ABCD2.05_Summary.xslt');
  36. }
  37.  
  38.  
  39.     /********************************************************************************************
  40.     * parsing the provider url and checking availability                                        *
  41.     *********************************************************************************************/
  42. $inf = parse_url($Provider);
  43.  
  44.  $host = $inf['host'];
  45.  
  46.  
  47.  $path = $inf['path'];
  48.  if (isset($inf['query'])) $path .= '?'.$inf['query'];
  49.  
  50.  if (isset($inf['port'])) $port = $inf['port'];
  51.  else $port = 80;
  52. if($Provider)
  53. {
  54. error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
  55. $fp = @fsockopen($host, $port, $errno, $error, 5);
  56. if(!$fp or !$host) { echo "<span class='error'>Connection to provider failed! ";
  57. if($_GET['ID_DNA'] != "") { $ProviderCheck = true; echo "Show data from cache.</span>"; }
  58. else { echo "Please contact your administrator.</span>";  } }
  59. if($fp and $host) {
  60.  
  61. if(!fopen($Provider,"r")) { echo "<span class='error'>Provider url incorrect! ";
  62. if($_GET['ID_DNA'] != "") { $ProviderCheck = true; echo "Show data from cache.</span>"; }
  63. else { echo "Please contact your administrator.</span>";  } }
  64. if(fopen($Provider,"r")) {
  65.  
  66.     /********************************************************************************************
  67.     * $searchform != "true" means system currently uses the input form and not the edit form    *
  68.     * $variable5 see line 145                                                                   *
  69.     *********************************************************************************************/
  70.  
  71. if($searchform != "true" and $variable5 == "") {
  72.  
  73. if($ID_Schema == 3) 
  74. { 
  75.     /************************************************************************************************
  76.     * $ID_Schema == 3 means source is a DiGIR provider (see also tableschema                        *
  77.     * DiGIR makes use of DarwinCore data schema which has two elements for a UnitID/CatalogueNumber *
  78.     * CatalogueNumber and CatalogueNumberText, both or only one of them can be filled with content  *
  79.     * if CatalogueNumberText != '' -> use this one; if not use the other                            *
  80.     *************************************************************************************************/
  81.  
  82. $file1 = $Provider.$QueryPart1.$Digir_Resource1.$QueryPart1_1.$Digir_Source1."%3C%2Fdestination%3E%0A%09%09%3Ctype%3Esearch%3C%2Ftype%3E%0A%09%09%3C%2Fheader%3E%0A%09%09%3Csearch%3E%0A%09%09%3Cfilter%3E+%3Cequals%3E+%3Cdarwin%3ACatalogNumberText%3E".$SpecimenNumber."%3C%2Fdarwin%3ACatalogNumberText%3E+%3C%2Fequals%3E+%3C%2Ffilter%3E%0A%09%09%3Crecords++start%3D%220%22+limit%3D%2210%22%3E%0A%09%09%3Cstructure+schemaLocation%3D%22http%3A%2F%2Fsearch.biocase.org%2Feurope%2Fstatic%2FdarwinObis.xsd%22%2F%3E%0A%09%09%3C%2Frecords%3E%0A%09%09%3Ccount%3Efalse%3C%2Fcount%3E%0A%09%09%3C%2Fsearch%3E%0A%09%09%3C%2Frequest%3E"; 
  83.  
  84.   $file2 = $Provider.$QueryPart1.$Digir_Resource1.$QueryPart1_1.$Digir_Source1."%3C%2Fdestination%3E%0A%09%09%3Ctype%3Esearch%3C%2Ftype%3E%0A%09%09%3C%2Fheader%3E%0A%09%09%3Csearch%3E%0A%09%09%3Cfilter%3E+%3Cequals%3E+%3Cdarwin%3ACatalogNumber%3E".$SpecimenNumber."%3C%2Fdarwin%3ACatalogNumber%3E+%3C%2Fequals%3E+%3C%2Ffilter%3E%0A%09%09%3Crecords++start%3D%220%22+limit%3D%2210%22%3E%0A%09%09%3Cstructure+schemaLocation%3D%22http%3A%2F%2Fsearch.biocase.org%2Feurope%2Fstatic%2FdarwinObis.xsd%22%2F%3E%0A%09%09%3C%2Frecords%3E%0A%09%09%3Ccount%3Efalse%3C%2Fcount%3E%0A%09%09%3C%2Fsearch%3E%0A%09%09%3C%2Frequest%3E";
  85.  
  86.      
  87.      $xml = new DOMDocument;
  88.      $xml->load($file1);
  89.      $CatNoText = $xml->getElementsByTagName('CatalogNumberText');
  90.  
  91.      if($CatNoText->item(0)->nodeValue == $SpecimenNumber) {  
  92.       $processor->setParameter('', 'formSpecimenNumber', $formSpecimenNumber);
  93.       $processor->importStyleSheet($xsl);
  94.       $xml1 = new DOMDocument('1.0', 'UTF-8');
  95.       $xml1->load($file1);
  96.       $html = $processor->transformToXML($xml1);
  97.       echo $html; 
  98.  }
  99.      if($CatNoText->item(0)->nodeValue != $SpecimenNumber) { 
  100.      $processor->setParameter('', 'formSpecimenNumber', $formSpecimenNumber);
  101.      $processor->importStyleSheet($xsl);
  102.      $xml2 = new DOMDocument('1.0', 'UTF-8');
  103.      $xml2->load($file2);
  104.      $html = $processor->transformToXML($xml2);
  105.      echo $html;  
  106.      
  107.   }
  108.  }
  109.  
  110. if($ID_Schema != 3) {
  111. $file = $Provider.$QueryPart1.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2.$SpecimenNumber.$QueryPart2;
  112. // echo $file;
  113. $processor->setParameter('', 'searchform', '');
  114. $processor->setParameter('', 'formSpecimenNumber', $formSpecimenNumber);
  115. $processor->importStyleSheet($xsl);
  116. $xml3 = new DOMDocument('1.0', 'UTF-8');
  117. $xml3->load($file);
  118. $html = $processor->transformToXML($xml3);
  119. echo $html;      }
  120.  
  121. } //if($searchform != "true"  and $variable5 == "")     
  122.  
  123.      
  124.  if($searchform != "true" and $variable5 != "") {
  125.  
  126.     /**********************************************************************************************
  127.     * sometimes the user received more than one specimen record (by using *), than he/she has     *
  128.     * to select one; to be sure that during query process the right one is called some further    *
  129.     * help form elements are filled with content and are checked here                             *
  130.     * this parameters are filled during the xslt transformation  (see scripts in folder XSLT)     *
  131.     **********************************************************************************************/
  132.  
  133. if($ID_Schema == 3 and $CatalogNoText == "True")
  134. {
  135. $file = $Provider.$QueryPart1b.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2b."CatalogNumberText%3E".$SourceUnitID."%3C%2Fdarwin%3ACatalogNumberText".$QueryPart3.$SourceInstitutionCode.$QueryPart4.$SourceCode.$QueryPart5;
  136.  
  137. } 
  138. if($ID_Schema == 3 and $CatalogNoText != "True")
  139. {
  140. $file = $Provider.$QueryPart1b.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2b."Cata
  141. logNumber%3E".$SourceUnitID."%3C%2Fdarwin%3ACatalogNumber".$QueryPart3.$SourceInstitutionCode.$QueryPart4.$SourceCode.$QueryPart5;
  142. } 
  143.  
  144. else
  145. {
  146.  
  147. $file = $Provider.$QueryPart1b.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2b.$SourceUnitID.$QueryPart3.$SourceInstitutionCode.$QueryPart4.$SourceCode.$QueryPart5; }
  148.  
  149. $processor->importStyleSheet($xsl);
  150. $processor->setParameter('', 'searchform', '');
  151. $xml = new DOMDocument('1.0', 'UTF-8');
  152. $xml->load($file);
  153. $html = $processor->transformToXML($xml);
  154. echo $html;  
  155.  
  156.  
  157.  } // if($searchform != "true" and $variable5 != "") { 
  158.  
  159.  
  160.  
  161.     /************************************************************************************************
  162.     * $searchform == "true" means system currently uses the edit/search form and not the input form *
  163.     ************************************************************************************************/
  164.     
  165.     
  166. if($searchform == "true")
  167. {
  168. if($ID_Schema == 3 and $CatalogNoText == "True")
  169. {
  170. $file = $Provider.$QueryPart1b.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2b."CatalogNumberText%3E".$SourceUnitID."%3C%2Fdarwin%3ACatalogNumberText".$QueryPart3.$SourceInstitutionCode.$QueryPart4.$SourceCode.$QueryPart5;
  171.  
  172. } 
  173. if($ID_Schema == 3 and $CatalogNoText != "True")
  174. {
  175. $file = $Provider.$QueryPart1b.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2b."Cata
  176. logNumber%3E".$SourceUnitID."%3C%2Fdarwin%3ACatalogNumber".$QueryPart3.$SourceInstitutionCode.$QueryPart4.$SourceCode.$QueryPart5;
  177.  
  178. } 
  179.  
  180. else
  181. {
  182. $file = $Provider.$QueryPart1b.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2b.$SourceUnitID.$QueryPart3.$SourceInstitutionCode.$QueryPart4.$SourceCode.$QueryPart5;
  183.  
  184. $processor->importStyleSheet($xsl);
  185. $processor->setParameter('', 'searchform', 'searchform');
  186. $xml3 = new DOMDocument('1.0', 'UTF-8');
  187. $xml3->load($file);
  188. $html = $processor->transformToXML($xml3);
  189. echo $html;     
  190.  
  191. }
  192.     
  193.   } //if($searchform == "true")
  194.   
  195.   
  196.   } //if(fopen($Provider,"r"))
  197.       
  198.   }
  199.  }
  200. ?>

Documentation generated on Tue, 29 Nov 2011 10:45:20 +0100 by phpDocumentor 1.4.3