示例#1
0
 public function __construct($id = null, $conType = 'readonly')
 {
     $this->conn = MySQLiConnectionFactory::getCon($conType);
     if ($id != null || is_numeric($id)) {
         $this->id = $id;
     }
 }
示例#2
0
 function __construct()
 {
     $this->conn = MySQLiConnectionFactory::getCon('write');
     if ($this->conn === false) {
         exit("ABORT: Image upload aborted: Unable to establish connection to database");
     }
 }
 function __construct($id)
 {
     $this->conn = MySQLiConnectionFactory::getCon("write");
     if (is_numeric($id)) {
         $this->clid = $id;
     }
 }
 public function __construct()
 {
     $this->con = MySQLiConnectionFactory::getCon("readonly");
     //Default settings
     $this->taxAuthId = 1;
     //0 = do not resolve taxonomy (no thesaurus); 1 = default taxonomy; > 1 = other taxonomies
 }
示例#5
0
 function __construct()
 {
     set_time_limit(2000);
     $this->conn = MySQLiConnectionFactory::getCon("write");
     $this->setUploadTargetPath();
     $this->targetArr = array('url', 'originalUrl', 'scientificName', 'tid', 'photographer', 'photographerUid', 'caption', 'locality', 'sourceUrl', 'anatomy', 'notes', 'owner', 'copyright', 'sortSequence', 'institutionCode', 'collectionCode', 'catalogNumber', 'occid');
 }
示例#6
0
 function __construct()
 {
     $this->conn = MySQLiConnectionFactory::getCon("write");
     $this->setUploadTargetPath();
     set_time_limit(3000);
     ini_set("max_input_time", 120);
     ini_set('auto_detect_line_endings', true);
 }
示例#7
0
 public function __construct($con = null)
 {
     if ($con) {
         //Inherits connection from another class
         $this->conn = $con;
     } else {
         $this->conn = MySQLiConnectionFactory::getCon("write");
     }
 }
示例#8
0
 public function editMetaData()
 {
     $setSql = "";
     $con = MySQLiConnectionFactory::getCon("write");
     $sql = 'UPDATE omsurveys SET ' . 'projectname = ' . ($_POST['projectname'] ? '"' . $this->cleanInStr(trim($_POST['projectname'])) . '"' : 'NULL') . ', ' . 'managers = ' . ($_POST['managers'] ? '"' . $this->cleanInStr(trim($_POST['managers'])) . '"' : 'NULL') . ', ' . 'locality = ' . ($_POST['locality'] ? '"' . $this->cleanInStr(trim($_POST['locality'])) . '"' : 'NULL') . ', ' . 'notes = ' . ($_POST['notes'] ? '"' . $this->cleanInStr(trim($_POST['notes'])) . '"' : 'NULL') . ', ' . 'latcentroid = ' . ($_POST['latcentroid'] ? $this->cleanInStr($_POST['latcentroid']) : 'NULL') . ', ' . 'longcentroid = ' . ($_POST['longcentroid'] ? $this->cleanInStr($_POST['longcentroid']) : 'NULL') . ', ' . 'ispublic = ' . ($_POST['ispublic'] ? 1 : 0) . ' ' . 'WHERE (surveyid = ' . $this->surveyId . ')';
     //echo $sql;
     $con->query($sql);
     $con->close();
 }
 public function __construct()
 {
     global $defaultLang;
     $this->con = MySQLiConnectionFactory::getCon("readonly");
     //Default settings
     $this->taxAuthId = 1;
     //0 = do not resolve taxonomy (no thesaurus); 1 = default taxonomy; > 1 = other taxonomies
     //$this->projName = "Arizona";
     $this->language = $defaultLang;
 }
 public function __construct($conn = null)
 {
     if ($conn) {
         $this->conn = $conn;
         $this->isShareConn = true;
     } else {
         $this->conn = MySQLiConnectionFactory::getCon("write");
     }
     $this->occFieldArr = array('catalognumber', 'othercatalognumbers', 'occurrenceid', 'family', 'scientificname', 'sciname', 'tidinterpreted', 'scientificnameauthorship', 'identifiedby', 'dateidentified', 'identificationreferences', 'identificationremarks', 'taxonremarks', 'identificationqualifier', 'typestatus', 'recordedby', 'recordnumber', 'associatedcollectors', 'eventdate', 'year', 'month', 'day', 'startdayofyear', 'enddayofyear', 'verbatimeventdate', 'habitat', 'substrate', 'fieldnumber', 'occurrenceremarks', 'associatedtaxa', 'verbatimattributes', 'dynamicproperties', 'reproductivecondition', 'cultivationstatus', 'establishmentmeans', 'lifestage', 'sex', 'individualcount', 'samplingprotocol', 'preparations', 'country', 'stateprovince', 'county', 'municipality', 'locality', 'localitysecurity', 'localitysecurityreason', 'decimallatitude', 'decimallongitude', 'geodeticdatum', 'coordinateuncertaintyinmeters', 'footprintwkt', 'locationremarks', 'verbatimcoordinates', 'georeferencedby', 'georeferenceprotocol', 'georeferencesources', 'georeferenceverificationstatus', 'georeferenceremarks', 'minimumelevationinmeters', 'maximumelevationinmeters', 'verbatimelevation', 'disposition', 'language', 'duplicatequantity', 'genericcolumn1', 'genericcolumn2', 'labelproject', 'observeruid', 'basisofrecord', 'ownerinstitutioncode', 'datelastmodified', 'processingstatus', 'recordenteredby', 'dateentered');
 }
 public function __construct()
 {
     global $serverRoot, $userRights, $isAdmin;
     //ini_set('memory_limit','512M');
     set_time_limit(500);
     //Ensure that PHP DOMDocument class is installed
     if (!class_exists('DOMDocument')) {
         exit('FATAL ERROR: PHP DOMDocument class is not installed, please contact your server admin');
     }
     $this->conn = MySQLiConnectionFactory::getCon('readonly');
     $this->ts = time();
     $this->condAllowArr = array('country', 'stateprovince', 'county', 'recordedby', 'family', 'sciname', 'processingstatus', 'ocr');
     $this->coreFieldArr = array('id' => '', 'accessURI' => 'http://rs.tdwg.org/ac/terms/accessURI', 'providerManagedID' => 'http://rs.tdwg.org/ac/terms/providerManagedID', 'title' => 'http://purl.org/dc/terms/title', 'comments' => 'http://rs.tdwg.org/ac/terms/comments', 'Owner' => 'http://ns.adobe.com/xap/1.0/rights/Owner', 'rights' => 'http://purl.org/dc/terms/rights', 'UsageTerms' => 'http://ns.adobe.com/xap/1.0/rights/UsageTerms', 'WebStatement' => 'http://ns.adobe.com/xap/1.0/rights/WebStatement', 'MetadataDate' => 'http://ns.adobe.com/xap/1.0/MetadataDate', 'associatedSpecimenReference' => 'http://rs.tdwg.org/ac/terms/associatedSpecimenReference', 'type' => 'http://purl.org/dc/terms/type', 'subtype' => 'http://rs.tdwg.org/ac/terms/subtype', 'format' => 'http://purl.org/dc/terms/format', 'metadataLanguage' => 'http://rs.tdwg.org/ac/terms/metadataLanguage');
     $this->stubFieldArr = array('coreid' => '', 'institutionCode' => 'http://rs.tdwg.org/dwc/terms/institutionCode', 'collectionCode' => 'http://rs.tdwg.org/dwc/terms/collectionCode', 'occurrenceID' => 'http://rs.tdwg.org/dwc/terms/occurrenceID', 'catalogNumber' => 'http://rs.tdwg.org/dwc/terms/catalogNumber', 'otherCatalogNumbers' => 'http://rs.tdwg.org/dwc/terms/otherCatalogNumbers', 'family' => 'http://rs.tdwg.org/dwc/terms/family', 'scientificName' => 'http://rs.tdwg.org/dwc/terms/scientificName', 'scientificNameAuthorship' => 'http://rs.tdwg.org/dwc/terms/scientificNameAuthorship', 'genus' => 'http://rs.tdwg.org/dwc/terms/genus', 'specificEpithet' => 'http://rs.tdwg.org/dwc/terms/specificEpithet', 'taxonRank' => 'http://rs.tdwg.org/dwc/terms/taxonRank', 'infraspecificEpithet' => 'http://rs.tdwg.org/dwc/terms/infraspecificEpithet', 'identifiedBy' => 'http://rs.tdwg.org/dwc/terms/identifiedBy', 'dateIdentified' => 'http://rs.tdwg.org/dwc/terms/dateIdentified', 'identificationReferences' => 'http://rs.tdwg.org/dwc/terms/identificationReferences', 'identificationRemarks' => 'http://rs.tdwg.org/dwc/terms/identificationRemarks', 'taxonRemarks' => 'http://rs.tdwg.org/dwc/terms/taxonRemarks', 'identificationQualifier' => 'http://rs.tdwg.org/dwc/terms/identificationQualifier', 'typeStatus' => 'http://rs.tdwg.org/dwc/terms/typeStatus', 'recordedBy' => 'http://rs.tdwg.org/dwc/terms/recordedBy', 'recordNumber' => 'http://rs.tdwg.org/dwc/terms/recordNumber', 'eventDate' => 'http://rs.tdwg.org/dwc/terms/eventDate', 'year' => 'http://rs.tdwg.org/dwc/terms/year', 'month' => 'http://rs.tdwg.org/dwc/terms/month', 'day' => 'http://rs.tdwg.org/dwc/terms/day', 'startDayOfYear' => 'http://rs.tdwg.org/dwc/terms/startDayOfYear', 'endDayOfYear' => 'http://rs.tdwg.org/dwc/terms/endDayOfYear', 'verbatimEventDate' => 'http://rs.tdwg.org/dwc/terms/verbatimEventDate', 'habitat' => 'http://rs.tdwg.org/dwc/terms/habitat', 'substrate' => '', 'fieldNumber' => 'http://rs.tdwg.org/dwc/terms/fieldNumber', 'occurrenceRemarks' => 'http://rs.tdwg.org/dwc/terms/occurrenceRemarks', 'informationWithheld' => 'http://rs.tdwg.org/dwc/terms/informationWithheld', 'dynamicProperties' => 'http://rs.tdwg.org/dwc/terms/dynamicProperties', 'associatedTaxa' => 'http://rs.tdwg.org/dwc/terms/associatedTaxa', 'reproductiveCondition' => 'http://rs.tdwg.org/dwc/terms/reproductiveCondition', 'establishmentMeans' => 'http://rs.tdwg.org/dwc/terms/establishmentMeans', 'lifeStage' => 'http://rs.tdwg.org/dwc/terms/lifeStage', 'sex' => 'http://rs.tdwg.org/dwc/terms/sex', 'individualCount' => 'http://rs.tdwg.org/dwc/terms/individualCount', 'samplingProtocol' => 'http://rs.tdwg.org/dwc/terms/samplingProtocol', 'preparations' => 'http://rs.tdwg.org/dwc/terms/preparations', 'country' => 'http://rs.tdwg.org/dwc/terms/country', 'stateProvince' => 'http://rs.tdwg.org/dwc/terms/stateProvince', 'county' => 'http://rs.tdwg.org/dwc/terms/county', 'municipality' => 'http://rs.tdwg.org/dwc/terms/municipality', 'locality' => 'http://rs.tdwg.org/dwc/terms/locality', 'decimalLatitude' => 'http://rs.tdwg.org/dwc/terms/decimalLatitude', 'decimalLongitude' => 'http://rs.tdwg.org/dwc/terms/decimalLongitude', 'geodeticDatum' => 'http://rs.tdwg.org/dwc/terms/geodeticDatum', 'coordinateUncertaintyInMeters' => 'http://rs.tdwg.org/dwc/terms/coordinateUncertaintyInMeters', 'footprintWKT' => 'http://rs.tdwg.org/dwc/terms/footprintWKT', 'verbatimCoordinates' => 'http://rs.tdwg.org/dwc/terms/verbatimCoordinates', 'georeferencedBy' => 'http://rs.tdwg.org/dwc/terms/georeferencedBy', 'georeferenceProtocol' => 'http://rs.tdwg.org/dwc/terms/georeferenceProtocol', 'georeferenceSources' => 'http://rs.tdwg.org/dwc/terms/georeferenceSources', 'georeferenceVerificationStatus' => 'http://rs.tdwg.org/dwc/terms/georeferenceVerificationStatus', 'georeferenceRemarks' => 'http://rs.tdwg.org/dwc/terms/georeferenceRemarks', 'minimumElevationInMeters' => 'http://rs.tdwg.org/dwc/terms/minimumElevationInMeters', 'maximumElevationInMeters' => 'http://rs.tdwg.org/dwc/terms/maximumElevationInMeters', 'verbatimElevation' => 'http://rs.tdwg.org/dwc/terms/verbatimElevation', 'ocrOutput' => '', 'language' => 'http://purl.org/dc/terms/language', 'recordId' => 'http://portal.idigbio.org/terms/recordId');
     $this->securityArr = array('locality', 'minimumElevationInMeters', 'maximumElevationInMeters', 'verbatimElevation', 'decimalLatitude', 'decimalLongitude', 'geodeticDatum', 'coordinateUncertaintyInMeters', 'footprintWKT', 'verbatimCoordinates', 'georeferenceRemarks', 'georeferencedBy', 'georeferenceProtocol', 'georeferenceSources', 'georeferenceVerificationStatus', 'habitat', 'informationWithheld');
 }
示例#12
0
 public function __construct()
 {
     global $userRights, $isAdmin, $charset;
     $this->conn = MySQLiConnectionFactory::getCon('readonly');
     //Set rare species variables
     $this->securityArr = array('locality', 'locationRemarks', 'minimumElevationInMeters', 'maximumElevationInMeters', 'verbatimElevation', 'decimalLatitude', 'decimalLongitude', 'geodeticDatum', 'coordinateUncertaintyInMeters', 'footprintWKT', 'verbatimCoordinates', 'georeferenceRemarks', 'georeferencedBy', 'georeferenceProtocol', 'georeferenceSources', 'georeferenceVerificationStatus', 'habitat');
     if ($isAdmin || array_key_exists("CollAdmin", $userRights) || array_key_exists("RareSppAdmin", $userRights) || array_key_exists("RareSppReadAll", $userRights)) {
         $this->redactLocalities = false;
     }
     if (array_key_exists('CollEditor', $userRights)) {
         $this->rareReaderArr = $userRights['CollEditor'];
     }
     if (array_key_exists('RareSppReader', $userRights)) {
         $this->rareReaderArr = array_unique(array_merge($this->rareReaderArr, $userRights['RareSppReader']));
     }
     //Character set
     $this->charSetSource = strtoupper($charset);
     $this->charSetOut = $this->charSetSource;
 }
 public function __construct()
 {
     //Ensure that PHP DOMDocument class is installed
     if (!class_exists('DOMDocument')) {
         exit('FATAL ERROR: PHP DOMDocument class is not installed, please contact your server admin');
     }
     $this->conn = MySQLiConnectionFactory::getCon('readonly');
     $this->ts = time();
     if (!$this->logFH && $this->verbose) {
         $logFile = $GLOBALS['SERVER_ROOT'] . (substr($GLOBALS['SERVER_ROOT'], -1) == '/' ? '' : '/') . "temp/logs/DWCA_" . date('Y-m-d') . ".log";
         $this->logFH = fopen($logFile, 'a');
     }
     //Character set
     $this->charSetSource = strtoupper($GLOBALS['CHARSET']);
     $this->charSetOut = $this->charSetSource;
     $this->condAllowArr = array('catalognumber', 'othercatalognumbers', 'occurrenceid', 'family', 'sciname', 'country', 'stateprovince', 'county', 'municipality', 'recordedby', 'recordnumber', 'eventdate', 'decimallatitude', 'decimallongitude', 'minimumelevationinmeters', 'maximumelevationinmeters', 'datelastmodified', 'dateentered');
     $this->securityArr = array('eventDate', 'month', 'day', 'startDayOfYear', 'endDayOfYear', 'verbatimEventDate', 'recordNumber', 'locality', 'locationRemarks', 'minimumElevationInMeters', 'maximumElevationInMeters', 'verbatimElevation', 'decimalLatitude', 'decimalLongitude', 'geodeticDatum', 'coordinateUncertaintyInMeters', 'footprintWKT', 'verbatimCoordinates', 'georeferenceRemarks', 'georeferencedBy', 'georeferenceProtocol', 'georeferenceSources', 'georeferenceVerificationStatus', 'habitat', 'informationWithheld');
     //ini_set('memory_limit','512M');
     set_time_limit(500);
 }
示例#14
0
 public function __construct()
 {
     $this->conn = MySQLiConnectionFactory::getCon("write");
     $this->imageRootPath = $GLOBALS["imageRootPath"];
     if (substr($this->imageRootPath, -1) != "/") {
         $this->imageRootPath .= "/";
     }
     $this->imageRootUrl = $GLOBALS["imageRootUrl"];
     if (substr($this->imageRootUrl, -1) != "/") {
         $this->imageRootUrl .= "/";
     }
     if (array_key_exists('imgTnWidth', $GLOBALS)) {
         $this->tnPixWidth = $GLOBALS['imgTnWidth'];
     }
     if (array_key_exists('imgWebWidth', $GLOBALS)) {
         $this->webPixWidth = $GLOBALS['imgWebWidth'];
     }
     if (array_key_exists('imgFileSizeLimit', $GLOBALS)) {
         $this->webFileSizeLimit = $GLOBALS['imgFileSizeLimit'];
     }
 }
 public function __construct($collId = 0)
 {
     $this->collId = $collId;
     $this->conn = MySQLiConnectionFactory::getCon("write");
     $sql = 'SELECT collid, institutioncode, collectioncode, collectionname, colltype FROM omcollections ';
     if ($collId && is_numeric($collId)) {
         $sql .= 'WHERE (collid = ' . $collId . ')';
     } else {
         $sql .= 'WHERE (colltype = "General Observations")';
     }
     $rs = $this->conn->query($sql);
     if ($r = $rs->fetch_object()) {
         $this->collMap['collid'] = $r->collid;
         $this->collMap['institutioncode'] = $r->institutioncode;
         $this->collMap['collectioncode'] = $r->collectioncode;
         $this->collMap['collectionname'] = $this->cleanOutStr($r->collectionname);
         $this->collMap['colltype'] = $r->colltype;
         if (!$this->collId) {
             $this->collId = $r->collid;
         }
     }
     $rs->close();
 }
示例#16
0
 public function __construct()
 {
     $this->conn = MySQLiConnectionFactory::getCon("readonly");
     $this->displayedWordCount = 100;
     if ($GLOBALS['charset'] == 'ISO-8859-1') {
         $this->supportUtf8 = false;
     }
     $this->tagUrl = "http://www.google.com/search?hl=en&q=";
     $this->backgroundColor = "#000";
     $this->wordColors[0] = "#5122CC";
     $this->wordColors[1] = "#229926";
     $this->wordColors[2] = "#330099";
     $this->wordColors[3] = "#819922";
     $this->wordColors[4] = "#22CCC3";
     $this->wordColors[5] = "#99008D";
     $this->wordColors[6] = "#943131";
     $this->wordColors[7] = "#B23B3B";
     $this->wordColors[8] = "#229938";
     $this->wordColors[9] = "#419922";
     $commonWordStr = "a,able,about,across,after,all,almost,also,am,among,an,and,any,are,arent," . "as,at,be,because,been,but,by,can,cant,cannot,could,couldve,couldnt,dear,did,didnt,do,does,doesnt," . "dont,either,else,ever,every,for,from,get,got,had,has,hasnt,have,he,her,him,his,how,however," . "i,if,in,into,is,isnt,it,its,just,least,let,like,likely,may,me,might,most,must,my,neither,no,nor,not,of,off," . "often,on,only,or,other,our,own,rather,said,say,says,she,should,since,so,some,than,that," . "the,their,them,then,there,theres,these,they,this,to,too,us,wants,was,wasnt,we,were,werent,what," . "when,when,where,which,while,who,whom,why,will,with,wont,would,wouldve,wouldnt,yet,you,your";
     //$commonWordStr = strtolower($commonWordStr);
     $this->commonWordArr = explode(",", $commonWordStr);
 }
 public function deleteVoucher($occid, $clid)
 {
     $status = true;
     if (is_numeric($occid) && is_numeric($clid)) {
         $sql = 'DELETE FROM fmvouchers WHERE (occid = ' . $occid . ') AND (clid = ' . $clid . ') ';
         $con = MySQLiConnectionFactory::getCon("write");
         if (!$con->query($sql)) {
             $this->errorMessage = 'ERROR loading ' . $con->error;
             $status = false;
         }
         if (!($con === null)) {
             $con->close();
         }
     }
     return $status;
 }
示例#18
0
<?php

include_once '../../../config/symbini.php';
include_once $SERVER_ROOT . '/config/dbconnection.php';
$con = MySQLiConnectionFactory::getCon("readonly");
$q = $con->real_escape_string($_REQUEST['term']);
$taxAuthId = array_key_exists('taid', $_REQUEST) ? $con->real_escape_string($_REQUEST['taid']) : 0;
$rankLimit = array_key_exists('rlimit', $_REQUEST) ? $con->real_escape_string($_REQUEST['rlimit']) : 0;
$rankLow = array_key_exists('rlow', $_REQUEST) ? $con->real_escape_string($_REQUEST['rlow']) : 0;
$rankHigh = array_key_exists('rhigh', $_REQUEST) ? $con->real_escape_string($_REQUEST['rhigh']) : 0;
$returnArr = array();
$sqlWhere = '';
$sql = 'SELECT t.tid, t.sciname, t.author FROM taxa t ';
if ($taxAuthId) {
    $sql .= 'INNER JOIN taxstatus ts ON t.tid = ts.tid ';
    $sqlWhere .= 'AND ts.taxauthid = ' . $taxAuthId . ' ';
}
if ($q) {
    $sqlWhere .= 'AND t.sciname LIKE "' . $q . '%" ';
}
if ($rankLimit) {
    $sqlWhere .= 'AND (t.rankid = ' . $rankLimit . ') ';
} else {
    if ($rankLow) {
        $sqlWhere .= 'AND (t.rankid > ' . $rankLow . ' OR t.rankid IS NULL) ';
    }
    if ($rankHigh) {
        $sqlWhere .= 'AND (t.rankid < ' . $rankHigh . ' OR t.rankid IS NULL) ';
    }
}
if ($sqlWhere) {
示例#19
0
 function __construct()
 {
     $this->conn = MySQLiConnectionFactory::getCon("write");
 }
示例#20
0
 private function getConnection($type)
 {
     return MySQLiConnectionFactory::getCon($type);
 }
示例#21
0
 function __construct()
 {
     $this->relevanceValue = 0.9;
     $this->keyCon = MySQLiConnectionFactory::getCon("readonly");
     $this->sql = "";
 }
 public function __construct()
 {
     $this->taxonCon = MySQLiConnectionFactory::getCon("write");
 }
 function __construct()
 {
     $this->conn = MySQLiConnectionFactory::getCon("readonly");
     set_time_limit(7200);
 }
示例#24
0
 function __construct()
 {
     $this->conn = MySQLiConnectionFactory::getCon("readonly");
 }
示例#25
0
 private function getCollection()
 {
     return MySQLiConnectionFactory::getCon("write");
 }
示例#26
0
 protected function getConnection($conType = "readonly")
 {
     return MySQLiConnectionFactory::getCon($conType);
 }
示例#27
0
 function __construct()
 {
     set_time_limit(2000);
     $this->conn = MySQLiConnectionFactory::getCon("write");
 }
 function __construct()
 {
     $this->conn = MySQLiConnectionFactory::getCon("write");
     $this->logPath = $GLOBALS['SERVER_ROOT'] . (substr($GLOBALS['SERVER_ROOT'], -1) == '/' ? '' : '/') . 'content/logs/';
 }
 public function submitReviews($postArr)
 {
     $statusStr = '';
     $occidArr = $postArr['occid'];
     if ($occidArr) {
         $successArr = array();
         $con = MySQLiConnectionFactory::getCon("write");
         foreach ($occidArr as $occid) {
             $points = $postArr['p-' . $occid];
             $comments = $this->cleanInStr($postArr['c-' . $occid]);
             $sql = 'UPDATE omcrowdsourcequeue ' . 'SET points = ' . $points . ',notes = ' . ($comments ? '"' . $comments . '"' : 'NULL') . ',reviewstatus = 10 ' . 'WHERE occid = ' . $occid;
             if ($con->query($sql)) {
                 $successArr[] = $occid;
             } else {
                 $statusStr = 'ERROR submitting reviews; ' . $con->error . '<br/>SQL = ' . $sql;
             }
         }
         if ($successArr) {
             //Change status to reviewed
             $sql2 = 'UPDATE omoccurrences SET processingstatus = "reviewed" WHERE occid IN(' . implode(',', $successArr) . ')';
             $con->query($sql2);
         }
         $con->close();
     }
     return $statusStr;
 }
示例#30
0
 public static function parseScientificName($inStr, $rankId = 0)
 {
     //Converts scinetific name with author embedded into separate fields
     $retArr = array('unitname1' => '', 'unitname2' => '', 'unitind3' => '', 'unitname3' => '');
     if ($inStr && is_string($inStr)) {
         //Remove underscores, common in NPS data
         $inStr = preg_replace('/_+/', ' ', $inStr);
         //Replace misc
         $inStr = str_replace(array('?', '*'), '', $inStr);
         if (stripos($inStr, 'cf. ') !== false || stripos($inStr, 'c.f. ') !== false || stripos($inStr, ' cf ') !== false) {
             $retArr['identificationqualifier'] = 'cf. ';
             $inStr = str_ireplace(array(' cf ', 'c.f. ', 'cf. '), ' ', $inStr);
         } elseif (stripos($inStr, 'aff. ') !== false || stripos($inStr, ' aff ') !== false) {
             $retArr['identificationqualifier'] = 'aff. ';
             $inStr = str_ireplace(array(' aff ', 'aff. '), ' ', $inStr);
         }
         if (stripos($inStr, ' spp.')) {
             $rankId = 180;
             $inStr = str_ireplace(' spp.', '', $inStr);
         }
         if (stripos($inStr, ' sp.')) {
             $rankId = 180;
             $inStr = str_ireplace(' sp.', '', $inStr);
         }
         //Remove extra spaces
         $inStr = preg_replace('/\\s\\s+/', ' ', $inStr);
         $sciNameArr = explode(' ', $inStr);
         if (count($sciNameArr)) {
             if (strtolower($sciNameArr[0]) == 'x') {
                 //Genus level hybrid
                 $retArr['unitind1'] = array_shift($sciNameArr);
             }
             //Genus
             $retArr['unitname1'] = ucfirst(strtolower(array_shift($sciNameArr)));
             if (count($sciNameArr)) {
                 if (strtolower($sciNameArr[0]) == 'x') {
                     //Species level hybrid
                     $retArr['unitind2'] = array_shift($sciNameArr);
                     $retArr['unitname2'] = array_shift($sciNameArr);
                 } elseif (strpos($sciNameArr[0], '.') !== false) {
                     //It is assumed that Author has been reached, thus stop process
                     $retArr['author'] = implode(' ', $sciNameArr);
                     unset($sciNameArr);
                 } else {
                     if (strpos($sciNameArr[0], '(') !== false) {
                         //Assumed subgenus exists, but keep a author incase an epithet does exist
                         $retArr['author'] = implode(' ', $sciNameArr);
                         array_shift($sciNameArr);
                     }
                     //Specific Epithet
                     $retArr['unitname2'] = array_shift($sciNameArr);
                 }
                 if ($retArr['unitname2'] && preg_match('/[A-Z]+/', $retArr['unitname2'])) {
                     if (preg_match('/[A-Z]{1}[a-z]+/', $retArr['unitname2'])) {
                         //Check to see if is term is genus author
                         $sql = 'SELECT tid FROM taxa WHERE unitname1 = "' . $retArr['unitname1'] . '" AND unitname2 = "' . $retArr['unitname2'] . '"';
                         $con = MySQLiConnectionFactory::getCon('readonly');
                         $rs = $con->query($sql);
                         if ($rs->num_rows) {
                             if (isset($retArr['author'])) {
                                 unset($retArr['author']);
                             }
                         } else {
                             //Second word is likely author, thus assume assume author has been reach and stop process
                             $retArr['unitname2'] = '';
                             unset($sciNameArr);
                         }
                         $rs->free();
                         $con->close();
                     }
                     $retArr['unitname2'] = strtolower($retArr['unitname2']);
                 }
             }
         }
         if (isset($sciNameArr) && $sciNameArr) {
             //Assume rest is author; if that is not true, author value will be replace in following loop
             $retArr['author'] = implode(' ', $sciNameArr);
             if (!$rankId || $rankId > 220) {
                 //cycles through the final terms to extract the last infraspecific data
                 while ($sciStr = array_shift($sciNameArr)) {
                     if ($sciStr == 'f.' || $sciStr == 'fo.' || $sciStr == 'fo' || $sciStr == 'forma') {
                         if ($sciNameArr) {
                             $retArr['unitind3'] = 'f.';
                             $nextStr = array_shift($sciNameArr);
                             if ($nextStr == 'var.' || $nextStr == 'ssp.' || $nextStr == 'subsp.') {
                                 $retArr['unitind3'] = $nextStr;
                                 $retArr['unitname3'] = array_shift($sciNameArr);
                                 $retArr['author'] = implode(' ', $sciNameArr);
                             } elseif (preg_match('/^[a-z]+$/', $nextStr)) {
                                 $retArr['unitname3'] = $nextStr;
                                 $retArr['author'] = implode(' ', $sciNameArr);
                             } else {
                                 $retArr['unitind3'] = '';
                             }
                         }
                     } elseif ($sciStr == 'var.' || $sciStr == 'var') {
                         if ($sciNameArr) {
                             $retArr['unitind3'] = 'var.';
                             $nextStr = array_shift($sciNameArr);
                             if ($nextStr == 'ssp.' || $nextStr == 'subsp.') {
                                 $retArr['unitind3'] = $nextStr;
                                 $retArr['unitname3'] = array_shift($sciNameArr);
                                 $retArr['author'] = implode(' ', $sciNameArr);
                             } elseif (preg_match('/^[a-z]+$/', $nextStr)) {
                                 $retArr['unitname3'] = $nextStr;
                                 $retArr['author'] = implode(' ', $sciNameArr);
                             } else {
                                 $retArr['unitind3'] = '';
                             }
                         }
                     } elseif ($sciStr == 'ssp.' || $sciStr == 'ssp' || $sciStr == 'subsp.' || $sciStr == 'subsp') {
                         if ($sciNameArr) {
                             $retArr['unitind3'] = 'subsp.';
                             $nextStr = array_shift($sciNameArr);
                             if (preg_match('/^[a-z]+$/', $nextStr)) {
                                 $retArr['unitname3'] = $nextStr;
                                 $retArr['author'] = implode(' ', $sciNameArr);
                             } else {
                                 $retArr['unitind3'] = '';
                             }
                         }
                     }
                 }
                 //Double check to see if infraSpecificEpithet is still embedded in author due initial lack of taxonRank indicator
                 if (!$retArr['unitname3'] && $retArr['author']) {
                     $arr = explode(' ', $retArr['author']);
                     $firstWord = array_shift($arr);
                     if (preg_match('/^[a-z]{2,}$/', $firstWord)) {
                         $sql = 'SELECT unitind3 FROM taxa ' . 'WHERE unitname1 = "' . $retArr['unitname1'] . '" AND unitname2 = "' . $retArr['unitname2'] . '" AND unitname3 = "' . $firstWord . '" ';
                         //echo $sql.'<br/>';
                         $con = MySQLiConnectionFactory::getCon('readonly');
                         $rs = $con->query($sql);
                         if ($r = $rs->fetch_object()) {
                             $retArr['unitind3'] = $r->unitind3;
                             $retArr['unitname3'] = $firstWord;
                             $retArr['author'] = implode(' ', $arr);
                         }
                         $rs->free();
                         $con->close();
                     }
                 }
             }
         }
         if (array_key_exists('unitind1', $retArr)) {
             $retArr['unitname1'] = $retArr['unitind1'] . ' ' . $retArr['unitname1'];
             unset($retArr['unitind1']);
         }
         if (array_key_exists('unitind2', $retArr)) {
             $retArr['unitname2'] = $retArr['unitind2'] . ' ' . $retArr['unitname2'];
             unset($retArr['unitind2']);
         }
         //Build sciname, without author
         $retArr['sciname'] = trim($retArr['unitname1'] . ' ' . $retArr['unitname2'] . ' ' . $retArr['unitind3'] . ' ' . $retArr['unitname3']);
         if ($rankId && is_numeric($rankId)) {
             $retArr['rankid'] = $rankId;
         } else {
             if ($retArr['unitname3']) {
                 if ($retArr['unitind3'] == 'ssp.' || !$retArr['unitind3']) {
                     $retArr['rankid'] = 230;
                 } elseif ($retArr['unitind3'] == 'var.') {
                     $retArr['rankid'] = 240;
                 } elseif ($retArr['unitind3'] == 'f.') {
                     $retArr['rankid'] = 260;
                 }
             } elseif ($retArr['unitname2']) {
                 $retArr['rankid'] = 220;
             } elseif ($retArr['unitname1']) {
                 if (substr($retArr['unitname1'], -5) == 'aceae' || substr($retArr['unitname1'], -4) == 'idae') {
                     $retArr['rankid'] = 140;
                 }
             }
         }
     } else {
     }
     return $retArr;
 }