Пример #1
0
 private function create_synonym($rec)
 {
     $exclude = array('"species"');
     foreach ($rec["synonyms"] as $syn) {
         if (in_array($syn["synonym"], $exclude)) {
             continue;
         }
         $synonym = new \eol_schema\Taxon();
         if (!Functions::is_utf8($syn["synonym"]) || !Functions::is_utf8($syn["syn_author"])) {
             continue;
         }
         $synonym->taxonID = (string) $syn["syn_id"];
         if (self::starts_with_small_letter($syn["synonym"])) {
             $parts = explode(" ", $rec["sciname"]);
             $syn["synonym"] = $parts[0] . " " . $syn["synonym"];
         }
         $synonym->scientificName = (string) $syn["synonym"];
         $synonym->scientificNameAuthorship = (string) $syn["syn_author"];
         $synonym->acceptedNameUsageID = (string) $rec["taxon_id"];
         $synonym->taxonomicStatus = "synonym";
         $synonym->taxonRemarks = (string) $syn["syn_remark"];
         $synonym->furtherInformationURL = (string) $syn["syn_url"];
         // special case e.g. http://turbellaria.umaine.edu/turb3.php?action=6&code=1412
         if (@$rec["parent_id"] == 10408) {
             $rec["parent_id"] = "";
         }
         $synonym->parentNameUsageID = (string) $rec["parent_id"];
         if (!$synonym->scientificName) {
             continue;
         }
         if ($synonym->scientificName == $rec["sciname"]) {
             echo "\n alert: synonym == valid name \n";
             print_r($rec);
             self::save_to_dump($synonym->taxonID, $this->dump_file_synonyms);
             continue;
         }
         if (!isset($this->taxon_ids[$synonym->taxonID])) {
             $this->archive_builder->write_object_to_file($synonym);
             $this->taxon_ids[$synonym->taxonID] = 1;
             self::save_to_dump($synonym->taxonID, $this->dump_file_synonyms);
         }
     }
 }
Пример #2
0
 private function write_archive($taxon)
 {
     $t = new \eol_schema\Taxon();
     $t->taxonID = $taxon['avibaseid'];
     $t->scientificName = $taxon['sciname'];
     $t->scientificNameAuthorship = $taxon['authorship'];
     $t->order = ucfirst(strtolower($taxon['order']));
     $t->family = $taxon['family'];
     $t->genus = self::get_genus($taxon['sciname']);
     $t->furtherInformationURL = self::AVIBASE_SOURCE_URL . $taxon['avibaseid'];
     if (!isset($this->taxon_ids[$t->taxonID])) {
         $this->taxon_ids[$t->taxonID] = '';
         $this->archive_builder->write_object_to_file($t);
     }
     //write comnames and synonyms
     $language_iso_codes = self::language_iso_codes();
     foreach ($taxon['comnames'] as $name) {
         if (!@$name['comnames']) {
             continue;
         }
         // e.g. http://avibase.bsc-eoc.org/species.jsp?avibaseid=483A2A51F4A5E37E -- see Malayalam
         foreach (@$name['comnames'] as $comname) {
             if (!($comname = trim($comname))) {
                 continue;
             }
             if (!Functions::is_utf8($comname)) {
                 $comname = utf8_encode($comname);
             }
             if ($name['lang'] == "Latin") {
                 if ($t->scientificName == $comname) {
                     continue;
                 }
                 $synonym = new \eol_schema\Taxon();
                 $synonym->taxonID = strtolower(str_ireplace(" ", "_", $comname));
                 $synonym->scientificName = $comname;
                 $synonym->acceptedNameUsageID = $taxon['avibaseid'];
                 $synonym->taxonomicStatus = "synonym";
                 if (!isset($this->taxon_ids[$synonym->taxonID])) {
                     $this->taxon_ids[$synonym->taxonID] = '';
                     $this->archive_builder->write_object_to_file($synonym);
                 }
             } else {
                 $v = new \eol_schema\VernacularName();
                 $v->taxonID = $taxon['avibaseid'];
                 $v->vernacularName = $comname;
                 $v->language = $language_iso_codes[$name['lang']];
                 $id = md5($v->vernacularName);
                 if (!isset($unique_id[$id])) {
                     $unique_id[$id] = '';
                     $this->archive_builder->write_object_to_file($v);
                 }
             }
         }
     }
 }
Пример #3
0
 function get_common_names($names)
 {
     // might need or not need this...
     $common = utf8_encode($name['commonName']);
     if (Functions::is_utf8($common)) {
         $arr_names[] = array("name" => Functions::import_decode($common), "language" => $name['xml_lang']);
     }
 }
 private function get_texts($description, $taxon_id, $title, $subject, $code, $reference_ids = null, $agent_ids = null)
 {
     $description = utf8_encode($description);
     if (!Functions::is_utf8($description)) {
         return;
     }
     $mr = new \eol_schema\MediaResource();
     if ($reference_ids) {
         $mr->referenceID = implode("; ", $reference_ids);
     }
     if ($agent_ids) {
         $mr->agentID = implode("; ", $agent_ids);
     }
     $mr->taxonID = $taxon_id;
     $mr->identifier = $mr->taxonID . "_" . $code;
     $mr->type = 'http://purl.org/dc/dcmitype/Text';
     $mr->language = 'en';
     $mr->format = 'text/html';
     $mr->furtherInformationURL = $this->taxon_link["species"] . str_replace("s_", "", $taxon_id);
     $mr->description = $description;
     $mr->CVterm = $subject;
     $mr->title = $title;
     $mr->creator = '';
     $mr->CreateDate = '';
     $mr->modified = '';
     $mr->UsageTerms = 'http://creativecommons.org/licenses/by-nc/3.0/';
     $mr->Owner = '';
     $mr->publisher = '';
     $mr->audience = 'Everyone';
     $mr->bibliographicCitation = $this->bibliographic_citation;
     $this->archive_builder->write_object_to_file($mr);
 }
 private function process_fields($records, $class, $allowed_fields)
 {
     foreach ($records as $rec) {
         if ($class == "VernacularName") {
             $c = new \eol_schema\VernacularName();
         } elseif ($class == "Agent") {
             $c = new \eol_schema\Agent();
         } elseif ($class == "Reference") {
             $c = new \eol_schema\Reference();
         } elseif ($class == "Taxon") {
             $c = new \eol_schema\Taxon();
         } elseif ($class == "MeasurementOrFact") {
             $c = new \eol_schema\MeasurementOrFact();
         } elseif ($class == "Occurrence") {
             $c = new \eol_schema\Occurrence();
         } elseif ($class == "Distribution") {
             $c = new \eol_schema\MediaResource();
         } elseif ($class == "Image") {
             $c = new \eol_schema\MediaResource();
         }
         $keys = array_keys($rec);
         $save = true;
         foreach ($keys as $key) {
             $temp = pathinfo($key);
             $field = $temp["basename"];
             /* resource specifications */
             // if($this->resource_id == "345") //3I Interactive resource
             // if(true)
             // {
             //     if($class == "Image" && $field == "license")            $field = "UsageTerms";
             //     if($class == "Distribution" && $field == "locality")    $field = "Description";
             // }
             /* end specifications */
             // manual adjustment bec. of a typo in meta.xml, without "s"
             if ($field == "measurementRemark") {
                 $field = "measurementRemarks";
             }
             /*
             // sample way to exclude if field is to be excluded
             if($field == "attribution") continue; //not recognized in eol: http://indiabiodiversity.org/terms/attribution
             */
             if (!in_array($field, $allowed_fields)) {
                 $this->debug["undefined"][$class][$field] = '';
                 continue;
             }
             // some fields have '#', e.g. "http://schemas.talis.com/2005/address/schema#localityName"
             $parts = explode("#", $field);
             if ($parts[0]) {
                 $field = $parts[0];
             }
             if (@$parts[1]) {
                 $field = $parts[1];
             }
             $value = trim((string) $rec[$key]);
             $value = trim(Functions::import_decode($value));
             if (!Functions::is_utf8($value)) {
                 $save = false;
             }
             //special arrangement
             if ($class == "Reference") {
                 if ($field == "identifier") {
                     $this->reference_ids[$value] = '';
                 }
                 if ($field == "full_reference") {
                     if (!$value) {
                         $full_ref = "";
                         if ($val = (string) @$rec["http://eol.org/schema/reference/primaryTitle"]) {
                             $full_ref .= $val;
                         } elseif ($val = (string) @$rec["http://purl.org/dc/terms/title"]) {
                             $full_ref .= $val;
                         }
                         if ($val = (string) @$rec["http://purl.org/ontology/bibo/pageStart"]) {
                             $full_ref .= ". Page(s) " . $val;
                         }
                         if ($val = (string) @$rec["http://purl.org/ontology/bibo/pageEnd"]) {
                             $full_ref .= " - " . $val;
                         }
                         if ($val = (string) @$rec["http://purl.org/ontology/bibo/volume"]) {
                             $full_ref .= ". Vol. " . $val;
                         }
                         if ($val = (string) @$rec["http://purl.org/dc/terms/publisher"]) {
                             $full_ref .= ". Publisher: " . $val;
                         }
                         if ($val = (string) @$rec["http://purl.org/ontology/bibo/authorList"]) {
                             $full_ref .= ". Author: " . $val;
                         }
                         if ($val = (string) @$rec["http://purl.org/ontology/bibo/editorList"]) {
                             $full_ref .= ". Editor: " . $val;
                         }
                         if ($val = (string) @$rec["http://purl.org/dc/terms/created"]) {
                             $full_ref .= ". " . $val;
                         }
                         if ($val = $full_ref) {
                             $value = $full_ref;
                         } else {
                             echo " -- still blank";
                         }
                     }
                 }
             }
             // if($class == "MeasurementOrFact" && $field == "referenceID")
             // {
             //     if($value)
             //     {
             //         if(!isset($this->reference_ids[$value])) echo " -- undefined refid:[$value]";
             //     }
             // }
             if ($value) {
                 $c->{$field} = $value;
             }
         }
         /* if($class == "objects") {} // sample way to filter */
         if ($save) {
             $this->archive_builder->write_object_to_file($c);
         }
     }
 }
Пример #6
0
 private function get_names()
 {
     //0    tsn serial not null
     //1    unit_ind1 char(1)
     //2    unit_name1 char(35) not null
     //3    unit_ind2 char(1)
     //4    unit_name2 varchar(35)
     //5    unit_ind3 varchar(7)
     //6    unit_name3 varchar(35)
     //7    unit_ind4 varchar(7)
     //8    unit_name4 varchar(35)
     //9    unnamed_taxon_ind char(1)
     //10   usage varchar(12,5) not null
     //11   unaccept_reason varchar(50,9)
     //12   credibility_rtng varchar(40,17) not null
     //13   completeness_rtng char(10)
     //14   currency_rating char(7)
     //15   phylo_sort_seq smallint
     //16   initial_time_stamp datetime year to second not null
     //17   parent_tsn integer
     //18   taxon_author_id integer
     //19   hybrid_author_id integer
     //20   kingdom_id smallint not null
     //21   rank_id smallint not null
     //22   update_date date not null
     //23   uncertain_prnt_ind char(3)
     $written_publication_ids = array();
     $path = $this->download_directory . "/" . $this->filenames['taxonomic_units'];
     $i = 0;
     foreach (new FileIterator($path) as $line) {
         if (!$line) {
             continue;
         }
         $line_data = explode("|", $line);
         $name_tsn = trim($line_data[0]);
         $x1 = trim($line_data[1]);
         $name_part_1 = trim($line_data[2]);
         $x2 = trim($line_data[3]);
         $name_part_2 = trim($line_data[4]);
         $sp_marker_1 = trim($line_data[5]);
         $name_part_3 = trim($line_data[6]);
         $sp_marker_2 = trim($line_data[7]);
         $name_part_4 = trim($line_data[8]);
         $validity = trim($line_data[10]);
         $reason = trim($line_data[11]);
         $comp_rating = trim($line_data[12]);
         $cred_rating = trim($line_data[13]);
         $curr_rating = trim($line_data[14]);
         $parent_tsn = trim($line_data[17]);
         $author_id = trim($line_data[18]);
         $rank_id = trim($line_data[21]);
         if (!$parent_tsn) {
             $parent_tsn = 0;
         }
         $name_string = $name_part_1;
         if (preg_match("/^[a-z]/", $name_part_1)) {
             echo "???????? {$name_tsn}) {$name_part_1}\n";
         }
         if ($x1) {
             $name_string = $x1 . " " . $name_string;
         }
         if ($x2) {
             $name_string .= " " . $x2;
         }
         if ($name_part_2) {
             $name_string .= " " . $name_part_2;
         }
         if ($sp_marker_1) {
             $name_string .= " " . $sp_marker_1;
         }
         if ($name_part_3) {
             $name_string .= " " . $name_part_3;
         }
         if ($sp_marker_2) {
             $name_string .= " " . $sp_marker_2;
         }
         if ($name_part_4) {
             $name_string .= " " . $name_part_4;
         }
         if ($a = @$this->authors[$author_id]) {
             $name_string = utf8_encode($name_string) . " " . $a;
         }
         $name_string = trim($name_string);
         $remarks = "";
         if ($comp_rating && $comp_rating != "unknown") {
             $remarks .= "Completeness: {$comp_rating}. ";
         }
         if ($cred_rating && $cred_rating != "unknown") {
             $remarks .= "Credibility: {$cred_rating}. ";
         }
         // if($curr_rating && $curr_rating != "unknown") $remarks .= "Currency: $curr_rating. ";
         if (isset($this->comment_links[$name_tsn])) {
             foreach ($this->comment_links[$name_tsn] as $comment_id) {
                 if ($c = @$this->comments[$comment_id]) {
                     $remarks .= $c . ". ";
                 }
             }
         }
         $remarks = str_replace("..", ".", $remarks);
         $remarks = trim($remarks);
         if (isset($this->synonym_of[$name_tsn])) {
             static $unavailable_reasons = array('database artifact', 'unavailable, database artifact', 'unavailable, incorrect orig. spelling', 'unavailable, literature misspelling', 'unavailable, suppressed by ruling', 'unavailable, other', 'unjustified emendation', 'nomen dubium', 'homonym (illegitimate)', 'superfluous renaming (illegitimate)');
             if (in_array($reason, $unavailable_reasons)) {
                 continue;
             }
             $taxon = new \eol_schema\Taxon();
             $taxon->taxonID = $name_tsn;
             $taxon->scientificName = $name_string;
             $taxon->parentNameUsageID = $this->synonym_of[$name_tsn];
             $taxon->taxonRank = $this->ranks[$rank_id];
             $taxon->taxonRemarks = $remarks;
             // $taxon->namePublishedIn = $publications;
             $taxon->taxonomicStatus = $reason;
             // if(isset($this->locations[$name_tsn])) $taxon->spatial = $this->locations[$name_tsn];
             if ($val = @$this->locations[$name_tsn]) {
                 self::add_string_types($taxon->taxonID, md5($val), $val, "http://eol.org/schema/terms/Present", true);
             }
             // http://rs.tdwg.org/ontology/voc/SPMInfoItems#Distribution - possible value for ITIS geographic division
             if (!Functions::is_utf8($taxon->scientificName)) {
                 echo "NOT UTF8 SYN: {$name_tsn} : {$taxon->scientificName}\n";
             }
             $this->archive_builder->write_object_to_file($taxon);
             @($this->all_statuses['synonyms'][$validity] += 1);
             @($this->all_statuses['synonym_reasons'][$reason] += 1);
         } else {
             // first loop and find all vernacular names
             $vernacular_names = array();
             if (isset($this->vernaculars[$name_tsn])) {
                 foreach ($this->vernaculars[$name_tsn] as $name_hash) {
                     $vernacular = new \eol_schema\VernacularName();
                     $vernacular->taxonID = $name_tsn;
                     $vernacular->vernacularName = $name_hash['name'];
                     $vernacular->language = self::get_iso_code_for_language($name_hash['language']);
                     if (!Functions::is_utf8($vernacular->vernacularName)) {
                         echo "NOT UTF8 VERN: {$name_tsn} : {$vernacular->vernacularName}\n";
                     }
                     $this->archive_builder->write_object_to_file($vernacular);
                     @($this->all_statuses['languages'][$name_hash['language']] += 1);
                 }
             }
             $publication_ids = array();
             if (isset($this->publication_links[$name_tsn])) {
                 foreach ($this->publication_links[$name_tsn] as $pub_id) {
                     if ($p = @$this->publications[$pub_id]) {
                         if (!isset($written_publication_ids[$pub_id])) {
                             $reference = new \eol_schema\Reference();
                             $reference->identifier = $pub_id;
                             $reference->full_reference = $p;
                             if (!Functions::is_utf8($reference->full_reference)) {
                                 echo "NOT UTF8 REF: {$name_tsn} : {$reference->full_reference}\n";
                             }
                             $this->archive_builder->write_object_to_file($reference);
                             $written_publication_ids[$pub_id] = 1;
                         }
                         $publication_ids[] = $pub_id;
                     }
                 }
             }
             if ($i % 5000 == 0) {
                 echo "{$i} : {$name_tsn} : {$name_string} : " . time_elapsed() . " : " . memory_get_usage() . "\n";
             }
             $i++;
             $taxon = new \eol_schema\Taxon();
             $taxon->taxonID = $name_tsn;
             $taxon->scientificName = $name_string;
             $taxon->parentNameUsageID = $parent_tsn;
             $taxon->taxonRank = $this->ranks[$rank_id];
             $taxon->taxonRemarks = $remarks;
             $taxon->referenceID = implode(";", $publication_ids);
             $taxon->taxonomicStatus = $validity;
             // if(isset($this->locations[$name_tsn])) $taxon->spatial = $this->locations[$name_tsn];
             if ($val = @$this->locations[$name_tsn]) {
                 self::add_string_types($taxon->taxonID, md5($val), $val, "http://eol.org/schema/terms/Present", true);
             }
             if (!Functions::is_utf8($taxon->scientificName)) {
                 echo "NOT UTF8: {$name_tsn} : {$taxon->scientificName}\n";
             }
             $this->archive_builder->write_object_to_file($taxon);
             @($this->all_statuses['valids'][$validity] += 1);
         }
     }
 }
Пример #7
0
 private function format_utf8($string)
 {
     $string = Functions::import_decode($string);
     if (!Functions::is_utf8($string)) {
         return utf8_encode($string);
     }
     return $string;
 }
 private function clean_string($str)
 {
     $str = trim($str);
     if (substr($str, 0, 1) == '"' && substr($str, -1) == '"') {
         $str = substr($str, 1, strlen($str) - 2);
     }
     if (!Functions::is_utf8($str)) {
         $str = utf8_encode($str);
     }
     return trim($str);
 }
Пример #9
0
function format_utf8($str)
{
    if (Functions::is_utf8($str)) {
        return $str;
    } else {
        return utf8_encode($str);
    }
}
Пример #10
0
 private function format_utf8($str)
 {
     if (!Functions::is_utf8($str)) {
         return utf8_encode($str);
     }
     return $str;
 }
Пример #11
0
 private static function lookup_with_cache_vimeo_call($vimeo, $command, $param, $options = array())
 {
     // default expire time is 15 days
     if (!isset($options['expire_seconds'])) {
         $options['expire_seconds'] = 1296000;
     }
     //debug orig value = 1296000
     if (!isset($options['timeout'])) {
         $options['timeout'] = 240;
     }
     if (!isset($options['cache_path'])) {
         $options['cache_path'] = DOC_ROOT . "tmp/cache/";
     }
     // if(!isset($options['cache_path'])) $options['cache_path'] = "/Volumes/Eli black/eol_cache/";    //debug - only during development
     $url = $command . implode("_", $param);
     $md5 = md5($url);
     $cache1 = substr($md5, 0, 2);
     $cache2 = substr($md5, 2, 2);
     $options['cache_path'] .= "vimeo/";
     if (!file_exists($options['cache_path'])) {
         mkdir($options['cache_path']);
     }
     if (!file_exists($options['cache_path'] . $cache1)) {
         mkdir($options['cache_path'] . $cache1);
     }
     if (!file_exists($options['cache_path'] . "{$cache1}/{$cache2}")) {
         mkdir($options['cache_path'] . "{$cache1}/{$cache2}");
     }
     $cache_path = $options['cache_path'] . "{$cache1}/{$cache2}/{$md5}.cache";
     if (file_exists($cache_path)) {
         $file_contents = file_get_contents($cache_path);
         if (!Functions::is_utf8($file_contents)) {
             $file_contents = utf8_encode($file_contents);
         }
         $obj = json_decode($file_contents);
         if ($file_contents || strval($file_contents) == "0") {
             $file_age_in_seconds = time() - filemtime($cache_path);
             if ($file_age_in_seconds < $options['expire_seconds']) {
                 return $obj;
             }
             if ($options['expire_seconds'] === false) {
                 return $obj;
             }
         }
         @unlink($cache_path);
     }
     if ($obj = $vimeo->call($command, $param)) {
         $file_contents = json_encode($obj);
         if ($FILE = Functions::file_open($cache_path, 'w+')) {
             fwrite($FILE, $file_contents);
             fclose($FILE);
         } else {
             if (!($h = Functions::file_open(DOC_ROOT . "/public/tmp/cant_delete.txt", 'a'))) {
                 return;
             }
             fwrite($h, $cache_path . "\n");
             fclose($h);
         }
         return $obj;
     }
     return false;
 }
Пример #12
0
 private function get_texts($description, $taxon_id, $title, $subject, $code, $reference_ids = null, $agent_ids = null)
 {
     $description = utf8_encode(self::remove_quotes($description));
     $description = str_ireplace("<br>", "xxxyyy", $description);
     $description = strip_tags($description);
     $description = str_ireplace("xxxyyy", "<br>", $description);
     if (in_array($code, $this->media_ids)) {
         return;
     }
     if (!Functions::is_utf8($description)) {
         return;
     }
     $this->media_ids[] = $code;
     if (in_array($subject, array("#TypeInformation"))) {
         $subject = $this->EOL . $subject;
     } else {
         $subject = $this->SPM . $subject;
     }
     $mr = new \eol_schema\MediaResource();
     if ($reference_ids) {
         $mr->referenceID = implode("; ", $reference_ids);
     }
     if ($agent_ids) {
         $mr->agentID = implode("; ", $agent_ids);
     }
     $mr->taxonID = $taxon_id;
     $mr->identifier = $code;
     $mr->type = "http://purl.org/dc/dcmitype/Text";
     $mr->language = "en";
     $mr->format = "text/html";
     $mr->furtherInformationURL = $this->taxon_url . $taxon_id;
     $mr->description = (string) $description;
     $mr->CVterm = $subject;
     $mr->title = $title;
     $mr->creator = "";
     $mr->CreateDate = "";
     $mr->modified = "";
     $mr->UsageTerms = "http://creativecommons.org/licenses/by-nc/3.0/";
     $mr->Owner = "";
     $mr->publisher = "";
     $mr->audience = "Everyone";
     $mr->bibliographicCitation = "";
     $this->archive_builder->write_object_to_file($mr);
 }
Пример #13
0
 function get_common_names($names)
 {
     $arr_names = array();
     if ($names) {
         foreach ($names as $name) {
             $common = utf8_encode($name['commonName']);
             if (Functions::is_utf8($common)) {
                 $arr_names[] = array("name" => Functions::import_decode($common), "language" => $name['xml_lang']);
             } else {
                 echo "\n not utf8 common name: [" . $common . "]\n";
             }
         }
     }
     return $arr_names;
 }
 private function get_contributor_name($url)
 {
     $options = array('resource_id' => 'gbif', 'expire_seconds' => false, 'download_wait_time' => 1000000, 'timeout' => 900, 'download_attempts' => 2, 'delay_in_minutes' => 2);
     // 15mins timeout
     $options = array('resource_id' => 'gbif', 'expire_seconds' => false, 'download_wait_time' => 1000000, 'timeout' => 900);
     // 15mins timeout
     if ($html = Functions::lookup_with_cache($url, $options)) {
         // <title property="dc:title">Herbarium Berolinense - Dataset detail</title>
         if (preg_match("/\"dc:title\">(.*?)\\- Dataset detail/ims", $html, $arr)) {
             if (!Functions::is_utf8($arr[1])) {
                 exit("\n culprit is contributor name \n");
             }
             return Functions::import_decode(trim($arr[1]));
         }
     }
 }
Пример #15
0
function fix_latin1_mangled_with_utf8_maybe_hopefully_most_of_the_time($str)
{
    return preg_replace_callback('#[\\xA1-\\xFF](?![\\x80-\\xBF]{2,})#', function ($m) {
        // utf8_encode($m[0]);
        if (Functions::is_utf8($m[0])) {
            $str = utf8_decode($m[0]);
            $str = utf8_encode($str);
            return $str;
        } else {
            return utf8_encode($m[0]);
        }
    }, $str);
}
Пример #16
0
 private function get_descriptions_from_html($html, $rec)
 {
     $descriptions = array();
     if (preg_match("/AUTHORSHIP AND CITATION\\:(.*?)Available\\:/ims", $html, $arr)) {
         $authorship_citation = self::clean_str(strip_tags($arr[1]), true);
         $authorship_citation = self::get_authorship_citation($authorship_citation);
         $descriptions["AUTHORSHIP AND CITATION"] = $authorship_citation;
     } else {
         echo "\n ALERT: no authorship and citation: " . $rec['url'];
     }
     if ($rec["kingdom"] == "Animalia") {
         $html = str_ireplace("ORDER :", "ORDER:", $html);
         $html = str_ireplace("CLASS :", "CLASS:", $html);
         if (preg_match("/ORDER\\:(.*?)<a name\\=\"CLASS\"/ims", $html, $arr) || preg_match("/ORDER\\:(.*?)<b>CLASS\\:/ims", $html, $arr)) {
             $order = trim(strip_tags($arr[1]));
         }
         if (isset($order)) {
             if (preg_match("/(.*?)\\(/ims", $order, $arr)) {
                 $order = trim($arr[1]);
             }
             //remove parenthesis
             echo "\n order:[{$order}]\n";
             $rec["order"] = $order;
         }
         if (isset($rec["order"])) {
             if ($rec["order"] == "Caudata") {
                 $rec["class"] = "Amphibian";
             } elseif (in_array($rec["order"], array("Passeriformes", "Piciformes", "Ciconiiformes", "Galliformes"))) {
                 $rec["class"] = "Bird";
             } elseif (in_array($rec["order"], array("Artiodactyla", "Carnivora"))) {
                 $rec["class"] = "Mammal";
             }
         } else {
             if (preg_match("/CLASS\\:(.*?)<a name\\=\"FEDERAL LEGAL STATUS\"/ims", $html, $arr) || preg_match("/CLASS\\:(.*?)<a name\\=\"FederalLegalStatus\"/ims", $html, $arr) || preg_match("/CLASS\\:(.*?)<b>FEDERAL LEGAL STATUS/ims", $html, $arr) || preg_match("/CLASS\\:(.*?)<a name\\=\"DistributionAndOccurrence\"/ims", $html, $arr) || preg_match("/CLASS\\:(.*?)<a name\\=\"DISTRIBUTION AND OCCURRENCE\"/ims", $html, $arr)) {
                 $class = trim(strip_tags($arr[1]));
             }
             if (isset($class)) {
                 if (preg_match("/(.*?)\\(/ims", $class, $arr)) {
                     $class = trim($arr[1]);
                 }
                 //remove parenthesis
                 $rec["class"] = $class;
             }
         }
         if (isset($rec["class"])) {
             echo "\n class:" . $rec["class"];
         }
     }
     // taxonomy
     if (preg_match("/TAXONOMY \\:(.*?)<b>/ims", $html, $arr)) {
         $taxonomy = $arr[1];
     } else {
         if (preg_match("/TAXONOMY\\:(.*?)<span/ims", $html, $arr)) {
             $taxonomy = $arr[1];
         } elseif (preg_match("/TAXONOMY\\:(.*?)<em/ims", $html, $arr)) {
             $taxonomy = $arr[1];
         } elseif (preg_match("/TAXONOMY\\:(.*?)<br><br>/ims", $html, $arr)) {
             $taxonomy = $arr[1];
         } elseif (preg_match("/TAXONOMY\\:(.*?)<b>/ims", $html, $arr)) {
             $taxonomy = $arr[1];
         }
     }
     if (isset($taxonomy)) {
         $taxonomy = utf8_encode($taxonomy);
         if (Functions::is_utf8($taxonomy)) {
             $descriptions["TAXONOMY"] = $taxonomy;
         }
     }
     // SYNONYMS
     if (preg_match("/SYNONYMS \\:(.*?)<b>/ims", $html, $arr)) {
         $synonyms = self::clean_str(strip_tags($arr[1], "<br><a>"));
     } elseif (preg_match("/SYNONYMS\\:(.*?)<br><br>/ims", $html, $arr)) {
         $synonyms = self::clean_str(strip_tags($arr[1], "<br><a>"));
     }
     if (isset($synonyms)) {
         $synonyms = self::further_clean($synonyms, "SYNONYMS", $html);
     }
     if (isset($synonyms)) {
         $descriptions["SYNONYMS"] = $synonyms;
     } else {
         echo "\n -no synonyms- \n";
     }
     //debug
     // COMMON NAMES
     if (preg_match("/COMMON NAMES \\:(.*?)<b>/ims", $html, $arr)) {
         $comnames = self::clean_str(strip_tags($arr[1], "<br><a>"));
     } elseif (preg_match("/COMMON NAMES\\:(.*?)<br><br>/ims", $html, $arr)) {
         $comnames = self::clean_str(strip_tags($arr[1], "<br><a>"));
     } elseif (preg_match("/COMMON NAMES\\:(.*?)<\\/td/ims", $html, $arr)) {
         $comnames = self::clean_str(strip_tags($arr[1], "<br><a>"));
     }
     if (isset($comnames)) {
         $comnames = self::further_clean($comnames, "COMMON NAMES", $html);
         $descriptions["COMMON NAMES"] = $comnames;
     } else {
         echo "\n -no comnames- \n";
     }
     //debug
     if (in_array($rec["url"], array("http://www.fs.fed.us/database/feis/plants/shrub/ceaoph/all.html", "http://www.fs.fed.us/database/feis/plants/shrub/bernev/all.html"))) {
         if (preg_match("/LIFE FORM\\:(.*?)<hr/ims", $html, $arr)) {
             $lifeform = $arr[1];
             if (!(stripos($lifeform, "federal legal status") != "" || stripos($lifeform, "other status") != "")) {
                 $descriptions["LIFE FORM"] = $lifeform;
             }
         }
     } else {
         $html = str_ireplace("<b>LIFE FORM :", "LIFE FORM:", $html);
         if (preg_match("/LIFE FORM\\:(.*?)<br><br>/ims", $html, $arr)) {
             $lifeform = $arr[1];
         } elseif (preg_match("/LIFE FORM\\:(.*?)<b>/ims", $html, $arr)) {
             $lifeform = $arr[1];
         }
         if (isset($lifeform)) {
             $descriptions["LIFE FORM"] = $lifeform;
             if (stripos($lifeform, "federal legal status") != "" || stripos($lifeform, "other status") != "") {
                 $descriptions["LIFE FORM"] = "";
                 if (preg_match("/(.*?)<a name\\=/ims", $lifeform, $arr)) {
                     $lifeform = $arr[1];
                     $descriptions["LIFE FORM"] = $lifeform;
                     if (stripos($lifeform, "federal legal status") != "" || stripos($lifeform, "other status") != "") {
                         $descriptions["LIFE FORM"] = "";
                         if (preg_match("/(.*?)<b>/ims", $lifeform, $arr)) {
                             $lifeform = $arr[1];
                             if (!(stripos($lifeform, "federal legal status") != "" || stripos($lifeform, "other status") != "")) {
                                 $descriptions["LIFE FORM"] = $lifeform;
                             }
                         }
                     }
                 }
             }
         }
     }
     $html = str_ireplace("FEDERAL LEGAL STATUS :", "FEDERAL LEGAL STATUS:", $html);
     if ($rec["kingdom"] == "Plantae") {
         if (preg_match("/FEDERAL LEGAL STATUS\\:(.*?)<br><br>/ims", $html, $arr)) {
             $federal_stat = $arr[1];
         } elseif (preg_match("/FEDERAL LEGAL STATUS\\:(.*?)<b>/ims", $html, $arr)) {
             $federal_stat = $arr[1];
         }
         if (isset($federal_stat)) {
             $descriptions["FEDERAL LEGAL STATUS"] = $federal_stat;
             if (stripos($federal_stat, "other status") != "") {
                 $descriptions["FEDERAL LEGAL STATUS"] = "";
                 if (preg_match("/(.*?)<a name\\=/ims", $federal_stat, $arr)) {
                     $federal_stat = $arr[1];
                     $descriptions["FEDERAL LEGAL STATUS"] = $federal_stat;
                     if (stripos($federal_stat, "other status") != "") {
                         $descriptions["FEDERAL LEGAL STATUS"] = "";
                         if (preg_match("/(.*?)<b>/ims", $federal_stat, $arr)) {
                             $federal_stat = $arr[1];
                             if (stripos($federal_stat, "other status") == "") {
                                 $descriptions["FEDERAL LEGAL STATUS"] = $federal_stat;
                             }
                         }
                     }
                 }
             }
         }
         if (isset($descriptions["FEDERAL LEGAL STATUS"])) {
             if (stripos($descriptions["FEDERAL LEGAL STATUS"], "No special status") != "") {
                 $descriptions["FEDERAL LEGAL STATUS"] = "";
             }
             if (stripos($descriptions["FEDERAL LEGAL STATUS"], "No legal status") != "") {
                 $descriptions["FEDERAL LEGAL STATUS"] = "";
             }
         }
     }
     // kingdom = Plantae
     $html = str_ireplace("OTHER STATUS :", "OTHER STATUS:", $html);
     if (preg_match("/OTHER STATUS\\:(.*?)<a name\\=/ims", $html, $arr)) {
         $other_stat = $arr[1];
     }
     if (isset($other_stat)) {
         $descriptions["OTHER STATUS"] = $other_stat;
         if (stripos($other_stat, "Management considerations") != "") {
             $descriptions["OTHER STATUS"] = "";
             if (preg_match("/(.*?)Management considerations\\:/ims", $other_stat, $arr)) {
                 $descriptions["OTHER STATUS"] = $arr[1];
             }
         }
     }
     /* DISTRIBUTION AND OCCURRENCE */
     $html = str_ireplace("GENERAL DISTRIBUTION :", "GENERAL DISTRIBUTION:", $html);
     if (in_array($rec["url"], array("http://www.fs.fed.us/database/feis/plants/shrub/ceaoph/all.html", "http://www.fs.fed.us/database/feis/plants/shrub/bernev/all.html"))) {
         if (preg_match("/GENERAL DISTRIBUTION\\:(.*?)United States\\:/ims", $html, $arr)) {
             $general_dist = $arr[1];
         } elseif (preg_match("/GENERAL DISTRIBUTION\\:(.*?)States\\:/ims", $html, $arr)) {
             $general_dist = $arr[1];
         }
     } else {
         if (preg_match("/GENERAL DISTRIBUTION\\:(.*?)<b>ECOSYSTEMS/ims", $html, $arr)) {
             $general_dist = $arr[1];
         } elseif (preg_match("/GENERAL DISTRIBUTION\\:(.*?)<span/ims", $html, $arr)) {
             $general_dist = $arr[1];
         }
     }
     if (isset($general_dist)) {
         $descriptions["GENERAL DISTRIBUTION"] = $general_dist;
     }
     if (preg_match("/ECOSYSTEMS \\:(.*?)<b>STATES/ims", $html, $arr) || preg_match("/ECOSYSTEMS\\:(.*?)<a name\\=\"STATES\"/ims", $html, $arr) || preg_match("/<a name\\=\"ECOSYSTEMS\">(.*?)<a name\\=\"STATES/ims", $html, $arr)) {
         $ecosystems = $arr[1];
         $descriptions["ECOSYSTEMS"] = $ecosystems;
     }
     if (in_array($rec["url"], array("http://www.fs.fed.us/database/feis/plants/shrub/ceaoph/all.html", "http://www.fs.fed.us/database/feis/plants/shrub/bernev/all.html"))) {
         if (preg_match("/states\\:(.*?)Site Characteristics\\:/ims", $html, $arr)) {
             $states = $arr[1];
         }
     } else {
         if (preg_match("/STATES \\:(.*?)<b>BLM/ims", $html, $arr) || preg_match("/STATES\\:(.*?)<a name\\=\"BLM PHYSIOGRAPHIC REGIONS\"/ims", $html, $arr) || preg_match("/<a name\\=\"STATES\\/PROVINCES\">(.*?)<a name\\=\"BLM PHYSIOGRAPHIC REGIONS\"/ims", $html, $arr)) {
             $states = $arr[1];
         }
     }
     if (isset($states)) {
         $states = str_ireplace("(key to state/province abbreviations)", "", $states);
         $descriptions["STATES"] = $states;
     }
     if (preg_match("/BLM PHYSIOGRAPHIC REGIONS \\:(.*?)<b>KUCHLER/ims", $html, $arr) || preg_match("/BLM PHYSIOGRAPHIC REGIONS\\:(.*?)<a name\\=\"KUCHLER PLANT ASSOCIATIONS\"/ims", $html, $arr) || preg_match("/<a name\\=\"BLM PHYSIOGRAPHIC REGIONS\">(.*?)<a name\\=\"KUCHLER PLANT ASSOCIATIONS\"/ims", $html, $arr)) {
         $blm_regions = $arr[1];
         $descriptions["BLM PHYSIOGRAPHIC REGIONS"] = $blm_regions;
     }
     if (preg_match("/KUCHLER PLANT ASSOCIATIONS \\:(.*?)<b>SAF/ims", $html, $arr) || preg_match("/KUCHLER PLANT ASSOCIATIONS\\:(.*?)<a name\\=\"SAF COVER TYPES\"/ims", $html, $arr) || preg_match("/<a name\\=\"KUCHLER PLANT ASSOCIATIONS\">(.*?)<a name\\=\"SAF COVER TYPES\"/ims", $html, $arr)) {
         $kuchler_assoc = $arr[1];
         $descriptions["KUCHLER PLANT ASSOCIATIONS"] = $kuchler_assoc;
     }
     if (preg_match("/SAF COVER TYPES \\:(.*?)<b>SRM/ims", $html, $arr) || preg_match("/SAF COVER TYPES\\:(.*?)<a name\\=\"SRM \\(RANGELAND\\) COVER TYPES\"/ims", $html, $arr) || preg_match("/<a name\\=\"SAF COVER TYPES\">(.*?)<a name\\=\"SRM \\(RANGELAND\\) COVER TYPES\"/ims", $html, $arr)) {
         $saf_types = $arr[1];
         $descriptions["SAF COVER TYPES"] = $saf_types;
     }
     if (preg_match("/SRM \\(RANGELAND\\) COVER TYPES \\:(.*?)<b>HABITAT TYPES AND PLANT COMMUNITIES/ims", $html, $arr)) {
         $srm_types = $arr[1];
     } elseif (preg_match("/SRM \\(RANGELAND\\) COVER TYPES \\:(.*?)<b>PLANT COMMUNITIES/ims", $html, $arr)) {
         $srm_types = $arr[1];
     } elseif (preg_match("/SRM \\(RANGELAND\\) COVER TYPES\\:(.*?)<a name\\=\"PLANT COMMUNITIES\"/ims", $html, $arr)) {
         $srm_types = $arr[1];
     } elseif (preg_match("/<a name\\=\"SRM \\(RANGELAND\\) COVER TYPES\">(.*?)<a name\\=\"HABITAT TYPES/ims", $html, $arr)) {
         $srm_types = $arr[1];
     }
     if (isset($srm_types)) {
         $descriptions["SRM (RANGELAND) COVER TYPES"] = $srm_types;
     }
     if (in_array($rec["url"], array("http://www.fs.fed.us/database/feis/plants/shrub/ceaoph/all.html", "http://www.fs.fed.us/database/feis/plants/shrub/bernev/all.html"))) {
         if (preg_match("/plant communities\\:(.*?)<a name\\=/ims", $html, $arr)) {
             $habitat_types = $arr[1];
         }
     } else {
         if (preg_match("/HABITAT TYPES AND PLANT COMMUNITIES\\:(.*?)<a name\\=\"BOTANICAL AND ECOLOGICAL CHARACTERISTICS/ims", $html, $arr)) {
             $habitat_types = $arr[1];
         } elseif (preg_match("/HABITAT TYPES AND PLANT COMMUNITIES\\:(.*?)<a name\\=\"BotanicalAndEcologicalCharacteristics/ims", $html, $arr)) {
             $habitat_types = $arr[1];
         } elseif (preg_match("/HABITAT TYPES AND PLANT COMMUNITIES \\:(.*?)<a name\\=\"MANAGEMENT CONSIDERATIONS/ims", $html, $arr)) {
             $habitat_types = $arr[1];
         }
     }
     if (isset($habitat_types)) {
         if (is_numeric(stripos($habitat_types, '<a name="MANAGEMENT CONSIDERATIONS"></a>'))) {
             if (preg_match("/HABITAT TYPES AND PLANT COMMUNITIES\\:(.*?)<a name\\=\"MANAGEMENT CONSIDERATIONS/ims", $html, $arr)) {
                 $habitat_types = $arr[1];
             }
         }
         $descriptions["HABITAT TYPES AND PLANT COMMUNITIES"] = $habitat_types;
     }
     if ($rec["kingdom"] == "Animalia") {
         //animals
         $html = str_ireplace("<b>PLANT COMMUNITIES :", "<b>PLANT COMMUNITIES:", $html);
         if (preg_match("/PLANT COMMUNITIES\\:(.*?)<a name\\=\"BIOLOGICAL DATA AND HABITAT REQUIREMENTS\"/ims", $html, $arr) || preg_match("/PLANT COMMUNITIES\\:(.*?)<a name\\=\"BiologicalDataAndHabitatRequirements\"/ims", $html, $arr) || preg_match("/PLANT COMMUNITIES\\:(.*?)<a name\\=\"BIOLOGICAL DATA AND HABITAT\"/ims", $html, $arr)) {
             $plant_comm = $arr[1];
             $descriptions["PLANT COMMUNITIES"] = $plant_comm;
         }
         /* BIOLOGICAL DATA AND HABITAT REQUIREMENTS */
         //animals
         // LIFE HISTORY subtopics
         $html_utf8 = utf8_encode($html);
         $html_utf8 = str_ireplace("Phenology</font>", "Phenology", $html_utf8);
         if (preg_match("/Ontogeny—<\\/b>(.*?)Phenology—<\\/b>/ims", $html_utf8, $arr)) {
             $ontogeny = $arr[1] . "xxx";
             if (preg_match("/Mating:(.*?)Reproductive rates:/ims", $ontogeny, $arr)) {
                 $descriptions["Mating"] = $arr[1];
             }
             if (preg_match("/Reproductive rates:(.*?)Gestation and litter size:/ims", $ontogeny, $arr)) {
                 $descriptions["Reproductive rates"] = $arr[1];
             }
             if (preg_match("/Gestation and litter size:(.*?)Development:/ims", $ontogeny, $arr)) {
                 $descriptions["Gestation and litter size"] = $arr[1];
             }
             if (preg_match("/Development:(.*?)Survival rates and mortality:/ms", $ontogeny, $arr)) {
                 $descriptions["Development"] = $arr[1];
             }
             if (preg_match("/Survival rates and mortality:(.*?)xxx/ims", $ontogeny, $arr)) {
                 $descriptions["Survival rates and mortality"] = $arr[1];
             }
         }
         if (preg_match("/Phenology—<\\/b>(.*?)Home range\\:/ims", $html_utf8, $arr)) {
             $descriptions["Phenology"] = $arr[1];
         }
         if (preg_match("/Home range\\:(.*?)<a name\\=\"PREFERRED HABITAT\"/ims", $html_utf8, $arr)) {
             $descriptions["Home range"] = $arr[1];
         }
         if (preg_match("/Physical description\\:(.*?)<a name\\=\"Physiology\">/ims", $html, $arr)) {
             $descriptions["Physical description"] = $arr[1];
         } elseif (preg_match("/Physical description\\:(.*?)<a name\\=\"CourtshipAndMating\">/ims", $html, $arr)) {
             $descriptions["Physical description"] = $arr[1];
         }
         if (preg_match("/Physiology\\:(.*?)<a name\\=\"CourtshipAndMating\">/ims", $html, $arr)) {
             $descriptions["Physiology"] = $arr[1];
         }
         if (preg_match("/Courtship and mating\\:(.*?)<a name\\=\"ReproductionAndDevelopment\">/ims", $html, $arr)) {
             $descriptions["Courtship and mating"] = $arr[1];
         }
         if (preg_match("/Reproduction and development\\:(.*?)<a name\\=\"SocialBehavior\">/ims", $html, $arr)) {
             $descriptions["Reproduction and development"] = $arr[1];
         } elseif (preg_match("/Reproduction and development\\:(.*?)<a name\\=\"Growth\">/ims", $html, $arr)) {
             $descriptions["Reproduction and development"] = $arr[1];
         }
         if (preg_match("/Social behavior\\:(.*?)<a name\\=\"HomeRangeAndMovements\">/ims", $html, $arr)) {
             $descriptions["Social behavior"] = $arr[1];
         } elseif (preg_match("/Social behavior\\:(.*?)<a name\\=\"MovementsAndHomeRange\">/ims", $html, $arr)) {
             $descriptions["Social behavior"] = $arr[1];
         }
         if (preg_match("/Home range and movements\\:(.*?)<a name\\=\"PopulationDensity\">/ims", $html, $arr)) {
             $descriptions["Home range and movements"] = $arr[1];
         } elseif (preg_match("/Movements and home range\\:(.*?)<a name\\=\"PopulationDensity\">/ims", $html, $arr)) {
             $descriptions["Home range and movements"] = $arr[1];
         } elseif (preg_match("/Home range and movement\\:(.*?)<a name\\=\"PREFERRED HABITAT\">/ims", $html, $arr)) {
             $descriptions["Home range and movements"] = $arr[1];
         }
         if (preg_match("/Population density\\:(.*?)<a name\\=\"Survival\">/ims", $html, $arr)) {
             $descriptions["Population density"] = $arr[1];
         } elseif (preg_match("/Population density\\:(.*?)<a name\\=\"LifeSpanAndSurvival\">/ims", $html, $arr)) {
             $descriptions["Population density"] = $arr[1];
         } elseif (preg_match("/Population density\\:(.*?)<a name\\=\"Home Range and Movements\">/ims", $html, $arr)) {
             $descriptions["Population density"] = $arr[1];
         }
         if (preg_match("/Survival\\:(.*?)<a name\\=\"LifeSpan\">/ims", $html, $arr)) {
             $descriptions["Survival"] = $arr[1];
         } elseif (preg_match("/Survival\\:(.*?)<a name\\=\"Population Density\">/ims", $html, $arr)) {
             $descriptions["Survival"] = $arr[1];
         }
         if (preg_match("/Life span\\:(.*?)<a name\\=\"DiseasesAndSourcesOfMortality\">/ims", $html, $arr)) {
             $descriptions["Life span"] = $arr[1];
         }
         if (preg_match("/Life span and survival\\:(.*?)<a name\\=\"Diet\">/ims", $html, $arr)) {
             $descriptions["Life span and survival"] = $arr[1];
         }
         /* other life history subtopics e.g http://www.fs.fed.us/database/feis/animals/reptile/gopo/all.html - Daily activity, Annual activity, Social interactions, Growth, Longevity */
         if (preg_match("/Daily activity\\:(.*?)<a name\\=\"Annual Activity\">/ims", $html, $arr)) {
             $descriptions["Daily activity"] = $arr[1];
         }
         if (preg_match("/Annual activity\\:(.*?)<a name\\=\"Social Interactions\">/ims", $html, $arr)) {
             $descriptions["Annual activity"] = $arr[1];
         }
         if (preg_match("/Social interactions\\:(.*?)<a name\\=\"Reproduction and Development\">/ims", $html, $arr)) {
             $descriptions["Social interactions"] = $arr[1];
         }
         if (preg_match("/Growth\\:(.*?)<a name\\=\"Longevity\">/ims", $html, $arr)) {
             $descriptions["Growth"] = $arr[1];
         }
         if (preg_match("/Longevity\\:(.*?)<a name\\=\"Survival\">/ims", $html, $arr)) {
             $descriptions["Longevity"] = $arr[1];
         }
         /* other life history subtopics e.g http://www.fs.fed.us/database/feis/animals/reptile/goag/all.html - Longevity and survivorship, Maturation, Reproduction, Annual cycle, Activity and movement, Density and home range */
         if (preg_match("/Longevity and survivorship<\\/a><\\/font>(.*?)<a name\\=\"Maturation\">/ims", $html, $arr)) {
             $descriptions["Longevity and survivorship"] = $arr[1];
         }
         if (preg_match("/Maturation<\\/a><\\/font>(.*?)<a name\\=\"Reproduction\">/ims", $html, $arr)) {
             $descriptions["Maturation"] = $arr[1];
         }
         if (preg_match("/Reproduction<\\/a><\\/font>(.*?)<a name\\=\"Annual Cycle\">/ims", $html, $arr)) {
             $descriptions["Reproduction"] = $arr[1];
         }
         if (preg_match("/Annual cycle<\\/a><\\/font>(.*?)<a name\\=\"Activity and movement\">/ims", $html, $arr)) {
             $descriptions["Annual cycle"] = $arr[1];
         } elseif (preg_match("/Annual cycle<\\/a>\\:(.*?)<a name\\=\"Activity and movement\">/ims", $html, $arr)) {
             $descriptions["Annual cycle"] = $arr[1];
         }
         if (preg_match("/Activity and movement<\\/a><\\/font>(.*?)<a name\\=\"Density and home range\">/ims", $html, $arr)) {
             $descriptions["Activity and movement"] = $arr[1];
         }
         if (preg_match("/Density and home range<\\/a><\\/font>(.*?)<a name\\=\"PREFERRED HABITAT\">/ims", $html, $arr)) {
             $descriptions["Density and home range"] = $arr[1];
         }
         //animals
         if (!(@$descriptions["Mating"] || @$descriptions["Reproductive rates"] || @$descriptions["Gestation and litter size"] || @$descriptions["Development"] || @$descriptions["Survival rates and mortality"] || @$descriptions["Ontogeny"] || @$descriptions["Phenology"] || @$descriptions["Home range"] || @$descriptions["Physical description"] || @$descriptions["Physiology"] || @$descriptions["Courtship and mating"] || @$descriptions["Reproduction and development"] || @$descriptions["Social behavior"] || @$descriptions["Home range and movements"] || @$descriptions["Population density"] || @$descriptions["Survival"] || @$descriptions["Life span"] || @$descriptions["Life span and survival"] || @$descriptions["Daily activity"] || @$descriptions["Annual activity"] || @$descriptions["Social interactions"] || @$descriptions["Growth"] || @$descriptions["Longevity"] || @$descriptions["Longevity and survivorship"] || @$descriptions["Maturation"] || @$descriptions["Reproduction"] || @$descriptions["Annual cycle"] || @$descriptions["Activity and movement"] || @$descriptions["Density and home range"])) {
             if (preg_match("/LIFE HISTORY\\:(.*?)<a name\\=\"DiseasesAndSourcesOfMortality\"/ims", $html, $arr)) {
                 $life_history = $arr[1];
             } elseif (preg_match("/LIFE HISTORY\\:(.*?)<a name\\=\"Diseases And Sources Of Mortality\"/ims", $html, $arr)) {
                 $life_history = $arr[1];
             } elseif (preg_match("/LIFE HISTORY\\:(.*?)<a name\\=\"Diet\"/ims", $html, $arr)) {
                 $life_history = $arr[1];
             } elseif (preg_match("/LIFE HISTORY\\:(.*?)<a name\\=\"PREFERRED HABITAT\"/ims", $html, $arr)) {
                 $life_history = $arr[1];
             }
             //http://www.fs.fed.us/database/feis/animals/mammal/neal/all.html
             if (isset($life_history)) {
                 $descriptions["LIFE HISTORY"] = $life_history;
             } else {
                 //animals
                 if (preg_match("/BIOLOGICAL DATA\\:(.*?)<a name\\=\"PreferredHabitat\"/ims", $html, $arr)) {
                     $biological_data = $arr[1];
                     $descriptions["BIOLOGICAL DATA"] = $biological_data;
                 }
             }
         }
         if (preg_match("/DIET\\:(.*?)<a name\\=\"PreferredHabitat\"/ims", $html, $arr)) {
             $descriptions["DIET"] = $arr[1];
         }
         // http://www.fs.fed.us/database/feis/animals/bird/apco/all.html
         //animals
         if (preg_match("/DISEASES AND SOURCES OF MORTALITY\\:(.*?)<a name\\=\"PreferredHabitat\"/ims", $html, $arr) || preg_match("/DISEASES AND SOURCES OF MORTALITY\\:(.*?)<a name\\=\"Preferred Habitat\"/ims", $html, $arr)) {
             $diseases = $arr[1];
             $descriptions["DISEASES AND SOURCES OF MORTALITY"] = $diseases;
         }
         //animals
         $html = str_ireplace("<b>TIMING OF MAJOR LIFE HISTORY EVENTS :", "<b>TIMING OF MAJOR LIFE HISTORY EVENTS:", $html);
         if (preg_match("/TIMING OF MAJOR LIFE HISTORY EVENTS\\:(.*?)<a name\\=\"PREFERRED HABITAT\"/ims", $html, $arr) || preg_match("/TIMING OF MAJOR LIFE HISTORY EVENTS\\:(.*?)<b>PREFERRED HABITAT/ims", $html, $arr)) {
             $major_life_history = $arr[1];
             $descriptions["TIMING OF MAJOR LIFE HISTORY EVENTS"] = $major_life_history;
         }
         //animals
         $html = str_ireplace("<b>PREFERRED HABITAT :", "<b>PREFERRED HABITAT:", $html);
         if (preg_match("/PREFERRED HABITAT\\:(.*?)<a name\\=\"COVER REQUIREMENTS\"/ims", $html, $arr) || preg_match("/PREFERRED HABITAT\\:(.*?)<a name\\=\"COVERREQUIREMENTS\"/ims", $html, $arr) || preg_match("/PREFERRED HABITAT\\:(.*?)<a name\\=\"FoodHabits\"/ims", $html, $arr) || preg_match("/PREFERRED HABITAT\\:(.*?)<a name\\=\"Food Habits\"/ims", $html, $arr) || preg_match("/PREFERRED HABITAT\\:(.*?)<b>COVER REQUIREMENTS/ims", $html, $arr) || preg_match("/PREFERRED HABITAT\\:(.*?)<a name\\=\"ManagementConsiderations\"/ims", $html, $arr)) {
             $pref_habitat = $arr[1];
         }
         if (isset($pref_habitat)) {
             $descriptions["PREFERRED HABITAT"] = $pref_habitat;
         }
         if (!is_numeric(stripos(@$descriptions["PREFERRED HABITAT"], "Cover requirements:"))) {
             //animals
             $html = str_ireplace("<b>COVER REQUIREMENTS :", "<b>COVER REQUIREMENTS:", $html);
             if (preg_match("/COVER REQUIREMENTS\\:(.*?)<a name\\=\"FOOD HABITS\"/ims", $html, $arr) || preg_match("/COVER REQUIREMENTS\\:(.*?)<b>FOOD HABITS/ims", $html, $arr) || preg_match("/<a name\\=\"CoverRequirements\">(.*?)<a name\\=\"FOODHABITS\"/ims", $html, $arr)) {
                 $cover_req = $arr[1];
                 $descriptions["COVER REQUIREMENTS"] = $cover_req;
             }
         }
         //animals
         $html = str_ireplace("<b>FOOD HABITS :", "<b>FOOD HABITS:", $html);
         // 1 of 2
         if (preg_match("/FOOD HABITS\\:(.*?)<a name\\=\"PREDATORS\"/ims", $html, $arr) || preg_match("/FOOD HABITS\\:(.*?)<a name\\=\"FederalLegalStatus\"/ims", $html, $arr) || preg_match("/FOOD HABITS\\:(.*?)<a name\\=\"Federal Legal Status\"/ims", $html, $arr) || preg_match("/FOOD HABITS\\:(.*?)<a name\\=\"Management Considerations\"/ims", $html, $arr) || preg_match("/FOOD HABITS\\:(.*?)<b>PREDATORS/ims", $html, $arr)) {
             $food_habits = $arr[1];
             $descriptions["FOOD HABITS"] = $food_habits;
         }
         //animals
         if (preg_match("/FEDERAL LEGAL STATUS\\:(.*?)<a name\\=\"OtherStatus\"/ims", $html, $arr)) {
             $federal_legal_stat = $arr[1];
         } elseif (preg_match("/FEDERAL LEGAL STATUS\\:(.*?)<a name\\=\"Other Status\"/ims", $html, $arr)) {
             $federal_legal_stat = $arr[1];
         } elseif (preg_match("/FEDERAL LEGAL STATUS\\:(.*?)<b>OTHER STATUS:/ims", $html, $arr)) {
             $federal_legal_stat = $arr[1];
         }
         if (isset($federal_legal_stat)) {
             $descriptions["FEDERAL LEGAL STATUS"] = $federal_legal_stat;
         }
         //animals
         if (preg_match("/OTHER STATUS\\:(.*?)<a name\\=\"ManagementConsiderations\"/ims", $html, $arr)) {
             $descriptions["OTHER STATUS"] = $arr[1];
         }
         if (!is_numeric(stripos(@$descriptions["DISEASES AND SOURCES OF MORTALITY"], "Predators:")) && !is_numeric(stripos(@$descriptions["Life span and survival"], "Predators:"))) {
             //animals
             $html = str_ireplace("<b>PREDATORS :", "<b>PREDATORS:", $html);
             if (preg_match("/PREDATORS\\:(.*?)<a name\\=\"MANAGEMENT CONSIDERATIONS\"/ims", $html, $arr) || preg_match("/PREDATORS\\:(.*?)<b>MANAGEMENT CONSIDERATIONS/ims", $html, $arr) || preg_match("/PREDATORS\\:(.*?)<a name\\=\"federallegalstatus\"/ims", $html, $arr)) {
                 $predators = $arr[1];
             }
             if (isset($predators)) {
                 $descriptions["PREDATORS"] = $predators;
             }
         }
         //animals
         $html = str_ireplace("MANAGEMENT CONSIDERATIONS :", "MANAGEMENT CONSIDERATIONS:", $html);
         if (preg_match("/MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"FIRE EFFECTS AND USE\"/ims", $html, $arr) || preg_match("/MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"FIRE EFFECTS\"/ims", $html, $arr) || preg_match("/MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"FireEffectsAndManagement\"/ims", $html, $arr) || preg_match("/MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"Fire Effects And Management\"/ims", $html, $arr) || preg_match("/<b>MANAGEMENT CONSIDERATIONS\\:(.*?)<b>REFERENCES/ims", $html, $arr)) {
             $descriptions["MANAGEMENT CONSIDERATIONS"] = $arr[1];
         }
         //animals
         $html = str_ireplace("<b>DIRECT FIRE EFFECTS ON ANIMALS :", "<b>DIRECT FIRE EFFECTS ON ANIMALS:", $html);
         if (preg_match("/DIRECT FIRE EFFECTS ON ANIMAL\\:(.*?)<a name\\=\"HABITAT RELATED FIRE EFFECTS\"/ims", $html, $arr) || preg_match("/DIRECT FIRE EFFECTS ON ANIMALS\\:(.*?)<b>HABITAT RELATED FIRE EFFECTS/ims", $html, $arr) || preg_match("/DIRECT FIRE EFFECTS\\:(.*?)<a name\\=\"IndirectFireEffects\"/ims", $html, $arr) || preg_match("/DIRECT FIRE EFFECTS\\:(.*?)<a name\\=\"Indirect Fire Effects\"/ims", $html, $arr) || preg_match("/DIRECT FIRE EFFECTS ON ANIMALS\\:(.*?)<a name\\=\"HABITAT-RELATED FIRE EFFECTS\"/ims", $html, $arr)) {
             $descriptions["DIRECT FIRE EFFECTS ON ANIMAL"] = $arr[1];
         }
         if (preg_match("/INDIRECT FIRE EFFECTS\\:(.*?)<a name\\=\"FireRegimes\"/ims", $html, $arr) || preg_match("/INDIRECT FIRE EFFECTS\\:(.*?)<a name\\=\"Fire Regimes\"/ims", $html, $arr)) {
             $descriptions["INDIRECT FIRE EFFECTS"] = $arr[1];
         }
         if (preg_match("/FUELS AND FIRE REGIMES\\:(.*?)<a name\\=\"FIRE MANAGEMENT CONSIDERATIONS/ims", $html, $arr)) {
             $fuels_and_fire_regimes = $arr[1];
         } elseif (preg_match("/FUELS AND FIRE REGIMES\\:(.*?)<a name\\=\"FireManagementConsiderations\"/ims", $html, $arr)) {
             $fuels_and_fire_regimes = $arr[1];
         }
         if (isset($fuels_and_fire_regimes)) {
             $descriptions["FUELS AND FIRE REGIMES"] = $fuels_and_fire_regimes;
         }
         //animals
         $html = str_ireplace("<b>HABITAT RELATED FIRE EFFECTS :", "<b>HABITAT RELATED FIRE EFFECTS:", $html);
         if (preg_match("/HABITAT RELATED FIRE EFFECTS\\:(.*?)<a name\\=\"FIRE USE\"/ims", $html, $arr) || preg_match("/HABITAT RELATED FIRE EFFECTS\\:(.*?)<b>FIRE USE/ims", $html, $arr) || preg_match("/Habitat-related Fire Effects\\:(.*?)<a name\\=\"FIRE USE\"/ims", $html, $arr) || preg_match("/Habitat-related Fire Effects\\:(.*?)<b>FIRE USE/ims", $html, $arr)) {
             $habitat_related = $arr[1];
         } elseif (preg_match("/HABITAT-RELATED FIRE EFFECTS\\:(.*?)<a name\\=\"FIRE MANAGEMENT CONSIDERATIONS\"/ims", $html, $arr) || preg_match("/HABITAT RELATED FIRE EFFECTS\\:(.*?)<a name\\=\"FIRE MANAGEMENT CONSIDERATIONS\"/ims", $html, $arr)) {
             $habitat_related = $arr[1];
         }
         if (isset($habitat_related)) {
             $descriptions["HABITAT RELATED FIRE EFFECTS"] = $habitat_related;
         }
         //animals
         $html = str_ireplace("<b>FIRE USE :", "<b>FIRE USE:", $html);
         if (preg_match("/FIRE USE\\:(.*?)<b>REFERENCES/ims", $html, $arr)) {
             $fire_use1 = trim($arr[1]);
         }
         if (preg_match("/FIRE USE\\:(.*?)<a name\\=\"REFERENCES\"/ims", $html, $arr)) {
             $fire_use2 = trim($arr[1]);
         }
         if (isset($fire_use1) && isset($fire_use2)) {
             $fire_use = $fire_use1;
             if (strlen($fire_use2) < strlen($fire_use)) {
                 $fire_use = $fire_use2;
             }
             $descriptions["FIRE USE"] = $fire_use;
         } elseif (isset($fire_use1)) {
             $descriptions["FIRE USE"] = $fire_use1;
         } elseif (isset($fire_use2)) {
             $descriptions["FIRE USE"] = $fire_use2;
         }
     }
     //if($rec["kingdom"] == "Animalia")
     /* MANAGEMENT CONSIDERATIONS */
     if (preg_match("/WOOD PRODUCTS VALUE \\:(.*?)<b>IMPORTANCE TO LIVESTOCK/ims", $html, $arr) || preg_match("/WOOD PRODUCTS VALUE \\:(.*?)<b>IMPORTANCE TO WILDLIFE/ims", $html, $arr)) {
         $descriptions["WOOD PRODUCTS VALUE"] = $arr[1];
     }
     if (preg_match("/IMPORTANCE TO LIVESTOCK AND WILDLIFE \\:(.*?)<b>PALATABILITY/ims", $html, $arr) || preg_match("/IMPORTANCE TO WILDLIFE AND LIVESTOCK\\:(.*?)<a name\\=\"Palatability/ims", $html, $arr) || preg_match("/IMPORTANCE TO WILDLIFE AND LIVESTOCK\\:(.*?)<a name\\=\"VALUE FOR REHABILITATION OF DISTURBED SITES/ims", $html, $arr) || preg_match("/IMPORTANCE TO LIVESTOCK AND WILDLIFE\\:(.*?)<a name\\=\"VALUE FOR REHABILITATION OF DISTURBED SITES/ims", $html, $arr) || preg_match("/IMPORTANCE TO LIVESTOCK AND WILDLIFE\\:(.*?)<a name\\=\"OTHER USES/ims", $html, $arr)) {
         $impt_livestock = $arr[1];
         $descriptions["IMPORTANCE TO LIVESTOCK AND WILDLIFE"] = $impt_livestock;
     }
     if (preg_match("/PALATABILITY \\:(.*?)<b>NUTRITIONAL VALUE/ims", $html, $arr)) {
         $palatability = $arr[1];
         $descriptions["PALATABILITY"] = $palatability;
     }
     if (preg_match("/PALATABILITY\\/NUTRITIONAL VALUE \\:(.*?)<b>COVER VALUE/ims", $html, $arr)) {
         $palatability_and_nutritional = $arr[1];
     } elseif (preg_match("/PALATABILITY AND NUTRITIONAL VALUE \\:(.*?)<b>COVER VALUE/ims", $html, $arr)) {
         $palatability_and_nutritional = $arr[1];
     } elseif (preg_match("/PALATABILITY AND NUTRITIONAL VALUE\\:(.*?)<a name\\=\"CoverValue\"/ims", $html, $arr)) {
         $palatability_and_nutritional = $arr[1];
     }
     if (isset($palatability_and_nutritional)) {
         $descriptions["PALATABILITY AND NUTRITIONAL VALUE"] = $palatability_and_nutritional;
     }
     if (preg_match("/NUTRITIONAL VALUE \\:(.*?)<b>COVER VALUE/ims", $html, $arr)) {
         $nutritional_value = $arr[1];
         $descriptions["NUTRITIONAL VALUE"] = $nutritional_value;
     }
     if (preg_match("/COVER VALUE \\:(.*?)<b>VALUE FOR REHABILITATION/ims", $html, $arr)) {
         $cover_value = $arr[1];
     } elseif (preg_match("/Cover Value for Wildlife \\:(.*?)<b>VALUE FOR REHABILITATION/ims", $html, $arr)) {
         $cover_value = $arr[1];
     }
     if (isset($cover_value)) {
         $descriptions["COVER VALUE"] = $cover_value;
     }
     if (preg_match("/VALUE FOR REHABILITATION OF DISTURBED SITES \\:(.*?)<b>OTHER USES/ims", $html, $arr)) {
         $rehabilitation_value = $arr[1];
     } elseif (preg_match("/VALUE FOR REHABILITATION OF DISTURBED SITES\\:(.*?)<a name\\=\"OTHER USES/ims", $html, $arr)) {
         $rehabilitation_value = $arr[1];
     }
     if (isset($rehabilitation_value)) {
         $descriptions["VALUE FOR REHABILITATION OF DISTURBED SITES"] = $rehabilitation_value;
     }
     if (preg_match("/OTHER USES AND VALUES \\:(.*?)<b>OTHER MANAGEMENT/ims", $html, $arr)) {
         $other_uses = $arr[1];
     } elseif (preg_match("/OTHER USES\\:(.*?)<a name\\=\"OTHER MANAGEMENT CONSIDERATIONS/ims", $html, $arr)) {
         $other_uses = $arr[1];
     } elseif (preg_match("/OTHER USES\\:(.*?)<a name\\=\"Impacts\"/ims", $html, $arr)) {
         $other_uses = $arr[1];
     } elseif (preg_match("/OTHER USES\\:(.*?)<a name\\=\"IMPACTS AND CONTROL\"/ims", $html, $arr)) {
         $other_uses = $arr[1];
     }
     if (isset($other_uses)) {
         $descriptions["OTHER USES AND VALUES"] = $other_uses;
     }
     if (preg_match("/IMPACTS\\:(.*?)<a name\\=\"Control\"/ims", $html, $arr)) {
         $impacts = $arr[1];
     }
     if (isset($impacts)) {
         $descriptions["IMPACTS"] = $impacts;
     }
     if (preg_match("/CONTROL\\:(.*?)<a name\\=\"AppendixFireRegimeTable\"/ims", $html, $arr)) {
         $control = $arr[1];
     }
     if (isset($control)) {
         $descriptions["CONTROL"] = $control;
     }
     if (preg_match("/IMPACTS AND CONTROL\\:(.*?)<a name\\=\"REFERENCES\"/ims", $html, $arr)) {
         $impacts_and_control = $arr[1];
     }
     if (isset($impacts_and_control)) {
         $descriptions["IMPACTS AND CONTROL"] = $impacts_and_control;
     }
     if (preg_match("/OTHER MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"BOTANICAL AND ECOLOGICAL/ims", $html, $arr)) {
         $other_management = $arr[1];
     } elseif (preg_match("/OTHER MANAGEMENT CONSIDERATIONS \\:(.*?)<a name\\=\"BOTANICAL AND ECOLOGICAL/ims", $html, $arr)) {
         $other_management = $arr[1];
     } elseif (preg_match("/OTHER MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"APPENDIX: FIRE REGIME TABLE/ims", $html, $arr)) {
         $other_management = $arr[1];
     } elseif (preg_match("/OTHER MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"REFERENCES\"/ims", $html, $arr)) {
         $other_management = $arr[1];
     }
     if (isset($other_management)) {
         $descriptions["OTHER MANAGEMENT CONSIDERATIONS"] = $other_management;
     }
     /* BOTANICAL AND ECOLOGICAL CHARACTERISTICS */
     if (preg_match("/GENERAL BOTANICAL CHARACTERISTICS \\:(.*?)<b>RAUNKIAER/ims", $html, $arr)) {
         $gen_botanical = $arr[1];
     } elseif (preg_match("/GENERAL BOTANICAL CHARACTERISTICS\\:(.*?)<a name\\=\"RAUNKIAER LIFE FORM/ims", $html, $arr)) {
         $gen_botanical = $arr[1];
     } elseif (preg_match("/GENERAL BOTANICAL CHARACTERISTICS\\:(.*?)<a name\\=\"SeasonalDevelopment\"/ims", $html, $arr)) {
         $gen_botanical = $arr[1];
     }
     if (isset($gen_botanical)) {
         $descriptions["GENERAL BOTANICAL CHARACTERISTICS"] = $gen_botanical;
     }
     if (!is_numeric(stripos(@$descriptions["GENERAL BOTANICAL CHARACTERISTICS"], "Raunkiaer"))) {
         if (preg_match("/RAUNKIAER LIFE FORM \\:(.*?)<b>REGENERATION/ims", $html, $arr)) {
             $raunkiaer_lifeform = $arr[1];
         } elseif (preg_match("/<a name\\=\"RAUNKIAER LIFE FORM\">(.*?)<a name\\=\"REGENERATION PROCESSES\"/ims", $html, $arr)) {
             $raunkiaer_lifeform = $arr[1];
         }
         if (isset($raunkiaer_lifeform)) {
             $descriptions["RAUNKIAER LIFE FORM"] = $raunkiaer_lifeform;
         }
     }
     if (preg_match("/REGENERATION PROCESSES \\:(.*?)<b>SITE CHARACTERISTICS/ims", $html, $arr)) {
         $regene_proc = $arr[1];
     } elseif (preg_match("/REGENERATION PROCESSES\\:(.*?)<a name\\=\"SITE CHARACTERISTICS/ims", $html, $arr)) {
         $regene_proc = $arr[1];
     } elseif (preg_match("/REGENERATION PROCESSES\\:(.*?)<a name\\=\"SiteCharacteristics\"/ims", $html, $arr)) {
         $regene_proc = $arr[1];
     }
     if (isset($regene_proc)) {
         $descriptions["REGENERATION PROCESSES"] = $regene_proc;
     }
     if (preg_match("/SITE CHARACTERISTICS \\:(.*?)<b>SUCCESSIONAL STATUS/ims", $html, $arr)) {
         $site_char = $arr[1];
     } elseif (preg_match("/SITE CHARACTERISTICS\\:(.*?)<a name\\=\"SUCCESSIONAL STATUS/ims", $html, $arr)) {
         $site_char = $arr[1];
     } elseif (preg_match("/SITE CHARACTERISTICS\\:(.*?)<a name\\=\"SuccessionalStatus\"/ims", $html, $arr)) {
         $site_char = $arr[1];
     }
     if (isset($site_char)) {
         $descriptions["SITE CHARACTERISTICS"] = $site_char;
     }
     if (preg_match("/SUCCESSIONAL STATUS \\:(.*?)<b>SEASONAL DEVELOPMENT/ims", $html, $arr)) {
         $successional_stat = $arr[1];
     } elseif (preg_match("/SUCCESSIONAL STATUS\\:(.*?)<a name\\=\"SEASONAL DEVELOPMENT/ims", $html, $arr)) {
         $successional_stat = $arr[1];
     } elseif (preg_match("/SUCCESSIONAL STATUS\\:(.*?)<a name\\=\"SeasonalDevelopment\"/ims", $html, $arr)) {
         $successional_stat = $arr[1];
     } elseif (preg_match("/SUCCESSIONAL STATUS\\:(.*?)<a name\\=\"FireEffectsAndManagement\"/ims", $html, $arr)) {
         $successional_stat = $arr[1];
     }
     if (isset($successional_stat)) {
         $descriptions["SUCCESSIONAL STATUS"] = $successional_stat;
     }
     $html = str_ireplace("SEASONAL DEVELOPMENT :", "SEASONAL DEVELOPMENT:", $html);
     if (preg_match("/SEASONAL DEVELOPMENT\\:(.*?)<a name\\=\"FIRE ECOLOGY/ims", $html, $arr)) {
         $seasonal_dev = $arr[1];
     } elseif (preg_match("/SEASONAL DEVELOPMENT\\:(.*?)<a name\\=\\'FIRE EFFECTS AND MANAGEMENT/ims", $html, $arr)) {
         $seasonal_dev = $arr[1];
     } elseif (preg_match("/SEASONAL DEVELOPMENT\\:(.*?)<a name\\=\"RegenerationProcesses\"/ims", $html, $arr)) {
         $seasonal_dev = $arr[1];
     }
     if (isset($seasonal_dev)) {
         $descriptions["SEASONAL DEVELOPMENT"] = $seasonal_dev;
     }
     /* FIRE EFFECTS AND MANAGEMENT  */
     if (preg_match("/FIRE EFFECTS\\:(.*?)<a name\\=\"FUELS AND FIRE REGIMES/ims", $html, $arr)) {
         $fire_effects = $arr[1];
     } elseif (preg_match("/FIRE EFFECTS\\:(.*?)<a name\\=\"FuelsAndFireRegimes\"/ims", $html, $arr)) {
         $fire_effects = $arr[1];
     }
     if (isset($fire_effects)) {
         $descriptions["FIRE EFFECTS"] = $fire_effects;
     }
     /* FIRE ECOLOGY */
     if (preg_match("/FIRE ECOLOGY OR ADAPTATIONS \\:(.*?)<b>POSTFIRE REGENERATION/ims", $html, $arr)) {
         $fire_ecology = $arr[1];
     } elseif (preg_match("/FIRE ECOLOGY OR ADAPTATIONS\\:(.*?)<a name\\=\"POSTFIRE REGENERATION/ims", $html, $arr)) {
         $fire_ecology = $arr[1];
     } elseif (preg_match("/FIRE ECOLOGY OR ADAPTATIONS\\:(.*?)<a name\\=\"PostfireRegeneration/ims", $html, $arr)) {
         $fire_ecology = $arr[1];
     }
     if (isset($fire_ecology)) {
         $descriptions["FIRE ECOLOGY OR ADAPTATIONS"] = $fire_ecology;
     }
     $html = str_ireplace("POSTFIRE REGENERATION STRATEGY :", "POSTFIRE REGENERATION STRATEGY:", $html);
     if (preg_match("/POSTFIRE REGENERATION STRATEGY\\:(.*?)<a name\\=\"FIRE EFFECTS/ims", $html, $arr)) {
         $postfire_rege = $arr[1];
     } elseif (preg_match("/<a name\\=\"POSTFIRE REGENERATION STRATEGY\">(.*?)<a name\\=\"FIRE EFFECTS/ims", $html, $arr)) {
         $postfire_rege = $arr[1];
     } elseif (preg_match("/<a name\\=\"POSTFIRE REGENERATION STRATEGY\">(.*?)<a name\\=\"FIREEFFECTS/ims", $html, $arr)) {
         $postfire_rege = $arr[1];
     }
     if (isset($postfire_rege)) {
         $descriptions["POSTFIRE REGENERATION STRATEGY"] = $postfire_rege;
     }
     if (!is_numeric(stripos(@$descriptions["FUELS AND FIRE REGIMES"], "Fire regimes:")) && !is_numeric(stripos(@$descriptions["FIRE ECOLOGY OR ADAPTATIONS"], "Fire regimes:"))) {
         if (preg_match("/FIRE REGIMES\\:(.*?)<a name\\=\"FireManagementConsiderations\"/ims", $html, $arr) || preg_match("/FIRE REGIMES\\:(.*?)<a name\\=\"Fire Management Considerations\"/ims", $html, $arr)) {
             $descriptions["FIRE REGIMES"] = $arr[1];
         }
     }
     /* FIRE EFFECTS */
     if (preg_match("/IMMEDIATE FIRE EFFECT ON LICHEN\\:(.*?)<a name\\=\"DISCUSSION AND QUALIFICATION OF FIRE EFFECT/ims", $html, $arr)) {
         $imm_fire_effect_lichen = $arr[1];
     }
     if (isset($imm_fire_effect_lichen)) {
         $descriptions["IMMEDIATE FIRE EFFECT ON LICHEN"] = $imm_fire_effect_lichen;
     }
     if (preg_match("/LICHEN RESPONSE TO FIRE\\:(.*?)<a name\\=\"DISCUSSION AND QUALIFICATION OF LICHEN RESPONSE/ims", $html, $arr)) {
         $lichen_response_2fire = $arr[1];
     }
     if (isset($lichen_response_2fire)) {
         $descriptions["LICHEN RESPONSE TO FIRE"] = $lichen_response_2fire;
     }
     if (preg_match("/DISCUSSION AND QUALIFICATION OF LICHEN RESPONSE\\:(.*?)<a name\\=\"FIRE MANAGEMENT CONSIDERATIONS/ims", $html, $arr)) {
         $d_and_q_of_lichen_response = $arr[1];
     }
     if (isset($d_and_q_of_lichen_response)) {
         $descriptions["DISCUSSION AND QUALIFICATION OF LICHEN RESPONSE"] = $d_and_q_of_lichen_response;
     }
     if (preg_match("/IMMEDIATE FIRE EFFECT ON PLANT \\:(.*?)<b>DISCUSSION AND QUALIFICATION OF FIRE EFFECT/ims", $html, $arr)) {
         $immediate_fire_effect = $arr[1];
     } elseif (preg_match("/IMMEDIATE FIRE EFFECT ON PLANT\\:(.*?)<a name\\=\"DISCUSSION AND QUALIFICATION OF FIRE EFFECT/ims", $html, $arr)) {
         $immediate_fire_effect = $arr[1];
     }
     if (isset($immediate_fire_effect)) {
         $descriptions["IMMEDIATE FIRE EFFECT ON PLANT"] = $immediate_fire_effect;
     }
     if (preg_match("/DISCUSSION AND QUALIFICATION OF FIRE EFFECT \\:(.*?)<b>PLANT RESPONSE TO FIRE/ims", $html, $arr)) {
         $discussion_fire_effect = $arr[1];
     } elseif (preg_match("/DISCUSSION AND QUALIFICATION OF FIRE EFFECT\\:(.*?)<a name\\=\"PLANT RESPONSE TO FIRE/ims", $html, $arr)) {
         $discussion_fire_effect = $arr[1];
     } elseif (preg_match("/DISCUSSION AND QUALIFICATION OF FIRE EFFECT\\:(.*?)<a name\\=\"LICHEN RESPONSE TO FIRE/ims", $html, $arr)) {
         $discussion_fire_effect = $arr[1];
     }
     if (isset($discussion_fire_effect)) {
         $descriptions["DISCUSSION AND QUALIFICATION OF FIRE EFFECT"] = $discussion_fire_effect;
     }
     if (preg_match("/PLANT RESPONSE TO FIRE \\:(.*?)<b>DISCUSSION AND QUALIFICATION OF PLANT RESPONSE/ims", $html, $arr)) {
         $plant_response_2fire = $arr[1];
     } elseif (preg_match("/PLANT RESPONSE TO FIRE\\:(.*?)<a name\\=\"DISCUSSION AND QUALIFICATION OF PLANT RESPONSE/ims", $html, $arr)) {
         $plant_response_2fire = $arr[1];
     }
     if (isset($plant_response_2fire)) {
         $descriptions["PLANT RESPONSE TO FIRE"] = $plant_response_2fire;
     }
     if (preg_match("/DISCUSSION AND QUALIFICATION OF PLANT RESPONSE \\:(.*?)<b>FIRE MANAGEMENT CONSIDERATIONS/ims", $html, $arr)) {
         $discussion_plant_response = $arr[1];
     } elseif (preg_match("/DISCUSSION AND QUALIFICATION OF PLANT RESPONSE\\:(.*?)<a name\\=\"FIRE MANAGEMENT CONSIDERATIONS/ims", $html, $arr)) {
         $discussion_plant_response = $arr[1];
     }
     if (isset($discussion_plant_response)) {
         if (in_array($rec['url'], array("http://www.fs.fed.us/database/feis/plants/vine/smirot/all.html", "http://www.fs.fed.us/database/feis/plants/tree/tsucan/all.html", "http://www.fs.fed.us/database/feis/plants/tree/quevel/all.html", "http://www.fs.fed.us/database/feis/plants/tree/querub/all.html", "http://www.fs.fed.us/database/feis/plants/tree/quemar/all.html", "http://www.fs.fed.us/database/feis/plants/tree/quealb/all.html", "http://www.fs.fed.us/database/feis/plants/tree/pinvir/all.html", "http://www.fs.fed.us/database/feis/plants/tree/pinstr/all.html")) || is_numeric(stripos($html, "<!DOCTYPE html PUBLIC"))) {
             $discussion_plant_response = str_ireplace(array("<br>", "\n"), " ", $discussion_plant_response);
         }
         $descriptions["DISCUSSION AND QUALIFICATION OF PLANT RESPONSE"] = $discussion_plant_response;
     }
     if (preg_match("/FIRE MANAGEMENT CONSIDERATIONS \\:(.*?)<a name\\=\"FIRE CASE STUDIES/ims", $html, $arr)) {
         $fire_mgnt_considerations = $arr[1];
     } elseif (preg_match("/FIRE MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"AppendixFireRegimeTable/ims", $html, $arr)) {
         $fire_mgnt_considerations = $arr[1];
     } elseif (preg_match("/FIRE MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"Appendix: Fire Regime Table/ims", $html, $arr)) {
         $fire_mgnt_considerations = $arr[1];
     } elseif (preg_match("/FIRE MANAGEMENT CONSIDERATIONS \\:(.*?)<a name\\=\"REFERENCES/ims", $html, $arr)) {
         $fire_mgnt_considerations = $arr[1];
     } elseif (preg_match("/FIRE MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"REFERENCES/ims", $html, $arr)) {
         $fire_mgnt_considerations = $arr[1];
     } elseif (preg_match("/FIRE MANAGEMENT CONSIDERATIONS\\:(.*?)<a name\\=\"MANAGEMENT CONSIDERATIONS/ims", $html, $arr)) {
         $fire_mgnt_considerations = $arr[1];
     } elseif (preg_match("/FIRE CONSIDERATIONS\\:(.*?)<a name\\=\"AppendixFireRegimeTable/ims", $html, $arr)) {
         $fire_mgnt_considerations = $arr[1];
     } elseif (preg_match("/FIRE CONSIDERATIONS\\:(.*?)<a name\\=\"Appendix: Fire Regime Table/ims", $html, $arr)) {
         $fire_mgnt_considerations = $arr[1];
     }
     if (isset($fire_mgnt_considerations)) {
         $descriptions["FIRE MANAGEMENT CONSIDERATIONS"] = $fire_mgnt_considerations;
     }
     $link_text = "Follow this link to the U.S. Forest Service Fire Effects Information Service to see a table with fire regime information that may be relevant to habitats in which this species occurs";
     $link = false;
     if (preg_match("/<a name\\=\"APPENDIX: FIRE REGIME TABLE\">(.*?)/ims", $html, $arr)) {
         $link = $rec['url'] . "#APPENDIX: FIRE REGIME TABLE";
     } elseif (preg_match("/<a name\\=\"AppendixFireRegimeTable\">(.*?)/ims", $html, $arr)) {
         $link = $rec['url'] . "#AppendixFireRegimeTable";
     }
     if ($link) {
         $descriptions["APPENDIX: FIRE REGIME TABLE"] = "<a href='" . $link . "'>{$link_text}</a>";
     }
     /* FIRE CASE STUDIES */
     $html = str_ireplace("FIRE CASE STUDY CITATION :", "FIRE CASE STUDY CITATION:", $html);
     $html = str_ireplace("SEASON/SEVERITY CLASSIFICATION :", "SEASON/SEVERITY CLASSIFICATION:", $html);
     $html = str_ireplace("STUDY LOCATION :", "STUDY LOCATION:", $html);
     $html = str_ireplace("PREFIRE HABITAT :", "PREFIRE HABITAT:", $html);
     $html = str_ireplace("SITE DESCRIPTION :", "SITE DESCRIPTION:", $html);
     $html = str_ireplace("FIRE DESCRIPTION :", "FIRE DESCRIPTION:", $html);
     $html = str_ireplace("FIRE EFFECTS ON ANIMAL SPECIES AND HABITAT :", "FIRE EFFECTS ON ANIMAL SPECIES AND HABITAT:", $html);
     $html = str_ireplace("FIRE MANAGEMENT IMPLICATIONS :", "FIRE MANAGEMENT IMPLICATIONS:", $html);
     if (preg_match("/<b>FIRE CASE STUDY CITATION\\:(.*?)<b>FIRE CASE STUDY REFERENCE\\:/ims", $html, $arr)) {
         $descriptions["FIRE CASE STUDY CITATION"] = self::clean_str(strip_tags($arr[1]), true);
     }
     if (preg_match("/<b>FIRE CASE STUDY REFERENCE\\:(.*?)<b>SEASON\\/SEVERITY CLASSIFICATION\\:/ims", $html, $arr)) {
         $descriptions["FIRE CASE STUDY REFERENCE"] = self::clean_str(strip_tags($arr[1]), true);
     }
     if (preg_match("/<b>SEASON\\/SEVERITY CLASSIFICATION\\:(.*?)<b>STUDY LOCATION\\:/ims", $html, $arr)) {
         $descriptions["SEASON/SEVERITY CLASSIFICATION"] = $arr[1];
     }
     if (preg_match("/<b>STUDY LOCATION\\:(.*?)<b>PREFIRE HABITAT\\:/ims", $html, $arr)) {
         $descriptions["STUDY LOCATION"] = $arr[1];
     }
     if (preg_match("/<b>PREFIRE HABITAT\\:(.*?)<b>SITE DESCRIPTION\\:/ims", $html, $arr)) {
         $descriptions["PREFIRE HABITAT"] = $arr[1];
     }
     if (preg_match("/<b>SITE DESCRIPTION\\:(.*?)<b>FIRE DESCRIPTION\\:/ims", $html, $arr)) {
         $descriptions["SITE DESCRIPTION"] = $arr[1];
     }
     if (preg_match("/<b>FIRE DESCRIPTION\\:(.*?)<b>FIRE EFFECTS ON ANIMAL SPECIES AND HABITAT\\:/ims", $html, $arr)) {
         $descriptions["FIRE DESCRIPTION"] = $arr[1];
     }
     if (preg_match("/<b>FIRE EFFECTS ON ANIMAL SPECIES AND HABITAT\\:(.*?)<b>FIRE MANAGEMENT IMPLICATIONS\\:/ims", $html, $arr)) {
         $descriptions["FIRE EFFECTS ON ANIMAL SPECIES AND HABITAT"] = $arr[1];
     }
     if (preg_match("/<b>FIRE MANAGEMENT IMPLICATIONS\\:(.*?)<a name\\=\"REFERENCES\"/ims", $html, $arr)) {
         $descriptions["FIRE MANAGEMENT IMPLICATIONS"] = $arr[1];
     }
     $rec['texts'] = $descriptions;
     return $rec;
 }
Пример #17
0
 public function check_if_with_content($phylum, $taxid, $dc_source, $barcode_image_url = false, $with_stats, $public_barcodes)
 {
     $src = self::BOLDS_DOMAIN_NEW . "/connect/REST/getBarcodeRepForSpecies.php?taxid=" . $taxid . "&iwidth=400";
     if ($barcode_image_url || self::barcode_image_available($src)) {
         $description = "The following is a representative barcode sequence, the centroid of all available sequences for this species.<br><a target='barcode' href='{$src}'><img src='{$src}' height=''></a>";
     } else {
         $description = "Barcode image not yet available.";
     }
     $description .= "<br><br>";
     if (!in_array($phylum, $this->phylum_without_sequence)) {
         //start get text dna sequece
         /* replaced
            $url = self::BOLDS_DOMAIN . "/pcontr.php?action=doPublicSequenceDownload&taxids=$taxid";
            $arr = self::get_text_dna_sequence($url);
            */
         $arr = $this->get_text_dna_sequence_v2($taxid);
         $count_sequence = $arr["count_sequence"];
         $text_dna_sequence = $arr["best_sequence"];
         // $url_fasta_file     = $arr["url_fasta_file"]; this will point to the fasta.fas file from BOLDS temp folder
         echo "\n[{$public_barcodes}]=[{$count_sequence}]\n";
         $str = "";
         if ($count_sequence > 0) {
             if ($count_sequence == 1) {
                 $str = "There is 1 barcode sequence available from BOLD and GenBank. \n                                         Below is the sequence of the barcode region Cytochrome oxidase subunit 1 (COI or COX1) from a member of the species.\n                                         See the <a target='BOLDSys' href='{$dc_source}'>BOLD taxonomy browser</a> for more complete information about this specimen.\n                                         Other sequences that do not yet meet barcode criteria may also be available.";
             } else {
                 $str = "There are {$count_sequence} barcode sequences available from BOLD and GenBank.\n                                         Below is a sequence of the barcode region Cytochrome oxidase subunit 1 (COI or COX1) from a member of the species.\n                                         See the <a target='BOLDSys' href='{$dc_source}'>BOLD taxonomy browser</a> for more complete information about this specimen and other sequences.";
             }
             $str .= "<br><br>";
             $text_dna_sequence .= "<br>-- end --<br>";
         }
         if (trim($text_dna_sequence) != "") {
             $temp = "{$str} ";
             $temp .= "<div style='font-size : x-small;overflow : scroll;'> {$text_dna_sequence} </div>";
         } else {
             $temp = "No available public DNA sequences. <br>";
         }
         if ($count_sequence > 0 || $with_stats) {
             /* one-click         
                $url_fasta_file = "http://services.eol.org/eol_php_code/applications/barcode/get_text_dna_sequence.php?taxid=$taxid";
                */
             /* 2-click per PL advice */
             $url_fasta_file = self::BOLDS_DOMAIN . "/pcontr.php?action=doPublicSequenceDownload&taxids={$taxid}";
             $temp .= "<br><a target='fasta' href='{$url_fasta_file}'>Download FASTA File</a>";
         }
         $description .= $temp;
         //end get text dna sequence
     } else {
         echo "\n this phylum is non-animal: [{$phylum}]";
     }
     if (is_numeric(stripos("Barcode image not yet available.", $description)) && is_numeric(stripos("No available public DNA sequences.", $description)) && !is_numeric(stripos("Download FASTA File", $description))) {
         return false;
     }
     if (Functions::is_utf8($description)) {
         return $description;
     } else {
         return false;
     }
 }
 public static function is_utf8($v)
 {
     $v = trim($v);
     if (!$v) {
         return true;
     }
     $return = Functions::is_utf8($v);
     return $return;
 }