$urlPrefix .= ':' . $_SERVER["SERVER_PORT"]; } $urlPrefix .= $clientRoot . (substr($clientRoot, -1) == '/' ? '' : '/'); $feedLink = $urlPrefix . 'webservices/dwc/rss.xml'; echo '<a href="' . $feedLink . '" target="_blank">' . $feedLink . '</a>'; } else { echo '--feed not published for any of the collections within the portal--'; } ?> </div> <?php if ($collId) { if ($action == 'Create/Refresh Darwin Core Archive') { echo '<ul>'; $dwcaManager->setVerbose(1); $dwcaManager->createDwcArchive(); $dwcaManager->writeRssFile(); echo '</ul>'; } if ($dwcaArr = $dwcaManager->getDwcaItems($collId)) { foreach ($dwcaArr as $k => $v) { ?> <div style="margin:10px;"> <div> <b>Title:</b> <?php echo $v['title']; ?> <form action="datapublisher.php" method="post" style="display:inline;" onsubmit="return window.confirm('Are you sure you want to delete this archive?');"> <input type="hidden" name="colliddel" value="<?php echo $v['collid'];
public function exportDataset($dsid) { //Get occurrence records $zip = array_key_exists('zip', $_POST) ? $_POST['zip'] : 0; $format = $_POST['format']; $extended = array_key_exists('extended', $_POST) ? $_POST['extended'] : 0; $redactLocalities = 1; $rareReaderArr = array(); if ($IS_ADMIN || array_key_exists("CollAdmin", $userRights)) { $redactLocalities = 0; } elseif (array_key_exists("RareSppAdmin", $userRights) || array_key_exists("RareSppReadAll", $userRights)) { $redactLocalities = 0; } else { if (array_key_exists('CollEditor', $userRights)) { $rareReaderArr = $userRights['CollEditor']; } if (array_key_exists('RareSppReader', $userRights)) { $rareReaderArr = array_unique(array_merge($rareReaderArr, $userRights['RareSppReader'])); } } $dwcaHandler = new DwcArchiverOccurrence(); $dwcaHandler->setCharSetOut($cSet); $dwcaHandler->setSchemaType($schema); $dwcaHandler->setExtended($extended); $dwcaHandler->setDelimiter($format); $dwcaHandler->setVerbose(0); $dwcaHandler->setRedactLocalities($redactLocalities); if ($rareReaderArr) { $dwcaHandler->setRareReaderArr($rareReaderArr); } $occurManager = new OccurrenceManager(); $dwcaHandler->setCustomWhereSql($occurManager->getSqlWhere()); $outputFile = null; if ($zip) { //Ouput file is a zip file $includeIdent = array_key_exists('identifications', $_POST) ? 1 : 0; $dwcaHandler->setIncludeDets($includeIdent); $images = array_key_exists('images', $_POST) ? 1 : 0; $dwcaHandler->setIncludeImgs($images); $outputFile = $dwcaHandler->createDwcArchive('webreq'); } else { //Output file is a flat occurrence file (not a zip file) $outputFile = $dwcaHandler->getOccurrenceFile(); } //ob_start(); $contentDesc = ''; if ($schema == 'dwc') { $contentDesc = 'Darwin Core '; } else { $contentDesc = 'Symbiota '; } $contentDesc .= 'Occurrence '; if ($zip) { $contentDesc .= 'Archive '; } $contentDesc .= 'File'; header('Content-Description: ' . $contentDesc); if ($zip) { header('Content-Type: application/zip'); } elseif ($format == 'csv') { header('Content-Type: text/csv; charset=' . $charset); } else { header('Content-Type: text/html; charset=' . $charset); } header('Content-Disposition: attachment; filename=' . basename($outputFile)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($outputFile)); ob_clean(); flush(); //od_end_clean(); readfile($outputFile); unlink($outputFile); }
$stArr = array_merge($searchStArr, $collStArr); $occurManager->setSearchTermsArr($stArr); } if ($schema == "backup") { $collid = $_POST["collid"]; if ($collid && is_numeric($collid)) { //check permissions due to sensitive localities not being redacted if ($isAdmin || array_key_exists("CollAdmin", $userRights) && in_array($collid, $userRights["CollAdmin"])) { $dwcaHandler->setSchemaType('backup'); $dwcaHandler->setCharSetOut($cSet); $dwcaHandler->setVerbose(0); $dwcaHandler->setIncludeDets(1); $dwcaHandler->setIncludeImgs(1); $dwcaHandler->setRedactLocalities(0); $dwcaHandler->setCollArr($collid); $archiveFile = $dwcaHandler->createDwcArchive(); if ($archiveFile) { //ob_start(); header('Content-Description: Symbiota Occurrence Backup File (DwC-Archive data package)'); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename=' . basename($archiveFile)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($archiveFile)); //od_end_clean(); readfile($archiveFile); unlink($archiveFile); } else { echo 'ERROR creating output file. Query probably did not include any records.';
if ($customField2) { $dwcaHandler->addCondition($customField2, $_POST['ct2'], $_POST['cv2']); } //Set GeoLocate CoGe variables $dwcaHandler->setGeolocateVariables(array('cogecomm' => $_POST['cogecomm'], 'cogename' => $_POST['cogename'], 'cogedescr' => $_POST['cogedescr'])); //Set direct path to file $tPath = $SERVER_ROOT; if (substr($tPath, -1) != '/' && substr($tPath, -1) != '\\') { $tPath .= '/'; } $pathFrag = 'temp/data/geolocate/'; $tPath .= $pathFrag; $dwcaHandler->setTargetPath($tPath); $cnt = $dwcaHandler->getOccurrenceCnt(); $fileName = 'CoGe' . '_' . time(); $path = $dwcaHandler->createDwcArchive($fileName); //Set URL path to file $urlPrefix = "http://"; if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $urlPrefix = "https://"; } $urlPrefix .= $_SERVER["SERVER_NAME"]; if ($_SERVER["SERVER_PORT"] && $_SERVER["SERVER_PORT"] != 80) { $urlPrefix .= ':' . $_SERVER["SERVER_PORT"]; } $urlPath = $urlPrefix . $CLIENT_ROOT; if (substr($urlPath, -1) != '/' && substr($urlPath, -1) != '\\') { $urlPath .= '/'; } $urlPath .= $pathFrag . $fileName . '_DwC-A.zip'; if ($cnt) {
$dwcaHandler->setCharSetOut('UTF-8'); $dwcaHandler->setSchemaType('coge'); $dwcaHandler->setExtended(false); $dwcaHandler->setDelimiter('csv'); $dwcaHandler->setVerbose(0); $dwcaHandler->setRedactLocalities(0); $dwcaHandler->setIncludeDets(0); $dwcaHandler->setIncludeImgs(0); $dwcaHandler->addCondition('decimallatitude', 'NULL'); $dwcaHandler->addCondition('decimallongitude', 'NULL'); $dwcaHandler->addCondition('locality', 'NOTNULL'); if ($processingStatus) { $dwcaHandler->addCondition('processingstatus', 'EQUALS', $processingStatus); } if ($customField1) { $dwcaHandler->addCondition($customField1, $_POST['ct1'], $_POST['cv1']); } if ($customField2) { $dwcaHandler->addCondition($customField2, $_POST['ct2'], $_POST['cv2']); } $tPath = $SERVER_ROOT; if (substr($tPath, -1) != '/' && substr($tPath, -1) != '\\') { $tPath .= '/'; } $tPath .= "temp/data/geolocate/"; $dwcaHandler->setTargetPath($tPath); $retArr['cnt'] = $dwcaHandler->getOccurrenceCnt(); $retArr['path'] = $dwcaHandler->createDwcArchive('CoGeCommunityFile' . '_' . time()); } } echo json_encode($retArr);